gcc/libjava/include/execution.h
David Daney 86acf60c5b configure.ac (INTERPRETER): New AM_CONDITIONAL.
* configure.ac (INTERPRETER): New AM_CONDITIONAL.
	* scripts/makemake.tcl (package_map): Mark jdwp and jvmti packages
	as being for interpreter only.  Place interpreter related files in
	'if INTERPRETER' block.
	(interpreter_package_files): New list.
	(interpreter_header_vars): Ditto.
	(emit_package_rule_to_list): Renamed from emit_package_rule with
	new target list parameter.
	(emit_package_rule): Rewritten to call emit_package_rule_to_list.
	(emit_interpreter_rule): New function.
	(emit_source_var): Place interpreter related files in
	interpreter_header_vars.
	* Makefile.am (ACLOCAL_AMFLAGS): Add -I libltdl.
	(libgcj_interpret_source_files): New variable.
	(libgcj_la_SOURCES): Move jvmti.cc and  interpret.cc to
	libgcj_interpret_source_files and include
	libgcj_interpret_source_files.
	(nat_jdwp_source_files): New variable.
	(nat_jvmti_source_files): Ditto.
	(nat_source_files): Move jdwp and jvmti related files to
	nat_jdwp_source_files and nat_jvmti_source_files and include
	nat_jdwp_source_files and nat_jvmti_source_files.
	* Makefile.in: Regenerate.
	* include/Makefile.in: Ditto.
	* testsuite/Makefile.in: Ditto.
	* gcj/Makefile.in: Ditto.
	* sources.am: Ditto.
	* configure: Ditto.
	* include/config.h.in: Ditto.
	* interpret.cc: Remove #ifdef INTERPRETER block.
	* stacktrace.cc (UnwindTraceFn): Do not handle proxy frames if
	interpreter disabled.
	* include/java-interp.h (_Jv_FrameType): Move outside of
	#ifdef INTERPRETER block.
	* include/execution.h (_Jv_IndirectCompiledEngine::do_get_closure_list,
	_Jv_InterpreterEngine, _Jv_soleInterpreterEngine): Place in
	#ifdef INTERPRETER block.
	* jni.cc (jvmti.h, jvmti-int.h):  Only include if INTERPRETER is
	defined.
	(_Jv_JNI_PopSystemFrame, _Jv_JNI_GetEnv): Only do jvmti processing
	if INTERPRETER is defined.
	* prims.cc (jvmti.h, jvmti-int.h, Jdwp.h, VMVirtualMachine.h):  Only
	include if INTERPRETER is defined.
	(defaultJdwpOptions, jdwpOptions, jvmti_agent_onload_func,
	jvmti_agent_onunload_func, jvmti_agentonload, jvmti_agentonunload,
	jvmti_agent_opts, load_jvmti_agent): Only define if INTERPRETER is
	defined.
	(parse_x_arg): Only process 'runjdwp:' if INTERPRETER is defined.
	(parse_init_args): Only process jvmti related options if
	INTERPRETER is defined.
	(_Jv_CreateJavaVM): Only call _Jv_JVMTI_Init if INTERPRETER is
	defined.
	(_Jv_RunMain): Only do jvmti and jdwp processing if INTERPRETER is
	defined.
	* link.cc (jvmti.h, jvmti-int.h):  Only include if INTERPRETER is
	defined.
	(_Jv_ThrowNoClassDefFoundError, _Jv_Linker::create_error_method):
	Define if if INTERPRETER is not defined.
	(_Jv_Linker::wait_for_state): Only do jvmti proccessing if
	INTERPRETER is defined.
	* boehm.cc (closure_list_pointer, finalize_closure_list,
	_Jv_ClosureListFinalizer): Only define if INTERPRETER is
	defined.
	* java/lang/natThread.cc (jvmti.h, jvmti-int.h):  Only include if
	INTERPRETER is defined.
	(finish_, _Jv_NotifyThreadStart): Only do jvmti proccessing if
	INTERPRETER is defined.
	* java/lang/Class.h (_Jv_InterpreterEngine): Move declaration
	and friend declaration inside #ifdef INTERPRETER block.
	* java/lang/natClass.cc (_Jv_ClosureList::releaseClosures,
	_Jv_ClosureList::registerClosure, _Jv_GetInterpClassSourceFile):
	Only define if INTERPRETER is defined.
	* java/lang/reflect/natVMProxy.cc (UnsupportedOperationException.h):
	Include.
	(generateProxyClass): Throw UnsupportedOperationException unless
	INTERPRETER is defined.

From-SVN: r127097
2007-07-31 16:17:21 +00:00

277 lines
6.7 KiB
C++

// execution.h - Execution engines. -*- c++ -*-
/* Copyright (C) 2004, 2006, 2007 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
#ifndef __JAVA_EXECUTION_H__
#define __JAVA_EXECUTION_H__
// This represents one execution engine. Note that we use function
// pointers and not virtual methods to avoid calls to
// __cxa_call_unexpected and the like.
struct _Jv_ExecutionEngine
{
public:
void (*unregister) (jclass);
// FIXME: probably should handle this elsewhere, see how
// interpreter does it.
bool (*need_resolve_string_fields) ();
void (*verify) (jclass);
void (*allocate_static_fields) (jclass, int, int);
void (*allocate_field_initializers) (jclass);
void (*create_ncode) (jclass);
_Jv_ResolvedMethod *(*resolve_method) (_Jv_Method *, jclass,
jboolean);
void (*post_miranda_hook) (jclass);
_Jv_ClosureList **(*get_closure_list) (jclass);
};
// This handles gcj-compiled code except that compiled with
// -findirect-classes.
struct _Jv_CompiledEngine : public _Jv_ExecutionEngine
{
public:
static void do_unregister (jclass)
{
}
static bool do_need_resolve_string_fields ()
{
return true;
}
static void do_verify (jclass klass)
{
_Jv_Linker::verify_type_assertions (klass);
}
static _Jv_ResolvedMethod *do_resolve_method (_Jv_Method *, jclass,
jboolean)
{
return NULL;
}
static void do_allocate_static_fields (jclass,
int,
int)
{
}
static void do_allocate_field_initializers (jclass)
{
}
static void do_create_ncode (jclass)
{
// Not needed.
}
static void do_post_miranda_hook (jclass)
{
// Not needed.
}
static _Jv_ClosureList **do_get_closure_list (jclass)
{
return NULL;
}
_Jv_CompiledEngine ()
{
unregister = do_unregister;
need_resolve_string_fields = do_need_resolve_string_fields;
verify = do_verify;
allocate_static_fields = do_allocate_static_fields;
allocate_field_initializers = do_allocate_field_initializers;
create_ncode = do_create_ncode;
resolve_method = do_resolve_method;
post_miranda_hook = do_post_miranda_hook;
get_closure_list = do_get_closure_list;
}
// These operators make it so we don't have to link in libstdc++.
void *operator new (size_t bytes)
{
return _Jv_Malloc(bytes);
}
void operator delete (void *mem)
{
_Jv_Free(mem);
}
};
class _Jv_IndirectCompiledClass
{
public:
void **field_initializers;
_Jv_ClosureList **closures;
};
// This handles gcj-compiled code compiled with -findirect-classes.
struct _Jv_IndirectCompiledEngine : public _Jv_CompiledEngine
{
_Jv_IndirectCompiledEngine () : _Jv_CompiledEngine ()
{
allocate_static_fields = do_allocate_static_fields;
allocate_field_initializers = do_allocate_field_initializers;
get_closure_list = do_get_closure_list;
}
static _Jv_IndirectCompiledClass *get_aux_info (jclass klass)
{
_Jv_IndirectCompiledClass *aux =
(_Jv_IndirectCompiledClass*)klass->aux_info;
if (!aux)
{
aux = (_Jv_IndirectCompiledClass*)
_Jv_AllocRawObj (sizeof (_Jv_IndirectCompiledClass));
klass->aux_info = aux;
}
return aux;
}
static void do_allocate_field_initializers (jclass klass)
{
_Jv_IndirectCompiledClass *aux = get_aux_info (klass);
if (!aux)
{
aux = (_Jv_IndirectCompiledClass*)
_Jv_AllocRawObj (sizeof (_Jv_IndirectCompiledClass));
klass->aux_info = aux;
}
aux->field_initializers = (void **)_Jv_Malloc (klass->field_count
* sizeof (void*));
for (int i = 0; i < klass->field_count; i++)
{
_Jv_Field *field = &klass->fields[i];
if (field->flags & java::lang::reflect::Modifier::STATIC)
{
aux->field_initializers[i] = field->u.addr;
field->u.addr = NULL;
}
}
}
static void do_allocate_static_fields (jclass klass,
int pointer_size,
int other_size)
{
// Splitting the allocations here lets us scan reference fields
// and avoid scanning non-reference fields.
char *reference_fields = (char *) _Jv_AllocRawObj (pointer_size);
char *non_reference_fields = (char *) _Jv_AllocBytes (other_size);
_Jv_IndirectCompiledClass *aux
= (_Jv_IndirectCompiledClass*)klass->aux_info;
for (int i = 0; i < klass->field_count; i++)
{
_Jv_Field *field = &klass->fields[i];
if ((field->flags & java::lang::reflect::Modifier::STATIC) == 0)
continue;
char *base = field->isRef() ? reference_fields : non_reference_fields;
field->u.addr = base + field->u.boffset;
if (aux->field_initializers[i])
{
int field_size;
if (! field->isRef ())
field_size = field->type->size ();
else
field_size = sizeof (jobject);
memcpy (field->u.addr, aux->field_initializers[i], field_size);
}
}
_Jv_Free (aux->field_initializers);
}
#ifdef INTERPRETER
static _Jv_ClosureList **do_get_closure_list (jclass klass)
{
_Jv_IndirectCompiledClass *aux = get_aux_info (klass);
if (!aux->closures)
aux->closures = _Jv_ClosureListFinalizer ();
return aux->closures;
}
#endif
};
#ifdef INTERPRETER
// This handles interpreted code.
class _Jv_InterpreterEngine : public _Jv_ExecutionEngine
{
public:
static void do_verify (jclass);
static void do_allocate_static_fields (jclass, int, int);
static void do_create_ncode (jclass);
static _Jv_ResolvedMethod *do_resolve_method (_Jv_Method *, jclass,
jboolean);
static bool do_need_resolve_string_fields ()
{
return false;
}
static void do_unregister(jclass klass)
{
_Jv_UnregisterClass(klass);
}
static void do_allocate_field_initializers (jclass)
{
}
static void do_post_miranda_hook (jclass);
static _Jv_ClosureList **do_get_closure_list (jclass klass);
_Jv_InterpreterEngine ()
{
unregister = do_unregister;
need_resolve_string_fields = do_need_resolve_string_fields;
verify = do_verify;
allocate_static_fields = do_allocate_static_fields;
allocate_field_initializers = do_allocate_field_initializers;
create_ncode = do_create_ncode;
resolve_method = do_resolve_method;
post_miranda_hook = do_post_miranda_hook;
get_closure_list = do_get_closure_list;
}
// These operators make it so we don't have to link in libstdc++.
void *operator new (size_t bytes)
{
return _Jv_Malloc(bytes);
}
void operator delete (void *mem)
{
_Jv_Free(mem);
}
};
extern _Jv_InterpreterEngine _Jv_soleInterpreterEngine;
#endif // INTERPRETER
extern _Jv_CompiledEngine _Jv_soleCompiledEngine;
extern _Jv_IndirectCompiledEngine _Jv_soleIndirectCompiledEngine;
#endif // __JAVA_EXECUTION_H__