harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r434076 [3/18] - in /incubator/harmony/enhanced/drlvm/trunk: build/make/components/ build/make/components/vm/ build/make/targets/ build/patches/lnx/ build/patches/lnx/APR/ build/patches/lnx/APR/threadproc/ build/patches/lnx/APR/threadproc/u...
Date Wed, 23 Aug 2006 16:49:21 GMT
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_vm_helpers.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_vm_helpers.h?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_vm_helpers.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_vm_helpers.h Wed Aug 23 09:48:41 2006
@@ -18,7 +18,7 @@
  * @version $Revision: 1.2.12.2.4.3 $
  */  
 #include "Class.h"
-#include "open/thread.h"
+
 
 
 /**

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp Wed Aug 23 09:48:41 2006
@@ -29,7 +29,7 @@
 #include "interp_vm_helpers.h"
 #include "ini.h"
 #include "compile.h"
-#include "open/thread.h"
+
 #include "thread_manager.h"
 
 // ppervov: HACK: allows using STL modifiers (dec/hex) and special constants (endl)
@@ -882,7 +882,7 @@
 #define DEF_OPCODE_CMP(CMP,check)                   \
 static inline void                                  \
 Opcode_##CMP(StackFrame& frame) {                   \
-    tmn_safe_point();                                \
+    hythread_safe_point();                                \
     int32 val = frame.stack.pick().i;               \
     frame.stack.ref() = FLAG_NONE; /* for OPCODE_IFNULL */ \
     DEBUG_BYTECODE("val = " << (int)val);                    \
@@ -906,7 +906,7 @@
 #define DEF_OPCODE_IF_ICMPXX(NAME,cmp)                          \
 static inline void                                              \
 Opcode_IF_ICMP ## NAME(StackFrame& frame) {                     \
-    tmn_safe_point();                                           \
+    hythread_safe_point();                                           \
     int32 val0 = frame.stack.pick(1).i;                         \
     int32 val1 = frame.stack.pick(0).i;                         \
     frame.stack.ref(1) = FLAG_NONE;                             \
@@ -987,7 +987,7 @@
         if (!other_class) {
              return false;
         }
-        assert(!tmn_is_suspend_enabled());
+        assert(!hythread_is_suspend_enabled());
         
         frame.stack.pick().cr = COMPRESS_REF(*(other_class->class_handle));
         frame.stack.ref() = FLAG_OBJECT;
@@ -2004,7 +2004,7 @@
             << method->get_name()->bytes << "/"
             << method->get_descriptor()->bytes<< endl);
 
-    tmn_safe_point();
+    hythread_safe_point();
     interpreterInvokeVirtual(frame, method);
 }
 
@@ -2020,7 +2020,7 @@
             << method->get_name()->bytes << "/"
             << method->get_descriptor()->bytes << endl);
 
-    tmn_safe_point();
+    hythread_safe_point();
     interpreterInvokeInterface(frame, method);
 }
 
@@ -2042,7 +2042,7 @@
         return;
     }
 
-    tmn_safe_point();
+    hythread_safe_point();
     interpreterInvokeStatic(frame, method);
 }
 
@@ -2058,7 +2058,7 @@
             << method->get_name()->bytes << "/"
              << method->get_descriptor()->bytes << endl);
 
-    tmn_safe_point();
+    hythread_safe_point();
     interpreterInvokeSpecial(frame, method);
 }
 
@@ -2108,14 +2108,14 @@
 
 static inline void
 Opcode_GOTO(StackFrame& frame) {
-    tmn_safe_point();
+    hythread_safe_point();
     DEBUG_BYTECODE("going to instruction");
     frame.ip += read_int16(frame.ip + 1);
 }
 
 static inline void
 Opcode_GOTO_W(StackFrame& frame) {
-    tmn_safe_point();
+    hythread_safe_point();
     DEBUG_BYTECODE("going to instruction");
     frame.ip += read_int32(frame.ip + 1);
 }
@@ -2256,14 +2256,14 @@
         return;
     }
     DEBUG_BYTECODE(" " << obj->vt()->clss->name->bytes << endl);
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     set_current_thread_exception(obj);
 }
 
 bool
 findExceptionHandler(StackFrame& frame, ManagedObject **exception, Handler **hh) {
     assert(!exn_raised());
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
 
     Method *m = frame.method;
     DEBUG_BYTECODE("Searching for exception handler:");
@@ -2387,13 +2387,16 @@
 
 static inline
 void UNUSED dump_all_java_stacks() {
-    tm_iterator_t * iterator = tm_iterator_create();
-    VM_thread *thread = tm_iterator_next(iterator);
+    hythread_iterator_t  iterator;
+    hythread_suspend_all(&iterator, NULL);
+    VM_thread *thread = get_vm_thread (hythread_iterator_next(&iterator));
     while(thread) {
         stack_dump(thread);
-        thread = tm_iterator_next(iterator);
+        thread = get_vm_thread (hythread_iterator_next(&iterator));
     }
-    tm_iterator_release(iterator);
+
+    hythread_resume_all( NULL);
+
     INFO("****** END OF JAVA STACKS *****\n");
 }
 
@@ -2407,9 +2410,9 @@
     val.j = 0;
 
     if (exc) {
-        tmn_suspend_enable();
+        hythread_suspend_enable();
         method_exit_callback(method, true, val);
-        tmn_suspend_disable();
+        hythread_suspend_disable();
         return;
     }
 
@@ -2447,9 +2450,9 @@
             ABORT("Unexpected java type");
     }
 
-    tmn_suspend_enable();
+    hythread_suspend_enable();
     method_exit_callback(method, false, val);
-    tmn_suspend_disable();
+    hythread_suspend_disable();
 }
 
 void
@@ -2461,15 +2464,15 @@
 
     M2N_ALLOC_MACRO;
     assert(!exn_raised());
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     
-    uint8 *first = (uint8*) p_TLS_vmthread->firstFrame;
+    uint8 *first = (uint8*) get_thread_ptr()->firstFrame;
     int stackLength = ((uint8*)first) - ((uint8*)&frame);
     if (stackLength > 500000) { // FIXME: hardcoded stack limit
-        if (!(p_TLS_vmthread->interpreter_state & INTERP_STATE_STACK_OVERFLOW)) {
-            p_TLS_vmthread->interpreter_state |= INTERP_STATE_STACK_OVERFLOW;
+        if (!(get_thread_ptr()->interpreter_state & INTERP_STATE_STACK_OVERFLOW)) {
+            get_thread_ptr()->interpreter_state |= INTERP_STATE_STACK_OVERFLOW;
             interp_throw_exception("java/lang/StackOverflowError");
-            p_TLS_vmthread->interpreter_state &= ~INTERP_STATE_STACK_OVERFLOW;
+            get_thread_ptr()->interpreter_state &= ~INTERP_STATE_STACK_OVERFLOW;
 
             if (frame.framePopListener)
                 frame_pop_callback(frame.framePopListener, frame.method, true);
@@ -2481,9 +2484,9 @@
     if (interpreter_ti_notification_mode
             & INTERPRETER_TI_METHOD_ENTRY_EVENT) {
         M2N_ALLOC_MACRO;
-        tmn_suspend_enable();
+        hythread_suspend_enable();
         method_entry_callback(frame.method);
-        tmn_suspend_disable();
+        hythread_suspend_disable();
         M2N_FREE_MACRO;
     }
 
@@ -2528,7 +2531,7 @@
         frame.last_bytecodes[(frame.n_last_bytecode++) & 7] = ip0;
 #endif
 
-        assert(!tmn_is_suspend_enabled());
+        assert(!hythread_is_suspend_enabled());
         switch(ip0) {
             case OPCODE_NOP:
                 Opcode_NOP(frame); break;
@@ -2889,12 +2892,12 @@
         exc = get_current_thread_exception();
         if (exc == 0) continue;
 got_exception:
-        if (p_TLS_vmthread->ti_exception_callback_pending) {
+        if (get_thread_ptr()->ti_exception_callback_pending) {
 
             assert(exn_raised());
-            assert(!tmn_is_suspend_enabled());
+            assert(!hythread_is_suspend_enabled());
             jvmti_interpreter_exception_event_callback_call();
-            assert(!tmn_is_suspend_enabled());
+            assert(!hythread_is_suspend_enabled());
 
             exc = get_current_thread_exception();
 
@@ -2928,7 +2931,7 @@
         if (frame.framePopListener)
             frame_pop_callback(frame.framePopListener, frame.method, true);
         M2N_FREE_MACRO;
-        assert(!tmn_is_suspend_enabled());
+        assert(!hythread_is_suspend_enabled());
         return;
     }
 }
@@ -2939,7 +2942,7 @@
         jvalue   *return_value,
         jvalue   *args) {
 
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
 
     StackFrame frame;
     memset(&frame, 0, sizeof(frame));
@@ -2951,7 +2954,7 @@
             frame.This = args[0].l->object;
     }
     if (frame.prev == 0) {
-        p_TLS_vmthread->firstFrame = (void*) &frame;
+        get_thread_ptr()->firstFrame = (void*) &frame;
     }
     setLastStackFrame(&frame);
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp Wed Aug 23 09:48:41 2006
@@ -23,7 +23,7 @@
 #include "interp_defs.h"
 #include "interp_native.h"
 #include "port_malloc.h"
-#include "open/thread.h"
+
 #include "thread_generic.h"
 
 static jint skip_old_frames(VM_thread *thread)
@@ -38,14 +38,14 @@
         Class *clss = method_get_class(first_frame->method);
         assert(clss);
 
-        if (strcmp(method_get_name(first_frame->method), "run") == 0 &&
+        if (strcmp(method_get_name(first_frame->method), "runImpl") == 0 &&
             strcmp(class_get_name(clss), "java/lang/VMStart$MainThread") == 0)
         {
             return 3;
         }
     }
 
-    return 0;
+    return 1;
 }
 
 jvmtiError
@@ -174,7 +174,7 @@
         return JVMTI_ERROR_TYPE_MISMATCH;
     }
 
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     tmn_suspend_disable();
     ManagedObject *obj = UNCOMPRESS_REF(frame->locals(slot).cr);
     if (NULL == obj) {
@@ -397,15 +397,15 @@
 #endif
 
 
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     assert(interpreter_ti_notification_mode & INTERPRETER_TI_METHOD_ENTRY_EVENT);
 
     jvmti_process_method_entry_event((jmethodID) method);
 
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
 }
 void method_exit_callback(Method *method, bool was_popped_by_exception, jvalue ret_val) {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     assert(interpreter_ti_notification_mode & INTERPRETER_TI_METHOD_EXIT_EVENT);
 
     jvmti_process_method_exit_event((jmethodID) method,
@@ -414,7 +414,7 @@
 
 void
 frame_pop_callback(FramePopListener *l, Method *method, jboolean was_popped_by_exception) {
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     tmn_suspend_enable();
 
     while (l) {
@@ -429,7 +429,7 @@
 
 jvmtiError
 interpreter_ti_pop_frame(jvmtiEnv * UNREF env, VM_thread *thread) {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     StackFrame *frame = getLastStackFrame(thread);
     if (frame->jvmti_pop_frame == POP_FRAME_AVAILABLE) {
         frame->jvmti_pop_frame = POP_FRAME_NOW;
@@ -445,7 +445,7 @@
                                 VM_thread *thread,
                                 int depth)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     StackFrame *frame = getLastStackFrame(thread);
 
     // skip depth of frames

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32BBPolling.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32BBPolling.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32BBPolling.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32BBPolling.cpp Wed Aug 23 09:48:41 2006
@@ -50,13 +50,14 @@
                                                              RegName_EDI);
         // Basic Block for flag address calculating. (To be inserted before the loopHeaders)
         BasicBlock * bbpFlagAddrBlock = irManager.newBasicBlock();
-#ifdef PLATFORM_POSIX
+//#ifdef PLATFORM_POSIX
          // TLS base can be obtained by calling get_thread_ptr()  (from vm_threads.h)
          Opnd * target=irManager.newImmOpnd( irManager.getTypeManager().getIntPtrType(),
                                              Opnd::RuntimeInfo::Kind_HelperAddress,
                                             (void*)CompilationInterface::Helper_GetSuspReqFlag
                                            );
          bbpFlagAddrBlock->appendInsts(irManager.newCallInst(target, &CallingConvention_STDCALL, 0, NULL, tlsBaseReg));
+/*
 #else // PLATFORM_POSIX
         // TLS base can be obtained from [fs:0x14]
         Opnd* tlsBase = irManager.newMemOpnd(typeInt32, MemOpndKind_Any, NULL, 0x14, RegName_FS);
@@ -67,7 +68,7 @@
             bbpFlagAddrBlock->appendInsts(irManager.newInst(Mnemonic_MOV, tlsBaseReg, tlsBase));
         }
 #endif // PLATFORM_POSIX
-
+*/
         // inserting bbpFlagAddrBlock before the given loopHeader
         uint32 startIndex = otherStartNdx[id];
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_ia32.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_ia32.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_ia32.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_ia32.cpp Wed Aug 23 09:48:41 2006
@@ -1260,9 +1260,10 @@
     m_curr_bb_state->seen_gcpt = true;
 
     veax();
-#ifdef PLATFORM_POSIX
+//#ifdef PLATFORM_POSIX
     gen_call_vm(rt_helper_get_thread_suspend_ptr, 0);
     voper(Mnemonic_CMP, MK_MEM32(RegName_EAX, 0), Imm32_0);
+/*
 #else
     // This is a bit quicker, but tricky way - VM uses TIB to store 
     // thread-specific info, and the offset of suspend request flag is 
@@ -1276,6 +1277,7 @@
                         MK_MEM32(RegName_EAX, rt_suspend_req_flag_offset));
     voper(Mnemonic_TEST, RegName_EAX, RegName_EAX);
 #endif
+*/
     unsigned patch_id = vjcc(ConditionMnemonic_E, InstPrefix_HintTaken);
     //
     gen_mem(MEM_TO_MEM|MEM_VARS|MEM_STACK|MEM_NO_UPDATE);

Added: incubator/harmony/enhanced/drlvm/trunk/vm/port/include/apr_thread_ext.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/port/include/apr_thread_ext.h?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/port/include/apr_thread_ext.h (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/port/include/apr_thread_ext.h Wed Aug 23 09:48:41 2006
@@ -0,0 +1,27 @@
+/**
+ * @author Andrey Chernyshev
+ * @version $Revision$
+ */
+
+
+#ifndef APR_EXT_H
+#define APR_EXT_H
+
+#include <apr.h>
+#include <apr_errno.h>
+#include <apr_thread_proc.h>
+#include <apr_portable.h>
+
+APR_DECLARE(apr_status_t) apr_thread_set_priority(apr_thread_t *thread, apr_int32_t priority);
+
+APR_DECLARE(void) apr_memory_rw_barrier();
+
+APR_DECLARE(apr_status_t) apr_thread_yield_other(apr_thread_t *thread);
+
+APR_DECLARE(apr_status_t) apr_thread_times(apr_thread_t *thread, 
+                                apr_time_t * kernel_time, apr_time_t * user_time);
+
+APR_DECLARE(apr_status_t) apr_thread_cancel(apr_thread_t *thread);
+
+
+#endif  /* APR_EXT_H */

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/port/include/apr_thread_ext.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/port/include/port_atomic.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/port/include/port_atomic.h?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/port/include/port_atomic.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/port/include/port_atomic.h Wed Aug 23 09:48:41 2006
@@ -27,8 +27,15 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-
-
+#ifdef __cplusplus
+#define INLINE inline
+#else 
+#ifdef WIN32
+#define INLINE __forceinline
+#else 
+#define INLINE static
+#endif
+#endif
 /**
  * All atomic operrations are perfomance critical, 
  * thus they are defined as inlined for most platforms in this file
@@ -36,7 +43,8 @@
  
  #if defined(_IPF_)
 
- /**  
+    
+/**
 * Atomic compare and exchange operation
 * @data[in, out]
 * @value[in] new value
@@ -65,10 +73,10 @@
 */
 APR_DECLARE(uint64) port_atomic_cas64(volatile uint64 * data, 
                                                  uint64 value, uint64 comp);
- 
+
 #elif defined( WIN32 )
 
-inline uint8 port_atomic_cas8(volatile uint8 * data , uint8 value, uint8 comp) {
+INLINE uint8 port_atomic_cas8(volatile uint8 * data , uint8 value, uint8 comp) {
     __asm {
         mov al,  comp
         mov dl,  value
@@ -79,7 +87,7 @@
     return comp;
 }
 
-inline uint16 port_atomic_cas16(volatile uint16 * data , uint16 value, uint16 comp) {
+INLINE uint16 port_atomic_cas16(volatile uint16 * data , uint16 value, uint16 comp) {
     __asm {
         mov ax,  comp
         mov dx,  value
@@ -90,7 +98,7 @@
     return comp;
 }
 
-inline uint64 port_atomic_cas64(volatile uint64 * data , uint64 value, uint64 comp) {
+INLINE uint64 port_atomic_cas64(volatile uint64 * data , uint64 value, uint64 comp) {
     __asm {
         lea esi, comp
         mov eax, [esi]
@@ -112,7 +120,7 @@
 
 #elif defined (PLATFORM_POSIX)  
 
-inline uint8 port_atomic_cas8(volatile uint8 * data , uint8 value, uint8 comp) {
+INLINE uint8 port_atomic_cas8(volatile uint8 * data , uint8 value, uint8 comp) {
 #if defined(_IA32_) || defined(_EM64T_)
     __asm__ __volatile__(
         "lock cmpxchgb %1, (%2)"
@@ -125,20 +133,22 @@
 #endif
 }
 
-inline uint16 port_atomic_cas16(volatile uint16 * data , uint16 value, uint16 comp) {
+INLINE uint16 port_atomic_cas16(volatile uint16 * data , uint16 value, uint16 comp) {
+    uint16 ret;
 #if defined(_IA32_) || defined(_EM64T_)
     __asm__ __volatile__(
-        "lock cmpxchgw %1, (%2)"
-        :"=a"(comp)
-        :"d"(value), "r"(data), "0"(comp)
+        "lock cmpxchgw %w1, %2"
+        :"=a"(ret)
+        :"q"(value), "m"(*data), "0"(comp)
+        : "memory"
     );
-    return comp;
+    return ret;
 #else
     ABORT("Not supported");
 #endif
 }
 
-inline uint64 port_atomic_cas64(volatile uint64 * data , uint64 value, uint64 comp) {
+INLINE uint64 port_atomic_cas64(volatile uint64 * data , uint64 value, uint64 comp) {
 #if defined(_IA32_)
     __asm__ __volatile__(
         "lea %0, %%esi;\n\t"
@@ -169,7 +179,7 @@
 #endif
 }
 
-inline void * port_atomic_compare_exchange_pointer(volatile void ** data, void * value, const void * comp) {
+INLINE void * port_atomic_compare_exchange_pointer(volatile void ** data, void * value, const void * comp) {
 #if defined(_IA32_)
     //return (void *) port_atomic_compare_exchange32((uint32 *)data, (uint32)value, (uint32)comp);
     uint32 Exchange = (uint32)value;
@@ -198,6 +208,8 @@
 }
 
 #endif //defined (POSIX)
+
+
 
 #ifdef __cplusplus
 }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_defs.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_defs.h?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_defs.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_defs.h Wed Aug 23 09:48:41 2006
@@ -527,6 +527,7 @@
 
 Mnemonic_SAL, Mnemonic_SHL=Mnemonic_SAL,// Shift left
 Mnemonic_SAR,                           // Unsigned shift right
+Mnemonic_ROR,                           // rotate right
 Mnemonic_SHR,                           // Signed shift right
 Mnemonic_SHRD,                          // Double Precision Shift Right
 Mnemonic_SHLD,                          // Double Precision Shift Left

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_tabl.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_tabl.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_tabl.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_tabl.cpp Wed Aug 23 09:48:41 2006
@@ -1111,6 +1111,7 @@
 DEFINE_SHIFT_MNEMONIC(SAL, _4)
 DEFINE_SHIFT_MNEMONIC(SAR, _7)
 DEFINE_SHIFT_MNEMONIC(SHR, _5)
+DEFINE_SHIFT_MNEMONIC(ROR, _1)
 
 #undef DEFINE_SHIFT_MNEMONIC
 BEGIN_MNEMONIC(SHLD, true, false, false, false, N )

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.cpp Wed Aug 23 09:48:41 2006
@@ -130,10 +130,10 @@
 
 const Mnemonic map_of_shift_opcode_2_mnemonic[] = {
     //shld_opc, shrd_opc,
-    // shl_opc, shr_opc, sar_opc, max_shift_opcode=5, 
-    //n_shift = 5
+    // shl_opc, shr_opc, sar_opc, ror_opc, max_shift_opcode=6, 
+    //n_shift = 6
     Mnemonic_SHLD,  Mnemonic_SHRD,  
-    Mnemonic_SHL,   Mnemonic_SHR,   Mnemonic_SAR,
+    Mnemonic_SHL,   Mnemonic_SHR,   Mnemonic_SAR, Mnemonic_ROR
 };
 
 #ifdef _DEBUG

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.h?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.h Wed Aug 23 09:48:41 2006
@@ -102,7 +102,7 @@
 //
 enum Shift_Opcode {
     shld_opc,   shrd_opc,   shl_opc,    shr_opc,
-    sar_opc,    max_shift_opcode=5,     n_shift = 5
+    sar_opc,    ror_opc, max_shift_opcode=6,     n_shift = 6
 };
 
 enum ConditionCode {
@@ -454,7 +454,7 @@
 ENCODER_DECLARE_EXPORT char * test(char * stream, const RM_Opnd & rm, const Imm_Opnd & imm, Opnd_Size sz = size_platf);
 ENCODER_DECLARE_EXPORT char * test(char * stream, const RM_Opnd & rm, const R_Opnd & r, Opnd_Size sz = size_platf);
 
-// shift instructions: shl, shr, sar, shld, shrd
+// shift instructions: shl, shr, sar, shld, shrd, ror
 ENCODER_DECLARE_EXPORT char * shift(char * stream, Shift_Opcode opc, const RM_Opnd & rm, const Imm_Opnd & imm, Opnd_Size sz = size_platf);
 ENCODER_DECLARE_EXPORT char * shift(char * stream, Shift_Opcode opc, const RM_Opnd & rm, Opnd_Size sz = size_platf);
 ENCODER_DECLARE_EXPORT char * shift(char * stream, Shift_Opcode opc, const RM_Opnd & rm, const R_Opnd & r, const Imm_Opnd & imm, Opnd_Size sz = size_platf);

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.inl
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.inl?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.inl (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.inl Wed Aug 23 09:48:41 2006
@@ -720,12 +720,12 @@
 }
 
 ENCODER_DECLARE_EXPORT char * scas( char * stream, unsigned char prefix ) {
+    EncoderBase::Operands args;
     if (prefix != no_prefix) {
         assert(prefix == prefix_repnz || prefix == prefix_repz);
         *stream = prefix;
         ++stream;
     }
-	EncoderBase::Operands args;
     return (char*)EncoderBase::encode(stream, Mnemonic_SCAS, args);
 }
 
@@ -735,6 +735,7 @@
         *stream = prefix;
         ++stream;
     }
+    
 	EncoderBase::Operands args;
 	return (char*)EncoderBase::encode(stream, Mnemonic_STOS, args);
 }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ia32/pim/m2n_ia32.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ia32/pim/m2n_ia32.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ia32/pim/m2n_ia32.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ia32/pim/m2n_ia32.cpp Wed Aug 23 09:48:41 2006
@@ -136,16 +136,11 @@
 
 unsigned m2n_ts_to_register_size()
 {
-#ifdef PLATFORM_POSIX
     return 22;
-#else //!PLATFORM_POSIX
-    return 7;
-#endif //!PLATFORM_POSIX
 }
 
 char* m2n_gen_ts_to_register(char* buf, R_Opnd* reg)
 {
-#ifdef PLATFORM_POSIX
     if (reg!=&eax_opnd)
         buf = push(buf,  eax_opnd);
     buf = push(buf,  ecx_opnd);
@@ -157,10 +152,6 @@
         buf = mov(buf, *reg,  eax_opnd);
         buf = pop(buf,  eax_opnd);
     }
-#else //!PLATFORM_POSIX
-    buf = prefix(buf, prefix_fs);
-    buf = mov(buf, *reg,  M_Opnd(0x14));
-#endif //!PLATFORM_POSIX
     return buf;
 }
 

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?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- 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 Wed Aug 23 09:48:41 2006
@@ -33,7 +33,7 @@
 #include "stub_code_utils.h"
 #include "open/vm_util.h" // For vm_get_boolean_property_value_with_default
 #include "interpreter.h"
-#include "open/thread.h"
+
 
 //////////////////////////////////////////////////////////////////////////
 // Utilities
@@ -98,7 +98,7 @@
 
 void m2n_set_last_frame(M2nFrame* lm2nf)
 {
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     p_TLS_vmthread->last_m2n_frame = lm2nf;
 }
 
@@ -222,7 +222,7 @@
 void free_local_object_handles2(ObjectHandles* head);
 
 void m2n_pop_local_handles() {
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     M2nFrame *m2n = m2n_get_last_frame();
     free_local_object_handles3(m2n_get_local_handles(m2n));
 }

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?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- 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 Wed Aug 23 09:48:41 2006
@@ -39,7 +39,7 @@
 #include "stub_code_utils.h"
 #include "root_set_enum_internal.h"
 
-#include "open/thread.h"
+
 
 #include <pthread.h>
 #include <signal.h>

Added: incubator/harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/apr_thread_ext.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/apr_thread_ext.c?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/apr_thread_ext.c (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/apr_thread_ext.c Wed Aug 23 09:48:41 2006
@@ -0,0 +1,140 @@
+#include "apr_thread_ext.h"
+//#include "apr_arch_threadproc.h"
+#include <pthread.h>
+#include <semaphore.h>
+
+int convert_priority(apr_int32_t priority);
+
+APR_DECLARE(apr_status_t) apr_thread_set_priority(apr_thread_t *thread, 
+                apr_int32_t priority) 
+{
+ /*   HANDLE *os_thread;
+    apr_status_t status;
+    
+    if (status = apr_os_thread_get(&((apr_os_thread_t *)os_thread), thread)) {
+        return status;
+    }
+    
+    if (SetThreadPriority(os_thread, (int)convert_priority(priority))) {
+        return APR_SUCCESS;
+    } else {
+        return apr_get_os_error();
+    }
+    */
+    return APR_SUCCESS;
+}
+
+int convert_priority(apr_int32_t priority) {
+    return (int)priority;
+}
+
+
+
+pthread_mutex_t yield_other_mutex = PTHREAD_MUTEX_INITIALIZER;
+sem_t yield_other_sem;
+int yield_other_init_flag = 0;
+
+void yield_other_handler(int signum, siginfo_t* info, void* context) {
+    if (yield_other_init_flag) {
+        sem_post(&yield_other_sem);
+    }
+       
+}
+
+static void init_thread_yield_other () {
+   struct sigaction sa;
+   //init notification semaphore
+   sem_init(&yield_other_sem,0,0);
+   //set signal handler
+    sigemptyset(&sa.sa_mask);
+    sa.sa_flags = SA_SIGINFO | SA_RESTART;
+    sa.sa_sigaction = yield_other_handler;
+    sigaction(SIGUSR2, &sa, NULL);
+    yield_other_init_flag = 1;
+    
+}
+// touch thread to flash memory
+APR_DECLARE(apr_status_t) apr_thread_yield_other(apr_thread_t* thread) {
+    apr_status_t status;
+    pthread_t *os_thread;
+
+    pthread_mutex_lock(&yield_other_mutex);
+    if (!yield_other_init_flag) {
+        init_thread_yield_other ();
+    }
+    if (!thread 
+         || (status = apr_os_thread_get((apr_os_thread_t**)&os_thread, thread)) !=APR_SUCCESS 
+         || !*os_thread) {
+        pthread_mutex_unlock(&yield_other_mutex);
+        return status;
+    }
+    if(!(pthread_kill(*os_thread, SIGUSR2))) {
+       sem_wait(&yield_other_sem);
+    }
+    pthread_mutex_unlock(&yield_other_mutex);    
+    return APR_SUCCESS; 
+}
+
+APR_DECLARE(void) apr_memory_rw_barrier() {
+    #ifdef _IPF_ 
+        asm volatile ("mf" ::: "memory");
+    #else
+        __asm__("mfence");
+    #endif    
+}
+
+APR_DECLARE(apr_status_t) apr_thread_times(apr_thread_t *thread, 
+                                apr_time_t * kernel_time, apr_time_t * user_time){
+/*    FILETIME creationTime;
+    FILETIME exitTime;
+    FILETIME kernelTime;
+    FILETIME userTime;
+    HANDLE hThread;
+    SYSTEMTIME sysTime;
+    int res;
+    __int64 xx;
+    __int32 * pp;
+
+    res = GetThreadTimes(
+        thread->td,
+        &creationTime,
+        &exitTime,
+        &kernelTime,
+        &userTime
+    );
+    
+    printf( "Creation time = %08x %08x\n", creationTime.dwHighDateTime, creationTime.dwLowDateTime);
+    printf( "Exit     time = %08x %08x\n", exitTime.dwHighDateTime, exitTime.dwLowDateTime);
+    printf( "Kernrl   time = %08x %08x %08d\n", kernelTime.dwHighDateTime
+                                      , kernelTime.dwLowDateTime, kernelTime.dwLowDateTime);
+    printf( "User     time = %08x %08x %08d\n", userTime.dwHighDateTime
+                                      , userTime.dwLowDateTime, userTime.dwLowDateTime);
+    printf("%d\n", 
+        ((unsigned)exitTime.dwLowDateTime - (unsigned)creationTime.dwLowDateTime)/10000000);
+    
+    FileTimeToSystemTime(&creationTime, &sysTime);
+    printf("%d %d %d %d %d %d \n", sysTime.wYear, sysTime.wMonth,
+        sysTime.wHour + 3, sysTime.wMinute, sysTime.wSecond, sysTime.wMilliseconds);
+    
+    pp = (int*)&xx;
+    *pp = kernelTime.dwLowDateTime;
+    *(pp + 1) = kernelTime.dwHighDateTime;
+    *kernel_time = xx;
+    pp = (int*)&xx;
+    *pp = userTime.dwLowDateTime;
+    *(pp + 1) = userTime.dwHighDateTime;
+    *user_time = xx;*/
+
+    return APR_SUCCESS; 
+}
+
+APR_DECLARE(apr_status_t) apr_thread_cancel(apr_thread_t *thread) {
+    apr_os_thread_t *os_thread;
+    apr_status_t status = apr_os_thread_get(&os_thread, thread);
+
+    if (status ) {
+        return status;
+    }
+    status = pthread_cancel(*(pthread_t *)os_thread);
+    return status;
+}

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/apr_thread_ext.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/apr_thread_ext.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/apr_thread_ext.c?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/apr_thread_ext.c (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/apr_thread_ext.c Wed Aug 23 09:48:41 2006
@@ -0,0 +1,118 @@
+#include <windows.h>
+#include <stdio.h>
+#include "apr_thread_ext.h"
+//#include "apr_arch_threadproc.h"
+
+static int convert_priority(apr_int32_t priority);
+
+APR_DECLARE(apr_status_t) apr_thread_set_priority(apr_thread_t *thread, 
+                apr_int32_t priority) 
+{
+    HANDLE *os_thread;
+    apr_status_t status;
+    
+    if (status = apr_os_thread_get(&((apr_os_thread_t *)os_thread), thread)) {
+        return status;
+    }
+    
+    if (SetThreadPriority(os_thread, (int)convert_priority(priority))) {
+        return APR_SUCCESS;
+    } else {
+        return apr_get_os_error();
+    }
+    
+    
+}
+
+static int convert_priority(apr_int32_t priority) {
+    return (int)priority;
+}
+
+// touch thread to flash memory
+APR_DECLARE(apr_status_t) apr_thread_yield_other(apr_thread_t* thread) {
+    HANDLE *os_thread = NULL;
+    apr_status_t status;   
+    if (status = apr_os_thread_get(&((apr_os_thread_t *)os_thread), thread)) {
+        return status;
+    }
+        if(!os_thread) {
+//        printf ("detached thread\n");
+              return status;
+        }
+       //printf("suspending %d\n", os_thread);
+    if(-1!=SuspendThread(os_thread)) {
+         ResumeThread(os_thread);
+ //      printf("resuming %d\n", os_thread);
+        } else {
+  //            printf("fail to suspend %d\n", os_thread);
+        }
+  return APR_SUCCESS; 
+}
+
+APR_DECLARE(void) apr_memory_rw_barrier() {
+    __asm mfence;
+}
+
+APR_DECLARE(apr_status_t) apr_thread_times(apr_thread_t *thread, 
+                                apr_time_t * kernel_time, apr_time_t * user_time){
+    FILETIME creationTime;
+    FILETIME exitTime;
+    FILETIME kernelTime;
+    FILETIME userTime;
+    HANDLE *hThread;
+    SYSTEMTIME sysTime;
+    int res;
+    __int64 xx;
+    __int32 * pp;
+    apr_status_t status;
+
+    if (status = apr_os_thread_get(&((apr_os_thread_t *)hThread), thread)) {
+        return status;
+    }
+                    
+    res = GetThreadTimes(
+        hThread,
+        &creationTime,
+        &exitTime,
+        &kernelTime,
+        &userTime
+    );
+    
+    printf( "Creation time = %08x %08x\n", creationTime.dwHighDateTime, creationTime.dwLowDateTime);
+    printf( "Exit     time = %08x %08x\n", exitTime.dwHighDateTime, exitTime.dwLowDateTime);
+    printf( "Kernrl   time = %08x %08x %08d\n", kernelTime.dwHighDateTime
+                                      , kernelTime.dwLowDateTime, kernelTime.dwLowDateTime);
+    printf( "User     time = %08x %08x %08d\n", userTime.dwHighDateTime
+                                      , userTime.dwLowDateTime, userTime.dwLowDateTime);
+    printf("%d\n", 
+        ((unsigned)exitTime.dwLowDateTime - (unsigned)creationTime.dwLowDateTime)/10000000);
+    
+    FileTimeToSystemTime(&creationTime, &sysTime);
+    printf("%d %d %d %d %d %d \n", sysTime.wYear, sysTime.wMonth,
+        sysTime.wHour + 3, sysTime.wMinute, sysTime.wSecond, sysTime.wMilliseconds);
+    
+    pp = (int*)&xx;
+    *pp = kernelTime.dwLowDateTime;
+    *(pp + 1) = kernelTime.dwHighDateTime;
+    *kernel_time = xx;
+    pp = (int*)&xx;
+    *pp = userTime.dwLowDateTime;
+    *(pp + 1) = userTime.dwHighDateTime;
+    *user_time = xx;
+
+    return APR_SUCCESS; 
+}
+
+APR_DECLARE(apr_status_t) apr_thread_cancel(apr_thread_t *thread) {
+    HANDLE *os_thread;
+    apr_status_t status;   
+    if (status = apr_os_thread_get(&((apr_os_thread_t *)os_thread), thread)) {
+        return status;
+    }
+    
+    if (TerminateThread(os_thread, 0)) {
+        return APR_SUCCESS;
+    } else {
+        return apr_get_os_error();
+    }
+}

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/apr_thread_ext.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/StackTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/StackTest.java?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/StackTest.java (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/StackTest.java Wed Aug 23 09:48:41 2006
@@ -13,6 +13,10 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
+
+/**
+ * @keyword XXX_fails
+ */
 public class StackTest {
 
     static int depth = 0;

Added: incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/framework/testframe.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/framework/testframe.c?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/framework/testframe.c (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/framework/testframe.c Wed Aug 23 09:48:41 2006
@@ -0,0 +1,126 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+
+/**
+ * @author Salikh Zakirov
+ * @version $Revision$
+ */
+#include "testframe.h"
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+
+
+/**
+   @file testframe.c
+   testframe.c contains implementation of Testframe framework functions
+   @ingroup testframe
+*/
+
+int log_level = LOG_LEVEL_INFO;
+int error_flag = 0;
+
+void log_error(char *fmt, ...) {
+    va_list argp;
+    if (error_flag) return;
+    error_flag = 1;
+    fprintf(stderr, "ERROR: ");
+    va_start(argp, fmt);
+    vfprintf(stderr, fmt, argp);
+    va_end(argp);
+    fprintf(stderr, "\n");
+    fflush(NULL);
+}
+
+void log_info(char *fmt, ...) {
+    va_list argp;
+
+    if (log_level<LOG_LEVEL_INFO) return;
+    fprintf(stdout, "INFO: ");
+    va_start(argp, fmt);
+    vfprintf(stdout, fmt, argp);
+    va_end(argp);
+    fprintf(stdout, "\n");
+    fflush(NULL);
+}
+
+void log_debug(char *fmt, ...) {
+    va_list argp;
+        
+    if (log_level<LOG_LEVEL_DEBUG) return;
+    fprintf(stdout, "DEBUG: ");
+    va_start(argp, fmt);
+    vfprintf(stdout, fmt, argp);
+    va_end(argp);
+    fprintf(stdout, "\n");
+    fflush(NULL);
+}
+
+int execute(char *name, int (*f)(void)) {
+    int status; 
+    if (f==NULL) {
+        log_error("no test function to execute");       
+        return TEST_ERROR;
+    }
+    log_info("TEST %s start", name);
+    error_flag = 0;
+    setup();
+    status = f();
+    if (status || error_flag){
+        log_info("TEST %s: FAILED", name);
+    } else {
+        log_info("TEST %s: PASSED", name);
+    }
+    teardown();
+    return status;
+}
+
+void log_set_level(int level) {
+    log_level = level;
+}
+
+int default_main(int argc, char *argv[]){
+        
+    int result;
+
+    TestDescriptor *p;
+
+    log_set_level(LOG_LEVEL_INFO);
+
+    if (argc>=2) {
+        /* execute given test only */
+        for (p=testDescriptor; (p->name!=NULL) && (strncmp(argv[1], p->name, strlen(p->name))!=0); p++) {}
+                                
+        if ((p->name!=NULL) && (p->func!=NULL)) {
+            return (execute(p->name, p->func));
+            fflush(NULL);
+        }
+    } else {
+        /* execute all tests */
+        result = 0;
+        for (p=testDescriptor; (p->name!=NULL); p++) {
+            //log_debug("executing test %s", p->name);
+            if (p->func!=NULL) { 
+                result = execute(p->name, p->func) || result;
+                fflush(NULL);
+            }
+        }
+        return result;
+    }
+    return (0);
+}
+

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/framework/testframe.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/framework/testframe.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/framework/testframe.h?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/framework/testframe.h (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/framework/testframe.h Wed Aug 23 09:48:41 2006
@@ -0,0 +1,291 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Salikh Zakirov
+ * @version $Revision$
+ */
+#ifndef _TESTFRAME_H_
+#define _TESTFRAME_H_
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+    /** \mainpage Testframe testing framework
+     *
+     * \section intro_sec Introduction
+     *
+     * Testframe is testing framework developed in C language. It will be used (hopely) for testing DRL VM internals and PVL interfaces.
+     *
+     * \section usage_sec Usage
+     * You need to include files testframe.h and testframe.c in your project.
+     * 
+     *  
+     * 
+     */
+
+
+
+    /**
+       @defgroup testframe Testframe testing framework
+    */
+
+    /**
+       @file testframe.h
+       Main include for Testframe testing framework
+       @ingroup testframe
+    */
+
+#ifndef NULL 
+#define NULL 0
+#endif
+
+    /* status codes */
+    /**
+     * Status code to indicate test success
+     @ingroup testframe
+    */
+#define TEST_PASSED 0
+    /**
+     * Status code to indicate test failure
+     @ingroup testframe
+    */
+#define TEST_FAILED 1
+    /**
+     * Status code to indicate error
+     @ingroup testframe
+    */
+#define TEST_ERROR 2
+
+    /**
+       @defgroup assertions Assertion checks
+    */
+
+    /* helper functions */
+    /**
+       A helper macro to indicate test failure with given message. Source file name and line number will be appended to the message.
+       @param message - text reason of test failure
+       @ingroup assertions
+    */
+#define tf_fail(message) log_error("Test failed: %s (%s:%d)", message, __FILE__, __LINE__); return TEST_FAILED
+    /**
+       A helper macro to indicate test success.
+       @ingroup assertions
+    */
+#define tf_pass() return TEST_PASSED
+    /**
+       A helper macro to check test assertion 
+       @param expression - a boolean expression to check, if it results in false then test will be failed.
+       @ingroup assertions
+    */
+#define tf_assert(expression) if (!(expression)) { log_error("Assertion '%s' failed at %s:%d", #expression, __FILE__, __LINE__); return TEST_FAILED; }
+    /**
+       A helper macro to check test assertion (for use in void function) 
+       @param expression - a boolean expression to check, if it results in false then test will be failed.
+       @ingroup assertions
+    */
+#define tf_assert_v(expression) if (!(expression)) { log_error("Assertion '%s' failed at %s:%d", #expression, __FILE__, __LINE__); return; }
+    /**
+       A helper macro to check test assertion and report message in case of check failure.
+       Source file name and line nimber will be appended to the message.
+       @param message - text reason of test failure.
+       @param expression - a boolean expression to check, if it results in false then test will be failed.
+       @ingroup assertions
+    */
+#define tf_assert_message(message, expression) if (!(expression)) { log_error("Assertion '%s' failed, message: %s at %s:%d", #expression, #message, __FILE__, __LINE__); return TEST_FAILED; }
+    /**
+       A helper macro to check whether supplied expression is NULL
+       @param expression - a boolean expression to check, if it results in false then test will be failed.
+       @ingroup assertions
+    */
+#define tf_assert_null(expression) tf_assert((expression)==NULL)
+    /**
+       A helper macro to check whether supplied expression is NULL and report message in case of check failure.
+       Source file name and line nimber will be appended to the message.
+
+       @param message - text reason of test failure.
+       @param expression - a boolean expression to check, if it results in false then test will be failed.
+       @ingroup assertions
+    */
+#define tf_assert_null_message(message, expression) tf_assert_message(message, (expression)==NULL)
+    /**
+       A helper macro to check whether supplied expression is not NULL
+       @param expression - a boolean expression to check, if it results in false then test will be failed.
+       @ingroup assertions
+    */
+#define tf_assert_not_null(expression) tf_assert((expression)!=NULL)
+    /**
+       A helper macro to check whether supplied expression is not NULL and report message in case of check failure.
+       Source file name and line nimber will be appended to the message.
+
+       @param message - text reason of test failure.
+       @param expression - a boolean expression to check, if it results in false then test will be failed.
+       @ingroup assertions
+    */
+#define tf_assert_not_null_message(message, expression) tf_assert(message, (expression)!=NULL)
+    /**
+       A helper macro to compare values of two expressions
+       @param expected - expected value
+       @param actual - actual value
+       @ingroup assertions
+    */
+#define tf_assert_same(expected, actual) tf_assert((expected)==(actual))
+    /**
+       A helper macro to compare values of two expressions (for use in void function)
+       @param expected - expected value
+       @param actual - actual value
+       @ingroup assertions
+    */
+#define tf_assert_same_v(expected, actual) tf_assert_v((expected)==(actual))
+    /**
+       A helper macro to compare values of two expressions and report message in case of mismatch
+       Source file name and line nimber will be appended to the message.
+       @param message - text reason of test failure.
+       @param expected - expected value
+       @param actual - actual value
+       @ingroup assertions
+    */
+#define tf_assert_same_message(message, expected, actual) tf_assert_message(message, (expected)==(actual))
+
+
+    /* test management macros */
+    /* 
+       @struct TestDescriptor
+       Structure describing test, holds test name and pointer to test function
+       for internal use only
+    */
+    typedef struct {
+        char *name;
+        int (*func)(void);
+    } TestDescriptor;
+
+
+    /**
+       Helper macro to start test list declarion. This list is necessary for test case execution engine.
+       @ingroup testframe
+    */
+#define TEST_LIST_START \
+    TestDescriptor testDescriptor[] = {
+
+        /**
+           Helper macro to include a test case into test list for execution engine. 
+
+           @param name of function, which implements test case
+           @ingroup testframe
+        */
+#define TEST(name) {#name , name},
+
+        /**
+           Helper macro to end test list declarion. This list is necessary for test case execution engine.
+           @ingroup testframe
+        */
+#define TEST_LIST_END {NULL, NULL}};
+
+
+
+    /* these functions must be implemented by test */
+    /**
+       Setup function for test case. Must be implemented by test writer.
+       @ingroup testframe
+    */
+    extern void setup();
+    /**
+       Clean up function for test case. Must be implemented by test writer
+       @ingroup testframe
+    */
+    extern void teardown();
+
+
+    /* these structure must be implemented by test via TEST_LIST_* macros */
+    extern TestDescriptor testDescriptor[];
+    /**
+       Engin for running test case. Should be included in the main() in form<br>
+       return default_main(int argc, char *argv[]);<br>
+
+       @param argc - number of command line arguments
+       @param argv - command line arguments (list of names of test cases to run)
+
+       @return TEST_PASSED if all test cases passed, TEST_FAIL or TEST_ERROR otherwise 
+
+       @ingroup testframe
+    */
+    extern int default_main(int argc, char *argv[]);
+
+
+    /**
+       @defgroup logging Logging functions
+    */
+
+    /* logging functions */
+    /**
+       logs error, arguments are the same as for printf()
+       prints to standard error
+
+       @ingroup logging
+    */
+    extern void log_error(char *format, ...);
+    /**
+       logs message, arguments are the same as for printf()
+       prints to standard output
+
+       @ingroup logging
+    */
+    extern void log_info(char *format, ...);
+    /**
+       logs message, arguments are the same as for printf()
+       prints to standard output
+
+       @ingroup logging
+    */
+    extern void log_debug(char *format, ...);
+
+    /**
+       Defines error-only log level
+       @ingroup logging
+    */
+#define LOG_LEVEL_ERROR 0
+    /**
+       Defines error and info only log level
+       @ingroup logging
+    */
+#define LOG_LEVEL_INFO 1
+    /**
+       Defines debug  log level
+       @ingroup logging
+    */
+#define LOG_LEVEL_DEBUG 2
+
+    /**
+       Sets logging level
+    
+       @param level - controls which messages to log <UL><LI>LOG_LEVEL_ERROR - log error only<LI>LOG_LEVEL_INFO - log errors and info<LI>LOG_LEVEL_INFO - logs everything</UL> 
+       @ingroup logging
+    */
+
+    extern void log_set_level(int level);
+
+    /**
+       logs debug output 
+       TODO - decide how to enable/disable it
+    */
+
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/framework/testframe.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_attrs.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_attrs.c?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_attrs.c (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_attrs.c Wed Aug 23 09:48:41 2006
@@ -0,0 +1,65 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "testframe.h"
+#include "thread_unit_test_utils.h"
+#include <open/jthread.h>
+#include <open/ti_thread.h>
+#include <open/hythread_ext.h>
+#include "jni_types.h"
+
+int helper_hythread_get_set_priority(void);
+
+/*
+ * Test jthread_get_priority(...)
+ */
+int test_jthread_get_priority (void){
+
+    tested_thread_sturct_t *tts;
+
+    // Initialize tts structures and run all tested threads
+    tested_threads_run(default_run_for_test);
+
+    reset_tested_thread_iterator(&tts);
+    while(next_tested_thread(&tts)){
+        //tf_assert(jthread_get_priority(tts->java_thread) == tts->attrs.priority);
+        tf_assert_same(jthread_set_priority(tts->java_thread, 0), TM_ERROR_NONE);
+        tf_assert(jthread_get_priority(tts->java_thread) == 0);
+        tf_assert_same(jthread_set_priority(tts->java_thread, 1), TM_ERROR_NONE);
+        tf_assert(jthread_get_priority(tts->java_thread) == 1);
+        tf_assert_same(jthread_set_priority(tts->java_thread, 2), TM_ERROR_NONE);
+        tf_assert(jthread_get_priority(tts->java_thread) == 2);
+    }
+
+    // Terminate all threads and clear tts structures
+    tested_threads_destroy();
+
+    return TEST_PASSED;
+} 
+
+/*
+ * Test jthread_set_priority(...)
+ */
+int test_jthread_set_priority (void){
+    return test_jthread_get_priority();
+} 
+
+TEST_LIST_START
+    TEST(test_jthread_get_priority)
+    TEST(test_jthread_set_priority)
+TEST_LIST_END;

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_attrs.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c Wed Aug 23 09:48:41 2006
@@ -0,0 +1,529 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+#include <stdio.h>
+#include "testframe.h"
+#include "thread_unit_test_utils.h"
+#include <open/jthread.h>
+#include <open/hythread_ext.h>
+#include "thread_private.h"
+
+/*
+ * Time for jthread_timed_join() to wait
+ * set in test_jthread_timed_join() and used in run_for_test_jthread_timed_join()
+ */
+int timed_join_wait_time;
+
+/*
+ * Test jthread_attach()
+ */
+void * APR_THREAD_FUNC run_for_test_jthread_attach(apr_thread_t *thread, void *args){
+
+    tested_thread_sturct_t * tts = current_thread_tts;
+    //JNIEnv * new_env = new_JNIEnv();
+    IDATA status;
+    
+    tts->jni_env = new_JNIEnv();
+    status = jthread_attach(tts->jni_env, tts->java_thread);
+    tts->phase = (status == TM_ERROR_NONE ? TT_PHASE_ATTACHED : TT_PHASE_ERROR);
+    while(1){
+        tts->clicks++;
+        sleep_a_click();
+        if (tts->stop) {
+            break;
+        }
+    }
+
+    tts->phase = TT_PHASE_DEAD;
+    return 0;
+}
+
+int test_jthread_attach(void) {
+
+    tested_thread_sturct_t * tts;
+
+    // Initialize tts structures and run all tested threads
+    tested_os_threads_run(run_for_test_jthread_attach);
+    
+    // Make second attach to the same jthread.
+    reset_tested_thread_iterator(&tts);
+    while(next_tested_thread(&tts)){
+        check_tested_thread_phase(tts, TT_PHASE_ATTACHED);
+        check_tested_thread_structures(tts);
+    }
+    // Terminate all threads and clear tts structures
+    tested_threads_destroy();
+    return TEST_PASSED;
+}
+
+/*
+ * Test jthread_detach()
+ */
+int test_jthread_detach (void){
+
+    tested_thread_sturct_t * tts;
+    jthread *thread;
+    hythread_t hythread;
+
+    // Initialize tts structures and run all tested threads
+    tested_threads_run(default_run_for_test);
+    
+    // Make second attach to the same jthread.
+    reset_tested_thread_iterator(&tts);
+    while(next_tested_thread(&tts)){
+        check_tested_thread_phase(tts, TT_PHASE_RUNNING);
+        hythread = vm_jthread_get_tm_data(tts->java_thread);
+        thread = hythread_get_private_data(hythread);
+        tf_assert_same(jthread_detach(tts->java_thread), TM_ERROR_NONE);
+        tf_assert_null(vm_jthread_get_tm_data(tts->java_thread));
+        //tf_assert_null(hythread_get_private_data(hythread));
+    }
+
+    // Terminate all threads and clear tts structures
+    tested_threads_destroy();
+    return TEST_PASSED;
+}
+
+/*
+ * Test hythread_create(...)
+ */
+int test_hythread_create(void) {
+
+    tested_thread_sturct_t *tts;
+
+    // Initialize tts structures and run all tested threads
+    tested_threads_run(default_run_for_test);
+    
+    // Test that all threads are running and have associated structures valid
+    reset_tested_thread_iterator(&tts);
+    while(next_tested_thread(&tts)){
+        check_tested_thread_phase(tts, TT_PHASE_RUNNING);
+        check_tested_thread_structures(tts);
+        tf_assert(tested_thread_is_running(tts));
+    }
+    // Terminate all tested threads and clear tts structures
+    tested_threads_destroy();
+
+    return TEST_PASSED;
+}
+
+/*
+ * Test hythread_create_with_function(...)
+ */
+void JNICALL jvmti_start_proc(jvmtiEnv *jvmti_env, JNIEnv *jni_env, void *arg){
+
+    tested_thread_sturct_t * tts = current_thread_tts;
+    
+    if (tts->jni_env != jni_env){
+        tts->phase = TT_PHASE_ERROR;
+        return;
+    }
+    if (tts->jvmti_start_proc_arg != arg){
+        tts->phase = TT_PHASE_ERROR;
+        return;
+    }
+    tts->phase = TT_PHASE_RUNNING;
+    while(1){
+        tts->clicks++;
+        sleep_a_click();
+        if (tts->stop) {
+            break;
+        }
+    }
+    tts->phase = TT_PHASE_DEAD;
+}
+
+int test_hythread_create_with_function(void) {
+
+    tested_thread_sturct_t *tts;
+    void * args = &args;
+
+    // Initialize tts structures and run all tested threads
+    tested_threads_run_with_jvmti_start_proc(jvmti_start_proc);
+    
+    // Test that all threads are running and have associated structures valid
+    reset_tested_thread_iterator(&tts);
+    while(next_tested_thread(&tts)){
+        check_tested_thread_phase(tts, TT_PHASE_RUNNING);
+        check_tested_thread_structures(tts);
+        tf_assert(tested_thread_is_running(tts));
+    }
+    // Terminate all threads and clear tts structures
+    tested_threads_destroy();
+
+    return TEST_PASSED;
+}
+
+/*
+ * Test jthread_join()
+ */
+void run_for_test_jthread_join(void){
+
+    tested_thread_sturct_t * tts = current_thread_tts;
+    tested_thread_sturct_t * prev_tts = tts; 
+    IDATA status;
+
+    prev_tested_thread(&prev_tts);
+    if (prev_tts == NULL){
+        // its the first tested thread
+        tts->phase = TT_PHASE_RUNNING;
+
+        while(1){
+            tts->clicks++;
+            sleep_a_click();
+            if (tts->stop) {
+                tts->phase = TT_PHASE_DEAD;
+                break;
+            }
+        }
+    } else {
+        // wait until previous thread ends 
+        tts->phase = TT_PHASE_WAITING_ON_JOIN;
+        status = jthread_join(prev_tts->java_thread);
+        tts->phase = (status == TM_ERROR_NONE ? TT_PHASE_DEAD : TT_PHASE_ERROR);
+    }
+}
+
+int test_jthread_join(void) {
+
+    tested_thread_sturct_t * tts;
+    
+    tf_assert(MAX_TESTED_THREAD_NUMBER > 1);
+
+    // Initialize tts structures and run all tested threads
+    tested_threads_run(run_for_test_jthread_join);
+
+    reset_tested_thread_iterator(&tts);
+    next_tested_thread(&tts);
+    check_tested_thread_phase(tts, TT_PHASE_RUNNING);
+    while(next_tested_thread(&tts)){
+        check_tested_thread_phase(tts, TT_PHASE_WAITING_ON_JOIN);
+    }
+
+    // make the first thread terminated and test that all threads are terminated
+    reset_tested_thread_iterator(&tts);
+    next_tested_thread(&tts);
+    tts->stop = 1;
+    check_tested_thread_phase(tts, TT_PHASE_DEAD);
+    jthread_sleep(20 * CLICK_TIME_MSEC * MAX_TESTED_THREAD_NUMBER, 0);
+    while(next_tested_thread(&tts)){
+        check_tested_thread_phase(tts, TT_PHASE_DEAD);
+    }
+
+    // Terminate all threads (not needed here) and clear tts structures
+    tested_threads_destroy();
+
+    return TEST_PASSED;
+}
+
+/*
+ * Test jthread_timed_join()
+ */
+void run_for_test_jthread_timed_join(void){
+
+    tested_thread_sturct_t * tts = current_thread_tts;
+    tested_thread_sturct_t * prev_tts = tts;
+    IDATA status;
+
+    prev_tested_thread(&prev_tts);
+    tts->phase = TT_PHASE_RUNNING;
+    if (prev_tts == NULL){
+        // its the first tested thread
+        while(1){
+            tts->clicks++;
+            sleep_a_click();
+            if (tts->stop) {
+                tts->phase = TT_PHASE_DEAD;
+                break;
+            }
+        }
+    } else {
+        // wait until timeout or previous thread ends 
+        status = jthread_timed_join(prev_tts->java_thread, timed_join_wait_time, 0);
+        printf("-------- status = %08x (%i) %i\n", status,  status, timed_join_wait_time);
+        tts->phase = TT_PHASE_DEAD;
+        if (timed_join_wait_time > CLICK_TIME_MSEC * 10){
+            // must be thread end
+            //tts->phase = (status == TM_ERROR_NONE ? TT_PHASE_DEAD : TT_PHASE_ERROR);
+        } else {
+            // must be timeout
+           //tts->phase = (status == TM_ERROR_TIMEOUT ? TT_PHASE_DEAD : TT_PHASE_ERROR);
+        }
+    }
+}
+
+int test_jthread_timed_join(void) {
+
+    tested_thread_sturct_t * tts;
+    
+    tf_assert(MAX_TESTED_THREAD_NUMBER > 1);
+
+    /*
+     * Test for jthread_timed_join() exit due to timeout
+     */
+    timed_join_wait_time = 10 * CLICK_TIME_MSEC;
+    // Initialize tts structures and run all tested threads
+    tested_threads_run(run_for_test_jthread_timed_join);
+
+    // skip the first thread
+    reset_tested_thread_iterator(&tts);
+    next_tested_thread(&tts);
+    jthread_sleep(20 * CLICK_TIME_MSEC * MAX_TESTED_THREAD_NUMBER, 0);
+    while(next_tested_thread(&tts)){
+        check_tested_thread_phase(tts, TT_PHASE_DEAD);
+    }
+
+    // Terminate all threads and clear tts structures
+    tested_threads_destroy();
+
+    /*
+     * Test for jthread_timed_join() before timeout
+     */
+    timed_join_wait_time = 1000 * CLICK_TIME_MSEC * MAX_TESTED_THREAD_NUMBER;
+    // Initialize tts structures and run all tested threads
+    tested_threads_run(run_for_test_jthread_timed_join);
+
+    // make the first thread terminated and test that all threads are terminated
+    reset_tested_thread_iterator(&tts);
+    next_tested_thread(&tts);
+    tts->stop = 1;
+    check_tested_thread_phase(tts, TT_PHASE_DEAD);
+    jthread_sleep(20 * CLICK_TIME_MSEC * MAX_TESTED_THREAD_NUMBER, 0);
+    while(next_tested_thread(&tts)){
+        check_tested_thread_phase(tts, TT_PHASE_DEAD);
+    }
+
+    // Terminate all threads and clear tts structures
+    tested_threads_destroy();
+
+    return TEST_PASSED;
+}
+
+/*
+ * Test jthread_exception_stop()
+ */
+void run_for_test_jthread_exception_stop(void){
+
+    tested_thread_sturct_t * tts = current_thread_tts;
+    
+    tts->phase = TT_PHASE_RUNNING;
+    while(1){
+        hythread_safe_point();
+        tts->clicks++;
+        sleep_a_click();
+        if (tts->stop) {
+            break;
+        }
+    }
+    tts->phase = TT_PHASE_DEAD;
+}
+
+int test_jthread_exception_stop (void){
+
+    tested_thread_sturct_t * tts;
+    jobject excn = new_jobject();
+    hythread_t hythread;
+    jvmti_thread_t jvmti_thread;
+
+    // Initialize tts structures and run all tested threads
+    tested_threads_run(run_for_test_jthread_exception_stop);
+
+    reset_tested_thread_iterator(&tts);
+    while(next_tested_thread(&tts)){
+        tf_assert_same(jthread_exception_stop(tts->java_thread, excn), TM_ERROR_NONE);
+        check_tested_thread_phase(tts, TT_PHASE_ANY);
+        hythread = vm_jthread_get_tm_data(tts->java_thread);
+        jvmti_thread = hythread_get_private_data(hythread);
+        tf_assert(vm_objects_are_equal(excn, jvmti_thread->stop_exception));
+    }
+
+    // Terminate all threads (not needed here) and clear tts structures
+    tested_threads_destroy();
+
+    return TEST_PASSED;
+}
+
+/*
+ * Test jthread_stop()
+ */
+
+int test_jthread_stop (void){
+
+    tested_thread_sturct_t * tts;
+    JNIEnv * env;
+    jclass excn;
+    hythread_t hythread;
+    jvmti_thread_t jvmti_thread;
+
+    env = new_JNIEnv();
+    excn = (*env) -> FindClass(env, "java/lang/ThreadDeath");
+
+    // Initialize tts structures and run all tested threads
+    tested_threads_run(run_for_test_jthread_exception_stop);
+
+    reset_tested_thread_iterator(&tts);
+    while(next_tested_thread(&tts)){
+        tf_assert_same(tts->excn, NULL);
+        tf_assert_same(jthread_stop(tts->java_thread), TM_ERROR_NONE);
+        check_tested_thread_phase(tts, TT_PHASE_ANY);
+        //tf_assert_same(tts->excn, excn);
+        hythread = vm_jthread_get_tm_data(tts->java_thread);
+        jvmti_thread = hythread_get_private_data(hythread);
+        //tf_assert_same(excn, jvmti_thread->stop_exception);
+
+        //tf_assert_same(jthread_stop(tts->java_thread), TM_ERROR_NONE);
+        //tf_assert_same(thread_deaf_excn, thread->stop_exception);
+    }
+
+    // Terminate all threads (not needed here) and clear tts structures
+    tested_threads_destroy();
+
+    return TEST_PASSED;
+}
+
+/*
+ * Test jthread_sleep(...)
+ */
+void run_for_test_jthread_sleep(void){
+
+    tested_thread_sturct_t * tts = current_thread_tts;
+    IDATA status;
+    
+    tts->phase = TT_PHASE_SLEEPING;
+    status = jthread_sleep(1000000, 0);
+    tts->phase = (status == TM_ERROR_INTERRUPT ? TT_PHASE_DEAD : TT_PHASE_ERROR);
+}
+int test_jthread_sleep(void) {
+
+    tested_thread_sturct_t *tts;
+    tested_thread_sturct_t *sleeping_tts;
+    int i;
+    int sleeping_nmb;
+
+    // Initialize tts structures and run all tested threads
+    tested_threads_run(run_for_test_jthread_sleep);
+
+    reset_tested_thread_iterator(&tts);
+    while(next_tested_thread(&tts)){
+        check_tested_thread_phase(tts, TT_PHASE_SLEEPING);      
+    }
+    for (i = 0; i <= MAX_TESTED_THREAD_NUMBER; i++){
+        sleeping_nmb = 0;
+        sleeping_tts = NULL;
+
+        reset_tested_thread_iterator(&tts);
+        while(next_tested_thread(&tts)){
+            check_tested_thread_phase(tts, TT_PHASE_ANY); // to make thread running
+            if (tts->phase == TT_PHASE_SLEEPING){
+                sleeping_nmb++;
+                sleeping_tts = tts;
+            } else {
+                check_tested_thread_phase(tts, TT_PHASE_DEAD);
+            }
+        }
+        if (MAX_TESTED_THREAD_NUMBER - sleeping_nmb - i != 0){
+            tf_fail("Wrong number of sleeping threads");
+        }
+        if (sleeping_nmb > 0){
+            tf_assert_same(jthread_interrupt(sleeping_tts->java_thread), TM_ERROR_NONE);
+            check_tested_thread_phase(sleeping_tts, TT_PHASE_DEAD);
+        }
+    }
+
+    // Terminate all threads and clear tts structures
+    tested_threads_destroy();
+
+    return TEST_PASSED;
+}
+
+/*
+ * Test jthread_get_JNI_env(...)
+ */
+int test_jthread_get_JNI_env(void) {
+
+    tested_thread_sturct_t *tts;
+
+    // Initialize tts structures and run all tested threads
+    tested_threads_run(default_run_for_test);
+
+    reset_tested_thread_iterator(&tts);
+    while(next_tested_thread(&tts)){
+        tf_assert_same(jthread_get_JNI_env(tts->java_thread), tts->jni_env);
+    }
+    // Terminate all threads and clear tts structures
+    tested_threads_destroy();
+
+    return TEST_PASSED;
+}
+
+/*
+ * Test hythread_yield()
+ */
+void run_for_test_hythread_yield(void){
+
+    tested_thread_sturct_t * tts = current_thread_tts;
+
+    /*
+      IDATA status;
+      tts->phase = TT_PHASE_RUNNING;
+    */
+
+    while(1){
+        tts->clicks++;
+        hythread_yield();
+        if (tts->stop) {
+            break;
+        }
+    }
+
+    /*
+      tts->phase = (status == TM_ERROR_NONE ? TT_PHASE_DEAD : TT_PHASE_ERROR);
+    */
+}
+int test_hythread_yield (void){
+
+    tested_thread_sturct_t *tts;
+
+    // Initialize tts structures and run all tested threads
+    tested_threads_run(run_for_test_hythread_yield);
+
+    reset_tested_thread_iterator(&tts);
+    while(next_tested_thread(&tts)){
+        tts->stop = 1;
+        check_tested_thread_phase(tts, TT_PHASE_DEAD);  
+    }
+
+    // Terminate all threads (not needed here) and clear tts structures
+    tested_threads_destroy();
+
+    return TEST_PASSED;
+} 
+
+TEST_LIST_START
+    TEST(test_jthread_attach)
+    TEST(test_jthread_detach)
+    TEST(test_hythread_create)
+    TEST(test_hythread_create_with_function)
+    TEST(test_jthread_get_JNI_env)
+    TEST(test_jthread_join)
+    //TEST(test_jthread_timed_join)
+    TEST(test_jthread_exception_stop)
+    TEST(test_jthread_stop)
+    TEST(test_jthread_sleep)
+    TEST(test_hythread_yield)
+TEST_LIST_END;
+    
+     

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_identify.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_identify.c?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_identify.c (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_identify.c Wed Aug 23 09:48:41 2006
@@ -0,0 +1,100 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+#include <stdio.h>
+#include "testframe.h"
+#include "thread_unit_test_utils.h"
+#include <open/jthread.h>
+#include <open/hythread_ext.h>
+#include "thread_private.h"
+
+
+/*
+ * Test jthread_self(...)
+ */
+void run_for_test_jthread_self(void){
+
+    tested_thread_sturct_t * tts = current_thread_tts;
+    
+    tts->phase = TT_PHASE_RUNNING;
+    while(1){
+        if (jthread_self()->object != tts->java_thread->object){
+            tts->phase = TT_PHASE_ERROR;
+            return;
+        }
+        tts->clicks++;
+        sleep_a_click();
+        if (tts->stop) {
+            break;
+        }
+    }
+    tts->phase = TT_PHASE_DEAD;
+}
+
+int test_jthread_self(void) {
+
+    tested_thread_sturct_t *tts;
+
+    // Initialize tts structures and run all tested threads
+    tested_threads_run(run_for_test_jthread_self);
+
+    reset_tested_thread_iterator(&tts);
+    while(next_tested_thread(&tts)){
+        tts->stop = 1;
+        check_tested_thread_phase(tts, TT_PHASE_DEAD);
+    }
+    // Terminate all threads (not needed here) and clear tts structures
+    tested_threads_destroy();
+
+    return TEST_PASSED;
+}
+
+/*
+ * Test jthread_get_id(...)
+ */
+int test_jthread_get_id(void) {
+
+    tested_thread_sturct_t *tts;
+    jlong id;
+
+    // Initialize tts structures and run all tested threads
+    tested_threads_run(default_run_for_test);
+
+    reset_tested_thread_iterator(&tts);
+    while(next_tested_thread(&tts)){
+        id = jthread_get_id(tts->java_thread);
+        tf_assert_same(jthread_get_thread(id)->object, tts->java_thread->object);
+        //tf_assert_same(hythread_detach(tts->java_thread), TM_ERROR_NONE);
+        //tf_assert(jthread_get_id(tts->java_thread) == 0);
+    }
+    // Terminate all threads (not needed here) and clear tts structures
+    tested_threads_destroy();
+
+    return TEST_PASSED;
+}
+/*
+ * Test jthread_get_thread(...)
+ */
+int test_jthread_get_thread(void) {
+
+    return test_jthread_get_id();
+}
+
+TEST_LIST_START
+    TEST(test_jthread_self)
+    TEST(test_jthread_get_id)
+    TEST(test_jthread_get_thread)
+TEST_LIST_END;

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_identify.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_interrupt.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_interrupt.c?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_interrupt.c (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_interrupt.c Wed Aug 23 09:48:41 2006
@@ -0,0 +1,186 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+#include <stdio.h>
+#include "testframe.h"
+#include "thread_unit_test_utils.h"
+#include <open/jthread.h>
+
+/*
+ * Test jthread_interrupt(...)
+ */
+void run_for_test_jthread_interrupt(void){
+
+    tested_thread_sturct_t * tts = current_thread_tts;
+    
+    tts->phase = TT_PHASE_RUNNING;
+    while(1){
+        tts->clicks++;
+        sleep_a_click();
+        if (jthread_is_interrupted(jthread_self())) {
+            break;
+        }
+    }
+    tts->phase = TT_PHASE_INTERRUPTED;
+    while(1){
+        tts->clicks++;
+        sleep_a_click();
+        if (tts->stop) {
+            break;
+        }
+    }
+    tts->phase = TT_PHASE_DEAD;
+}
+
+int test_jthread_interrupt(void){
+
+    tested_thread_sturct_t *tts;
+
+    // Initialize tts structures and run all tested threads
+    tested_threads_run(run_for_test_jthread_interrupt);
+
+    reset_tested_thread_iterator(&tts);
+    while(next_tested_thread(&tts)){
+        tf_assert_same(jthread_is_interrupted(tts->java_thread), 0);
+        tf_assert_same(jthread_clear_interrupted(tts->java_thread), TM_ERROR_NONE);
+        tf_assert_same(jthread_is_interrupted(tts->java_thread), 0);
+
+        tf_assert_same(jthread_interrupt(tts->java_thread), TM_ERROR_NONE);
+
+        check_tested_thread_phase(tts, TT_PHASE_INTERRUPTED);
+        tf_assert_same(jthread_is_interrupted(tts->java_thread), 1);
+        tf_assert_same(jthread_interrupt(tts->java_thread), TM_ERROR_NONE);
+        tf_assert_same(jthread_is_interrupted(tts->java_thread), 1);
+        tf_assert_same(jthread_clear_interrupted(tts->java_thread), TM_ERROR_INTERRUPT);
+        tf_assert_same(jthread_is_interrupted(tts->java_thread), 0);
+    }
+    // Terminate all threads and clear tts structures
+    tested_threads_destroy();
+
+    return TEST_PASSED;
+} 
+/*
+ * Test jthread_is_interrupted(...)
+ */
+void run_for_test_jthread_is_interrupted(void){
+
+    tested_thread_sturct_t * tts = current_thread_tts;
+    
+    tts->phase = TT_PHASE_RUNNING;
+    while(1){
+        tts->clicks++;
+        sleep_a_click();
+        if (jthread_is_interrupted(jthread_self())) {
+            break;
+        }
+    }
+    tts->phase = TT_PHASE_INTERRUPTED;
+    while(1){
+        tts->clicks++;
+        sleep_a_click();
+        if (tts->stop) {
+            break;
+        }
+    }
+    tts->phase = TT_PHASE_DEAD;
+}
+int test_jthread_is_interrupted(void){
+
+    tested_thread_sturct_t *tts;
+
+    // Initialize tts structures and run all tested threads
+    tested_threads_run(run_for_test_jthread_is_interrupted);
+
+    reset_tested_thread_iterator(&tts);
+    while(next_tested_thread(&tts)){
+        tf_assert_same(jthread_is_interrupted(tts->java_thread), 0);
+        tf_assert_same(jthread_clear_interrupted(tts->java_thread), TM_ERROR_NONE);
+        tf_assert_same(jthread_is_interrupted(tts->java_thread), 0);
+
+        tf_assert_same(jthread_interrupt(tts->java_thread), TM_ERROR_NONE);
+
+        check_tested_thread_phase(tts, TT_PHASE_INTERRUPTED);
+        tf_assert_same(jthread_is_interrupted(tts->java_thread), 1);
+        tf_assert_same(jthread_interrupt(tts->java_thread), TM_ERROR_NONE);
+        tf_assert_same(jthread_is_interrupted(tts->java_thread), 1);
+        tf_assert_same(jthread_clear_interrupted(tts->java_thread), TM_ERROR_INTERRUPT);
+        tf_assert_same(jthread_is_interrupted(tts->java_thread), 0);
+    }
+    // Terminate all threads and clear tts structures
+    tested_threads_destroy();
+
+    return TEST_PASSED;
+} 
+
+/*
+ * Test jthread_clear_interrupted(...)
+ */
+void run_for_test_jthread_clear_interrupted(void){
+
+    tested_thread_sturct_t * tts = current_thread_tts;
+    
+    tts->phase = TT_PHASE_RUNNING;
+    while(1){
+        tts->clicks++;
+        sleep_a_click();
+        if (jthread_is_interrupted(jthread_self())) {
+            break;
+        }
+    }
+    tts->phase = TT_PHASE_INTERRUPTED;
+    while(1){
+        tts->clicks++;
+        sleep_a_click();
+        if (tts->stop) {
+            break;
+        }
+    }
+    tts->phase = TT_PHASE_DEAD;
+}
+
+int test_jthread_clear_interrupted(void){
+
+    tested_thread_sturct_t *tts;
+
+    // Initialize tts structures and run all tested threads
+    tested_threads_run(run_for_test_jthread_clear_interrupted);
+
+    reset_tested_thread_iterator(&tts);
+    while(next_tested_thread(&tts)){
+        tf_assert_same(jthread_is_interrupted(tts->java_thread), 0);
+        tf_assert_same(jthread_clear_interrupted(tts->java_thread), TM_ERROR_NONE);
+        tf_assert_same(jthread_is_interrupted(tts->java_thread), 0);
+
+        tf_assert_same(jthread_interrupt(tts->java_thread), TM_ERROR_NONE);
+
+        check_tested_thread_phase(tts, TT_PHASE_INTERRUPTED);
+        tf_assert_same(jthread_is_interrupted(tts->java_thread), 1);
+        tf_assert_same(jthread_interrupt(tts->java_thread), TM_ERROR_NONE);
+        tf_assert_same(jthread_is_interrupted(tts->java_thread), 1);
+        tf_assert_same(jthread_clear_interrupted(tts->java_thread), TM_ERROR_INTERRUPT);
+        tf_assert_same(jthread_is_interrupted(tts->java_thread), 0);
+    }
+    // Terminate all threads and clear tts structures
+    tested_threads_destroy();
+
+    return TEST_PASSED;
+} 
+
+TEST_LIST_START
+    TEST(test_jthread_interrupt)
+    TEST(test_jthread_is_interrupted)
+    TEST(test_jthread_clear_interrupted)
+TEST_LIST_END;

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_interrupt.c
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message