diff options
Diffstat (limited to 'libjava/interpret.cc')
-rw-r--r-- | libjava/interpret.cc | 81 |
1 files changed, 40 insertions, 41 deletions
diff --git a/libjava/interpret.cc b/libjava/interpret.cc index c5d2afdb905..332833b4454 100644 --- a/libjava/interpret.cc +++ b/libjava/interpret.cc @@ -774,46 +774,17 @@ _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; - // 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 - // rather than about the interpreter itself. FRAME_DESC has a - // destructor so it cleans up automatically when the interpreter - // returns. - java::lang::Thread *thread = java::lang::Thread::currentThread(); - _Jv_MethodChain frame_desc (this, - (_Jv_MethodChain **) &thread->interp_frame); - - _Jv_word stack[max_stack]; - _Jv_word *sp = stack; - - _Jv_word locals[max_locals]; - - /* Go straight at it! the ffi raw format matches the internal - stack representation exactly. At least, that's the idea. - */ - memcpy ((void*) locals, (void*) args, args_raw_size); - - _Jv_word *pool_data = defining_class->constants.data; - - /* These three are temporaries for common code used by several - instructions. */ - void (*fun)(); - _Jv_ResolvedMethod* rmeth; - int tmpval; - #define INSN_LABEL(op) &&insn_##op static const void *const insn_target[] = @@ -1027,6 +998,41 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args) 0 }; + // 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. + if (_Jv_StartOfInterpreter == NULL) + _Jv_StartOfInterpreter = _Unwind_FindEnclosingFunction ((void *) insn_target[0]); + + // 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 + // rather than about the interpreter itself. FRAME_DESC has a + // destructor so it cleans up automatically when the interpreter + // returns. + java::lang::Thread *thread = java::lang::Thread::currentThread(); + _Jv_MethodChain frame_desc (this, + (_Jv_MethodChain **) &thread->interp_frame); + + _Jv_word stack[max_stack]; + _Jv_word *sp = stack; + + _Jv_word locals[max_locals]; + + /* Go straight at it! the ffi raw format matches the internal + stack representation exactly. At least, that's the idea. + */ + memcpy ((void*) locals, (void*) args, args_raw_size); + + _Jv_word *pool_data = defining_class->constants.data; + + /* These three are temporaries for common code used by several + instructions. */ + void (*fun)(); + _Jv_ResolvedMethod* rmeth; + int tmpval; + pc_t pc; #ifdef DIRECT_THREADED @@ -3227,13 +3233,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) { |