OSDN Git Service

2005-05-18 Thomas Koenig <Thomas.Koenig@online.de>
[pf3gnuchains/gcc-fork.git] / libjava / include / execution.h
1 // execution.h - Execution engines. -*- c++ -*-
2
3 /* Copyright (C) 2004  Free Software Foundation
4
5    This file is part of libgcj.
6
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
9 details.  */
10
11 #ifndef __JAVA_EXECUTION_H__
12 #define __JAVA_EXECUTION_H__
13
14 // This represents one execution engine.  Note that we use function
15 // pointers and not virtual methods to avoid calls to
16 // __cxa_call_unexpected and the like.
17 struct _Jv_ExecutionEngine
18 {
19  public:
20
21   void (*unregister) (jclass);
22   // FIXME: probably should handle this elsewhere, see how
23   // interpreter does it.
24   bool (*need_resolve_string_fields) ();
25   void (*verify) (jclass);
26   void (*allocate_static_fields) (jclass, int);
27   void (*create_ncode) (jclass);
28   _Jv_ResolvedMethod *(*resolve_method) (_Jv_Method *, jclass,
29                                          jboolean, jint);
30   void (*post_miranda_hook) (jclass);
31 };
32
33 // This handles all gcj-compiled code, including BC ABI.
34 struct _Jv_CompiledEngine : public _Jv_ExecutionEngine
35 {
36  public:
37
38   static void do_unregister (jclass)
39   {
40   }
41
42   static bool do_need_resolve_string_fields ()
43   {
44     return true;
45   }
46
47   static void do_verify (jclass klass)
48   {
49     _Jv_Linker::verify_type_assertions (klass);
50   }
51
52   static _Jv_ResolvedMethod *do_resolve_method (_Jv_Method *, jclass,
53                                                 jboolean, jint)
54   {
55     return NULL;
56   }
57
58   static void do_allocate_static_fields (jclass, int)
59   {
60     // Compiled classes don't need this.
61   }
62
63   static void do_create_ncode (jclass)
64   {
65     // Not needed.
66   }
67
68   static void do_post_miranda_hook (jclass)
69   {
70     // Not needed.
71   }
72
73   _Jv_CompiledEngine ()
74   {
75     unregister = do_unregister;
76     need_resolve_string_fields = do_need_resolve_string_fields;
77     verify = do_verify;
78     allocate_static_fields = do_allocate_static_fields;
79     create_ncode = do_create_ncode;
80     resolve_method = do_resolve_method;
81     post_miranda_hook = do_post_miranda_hook;
82   }
83
84   // These operators make it so we don't have to link in libstdc++.
85   void *operator new (size_t bytes)
86   {
87     return _Jv_Malloc(bytes);
88   }
89
90   void operator delete (void *mem)
91   {
92     _Jv_Free(mem);
93   }
94 };
95
96 // This handles interpreted code.
97 class _Jv_InterpreterEngine : public _Jv_ExecutionEngine
98 {
99  public:
100
101   static void do_verify (jclass);
102   static void do_allocate_static_fields (jclass, int);
103   static void do_create_ncode (jclass);
104   static _Jv_ResolvedMethod *do_resolve_method (_Jv_Method *, jclass,
105                                                 jboolean, jint);
106
107   static bool do_need_resolve_string_fields ()
108   {
109     return false;
110   }
111
112   static void do_unregister(jclass klass)
113   {
114     _Jv_UnregisterClass(klass);
115   }
116
117   static void do_post_miranda_hook (jclass);
118
119   _Jv_InterpreterEngine ()
120   {
121     unregister = do_unregister;
122     need_resolve_string_fields = do_need_resolve_string_fields;
123     verify = do_verify;
124     allocate_static_fields = do_allocate_static_fields;
125     create_ncode = do_create_ncode;
126     resolve_method = do_resolve_method;
127     post_miranda_hook = do_post_miranda_hook;
128   }
129
130   // These operators make it so we don't have to link in libstdc++.
131   void *operator new (size_t bytes)
132   {
133     return _Jv_Malloc(bytes);
134   }
135
136   void operator delete (void *mem)
137   {
138     _Jv_Free(mem);
139   }
140 };
141
142
143 extern _Jv_InterpreterEngine _Jv_soleInterpreterEngine;
144 extern _Jv_CompiledEngine _Jv_soleCompiledEngine;
145
146 #endif // __JAVA_EXECUTION_H__