OSDN Git Service

* passes.c (rest_of_handle_jump): Remove dead code.
[pf3gnuchains/gcc-fork.git] / libjava / interpret.cc
index 40c7cba..0446c72 100644 (file)
@@ -774,18 +774,25 @@ _Jv_InterpMethod::compile (const void * const *insn_targets)
 }
 #endif /* DIRECT_THREADED */
 
-// This function exists so that the stack-tracing code can find the
-// boundaries of the interpreter.
-void
-_Jv_StartOfInterpreter (void)
-{
-}
+// These exist so that the stack-tracing code can find the boundaries
+// of the interpreter.
+void *_Jv_StartOfInterpreter;
+void *_Jv_EndOfInterpreter;
+extern "C" void *_Unwind_FindEnclosingFunction (void *pc);
 
 void
 _Jv_InterpMethod::run (void *retp, ffi_raw *args)
 {
   using namespace java::lang::reflect;
 
+  // Record the address of the start of this member function in
+  // _Jv_StartOfInterpreter.  Such a write to a global variable
+  // without acquiring a lock is correct iff reads and writes of words
+  // in memory are atomic, but Java requires that anyway.
+ foo:
+  if (_Jv_StartOfInterpreter == NULL)
+    _Jv_StartOfInterpreter = _Unwind_FindEnclosingFunction (&&foo);
+
   // FRAME_DESC registers this particular invocation as the top-most
   // interpreter frame.  This lets the stack tracing code (for
   // Throwable) print information about the method being interpreted
@@ -1207,15 +1214,15 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args)
            switch (rtype)
              {
              case FFI_TYPE_SINT8:
-               PUSHI (rvalue.byte_value);
+               PUSHI ((jbyte)(rvalue.int_value & 0xff));
                break;
 
              case FFI_TYPE_SINT16:
-               PUSHI (rvalue.short_value);
+               PUSHI ((jshort)(rvalue.int_value & 0xffff));
                break;
 
              case FFI_TYPE_UINT16:
-               PUSHI (rvalue.char_value);
+               PUSHI (rvalue.int_value & 0xffff);
                break;
 
              case FFI_TYPE_FLOAT:
@@ -3219,13 +3226,6 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args)
     }
 }
 
-// This function exists so that the stack-tracing code can find the
-// boundaries of the interpreter.
-void
-_Jv_EndOfInterpreter (void)
-{
-}
-
 static void
 throw_internal_error (char *msg)
 {