| 1 |
287 |
jeremybenn |
/* Process declarations and variables for the GNU compiler for the
|
| 2 |
|
|
Java(TM) language.
|
| 3 |
|
|
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007,
|
| 4 |
|
|
2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
|
| 5 |
|
|
|
| 6 |
|
|
This file is part of GCC.
|
| 7 |
|
|
|
| 8 |
|
|
GCC is free software; you can redistribute it and/or modify
|
| 9 |
|
|
it under the terms of the GNU General Public License as published by
|
| 10 |
|
|
the Free Software Foundation; either version 3, or (at your option)
|
| 11 |
|
|
any later version.
|
| 12 |
|
|
|
| 13 |
|
|
GCC is distributed in the hope that it will be useful,
|
| 14 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 15 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 16 |
|
|
GNU General Public License for more details.
|
| 17 |
|
|
|
| 18 |
|
|
You should have received a copy of the GNU General Public License
|
| 19 |
|
|
along with GCC; see the file COPYING3. If not see
|
| 20 |
|
|
<http://www.gnu.org/licenses/>.
|
| 21 |
|
|
|
| 22 |
|
|
Java and all Java-based marks are trademarks or registered trademarks
|
| 23 |
|
|
of Sun Microsystems, Inc. in the United States and other countries.
|
| 24 |
|
|
The Free Software Foundation is independent of Sun Microsystems, Inc. */
|
| 25 |
|
|
|
| 26 |
|
|
/* Hacked by Per Bothner <bothner@cygnus.com> February 1996. */
|
| 27 |
|
|
|
| 28 |
|
|
#include "config.h"
|
| 29 |
|
|
#include "system.h"
|
| 30 |
|
|
#include "coretypes.h"
|
| 31 |
|
|
#include "tm.h"
|
| 32 |
|
|
#include "tree.h"
|
| 33 |
|
|
#include "rtl.h"
|
| 34 |
|
|
#include "real.h"
|
| 35 |
|
|
#include "toplev.h"
|
| 36 |
|
|
#include "flags.h"
|
| 37 |
|
|
#include "java-tree.h"
|
| 38 |
|
|
#include "jcf.h"
|
| 39 |
|
|
#include "function.h"
|
| 40 |
|
|
#include "expr.h"
|
| 41 |
|
|
#include "libfuncs.h"
|
| 42 |
|
|
#include "except.h"
|
| 43 |
|
|
#include "java-except.h"
|
| 44 |
|
|
#include "ggc.h"
|
| 45 |
|
|
#include "timevar.h"
|
| 46 |
|
|
#include "cgraph.h"
|
| 47 |
|
|
#include "tree-inline.h"
|
| 48 |
|
|
#include "target.h"
|
| 49 |
|
|
#include "version.h"
|
| 50 |
|
|
#include "tree-iterator.h"
|
| 51 |
|
|
#include "langhooks.h"
|
| 52 |
|
|
#include "cgraph.h"
|
| 53 |
|
|
|
| 54 |
|
|
#if defined (DEBUG_JAVA_BINDING_LEVELS)
|
| 55 |
|
|
extern void indent (void);
|
| 56 |
|
|
#endif
|
| 57 |
|
|
|
| 58 |
|
|
static tree push_jvm_slot (int, tree);
|
| 59 |
|
|
static tree lookup_name_current_level (tree);
|
| 60 |
|
|
static tree push_promoted_type (const char *, tree);
|
| 61 |
|
|
static struct binding_level *make_binding_level (void);
|
| 62 |
|
|
static tree create_primitive_vtable (const char *);
|
| 63 |
|
|
static tree check_local_unnamed_variable (tree, tree, tree);
|
| 64 |
|
|
static void parse_version (void);
|
| 65 |
|
|
|
| 66 |
|
|
|
| 67 |
|
|
/* The following ABI flags are used in the high-order bits of the version
|
| 68 |
|
|
ID field. The version ID number itself should never be larger than
|
| 69 |
|
|
0xfffff, so it should be safe to use top 12 bits for these flags. */
|
| 70 |
|
|
|
| 71 |
|
|
#define FLAG_BINARYCOMPAT_ABI (1<<31) /* Class is built with the BC-ABI. */
|
| 72 |
|
|
|
| 73 |
|
|
#define FLAG_BOOTSTRAP_LOADER (1<<30) /* Used when defining a class that
|
| 74 |
|
|
should be loaded by the bootstrap
|
| 75 |
|
|
loader. */
|
| 76 |
|
|
|
| 77 |
|
|
/* If an ABI change is made within a GCC release series, rendering current
|
| 78 |
|
|
binaries incompatible with the old runtimes, this number must be set to
|
| 79 |
|
|
enforce the compatibility rules. */
|
| 80 |
|
|
#define MINOR_BINARYCOMPAT_ABI_VERSION 1
|
| 81 |
|
|
|
| 82 |
|
|
/* The runtime may recognize a variety of BC ABIs (objects generated by
|
| 83 |
|
|
different version of gcj), but will probably always require strict
|
| 84 |
|
|
matching for the ordinary (C++) ABI. */
|
| 85 |
|
|
|
| 86 |
|
|
/* The version ID of the BC ABI that we generate. This must be kept in
|
| 87 |
|
|
sync with parse_version(), libgcj, and reality (if the BC format changes,
|
| 88 |
|
|
this must change). */
|
| 89 |
|
|
#define GCJ_CURRENT_BC_ABI_VERSION \
|
| 90 |
|
|
(4 * 100000 + 0 * 1000 + MINOR_BINARYCOMPAT_ABI_VERSION)
|
| 91 |
|
|
|
| 92 |
|
|
/* The ABI version number. */
|
| 93 |
|
|
tree gcj_abi_version;
|
| 94 |
|
|
|
| 95 |
|
|
/* Name of the Cloneable class. */
|
| 96 |
|
|
tree java_lang_cloneable_identifier_node;
|
| 97 |
|
|
|
| 98 |
|
|
/* Name of the Serializable class. */
|
| 99 |
|
|
tree java_io_serializable_identifier_node;
|
| 100 |
|
|
|
| 101 |
|
|
/* The DECL_MAP is a mapping from (index, type) to a decl node.
|
| 102 |
|
|
If index < max_locals, it is the index of a local variable.
|
| 103 |
|
|
if index >= max_locals, then index-max_locals is a stack slot.
|
| 104 |
|
|
The DECL_MAP mapping is represented as a TREE_VEC whose elements
|
| 105 |
|
|
are a list of decls (VAR_DECL or PARM_DECL) chained by
|
| 106 |
|
|
DECL_LOCAL_SLOT_CHAIN; the index finds the TREE_VEC element, and then
|
| 107 |
|
|
we search the chain for a decl with a matching TREE_TYPE. */
|
| 108 |
|
|
|
| 109 |
|
|
static GTY(()) tree decl_map;
|
| 110 |
|
|
|
| 111 |
|
|
/* The base_decl_map is contains one variable of ptr_type: this is
|
| 112 |
|
|
used to contain every variable of reference type that is ever
|
| 113 |
|
|
stored in a local variable slot. */
|
| 114 |
|
|
|
| 115 |
|
|
static GTY(()) tree base_decl_map;
|
| 116 |
|
|
|
| 117 |
|
|
/* An index used to make temporary identifiers unique. */
|
| 118 |
|
|
static int uniq;
|
| 119 |
|
|
|
| 120 |
|
|
/* A list of local variables VAR_DECLs for this method that we have seen
|
| 121 |
|
|
debug information, but we have not reached their starting (byte) PC yet. */
|
| 122 |
|
|
|
| 123 |
|
|
static GTY(()) tree pending_local_decls;
|
| 124 |
|
|
|
| 125 |
|
|
/* The decl for "_Jv_ResolvePoolEntry". */
|
| 126 |
|
|
tree soft_resolvepoolentry_node;
|
| 127 |
|
|
|
| 128 |
|
|
/* The decl for the .constants field of an instance of Class. */
|
| 129 |
|
|
tree constants_field_decl_node;
|
| 130 |
|
|
|
| 131 |
|
|
/* The decl for the .data field of an instance of Class. */
|
| 132 |
|
|
tree constants_data_field_decl_node;
|
| 133 |
|
|
|
| 134 |
|
|
#if defined(DEBUG_JAVA_BINDING_LEVELS)
|
| 135 |
|
|
int binding_depth = 0;
|
| 136 |
|
|
int is_class_level = 0;
|
| 137 |
|
|
int current_pc;
|
| 138 |
|
|
|
| 139 |
|
|
void
|
| 140 |
|
|
indent (void)
|
| 141 |
|
|
{
|
| 142 |
|
|
int i;
|
| 143 |
|
|
|
| 144 |
|
|
for (i = 0; i < binding_depth*2; i++)
|
| 145 |
|
|
putc (' ', stderr);
|
| 146 |
|
|
}
|
| 147 |
|
|
#endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */
|
| 148 |
|
|
|
| 149 |
|
|
/* True if decl is a named local variable, i.e. if it is an alias
|
| 150 |
|
|
that's used only for debugging purposes. */
|
| 151 |
|
|
|
| 152 |
|
|
static bool
|
| 153 |
|
|
debug_variable_p (tree decl)
|
| 154 |
|
|
{
|
| 155 |
|
|
if (TREE_CODE (decl) == PARM_DECL)
|
| 156 |
|
|
return false;
|
| 157 |
|
|
|
| 158 |
|
|
if (LOCAL_SLOT_P (decl))
|
| 159 |
|
|
return false;
|
| 160 |
|
|
|
| 161 |
|
|
return true;
|
| 162 |
|
|
}
|
| 163 |
|
|
|
| 164 |
|
|
static tree
|
| 165 |
|
|
push_jvm_slot (int index, tree decl)
|
| 166 |
|
|
{
|
| 167 |
|
|
DECL_CONTEXT (decl) = current_function_decl;
|
| 168 |
|
|
layout_decl (decl, 0);
|
| 169 |
|
|
|
| 170 |
|
|
/* Now link the decl into the decl_map. */
|
| 171 |
|
|
if (DECL_LANG_SPECIFIC (decl) == NULL)
|
| 172 |
|
|
{
|
| 173 |
|
|
MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl);
|
| 174 |
|
|
DECL_LOCAL_START_PC (decl) = 0;
|
| 175 |
|
|
DECL_LOCAL_END_PC (decl) = DECL_CODE_LENGTH (current_function_decl);
|
| 176 |
|
|
DECL_LOCAL_SLOT_NUMBER (decl) = index;
|
| 177 |
|
|
}
|
| 178 |
|
|
DECL_LOCAL_SLOT_CHAIN (decl) = TREE_VEC_ELT (decl_map, index);
|
| 179 |
|
|
TREE_VEC_ELT (decl_map, index) = decl;
|
| 180 |
|
|
|
| 181 |
|
|
return decl;
|
| 182 |
|
|
}
|
| 183 |
|
|
|
| 184 |
|
|
/* Find the best declaration based upon type. If 'decl' fits 'type' better
|
| 185 |
|
|
than 'best', return 'decl'. Otherwise return 'best'. */
|
| 186 |
|
|
|
| 187 |
|
|
static tree
|
| 188 |
|
|
check_local_unnamed_variable (tree best, tree decl, tree type)
|
| 189 |
|
|
{
|
| 190 |
|
|
tree decl_type = TREE_TYPE (decl);
|
| 191 |
|
|
|
| 192 |
|
|
gcc_assert (! LOCAL_VAR_OUT_OF_SCOPE_P (decl));
|
| 193 |
|
|
|
| 194 |
|
|
/* Use the same decl for all integer types <= 32 bits. This is
|
| 195 |
|
|
necessary because sometimes a value is stored as (for example)
|
| 196 |
|
|
boolean but loaded as int. */
|
| 197 |
|
|
if (decl_type == type
|
| 198 |
|
|
|| (INTEGRAL_TYPE_P (decl_type)
|
| 199 |
|
|
&& INTEGRAL_TYPE_P (type)
|
| 200 |
|
|
&& TYPE_PRECISION (decl_type) <= 32
|
| 201 |
|
|
&& TYPE_PRECISION (type) <= 32
|
| 202 |
|
|
&& TYPE_PRECISION (decl_type) >= TYPE_PRECISION (type))
|
| 203 |
|
|
/* ptr_type_node is used for null pointers, which are
|
| 204 |
|
|
assignment compatible with everything. */
|
| 205 |
|
|
|| (TREE_CODE (decl_type) == POINTER_TYPE
|
| 206 |
|
|
&& type == ptr_type_node)
|
| 207 |
|
|
/* Whenever anyone wants to use a slot that is initially
|
| 208 |
|
|
occupied by a PARM_DECL of pointer type they must get that
|
| 209 |
|
|
decl, even if they asked for a pointer to a different type.
|
| 210 |
|
|
However, if someone wants a scalar variable in a slot that
|
| 211 |
|
|
initially held a pointer arg -- or vice versa -- we create a
|
| 212 |
|
|
new VAR_DECL.
|
| 213 |
|
|
|
| 214 |
|
|
???: As long as verification is correct, this will be a
|
| 215 |
|
|
compatible type. But maybe we should create a dummy variable
|
| 216 |
|
|
and replace all references to it with the DECL and a
|
| 217 |
|
|
NOP_EXPR.
|
| 218 |
|
|
*/
|
| 219 |
|
|
|| (TREE_CODE (decl_type) == POINTER_TYPE
|
| 220 |
|
|
&& TREE_CODE (decl) == PARM_DECL
|
| 221 |
|
|
&& TREE_CODE (type) == POINTER_TYPE))
|
| 222 |
|
|
{
|
| 223 |
|
|
if (best == NULL_TREE
|
| 224 |
|
|
|| (decl_type == type && TREE_TYPE (best) != type))
|
| 225 |
|
|
return decl;
|
| 226 |
|
|
}
|
| 227 |
|
|
|
| 228 |
|
|
return best;
|
| 229 |
|
|
}
|
| 230 |
|
|
|
| 231 |
|
|
|
| 232 |
|
|
/* Find a VAR_DECL (or PARM_DECL) at local index INDEX that has type TYPE,
|
| 233 |
|
|
that is valid at PC (or -1 if any pc).
|
| 234 |
|
|
If there is no existing matching decl, allocate one. */
|
| 235 |
|
|
|
| 236 |
|
|
tree
|
| 237 |
|
|
find_local_variable (int index, tree type, int pc ATTRIBUTE_UNUSED)
|
| 238 |
|
|
{
|
| 239 |
|
|
tree tmp = TREE_VEC_ELT (decl_map, index);
|
| 240 |
|
|
tree decl = NULL_TREE;
|
| 241 |
|
|
|
| 242 |
|
|
/* Scan through every declaration that has been created in this
|
| 243 |
|
|
slot. We're only looking for variables that correspond to local
|
| 244 |
|
|
index declarations and PARM_DECLs, not named variables: such
|
| 245 |
|
|
local variables are used only for debugging information. */
|
| 246 |
|
|
while (tmp != NULL_TREE)
|
| 247 |
|
|
{
|
| 248 |
|
|
if (! debug_variable_p (tmp))
|
| 249 |
|
|
decl = check_local_unnamed_variable (decl, tmp, type);
|
| 250 |
|
|
tmp = DECL_LOCAL_SLOT_CHAIN (tmp);
|
| 251 |
|
|
}
|
| 252 |
|
|
|
| 253 |
|
|
/* gcj has a function called promote_type(), which is used by both
|
| 254 |
|
|
the bytecode compiler and the source compiler. Unfortunately,
|
| 255 |
|
|
the type systems for the Java VM and the Java language are not
|
| 256 |
|
|
the same: a boolean in the VM promotes to an int, not to a wide
|
| 257 |
|
|
boolean. If our caller wants something to hold a boolean, that
|
| 258 |
|
|
had better be an int, because that slot might be re-used
|
| 259 |
|
|
later in integer context. */
|
| 260 |
|
|
if (TREE_CODE (type) == BOOLEAN_TYPE)
|
| 261 |
|
|
type = integer_type_node;
|
| 262 |
|
|
|
| 263 |
|
|
/* If we don't find a match, create one with the type passed in.
|
| 264 |
|
|
The name of the variable is #n#m, which n is the variable index
|
| 265 |
|
|
in the local variable area and m is a dummy identifier for
|
| 266 |
|
|
uniqueness -- multiple variables may share the same local
|
| 267 |
|
|
variable index. We don't call pushdecl() to push pointer types
|
| 268 |
|
|
into a binding expr because they'll all be replaced by a single
|
| 269 |
|
|
variable that is used for every reference in that local variable
|
| 270 |
|
|
slot. */
|
| 271 |
|
|
if (! decl)
|
| 272 |
|
|
{
|
| 273 |
|
|
char buf[64];
|
| 274 |
|
|
tree name;
|
| 275 |
|
|
sprintf (buf, "#slot#%d#%d", index, uniq++);
|
| 276 |
|
|
name = get_identifier (buf);
|
| 277 |
|
|
decl = build_decl (input_location, VAR_DECL, name, type);
|
| 278 |
|
|
DECL_IGNORED_P (decl) = 1;
|
| 279 |
|
|
DECL_ARTIFICIAL (decl) = 1;
|
| 280 |
|
|
decl = push_jvm_slot (index, decl);
|
| 281 |
|
|
LOCAL_SLOT_P (decl) = 1;
|
| 282 |
|
|
|
| 283 |
|
|
if (TREE_CODE (type) != POINTER_TYPE)
|
| 284 |
|
|
pushdecl_function_level (decl);
|
| 285 |
|
|
}
|
| 286 |
|
|
|
| 287 |
|
|
/* As well as creating a local variable that matches the type, we
|
| 288 |
|
|
also create a base variable (of ptr_type) that will hold all its
|
| 289 |
|
|
aliases. */
|
| 290 |
|
|
if (TREE_CODE (type) == POINTER_TYPE
|
| 291 |
|
|
&& ! TREE_VEC_ELT (base_decl_map, index))
|
| 292 |
|
|
{
|
| 293 |
|
|
char buf[64];
|
| 294 |
|
|
tree name;
|
| 295 |
|
|
tree base_decl;
|
| 296 |
|
|
sprintf (buf, "#ref#%d#%d", index, uniq++);
|
| 297 |
|
|
name = get_identifier (buf);
|
| 298 |
|
|
base_decl
|
| 299 |
|
|
= TREE_VEC_ELT (base_decl_map, index)
|
| 300 |
|
|
= build_decl (input_location, VAR_DECL, name, ptr_type_node);
|
| 301 |
|
|
pushdecl_function_level (base_decl);
|
| 302 |
|
|
DECL_IGNORED_P (base_decl) = 1;
|
| 303 |
|
|
DECL_ARTIFICIAL (base_decl) = 1;
|
| 304 |
|
|
}
|
| 305 |
|
|
|
| 306 |
|
|
return decl;
|
| 307 |
|
|
}
|
| 308 |
|
|
|
| 309 |
|
|
/* Called during genericization for every variable. If the variable
|
| 310 |
|
|
is a temporary of pointer type, replace it with a common variable
|
| 311 |
|
|
thath is used to hold all pointer types that are ever stored in
|
| 312 |
|
|
that slot. Set WANT_LVALUE if you want a variable that is to be
|
| 313 |
|
|
written to. */
|
| 314 |
|
|
|
| 315 |
|
|
static tree
|
| 316 |
|
|
java_replace_reference (tree var_decl, bool want_lvalue)
|
| 317 |
|
|
{
|
| 318 |
|
|
tree decl_type;
|
| 319 |
|
|
|
| 320 |
|
|
if (! base_decl_map)
|
| 321 |
|
|
return var_decl;
|
| 322 |
|
|
|
| 323 |
|
|
decl_type = TREE_TYPE (var_decl);
|
| 324 |
|
|
|
| 325 |
|
|
if (TREE_CODE (decl_type) == POINTER_TYPE)
|
| 326 |
|
|
{
|
| 327 |
|
|
if (DECL_LANG_SPECIFIC (var_decl)
|
| 328 |
|
|
&& LOCAL_SLOT_P (var_decl))
|
| 329 |
|
|
{
|
| 330 |
|
|
int index = DECL_LOCAL_SLOT_NUMBER (var_decl);
|
| 331 |
|
|
tree base_decl = TREE_VEC_ELT (base_decl_map, index);
|
| 332 |
|
|
|
| 333 |
|
|
gcc_assert (base_decl);
|
| 334 |
|
|
if (! want_lvalue)
|
| 335 |
|
|
base_decl = build1 (NOP_EXPR, decl_type, base_decl);
|
| 336 |
|
|
|
| 337 |
|
|
return base_decl;
|
| 338 |
|
|
}
|
| 339 |
|
|
}
|
| 340 |
|
|
|
| 341 |
|
|
return var_decl;
|
| 342 |
|
|
}
|
| 343 |
|
|
|
| 344 |
|
|
/* Helper for java_genericize. */
|
| 345 |
|
|
|
| 346 |
|
|
tree
|
| 347 |
|
|
java_replace_references (tree *tp, int *walk_subtrees,
|
| 348 |
|
|
void *data ATTRIBUTE_UNUSED)
|
| 349 |
|
|
{
|
| 350 |
|
|
if (TREE_CODE (*tp) == MODIFY_EXPR)
|
| 351 |
|
|
{
|
| 352 |
|
|
source_location loc = EXPR_LOCATION (*tp);
|
| 353 |
|
|
tree lhs = TREE_OPERAND (*tp, 0);
|
| 354 |
|
|
/* This is specific to the bytecode compiler. If a variable has
|
| 355 |
|
|
LOCAL_SLOT_P set, replace an assignment to it with an assignment
|
| 356 |
|
|
to the corresponding variable that holds all its aliases. */
|
| 357 |
|
|
if (TREE_CODE (lhs) == VAR_DECL
|
| 358 |
|
|
&& DECL_LANG_SPECIFIC (lhs)
|
| 359 |
|
|
&& LOCAL_SLOT_P (lhs)
|
| 360 |
|
|
&& TREE_CODE (TREE_TYPE (lhs)) == POINTER_TYPE)
|
| 361 |
|
|
{
|
| 362 |
|
|
tree new_lhs = java_replace_reference (lhs, /* want_lvalue */ true);
|
| 363 |
|
|
tree new_rhs = build1 (NOP_EXPR, TREE_TYPE (new_lhs),
|
| 364 |
|
|
TREE_OPERAND (*tp, 1));
|
| 365 |
|
|
tree tem = build2 (MODIFY_EXPR, TREE_TYPE (new_lhs),
|
| 366 |
|
|
new_lhs, new_rhs);
|
| 367 |
|
|
*tp = build1 (NOP_EXPR, TREE_TYPE (lhs), tem);
|
| 368 |
|
|
SET_EXPR_LOCATION (tem, loc);
|
| 369 |
|
|
SET_EXPR_LOCATION (new_rhs, loc);
|
| 370 |
|
|
SET_EXPR_LOCATION (*tp, loc);
|
| 371 |
|
|
}
|
| 372 |
|
|
}
|
| 373 |
|
|
if (TREE_CODE (*tp) == VAR_DECL)
|
| 374 |
|
|
{
|
| 375 |
|
|
*tp = java_replace_reference (*tp, /* want_lvalue */ false);
|
| 376 |
|
|
*walk_subtrees = 0;
|
| 377 |
|
|
}
|
| 378 |
|
|
|
| 379 |
|
|
return NULL_TREE;
|
| 380 |
|
|
}
|
| 381 |
|
|
|
| 382 |
|
|
/* Same as find_local_index, except that INDEX is a stack index. */
|
| 383 |
|
|
|
| 384 |
|
|
tree
|
| 385 |
|
|
find_stack_slot (int index, tree type)
|
| 386 |
|
|
{
|
| 387 |
|
|
return find_local_variable (index + DECL_MAX_LOCALS (current_function_decl),
|
| 388 |
|
|
type, -1);
|
| 389 |
|
|
}
|
| 390 |
|
|
|
| 391 |
|
|
struct GTY(())
|
| 392 |
|
|
binding_level {
|
| 393 |
|
|
/* A chain of _DECL nodes for all variables, constants, functions,
|
| 394 |
|
|
* and typedef types. These are in the reverse of the order supplied.
|
| 395 |
|
|
*/
|
| 396 |
|
|
tree names;
|
| 397 |
|
|
|
| 398 |
|
|
/* For each level, a list of shadowed outer-level local definitions
|
| 399 |
|
|
to be restored when this level is popped.
|
| 400 |
|
|
Each link is a TREE_LIST whose TREE_PURPOSE is an identifier and
|
| 401 |
|
|
whose TREE_VALUE is its old definition (a kind of ..._DECL node). */
|
| 402 |
|
|
tree shadowed;
|
| 403 |
|
|
|
| 404 |
|
|
/* For each level (except not the global one),
|
| 405 |
|
|
a chain of BLOCK nodes for all the levels
|
| 406 |
|
|
that were entered and exited one level down. */
|
| 407 |
|
|
tree blocks;
|
| 408 |
|
|
|
| 409 |
|
|
/* The binding level which this one is contained in (inherits from). */
|
| 410 |
|
|
struct binding_level *level_chain;
|
| 411 |
|
|
|
| 412 |
|
|
/* The bytecode PC that marks the end of this level. */
|
| 413 |
|
|
int end_pc;
|
| 414 |
|
|
/* The bytecode PC that marks the start of this level. */
|
| 415 |
|
|
int start_pc;
|
| 416 |
|
|
|
| 417 |
|
|
/* The statements in this binding level. */
|
| 418 |
|
|
tree stmts;
|
| 419 |
|
|
|
| 420 |
|
|
/* An exception range associated with this binding level. */
|
| 421 |
|
|
struct eh_range * GTY((skip (""))) exception_range;
|
| 422 |
|
|
|
| 423 |
|
|
/* Binding depth at which this level began. Used only for debugging. */
|
| 424 |
|
|
unsigned binding_depth;
|
| 425 |
|
|
|
| 426 |
|
|
/* The location at which this level began. */
|
| 427 |
|
|
source_location loc;
|
| 428 |
|
|
};
|
| 429 |
|
|
|
| 430 |
|
|
#define NULL_BINDING_LEVEL (struct binding_level *) NULL
|
| 431 |
|
|
|
| 432 |
|
|
/* The binding level currently in effect. */
|
| 433 |
|
|
|
| 434 |
|
|
static GTY(()) struct binding_level *current_binding_level;
|
| 435 |
|
|
|
| 436 |
|
|
/* A chain of binding_level structures awaiting reuse. */
|
| 437 |
|
|
|
| 438 |
|
|
static GTY(()) struct binding_level *free_binding_level;
|
| 439 |
|
|
|
| 440 |
|
|
/* The outermost binding level, for names of file scope.
|
| 441 |
|
|
This is created when the compiler is started and exists
|
| 442 |
|
|
through the entire run. */
|
| 443 |
|
|
|
| 444 |
|
|
static GTY(()) struct binding_level *global_binding_level;
|
| 445 |
|
|
|
| 446 |
|
|
/* The binding level that holds variables declared at the outermost
|
| 447 |
|
|
level within a function body. */
|
| 448 |
|
|
|
| 449 |
|
|
static struct binding_level *function_binding_level;
|
| 450 |
|
|
|
| 451 |
|
|
/* A PC value bigger than any PC value we may ever may encounter. */
|
| 452 |
|
|
|
| 453 |
|
|
#define LARGEST_PC (( (unsigned int)1 << (HOST_BITS_PER_INT - 1)) - 1)
|
| 454 |
|
|
|
| 455 |
|
|
/* Binding level structures are initialized by copying this one. */
|
| 456 |
|
|
|
| 457 |
|
|
static const struct binding_level clear_binding_level
|
| 458 |
|
|
= {
|
| 459 |
|
|
NULL_TREE, /* names */
|
| 460 |
|
|
NULL_TREE, /* shadowed */
|
| 461 |
|
|
NULL_TREE, /* blocks */
|
| 462 |
|
|
NULL_BINDING_LEVEL, /* level_chain */
|
| 463 |
|
|
LARGEST_PC, /* end_pc */
|
| 464 |
|
|
0, /* start_pc */
|
| 465 |
|
|
NULL, /* stmts */
|
| 466 |
|
|
NULL, /* exception_range */
|
| 467 |
|
|
0, /* binding_depth */
|
| 468 |
|
|
0, /* loc */
|
| 469 |
|
|
};
|
| 470 |
|
|
|
| 471 |
|
|
tree java_global_trees[JTI_MAX];
|
| 472 |
|
|
|
| 473 |
|
|
/* Build (and pushdecl) a "promoted type" for all standard
|
| 474 |
|
|
types shorter than int. */
|
| 475 |
|
|
|
| 476 |
|
|
static tree
|
| 477 |
|
|
push_promoted_type (const char *name, tree actual_type)
|
| 478 |
|
|
{
|
| 479 |
|
|
tree type = make_node (TREE_CODE (actual_type));
|
| 480 |
|
|
#if 1
|
| 481 |
|
|
tree in_min = TYPE_MIN_VALUE (int_type_node);
|
| 482 |
|
|
tree in_max = TYPE_MAX_VALUE (int_type_node);
|
| 483 |
|
|
#else
|
| 484 |
|
|
tree in_min = TYPE_MIN_VALUE (actual_type);
|
| 485 |
|
|
tree in_max = TYPE_MAX_VALUE (actual_type);
|
| 486 |
|
|
#endif
|
| 487 |
|
|
TYPE_MIN_VALUE (type) = copy_node (in_min);
|
| 488 |
|
|
TREE_TYPE (TYPE_MIN_VALUE (type)) = type;
|
| 489 |
|
|
TYPE_MAX_VALUE (type) = copy_node (in_max);
|
| 490 |
|
|
TREE_TYPE (TYPE_MAX_VALUE (type)) = type;
|
| 491 |
|
|
TYPE_PRECISION (type) = TYPE_PRECISION (int_type_node);
|
| 492 |
|
|
TYPE_STRING_FLAG (type) = TYPE_STRING_FLAG (actual_type);
|
| 493 |
|
|
layout_type (type);
|
| 494 |
|
|
pushdecl (build_decl (input_location,
|
| 495 |
|
|
TYPE_DECL, get_identifier (name), type));
|
| 496 |
|
|
return type;
|
| 497 |
|
|
}
|
| 498 |
|
|
|
| 499 |
|
|
/* Return tree that represents a vtable for a primitive array. */
|
| 500 |
|
|
static tree
|
| 501 |
|
|
create_primitive_vtable (const char *name)
|
| 502 |
|
|
{
|
| 503 |
|
|
tree r;
|
| 504 |
|
|
char buf[50];
|
| 505 |
|
|
|
| 506 |
|
|
sprintf (buf, "_Jv_%sVTable", name);
|
| 507 |
|
|
r = build_decl (input_location,
|
| 508 |
|
|
VAR_DECL, get_identifier (buf), ptr_type_node);
|
| 509 |
|
|
DECL_EXTERNAL (r) = 1;
|
| 510 |
|
|
return r;
|
| 511 |
|
|
}
|
| 512 |
|
|
|
| 513 |
|
|
/* Parse the version string and compute the ABI version number. */
|
| 514 |
|
|
static void
|
| 515 |
|
|
parse_version (void)
|
| 516 |
|
|
{
|
| 517 |
|
|
const char *p = version_string;
|
| 518 |
|
|
unsigned int major = 0, minor = 0;
|
| 519 |
|
|
unsigned int abi_version;
|
| 520 |
|
|
|
| 521 |
|
|
/* Skip leading junk. */
|
| 522 |
|
|
while (*p && !ISDIGIT (*p))
|
| 523 |
|
|
++p;
|
| 524 |
|
|
gcc_assert (*p);
|
| 525 |
|
|
|
| 526 |
|
|
/* Extract major version. */
|
| 527 |
|
|
while (ISDIGIT (*p))
|
| 528 |
|
|
{
|
| 529 |
|
|
major = major * 10 + *p - '0';
|
| 530 |
|
|
++p;
|
| 531 |
|
|
}
|
| 532 |
|
|
|
| 533 |
|
|
gcc_assert (*p == '.' && ISDIGIT (p[1]));
|
| 534 |
|
|
++p;
|
| 535 |
|
|
|
| 536 |
|
|
/* Extract minor version. */
|
| 537 |
|
|
while (ISDIGIT (*p))
|
| 538 |
|
|
{
|
| 539 |
|
|
minor = minor * 10 + *p - '0';
|
| 540 |
|
|
++p;
|
| 541 |
|
|
}
|
| 542 |
|
|
|
| 543 |
|
|
if (flag_indirect_dispatch)
|
| 544 |
|
|
{
|
| 545 |
|
|
abi_version = GCJ_CURRENT_BC_ABI_VERSION;
|
| 546 |
|
|
abi_version |= FLAG_BINARYCOMPAT_ABI;
|
| 547 |
|
|
}
|
| 548 |
|
|
else /* C++ ABI */
|
| 549 |
|
|
{
|
| 550 |
|
|
/* Implicit in this computation is the idea that we won't break the
|
| 551 |
|
|
old-style binary ABI in a sub-minor release (e.g., from 4.0.0 to
|
| 552 |
|
|
4.0.1). */
|
| 553 |
|
|
abi_version = 100000 * major + 1000 * minor;
|
| 554 |
|
|
}
|
| 555 |
|
|
if (flag_bootstrap_classes)
|
| 556 |
|
|
abi_version |= FLAG_BOOTSTRAP_LOADER;
|
| 557 |
|
|
|
| 558 |
|
|
gcj_abi_version = build_int_cstu (ptr_type_node, abi_version);
|
| 559 |
|
|
}
|
| 560 |
|
|
|
| 561 |
|
|
void
|
| 562 |
|
|
java_init_decl_processing (void)
|
| 563 |
|
|
{
|
| 564 |
|
|
tree endlink;
|
| 565 |
|
|
tree field = NULL_TREE;
|
| 566 |
|
|
tree t;
|
| 567 |
|
|
|
| 568 |
|
|
init_class_processing ();
|
| 569 |
|
|
|
| 570 |
|
|
current_function_decl = NULL;
|
| 571 |
|
|
current_binding_level = NULL_BINDING_LEVEL;
|
| 572 |
|
|
free_binding_level = NULL_BINDING_LEVEL;
|
| 573 |
|
|
pushlevel (0); /* make the binding_level structure for global names */
|
| 574 |
|
|
global_binding_level = current_binding_level;
|
| 575 |
|
|
|
| 576 |
|
|
/* The code here must be similar to build_common_tree_nodes{,_2} in
|
| 577 |
|
|
tree.c, especially as to the order of initializing common nodes. */
|
| 578 |
|
|
error_mark_node = make_node (ERROR_MARK);
|
| 579 |
|
|
TREE_TYPE (error_mark_node) = error_mark_node;
|
| 580 |
|
|
|
| 581 |
|
|
/* Create sizetype first - needed for other types. */
|
| 582 |
|
|
initialize_sizetypes (false);
|
| 583 |
|
|
|
| 584 |
|
|
byte_type_node = make_signed_type (8);
|
| 585 |
|
|
pushdecl (build_decl (BUILTINS_LOCATION,
|
| 586 |
|
|
TYPE_DECL, get_identifier ("byte"), byte_type_node));
|
| 587 |
|
|
short_type_node = make_signed_type (16);
|
| 588 |
|
|
pushdecl (build_decl (BUILTINS_LOCATION,
|
| 589 |
|
|
TYPE_DECL, get_identifier ("short"), short_type_node));
|
| 590 |
|
|
int_type_node = make_signed_type (32);
|
| 591 |
|
|
pushdecl (build_decl (BUILTINS_LOCATION,
|
| 592 |
|
|
TYPE_DECL, get_identifier ("int"), int_type_node));
|
| 593 |
|
|
long_type_node = make_signed_type (64);
|
| 594 |
|
|
pushdecl (build_decl (BUILTINS_LOCATION,
|
| 595 |
|
|
TYPE_DECL, get_identifier ("long"), long_type_node));
|
| 596 |
|
|
|
| 597 |
|
|
unsigned_byte_type_node = make_unsigned_type (8);
|
| 598 |
|
|
pushdecl (build_decl (BUILTINS_LOCATION,
|
| 599 |
|
|
TYPE_DECL, get_identifier ("unsigned byte"),
|
| 600 |
|
|
unsigned_byte_type_node));
|
| 601 |
|
|
unsigned_short_type_node = make_unsigned_type (16);
|
| 602 |
|
|
pushdecl (build_decl (BUILTINS_LOCATION,
|
| 603 |
|
|
TYPE_DECL, get_identifier ("unsigned short"),
|
| 604 |
|
|
unsigned_short_type_node));
|
| 605 |
|
|
unsigned_int_type_node = make_unsigned_type (32);
|
| 606 |
|
|
pushdecl (build_decl (BUILTINS_LOCATION,
|
| 607 |
|
|
TYPE_DECL, get_identifier ("unsigned int"),
|
| 608 |
|
|
unsigned_int_type_node));
|
| 609 |
|
|
unsigned_long_type_node = make_unsigned_type (64);
|
| 610 |
|
|
pushdecl (build_decl (BUILTINS_LOCATION,
|
| 611 |
|
|
TYPE_DECL, get_identifier ("unsigned long"),
|
| 612 |
|
|
unsigned_long_type_node));
|
| 613 |
|
|
|
| 614 |
|
|
/* This is not a java type, however tree-dfa requires a definition for
|
| 615 |
|
|
size_type_node. */
|
| 616 |
|
|
size_type_node = make_unsigned_type (POINTER_SIZE);
|
| 617 |
|
|
set_sizetype (size_type_node);
|
| 618 |
|
|
|
| 619 |
|
|
/* Define these next since types below may used them. */
|
| 620 |
|
|
integer_type_node = java_type_for_size (INT_TYPE_SIZE, 0);
|
| 621 |
|
|
integer_zero_node = build_int_cst (NULL_TREE, 0);
|
| 622 |
|
|
integer_one_node = build_int_cst (NULL_TREE, 1);
|
| 623 |
|
|
integer_two_node = build_int_cst (NULL_TREE, 2);
|
| 624 |
|
|
integer_four_node = build_int_cst (NULL_TREE, 4);
|
| 625 |
|
|
integer_minus_one_node = build_int_cst (NULL_TREE, -1);
|
| 626 |
|
|
|
| 627 |
|
|
/* A few values used for range checking in the lexer. */
|
| 628 |
|
|
decimal_int_max = build_int_cstu (unsigned_int_type_node, 0x80000000);
|
| 629 |
|
|
#if HOST_BITS_PER_WIDE_INT == 64
|
| 630 |
|
|
decimal_long_max = build_int_cstu (unsigned_long_type_node,
|
| 631 |
|
|
0x8000000000000000LL);
|
| 632 |
|
|
#elif HOST_BITS_PER_WIDE_INT == 32
|
| 633 |
|
|
decimal_long_max = build_int_cst_wide (unsigned_long_type_node,
|
| 634 |
|
|
0, 0x80000000);
|
| 635 |
|
|
#else
|
| 636 |
|
|
#error "unsupported size"
|
| 637 |
|
|
#endif
|
| 638 |
|
|
|
| 639 |
|
|
size_zero_node = size_int (0);
|
| 640 |
|
|
size_one_node = size_int (1);
|
| 641 |
|
|
bitsize_zero_node = bitsize_int (0);
|
| 642 |
|
|
bitsize_one_node = bitsize_int (1);
|
| 643 |
|
|
bitsize_unit_node = bitsize_int (BITS_PER_UNIT);
|
| 644 |
|
|
|
| 645 |
|
|
long_zero_node = build_int_cst (long_type_node, 0);
|
| 646 |
|
|
|
| 647 |
|
|
void_type_node = make_node (VOID_TYPE);
|
| 648 |
|
|
pushdecl (build_decl (BUILTINS_LOCATION,
|
| 649 |
|
|
TYPE_DECL, get_identifier ("void"), void_type_node));
|
| 650 |
|
|
layout_type (void_type_node); /* Uses size_zero_node */
|
| 651 |
|
|
|
| 652 |
|
|
ptr_type_node = build_pointer_type (void_type_node);
|
| 653 |
|
|
const_ptr_type_node
|
| 654 |
|
|
= build_pointer_type (build_type_variant (void_type_node, 1, 0));
|
| 655 |
|
|
|
| 656 |
|
|
t = make_node (VOID_TYPE);
|
| 657 |
|
|
layout_type (t); /* Uses size_zero_node */
|
| 658 |
|
|
return_address_type_node = build_pointer_type (t);
|
| 659 |
|
|
|
| 660 |
|
|
null_pointer_node = build_int_cst (ptr_type_node, 0);
|
| 661 |
|
|
|
| 662 |
|
|
char_type_node = make_node (INTEGER_TYPE);
|
| 663 |
|
|
TYPE_STRING_FLAG (char_type_node) = 1;
|
| 664 |
|
|
TYPE_PRECISION (char_type_node) = 16;
|
| 665 |
|
|
fixup_unsigned_type (char_type_node);
|
| 666 |
|
|
pushdecl (build_decl (BUILTINS_LOCATION,
|
| 667 |
|
|
TYPE_DECL, get_identifier ("char"), char_type_node));
|
| 668 |
|
|
|
| 669 |
|
|
boolean_type_node = make_node (BOOLEAN_TYPE);
|
| 670 |
|
|
TYPE_PRECISION (boolean_type_node) = 1;
|
| 671 |
|
|
fixup_unsigned_type (boolean_type_node);
|
| 672 |
|
|
pushdecl (build_decl (BUILTINS_LOCATION,
|
| 673 |
|
|
TYPE_DECL, get_identifier ("boolean"),
|
| 674 |
|
|
boolean_type_node));
|
| 675 |
|
|
boolean_false_node = TYPE_MIN_VALUE (boolean_type_node);
|
| 676 |
|
|
boolean_true_node = TYPE_MAX_VALUE (boolean_type_node);
|
| 677 |
|
|
|
| 678 |
|
|
promoted_byte_type_node
|
| 679 |
|
|
= push_promoted_type ("promoted_byte", byte_type_node);
|
| 680 |
|
|
promoted_short_type_node
|
| 681 |
|
|
= push_promoted_type ("promoted_short", short_type_node);
|
| 682 |
|
|
promoted_char_type_node
|
| 683 |
|
|
= push_promoted_type ("promoted_char", char_type_node);
|
| 684 |
|
|
promoted_boolean_type_node
|
| 685 |
|
|
= push_promoted_type ("promoted_boolean", boolean_type_node);
|
| 686 |
|
|
|
| 687 |
|
|
float_type_node = make_node (REAL_TYPE);
|
| 688 |
|
|
TYPE_PRECISION (float_type_node) = 32;
|
| 689 |
|
|
pushdecl (build_decl (BUILTINS_LOCATION,
|
| 690 |
|
|
TYPE_DECL, get_identifier ("float"),
|
| 691 |
|
|
float_type_node));
|
| 692 |
|
|
layout_type (float_type_node);
|
| 693 |
|
|
|
| 694 |
|
|
double_type_node = make_node (REAL_TYPE);
|
| 695 |
|
|
TYPE_PRECISION (double_type_node) = 64;
|
| 696 |
|
|
pushdecl (build_decl (BUILTINS_LOCATION,
|
| 697 |
|
|
TYPE_DECL, get_identifier ("double"),
|
| 698 |
|
|
double_type_node));
|
| 699 |
|
|
layout_type (double_type_node);
|
| 700 |
|
|
|
| 701 |
|
|
float_zero_node = build_real (float_type_node, dconst0);
|
| 702 |
|
|
double_zero_node = build_real (double_type_node, dconst0);
|
| 703 |
|
|
|
| 704 |
|
|
/* These are the vtables for arrays of primitives. */
|
| 705 |
|
|
boolean_array_vtable = create_primitive_vtable ("boolean");
|
| 706 |
|
|
byte_array_vtable = create_primitive_vtable ("byte");
|
| 707 |
|
|
char_array_vtable = create_primitive_vtable ("char");
|
| 708 |
|
|
short_array_vtable = create_primitive_vtable ("short");
|
| 709 |
|
|
int_array_vtable = create_primitive_vtable ("int");
|
| 710 |
|
|
long_array_vtable = create_primitive_vtable ("long");
|
| 711 |
|
|
float_array_vtable = create_primitive_vtable ("float");
|
| 712 |
|
|
double_array_vtable = create_primitive_vtable ("double");
|
| 713 |
|
|
|
| 714 |
|
|
one_elt_array_domain_type = build_index_type (integer_one_node);
|
| 715 |
|
|
utf8const_type = make_node (RECORD_TYPE);
|
| 716 |
|
|
PUSH_FIELD (input_location,
|
| 717 |
|
|
utf8const_type, field, "hash", unsigned_short_type_node);
|
| 718 |
|
|
PUSH_FIELD (input_location,
|
| 719 |
|
|
utf8const_type, field, "length", unsigned_short_type_node);
|
| 720 |
|
|
FINISH_RECORD (utf8const_type);
|
| 721 |
|
|
utf8const_ptr_type = build_pointer_type (utf8const_type);
|
| 722 |
|
|
|
| 723 |
|
|
atable_type = build_array_type (ptr_type_node,
|
| 724 |
|
|
one_elt_array_domain_type);
|
| 725 |
|
|
TYPE_NONALIASED_COMPONENT (atable_type) = 1;
|
| 726 |
|
|
atable_ptr_type = build_pointer_type (atable_type);
|
| 727 |
|
|
|
| 728 |
|
|
itable_type = build_array_type (ptr_type_node,
|
| 729 |
|
|
one_elt_array_domain_type);
|
| 730 |
|
|
TYPE_NONALIASED_COMPONENT (itable_type) = 1;
|
| 731 |
|
|
itable_ptr_type = build_pointer_type (itable_type);
|
| 732 |
|
|
|
| 733 |
|
|
symbol_type = make_node (RECORD_TYPE);
|
| 734 |
|
|
PUSH_FIELD (input_location,
|
| 735 |
|
|
symbol_type, field, "clname", utf8const_ptr_type);
|
| 736 |
|
|
PUSH_FIELD (input_location, symbol_type, field, "name", utf8const_ptr_type);
|
| 737 |
|
|
PUSH_FIELD (input_location,
|
| 738 |
|
|
symbol_type, field, "signature", utf8const_ptr_type);
|
| 739 |
|
|
FINISH_RECORD (symbol_type);
|
| 740 |
|
|
|
| 741 |
|
|
symbols_array_type = build_array_type (symbol_type,
|
| 742 |
|
|
one_elt_array_domain_type);
|
| 743 |
|
|
symbols_array_ptr_type = build_pointer_type (symbols_array_type);
|
| 744 |
|
|
|
| 745 |
|
|
assertion_entry_type = make_node (RECORD_TYPE);
|
| 746 |
|
|
PUSH_FIELD (input_location,
|
| 747 |
|
|
assertion_entry_type, field, "assertion_code", integer_type_node);
|
| 748 |
|
|
PUSH_FIELD (input_location,
|
| 749 |
|
|
assertion_entry_type, field, "op1", utf8const_ptr_type);
|
| 750 |
|
|
PUSH_FIELD (input_location,
|
| 751 |
|
|
assertion_entry_type, field, "op2", utf8const_ptr_type);
|
| 752 |
|
|
FINISH_RECORD (assertion_entry_type);
|
| 753 |
|
|
|
| 754 |
|
|
assertion_table_type = build_array_type (assertion_entry_type,
|
| 755 |
|
|
one_elt_array_domain_type);
|
| 756 |
|
|
|
| 757 |
|
|
/* As you're adding items here, please update the code right after
|
| 758 |
|
|
this section, so that the filename containing the source code of
|
| 759 |
|
|
the pre-defined class gets registered correctly. */
|
| 760 |
|
|
unqualified_object_id_node = get_identifier ("Object");
|
| 761 |
|
|
object_type_node = lookup_class (get_identifier ("java.lang.Object"));
|
| 762 |
|
|
object_ptr_type_node = promote_type (object_type_node);
|
| 763 |
|
|
string_type_node = lookup_class (get_identifier ("java.lang.String"));
|
| 764 |
|
|
string_ptr_type_node = promote_type (string_type_node);
|
| 765 |
|
|
class_type_node = lookup_class (get_identifier ("java.lang.Class"));
|
| 766 |
|
|
throwable_type_node = lookup_class (get_identifier ("java.lang.Throwable"));
|
| 767 |
|
|
exception_type_node = lookup_class (get_identifier ("java.lang.Exception"));
|
| 768 |
|
|
runtime_exception_type_node =
|
| 769 |
|
|
lookup_class (get_identifier ("java.lang.RuntimeException"));
|
| 770 |
|
|
error_exception_type_node =
|
| 771 |
|
|
lookup_class (get_identifier ("java.lang.Error"));
|
| 772 |
|
|
|
| 773 |
|
|
rawdata_ptr_type_node
|
| 774 |
|
|
= promote_type (lookup_class (get_identifier ("gnu.gcj.RawData")));
|
| 775 |
|
|
|
| 776 |
|
|
add_predefined_file (get_identifier ("java/lang/Class.java"));
|
| 777 |
|
|
add_predefined_file (get_identifier ("java/lang/Error.java"));
|
| 778 |
|
|
add_predefined_file (get_identifier ("java/lang/Object.java"));
|
| 779 |
|
|
add_predefined_file (get_identifier ("java/lang/RuntimeException.java"));
|
| 780 |
|
|
add_predefined_file (get_identifier ("java/lang/String.java"));
|
| 781 |
|
|
add_predefined_file (get_identifier ("java/lang/Throwable.java"));
|
| 782 |
|
|
add_predefined_file (get_identifier ("gnu/gcj/RawData.java"));
|
| 783 |
|
|
add_predefined_file (get_identifier ("java/lang/Exception.java"));
|
| 784 |
|
|
add_predefined_file (get_identifier ("java/lang/ClassNotFoundException.java"));
|
| 785 |
|
|
add_predefined_file (get_identifier ("java/lang/NoClassDefFoundError.java"));
|
| 786 |
|
|
|
| 787 |
|
|
methodtable_type = make_node (RECORD_TYPE);
|
| 788 |
|
|
layout_type (methodtable_type);
|
| 789 |
|
|
build_decl (BUILTINS_LOCATION,
|
| 790 |
|
|
TYPE_DECL, get_identifier ("methodtable"), methodtable_type);
|
| 791 |
|
|
methodtable_ptr_type = build_pointer_type (methodtable_type);
|
| 792 |
|
|
|
| 793 |
|
|
TYPE_identifier_node = get_identifier ("TYPE");
|
| 794 |
|
|
init_identifier_node = get_identifier ("<init>");
|
| 795 |
|
|
clinit_identifier_node = get_identifier ("<clinit>");
|
| 796 |
|
|
void_signature_node = get_identifier ("()V");
|
| 797 |
|
|
finalize_identifier_node = get_identifier ("finalize");
|
| 798 |
|
|
this_identifier_node = get_identifier ("this");
|
| 799 |
|
|
|
| 800 |
|
|
java_lang_cloneable_identifier_node = get_identifier ("java.lang.Cloneable");
|
| 801 |
|
|
java_io_serializable_identifier_node =
|
| 802 |
|
|
get_identifier ("java.io.Serializable");
|
| 803 |
|
|
|
| 804 |
|
|
/* for lack of a better place to put this stub call */
|
| 805 |
|
|
init_expr_processing();
|
| 806 |
|
|
|
| 807 |
|
|
constants_type_node = make_node (RECORD_TYPE);
|
| 808 |
|
|
PUSH_FIELD (input_location,
|
| 809 |
|
|
constants_type_node, field, "size", unsigned_int_type_node);
|
| 810 |
|
|
PUSH_FIELD (input_location,
|
| 811 |
|
|
constants_type_node, field, "tags", ptr_type_node);
|
| 812 |
|
|
PUSH_FIELD (input_location,
|
| 813 |
|
|
constants_type_node, field, "data", ptr_type_node);
|
| 814 |
|
|
constants_data_field_decl_node = field;
|
| 815 |
|
|
FINISH_RECORD (constants_type_node);
|
| 816 |
|
|
build_decl (BUILTINS_LOCATION,
|
| 817 |
|
|
TYPE_DECL, get_identifier ("constants"), constants_type_node);
|
| 818 |
|
|
|
| 819 |
|
|
access_flags_type_node = unsigned_short_type_node;
|
| 820 |
|
|
|
| 821 |
|
|
dtable_type = make_node (RECORD_TYPE);
|
| 822 |
|
|
dtable_ptr_type = build_pointer_type (dtable_type);
|
| 823 |
|
|
|
| 824 |
|
|
otable_type = build_array_type (integer_type_node,
|
| 825 |
|
|
one_elt_array_domain_type);
|
| 826 |
|
|
TYPE_NONALIASED_COMPONENT (otable_type) = 1;
|
| 827 |
|
|
otable_ptr_type = build_pointer_type (otable_type);
|
| 828 |
|
|
|
| 829 |
|
|
PUSH_FIELD (input_location,
|
| 830 |
|
|
object_type_node, field, "vtable", dtable_ptr_type);
|
| 831 |
|
|
DECL_FCONTEXT (field) = object_type_node;
|
| 832 |
|
|
TYPE_VFIELD (object_type_node) = field;
|
| 833 |
|
|
|
| 834 |
|
|
/* This isn't exactly true, but it is what we have in the source.
|
| 835 |
|
|
There is an unresolved issue here, which is whether the vtable
|
| 836 |
|
|
should be marked by the GC. */
|
| 837 |
|
|
if (! flag_hash_synchronization)
|
| 838 |
|
|
PUSH_FIELD (input_location, object_type_node, field, "sync_info",
|
| 839 |
|
|
build_pointer_type (object_type_node));
|
| 840 |
|
|
for (t = TYPE_FIELDS (object_type_node); t != NULL_TREE; t = TREE_CHAIN (t))
|
| 841 |
|
|
FIELD_PRIVATE (t) = 1;
|
| 842 |
|
|
FINISH_RECORD (object_type_node);
|
| 843 |
|
|
|
| 844 |
|
|
field_type_node = make_node (RECORD_TYPE);
|
| 845 |
|
|
field_ptr_type_node = build_pointer_type (field_type_node);
|
| 846 |
|
|
method_type_node = make_node (RECORD_TYPE);
|
| 847 |
|
|
method_ptr_type_node = build_pointer_type (method_type_node);
|
| 848 |
|
|
|
| 849 |
|
|
set_super_info (0, class_type_node, object_type_node, 0);
|
| 850 |
|
|
set_super_info (0, string_type_node, object_type_node, 0);
|
| 851 |
|
|
class_ptr_type = build_pointer_type (class_type_node);
|
| 852 |
|
|
|
| 853 |
|
|
PUSH_FIELD (input_location,
|
| 854 |
|
|
class_type_node, field, "next_or_version", class_ptr_type);
|
| 855 |
|
|
PUSH_FIELD (input_location,
|
| 856 |
|
|
class_type_node, field, "name", utf8const_ptr_type);
|
| 857 |
|
|
PUSH_FIELD (input_location,
|
| 858 |
|
|
class_type_node, field, "accflags", access_flags_type_node);
|
| 859 |
|
|
PUSH_FIELD (input_location,
|
| 860 |
|
|
class_type_node, field, "superclass", class_ptr_type);
|
| 861 |
|
|
PUSH_FIELD (input_location,
|
| 862 |
|
|
class_type_node, field, "constants", constants_type_node);
|
| 863 |
|
|
constants_field_decl_node = field;
|
| 864 |
|
|
PUSH_FIELD (input_location,
|
| 865 |
|
|
class_type_node, field, "methods", method_ptr_type_node);
|
| 866 |
|
|
PUSH_FIELD (input_location,
|
| 867 |
|
|
class_type_node, field, "method_count", short_type_node);
|
| 868 |
|
|
PUSH_FIELD (input_location,
|
| 869 |
|
|
class_type_node, field, "vtable_method_count", short_type_node);
|
| 870 |
|
|
PUSH_FIELD (input_location,
|
| 871 |
|
|
class_type_node, field, "fields", field_ptr_type_node);
|
| 872 |
|
|
PUSH_FIELD (input_location,
|
| 873 |
|
|
class_type_node, field, "size_in_bytes", int_type_node);
|
| 874 |
|
|
PUSH_FIELD (input_location,
|
| 875 |
|
|
class_type_node, field, "field_count", short_type_node);
|
| 876 |
|
|
PUSH_FIELD (input_location,
|
| 877 |
|
|
class_type_node, field, "static_field_count", short_type_node);
|
| 878 |
|
|
PUSH_FIELD (input_location,
|
| 879 |
|
|
class_type_node, field, "vtable", dtable_ptr_type);
|
| 880 |
|
|
PUSH_FIELD (input_location,
|
| 881 |
|
|
class_type_node, field, "otable", otable_ptr_type);
|
| 882 |
|
|
PUSH_FIELD (input_location,
|
| 883 |
|
|
class_type_node, field, "otable_syms",
|
| 884 |
|
|
symbols_array_ptr_type);
|
| 885 |
|
|
PUSH_FIELD (input_location,
|
| 886 |
|
|
class_type_node, field, "atable", atable_ptr_type);
|
| 887 |
|
|
PUSH_FIELD (input_location,
|
| 888 |
|
|
class_type_node, field, "atable_syms",
|
| 889 |
|
|
symbols_array_ptr_type);
|
| 890 |
|
|
PUSH_FIELD (input_location,
|
| 891 |
|
|
class_type_node, field, "itable", itable_ptr_type);
|
| 892 |
|
|
PUSH_FIELD (input_location, class_type_node, field, "itable_syms",
|
| 893 |
|
|
symbols_array_ptr_type);
|
| 894 |
|
|
PUSH_FIELD (input_location,
|
| 895 |
|
|
class_type_node, field, "catch_classes", ptr_type_node);
|
| 896 |
|
|
PUSH_FIELD (input_location, class_type_node, field, "interfaces",
|
| 897 |
|
|
build_pointer_type (class_ptr_type));
|
| 898 |
|
|
PUSH_FIELD (input_location, class_type_node, field, "loader", ptr_type_node);
|
| 899 |
|
|
PUSH_FIELD (input_location,
|
| 900 |
|
|
class_type_node, field, "interface_count", short_type_node);
|
| 901 |
|
|
PUSH_FIELD (input_location, class_type_node, field, "state", byte_type_node);
|
| 902 |
|
|
PUSH_FIELD (input_location, class_type_node, field, "thread", ptr_type_node);
|
| 903 |
|
|
PUSH_FIELD (input_location,
|
| 904 |
|
|
class_type_node, field, "depth", short_type_node);
|
| 905 |
|
|
PUSH_FIELD (input_location,
|
| 906 |
|
|
class_type_node, field, "ancestors", ptr_type_node);
|
| 907 |
|
|
PUSH_FIELD (input_location, class_type_node, field, "idt", ptr_type_node);
|
| 908 |
|
|
PUSH_FIELD (input_location,
|
| 909 |
|
|
class_type_node, field, "arrayclass", ptr_type_node);
|
| 910 |
|
|
PUSH_FIELD (input_location,
|
| 911 |
|
|
class_type_node, field, "protectionDomain", ptr_type_node);
|
| 912 |
|
|
PUSH_FIELD (input_location,
|
| 913 |
|
|
class_type_node, field, "assertion_table", ptr_type_node);
|
| 914 |
|
|
PUSH_FIELD (input_location,
|
| 915 |
|
|
class_type_node, field, "hack_signers", ptr_type_node);
|
| 916 |
|
|
PUSH_FIELD (input_location, class_type_node, field, "chain", ptr_type_node);
|
| 917 |
|
|
PUSH_FIELD (input_location,
|
| 918 |
|
|
class_type_node, field, "aux_info", ptr_type_node);
|
| 919 |
|
|
PUSH_FIELD (input_location, class_type_node, field, "engine", ptr_type_node);
|
| 920 |
|
|
PUSH_FIELD (input_location,
|
| 921 |
|
|
class_type_node, field, "reflection_data", ptr_type_node);
|
| 922 |
|
|
for (t = TYPE_FIELDS (class_type_node); t != NULL_TREE; t = TREE_CHAIN (t))
|
| 923 |
|
|
FIELD_PRIVATE (t) = 1;
|
| 924 |
|
|
push_super_field (class_type_node, object_type_node);
|
| 925 |
|
|
|
| 926 |
|
|
FINISH_RECORD (class_type_node);
|
| 927 |
|
|
build_decl (BUILTINS_LOCATION,
|
| 928 |
|
|
TYPE_DECL, get_identifier ("Class"), class_type_node);
|
| 929 |
|
|
|
| 930 |
|
|
field_info_union_node = make_node (UNION_TYPE);
|
| 931 |
|
|
PUSH_FIELD (input_location,
|
| 932 |
|
|
field_info_union_node, field, "boffset", int_type_node);
|
| 933 |
|
|
PUSH_FIELD (input_location,
|
| 934 |
|
|
field_info_union_node, field, "addr", ptr_type_node);
|
| 935 |
|
|
layout_type (field_info_union_node);
|
| 936 |
|
|
|
| 937 |
|
|
PUSH_FIELD (input_location,
|
| 938 |
|
|
field_type_node, field, "name", utf8const_ptr_type);
|
| 939 |
|
|
PUSH_FIELD (input_location, field_type_node, field, "type", class_ptr_type);
|
| 940 |
|
|
PUSH_FIELD (input_location,
|
| 941 |
|
|
field_type_node, field, "accflags", access_flags_type_node);
|
| 942 |
|
|
PUSH_FIELD (input_location,
|
| 943 |
|
|
field_type_node, field, "bsize", unsigned_short_type_node);
|
| 944 |
|
|
PUSH_FIELD (input_location,
|
| 945 |
|
|
field_type_node, field, "info", field_info_union_node);
|
| 946 |
|
|
FINISH_RECORD (field_type_node);
|
| 947 |
|
|
build_decl (BUILTINS_LOCATION,
|
| 948 |
|
|
TYPE_DECL, get_identifier ("Field"), field_type_node);
|
| 949 |
|
|
|
| 950 |
|
|
nativecode_ptr_array_type_node
|
| 951 |
|
|
= build_array_type (nativecode_ptr_type_node, one_elt_array_domain_type);
|
| 952 |
|
|
|
| 953 |
|
|
PUSH_FIELD (input_location,
|
| 954 |
|
|
dtable_type, field, "class", class_ptr_type);
|
| 955 |
|
|
PUSH_FIELD (input_location,
|
| 956 |
|
|
dtable_type, field, "methods", nativecode_ptr_array_type_node);
|
| 957 |
|
|
FINISH_RECORD (dtable_type);
|
| 958 |
|
|
build_decl (BUILTINS_LOCATION,
|
| 959 |
|
|
TYPE_DECL, get_identifier ("dispatchTable"), dtable_type);
|
| 960 |
|
|
|
| 961 |
|
|
jexception_type = make_node (RECORD_TYPE);
|
| 962 |
|
|
PUSH_FIELD (input_location,
|
| 963 |
|
|
jexception_type, field, "start_pc", ptr_type_node);
|
| 964 |
|
|
PUSH_FIELD (input_location, jexception_type, field, "end_pc", ptr_type_node);
|
| 965 |
|
|
PUSH_FIELD (input_location,
|
| 966 |
|
|
jexception_type, field, "handler_pc", ptr_type_node);
|
| 967 |
|
|
PUSH_FIELD (input_location,
|
| 968 |
|
|
jexception_type, field, "catch_type", class_ptr_type);
|
| 969 |
|
|
FINISH_RECORD (jexception_type);
|
| 970 |
|
|
build_decl (BUILTINS_LOCATION,
|
| 971 |
|
|
TYPE_DECL, get_identifier ("jexception"), field_type_node);
|
| 972 |
|
|
jexception_ptr_type = build_pointer_type (jexception_type);
|
| 973 |
|
|
|
| 974 |
|
|
lineNumberEntry_type = make_node (RECORD_TYPE);
|
| 975 |
|
|
PUSH_FIELD (input_location,
|
| 976 |
|
|
lineNumberEntry_type, field, "line_nr", unsigned_short_type_node);
|
| 977 |
|
|
PUSH_FIELD (input_location,
|
| 978 |
|
|
lineNumberEntry_type, field, "start_pc", ptr_type_node);
|
| 979 |
|
|
FINISH_RECORD (lineNumberEntry_type);
|
| 980 |
|
|
|
| 981 |
|
|
lineNumbers_type = make_node (RECORD_TYPE);
|
| 982 |
|
|
PUSH_FIELD (input_location,
|
| 983 |
|
|
lineNumbers_type, field, "length", unsigned_int_type_node);
|
| 984 |
|
|
FINISH_RECORD (lineNumbers_type);
|
| 985 |
|
|
|
| 986 |
|
|
PUSH_FIELD (input_location,
|
| 987 |
|
|
method_type_node, field, "name", utf8const_ptr_type);
|
| 988 |
|
|
PUSH_FIELD (input_location,
|
| 989 |
|
|
method_type_node, field, "signature", utf8const_ptr_type);
|
| 990 |
|
|
PUSH_FIELD (input_location,
|
| 991 |
|
|
method_type_node, field, "accflags", access_flags_type_node);
|
| 992 |
|
|
PUSH_FIELD (input_location,
|
| 993 |
|
|
method_type_node, field, "index", unsigned_short_type_node);
|
| 994 |
|
|
PUSH_FIELD (input_location,
|
| 995 |
|
|
method_type_node, field, "ncode", nativecode_ptr_type_node);
|
| 996 |
|
|
PUSH_FIELD (input_location,
|
| 997 |
|
|
method_type_node, field, "throws", ptr_type_node);
|
| 998 |
|
|
FINISH_RECORD (method_type_node);
|
| 999 |
|
|
build_decl (BUILTINS_LOCATION,
|
| 1000 |
|
|
TYPE_DECL, get_identifier ("Method"), method_type_node);
|
| 1001 |
|
|
|
| 1002 |
|
|
endlink = end_params_node = tree_cons (NULL_TREE, void_type_node, NULL_TREE);
|
| 1003 |
|
|
|
| 1004 |
|
|
t = tree_cons (NULL_TREE, class_ptr_type, endlink);
|
| 1005 |
|
|
alloc_object_node = add_builtin_function ("_Jv_AllocObject",
|
| 1006 |
|
|
build_function_type (ptr_type_node, t),
|
| 1007 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1008 |
|
|
DECL_IS_MALLOC (alloc_object_node) = 1;
|
| 1009 |
|
|
alloc_no_finalizer_node =
|
| 1010 |
|
|
add_builtin_function ("_Jv_AllocObjectNoFinalizer",
|
| 1011 |
|
|
build_function_type (ptr_type_node, t),
|
| 1012 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1013 |
|
|
DECL_IS_MALLOC (alloc_no_finalizer_node) = 1;
|
| 1014 |
|
|
|
| 1015 |
|
|
t = tree_cons (NULL_TREE, ptr_type_node, endlink);
|
| 1016 |
|
|
soft_initclass_node = add_builtin_function ("_Jv_InitClass",
|
| 1017 |
|
|
build_function_type (void_type_node,
|
| 1018 |
|
|
t),
|
| 1019 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1020 |
|
|
t = tree_cons (NULL_TREE, class_ptr_type,
|
| 1021 |
|
|
tree_cons (NULL_TREE, int_type_node, endlink));
|
| 1022 |
|
|
soft_resolvepoolentry_node
|
| 1023 |
|
|
= add_builtin_function ("_Jv_ResolvePoolEntry",
|
| 1024 |
|
|
build_function_type (ptr_type_node, t),
|
| 1025 |
|
|
0,NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1026 |
|
|
DECL_PURE_P (soft_resolvepoolentry_node) = 1;
|
| 1027 |
|
|
throw_node = add_builtin_function ("_Jv_Throw",
|
| 1028 |
|
|
build_function_type (void_type_node, t),
|
| 1029 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1030 |
|
|
/* Mark throw_nodes as `noreturn' functions with side effects. */
|
| 1031 |
|
|
TREE_THIS_VOLATILE (throw_node) = 1;
|
| 1032 |
|
|
TREE_SIDE_EFFECTS (throw_node) = 1;
|
| 1033 |
|
|
|
| 1034 |
|
|
t = build_function_type (void_type_node, tree_cons (NULL_TREE, ptr_type_node,
|
| 1035 |
|
|
endlink));
|
| 1036 |
|
|
soft_monitorenter_node
|
| 1037 |
|
|
= add_builtin_function ("_Jv_MonitorEnter", t, 0, NOT_BUILT_IN,
|
| 1038 |
|
|
NULL, NULL_TREE);
|
| 1039 |
|
|
soft_monitorexit_node
|
| 1040 |
|
|
= add_builtin_function ("_Jv_MonitorExit", t, 0, NOT_BUILT_IN,
|
| 1041 |
|
|
NULL, NULL_TREE);
|
| 1042 |
|
|
|
| 1043 |
|
|
t = tree_cons (NULL_TREE, ptr_type_node,
|
| 1044 |
|
|
tree_cons (NULL_TREE, int_type_node, endlink));
|
| 1045 |
|
|
soft_newarray_node
|
| 1046 |
|
|
= add_builtin_function ("_Jv_NewPrimArray",
|
| 1047 |
|
|
build_function_type (ptr_type_node, t),
|
| 1048 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1049 |
|
|
DECL_IS_MALLOC (soft_newarray_node) = 1;
|
| 1050 |
|
|
|
| 1051 |
|
|
t = tree_cons (NULL_TREE, int_type_node,
|
| 1052 |
|
|
tree_cons (NULL_TREE, class_ptr_type,
|
| 1053 |
|
|
tree_cons (NULL_TREE, object_ptr_type_node,
|
| 1054 |
|
|
endlink)));
|
| 1055 |
|
|
soft_anewarray_node
|
| 1056 |
|
|
= add_builtin_function ("_Jv_NewObjectArray",
|
| 1057 |
|
|
build_function_type (ptr_type_node, t),
|
| 1058 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1059 |
|
|
DECL_IS_MALLOC (soft_anewarray_node) = 1;
|
| 1060 |
|
|
|
| 1061 |
|
|
/* There is no endlink here because _Jv_NewMultiArray is a varargs
|
| 1062 |
|
|
function. */
|
| 1063 |
|
|
t = tree_cons (NULL_TREE, ptr_type_node,
|
| 1064 |
|
|
tree_cons (NULL_TREE, int_type_node, NULL_TREE));
|
| 1065 |
|
|
soft_multianewarray_node
|
| 1066 |
|
|
= add_builtin_function ("_Jv_NewMultiArray",
|
| 1067 |
|
|
build_function_type (ptr_type_node, t),
|
| 1068 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1069 |
|
|
DECL_IS_MALLOC (soft_multianewarray_node) = 1;
|
| 1070 |
|
|
|
| 1071 |
|
|
t = build_function_type (void_type_node,
|
| 1072 |
|
|
tree_cons (NULL_TREE, int_type_node, endlink));
|
| 1073 |
|
|
soft_badarrayindex_node
|
| 1074 |
|
|
= add_builtin_function ("_Jv_ThrowBadArrayIndex", t,
|
| 1075 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1076 |
|
|
/* Mark soft_badarrayindex_node as a `noreturn' function with side
|
| 1077 |
|
|
effects. */
|
| 1078 |
|
|
TREE_THIS_VOLATILE (soft_badarrayindex_node) = 1;
|
| 1079 |
|
|
TREE_SIDE_EFFECTS (soft_badarrayindex_node) = 1;
|
| 1080 |
|
|
|
| 1081 |
|
|
soft_nullpointer_node
|
| 1082 |
|
|
= add_builtin_function ("_Jv_ThrowNullPointerException",
|
| 1083 |
|
|
build_function_type (void_type_node, endlink),
|
| 1084 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1085 |
|
|
/* Mark soft_nullpointer_node as a `noreturn' function with side
|
| 1086 |
|
|
effects. */
|
| 1087 |
|
|
TREE_THIS_VOLATILE (soft_nullpointer_node) = 1;
|
| 1088 |
|
|
TREE_SIDE_EFFECTS (soft_nullpointer_node) = 1;
|
| 1089 |
|
|
|
| 1090 |
|
|
soft_abstractmethod_node
|
| 1091 |
|
|
= add_builtin_function ("_Jv_ThrowAbstractMethodError",
|
| 1092 |
|
|
build_function_type (void_type_node, endlink),
|
| 1093 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1094 |
|
|
/* Mark soft_abstractmethod_node as a `noreturn' function with side
|
| 1095 |
|
|
effects. */
|
| 1096 |
|
|
TREE_THIS_VOLATILE (soft_abstractmethod_node) = 1;
|
| 1097 |
|
|
TREE_SIDE_EFFECTS (soft_abstractmethod_node) = 1;
|
| 1098 |
|
|
|
| 1099 |
|
|
soft_nosuchfield_node
|
| 1100 |
|
|
= add_builtin_function ("_Jv_ThrowNoSuchFieldError",
|
| 1101 |
|
|
build_function_type (void_type_node, endlink),
|
| 1102 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1103 |
|
|
/* Mark soft_nosuchfield_node as a `noreturn' function with side
|
| 1104 |
|
|
effects. */
|
| 1105 |
|
|
TREE_THIS_VOLATILE (soft_nosuchfield_node) = 1;
|
| 1106 |
|
|
TREE_SIDE_EFFECTS (soft_nosuchfield_node) = 1;
|
| 1107 |
|
|
|
| 1108 |
|
|
t = tree_cons (NULL_TREE, class_ptr_type,
|
| 1109 |
|
|
tree_cons (NULL_TREE, object_ptr_type_node, endlink));
|
| 1110 |
|
|
soft_checkcast_node
|
| 1111 |
|
|
= add_builtin_function ("_Jv_CheckCast",
|
| 1112 |
|
|
build_function_type (ptr_type_node, t),
|
| 1113 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1114 |
|
|
t = tree_cons (NULL_TREE, object_ptr_type_node,
|
| 1115 |
|
|
tree_cons (NULL_TREE, class_ptr_type, endlink));
|
| 1116 |
|
|
soft_instanceof_node
|
| 1117 |
|
|
= add_builtin_function ("_Jv_IsInstanceOf",
|
| 1118 |
|
|
build_function_type (boolean_type_node, t),
|
| 1119 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1120 |
|
|
DECL_PURE_P (soft_instanceof_node) = 1;
|
| 1121 |
|
|
t = tree_cons (NULL_TREE, object_ptr_type_node,
|
| 1122 |
|
|
tree_cons (NULL_TREE, object_ptr_type_node, endlink));
|
| 1123 |
|
|
soft_checkarraystore_node
|
| 1124 |
|
|
= add_builtin_function ("_Jv_CheckArrayStore",
|
| 1125 |
|
|
build_function_type (void_type_node, t),
|
| 1126 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1127 |
|
|
t = tree_cons (NULL_TREE, ptr_type_node,
|
| 1128 |
|
|
tree_cons (NULL_TREE, ptr_type_node,
|
| 1129 |
|
|
tree_cons (NULL_TREE, int_type_node, endlink)));
|
| 1130 |
|
|
soft_lookupinterfacemethod_node
|
| 1131 |
|
|
= add_builtin_function ("_Jv_LookupInterfaceMethodIdx",
|
| 1132 |
|
|
build_function_type (ptr_type_node, t),
|
| 1133 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1134 |
|
|
DECL_PURE_P (soft_lookupinterfacemethod_node) = 1;
|
| 1135 |
|
|
t = tree_cons (NULL_TREE, ptr_type_node,
|
| 1136 |
|
|
tree_cons (NULL_TREE, ptr_type_node,
|
| 1137 |
|
|
tree_cons (NULL_TREE, ptr_type_node, endlink)));
|
| 1138 |
|
|
soft_lookupinterfacemethodbyname_node
|
| 1139 |
|
|
= add_builtin_function ("_Jv_LookupInterfaceMethod",
|
| 1140 |
|
|
build_function_type (ptr_type_node, t),
|
| 1141 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1142 |
|
|
t = tree_cons (NULL_TREE, object_ptr_type_node,
|
| 1143 |
|
|
tree_cons (NULL_TREE, ptr_type_node,
|
| 1144 |
|
|
tree_cons (NULL_TREE, ptr_type_node,
|
| 1145 |
|
|
tree_cons (NULL_TREE, int_type_node,
|
| 1146 |
|
|
endlink))));
|
| 1147 |
|
|
soft_lookupjnimethod_node
|
| 1148 |
|
|
= add_builtin_function ("_Jv_LookupJNIMethod",
|
| 1149 |
|
|
build_function_type (ptr_type_node, t),
|
| 1150 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1151 |
|
|
t = tree_cons (NULL_TREE, ptr_type_node, endlink);
|
| 1152 |
|
|
soft_getjnienvnewframe_node
|
| 1153 |
|
|
= add_builtin_function ("_Jv_GetJNIEnvNewFrame",
|
| 1154 |
|
|
build_function_type (ptr_type_node, t),
|
| 1155 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1156 |
|
|
soft_jnipopsystemframe_node
|
| 1157 |
|
|
= add_builtin_function ("_Jv_JNI_PopSystemFrame",
|
| 1158 |
|
|
build_function_type (void_type_node, t),
|
| 1159 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1160 |
|
|
|
| 1161 |
|
|
t = tree_cons (NULL_TREE, object_ptr_type_node, endlink);
|
| 1162 |
|
|
soft_unwrapjni_node
|
| 1163 |
|
|
= add_builtin_function ("_Jv_UnwrapJNIweakReference",
|
| 1164 |
|
|
build_function_type (object_ptr_type_node, t),
|
| 1165 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1166 |
|
|
|
| 1167 |
|
|
t = tree_cons (NULL_TREE, int_type_node,
|
| 1168 |
|
|
tree_cons (NULL_TREE, int_type_node, endlink));
|
| 1169 |
|
|
soft_idiv_node
|
| 1170 |
|
|
= add_builtin_function ("_Jv_divI",
|
| 1171 |
|
|
build_function_type (int_type_node, t),
|
| 1172 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1173 |
|
|
|
| 1174 |
|
|
soft_irem_node
|
| 1175 |
|
|
= add_builtin_function ("_Jv_remI",
|
| 1176 |
|
|
build_function_type (int_type_node, t),
|
| 1177 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1178 |
|
|
|
| 1179 |
|
|
t = tree_cons (NULL_TREE, long_type_node,
|
| 1180 |
|
|
tree_cons (NULL_TREE, long_type_node, endlink));
|
| 1181 |
|
|
soft_ldiv_node
|
| 1182 |
|
|
= add_builtin_function ("_Jv_divJ",
|
| 1183 |
|
|
build_function_type (long_type_node, t),
|
| 1184 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1185 |
|
|
|
| 1186 |
|
|
soft_lrem_node
|
| 1187 |
|
|
= add_builtin_function ("_Jv_remJ",
|
| 1188 |
|
|
build_function_type (long_type_node, t),
|
| 1189 |
|
|
0, NOT_BUILT_IN, NULL, NULL_TREE);
|
| 1190 |
|
|
|
| 1191 |
|
|
initialize_builtins ();
|
| 1192 |
|
|
|
| 1193 |
|
|
soft_fmod_node = built_in_decls[BUILT_IN_FMOD];
|
| 1194 |
|
|
|
| 1195 |
|
|
parse_version ();
|
| 1196 |
|
|
}
|
| 1197 |
|
|
|
| 1198 |
|
|
|
| 1199 |
|
|
/* Look up NAME in the current binding level and its superiors
|
| 1200 |
|
|
in the namespace of variables, functions and typedefs.
|
| 1201 |
|
|
Return a ..._DECL node of some kind representing its definition,
|
| 1202 |
|
|
or return 0 if it is undefined. */
|
| 1203 |
|
|
|
| 1204 |
|
|
tree
|
| 1205 |
|
|
lookup_name (tree name)
|
| 1206 |
|
|
{
|
| 1207 |
|
|
tree val;
|
| 1208 |
|
|
if (current_binding_level != global_binding_level
|
| 1209 |
|
|
&& IDENTIFIER_LOCAL_VALUE (name))
|
| 1210 |
|
|
val = IDENTIFIER_LOCAL_VALUE (name);
|
| 1211 |
|
|
else
|
| 1212 |
|
|
val = IDENTIFIER_GLOBAL_VALUE (name);
|
| 1213 |
|
|
return val;
|
| 1214 |
|
|
}
|
| 1215 |
|
|
|
| 1216 |
|
|
/* Similar to `lookup_name' but look only at current binding level and
|
| 1217 |
|
|
the previous one if it's the parameter level. */
|
| 1218 |
|
|
|
| 1219 |
|
|
static tree
|
| 1220 |
|
|
lookup_name_current_level (tree name)
|
| 1221 |
|
|
{
|
| 1222 |
|
|
tree t;
|
| 1223 |
|
|
|
| 1224 |
|
|
if (current_binding_level == global_binding_level)
|
| 1225 |
|
|
return IDENTIFIER_GLOBAL_VALUE (name);
|
| 1226 |
|
|
|
| 1227 |
|
|
if (IDENTIFIER_LOCAL_VALUE (name) == 0)
|
| 1228 |
|
|
return 0;
|
| 1229 |
|
|
|
| 1230 |
|
|
for (t = current_binding_level->names; t; t = TREE_CHAIN (t))
|
| 1231 |
|
|
if (DECL_NAME (t) == name)
|
| 1232 |
|
|
break;
|
| 1233 |
|
|
|
| 1234 |
|
|
return t;
|
| 1235 |
|
|
}
|
| 1236 |
|
|
|
| 1237 |
|
|
/* Record a decl-node X as belonging to the current lexical scope.
|
| 1238 |
|
|
Check for errors (such as an incompatible declaration for the same
|
| 1239 |
|
|
name already seen in the same scope).
|
| 1240 |
|
|
|
| 1241 |
|
|
Returns either X or an old decl for the same name.
|
| 1242 |
|
|
If an old decl is returned, it may have been smashed
|
| 1243 |
|
|
to agree with what X says. */
|
| 1244 |
|
|
|
| 1245 |
|
|
tree
|
| 1246 |
|
|
pushdecl (tree x)
|
| 1247 |
|
|
{
|
| 1248 |
|
|
tree t;
|
| 1249 |
|
|
tree name = DECL_NAME (x);
|
| 1250 |
|
|
struct binding_level *b = current_binding_level;
|
| 1251 |
|
|
|
| 1252 |
|
|
if (TREE_CODE (x) != TYPE_DECL)
|
| 1253 |
|
|
DECL_CONTEXT (x) = current_function_decl;
|
| 1254 |
|
|
if (name)
|
| 1255 |
|
|
{
|
| 1256 |
|
|
t = lookup_name_current_level (name);
|
| 1257 |
|
|
if (t != 0 && t == error_mark_node)
|
| 1258 |
|
|
/* error_mark_node is 0 for a while during initialization! */
|
| 1259 |
|
|
{
|
| 1260 |
|
|
t = 0;
|
| 1261 |
|
|
error ("%q+D used prior to declaration", x);
|
| 1262 |
|
|
}
|
| 1263 |
|
|
|
| 1264 |
|
|
/* If we're naming a hitherto-unnamed type, set its TYPE_NAME
|
| 1265 |
|
|
to point to the TYPE_DECL.
|
| 1266 |
|
|
Since Java does not have typedefs, a type can only have
|
| 1267 |
|
|
one (true) name, given by a class, interface, or builtin. */
|
| 1268 |
|
|
if (TREE_CODE (x) == TYPE_DECL
|
| 1269 |
|
|
&& TYPE_NAME (TREE_TYPE (x)) == 0
|
| 1270 |
|
|
&& TREE_TYPE (x) != error_mark_node)
|
| 1271 |
|
|
{
|
| 1272 |
|
|
TYPE_NAME (TREE_TYPE (x)) = x;
|
| 1273 |
|
|
TYPE_STUB_DECL (TREE_TYPE (x)) = x;
|
| 1274 |
|
|
}
|
| 1275 |
|
|
|
| 1276 |
|
|
/* This name is new in its binding level.
|
| 1277 |
|
|
Install the new declaration and return it. */
|
| 1278 |
|
|
if (b == global_binding_level)
|
| 1279 |
|
|
{
|
| 1280 |
|
|
/* Install a global value. */
|
| 1281 |
|
|
|
| 1282 |
|
|
IDENTIFIER_GLOBAL_VALUE (name) = x;
|
| 1283 |
|
|
}
|
| 1284 |
|
|
else
|
| 1285 |
|
|
{
|
| 1286 |
|
|
/* Here to install a non-global value. */
|
| 1287 |
|
|
tree oldlocal = IDENTIFIER_LOCAL_VALUE (name);
|
| 1288 |
|
|
IDENTIFIER_LOCAL_VALUE (name) = x;
|
| 1289 |
|
|
|
| 1290 |
|
|
/* If storing a local value, there may already be one (inherited).
|
| 1291 |
|
|
If so, record it for restoration when this binding level ends. */
|
| 1292 |
|
|
if (oldlocal != 0)
|
| 1293 |
|
|
b->shadowed = tree_cons (name, oldlocal, b->shadowed);
|
| 1294 |
|
|
}
|
| 1295 |
|
|
}
|
| 1296 |
|
|
|
| 1297 |
|
|
/* Put decls on list in reverse order.
|
| 1298 |
|
|
We will reverse them later if necessary. */
|
| 1299 |
|
|
TREE_CHAIN (x) = b->names;
|
| 1300 |
|
|
b->names = x;
|
| 1301 |
|
|
|
| 1302 |
|
|
return x;
|
| 1303 |
|
|
}
|
| 1304 |
|
|
|
| 1305 |
|
|
void
|
| 1306 |
|
|
pushdecl_force_head (tree x)
|
| 1307 |
|
|
{
|
| 1308 |
|
|
current_binding_level->names = x;
|
| 1309 |
|
|
}
|
| 1310 |
|
|
|
| 1311 |
|
|
/* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL, if appropriate. */
|
| 1312 |
|
|
|
| 1313 |
|
|
tree
|
| 1314 |
|
|
pushdecl_top_level (tree x)
|
| 1315 |
|
|
{
|
| 1316 |
|
|
tree t;
|
| 1317 |
|
|
struct binding_level *b = current_binding_level;
|
| 1318 |
|
|
|
| 1319 |
|
|
current_binding_level = global_binding_level;
|
| 1320 |
|
|
t = pushdecl (x);
|
| 1321 |
|
|
current_binding_level = b;
|
| 1322 |
|
|
return t;
|
| 1323 |
|
|
}
|
| 1324 |
|
|
|
| 1325 |
|
|
/* Like pushdecl, only it places X in FUNCTION_BINDING_LEVEL, if appropriate. */
|
| 1326 |
|
|
|
| 1327 |
|
|
tree
|
| 1328 |
|
|
pushdecl_function_level (tree x)
|
| 1329 |
|
|
{
|
| 1330 |
|
|
tree t;
|
| 1331 |
|
|
struct binding_level *b = current_binding_level;
|
| 1332 |
|
|
|
| 1333 |
|
|
current_binding_level = function_binding_level;
|
| 1334 |
|
|
t = pushdecl (x);
|
| 1335 |
|
|
current_binding_level = b;
|
| 1336 |
|
|
return t;
|
| 1337 |
|
|
}
|
| 1338 |
|
|
|
| 1339 |
|
|
/* Nonzero if we are currently in the global binding level. */
|
| 1340 |
|
|
|
| 1341 |
|
|
int
|
| 1342 |
|
|
global_bindings_p (void)
|
| 1343 |
|
|
{
|
| 1344 |
|
|
return current_binding_level == global_binding_level;
|
| 1345 |
|
|
}
|
| 1346 |
|
|
|
| 1347 |
|
|
/* Return the list of declarations of the current level.
|
| 1348 |
|
|
Note that this list is in reverse order unless/until
|
| 1349 |
|
|
you nreverse it; and when you do nreverse it, you must
|
| 1350 |
|
|
store the result back using `storedecls' or you will lose. */
|
| 1351 |
|
|
|
| 1352 |
|
|
tree
|
| 1353 |
|
|
getdecls (void)
|
| 1354 |
|
|
{
|
| 1355 |
|
|
return current_binding_level->names;
|
| 1356 |
|
|
}
|
| 1357 |
|
|
|
| 1358 |
|
|
/* Create a new `struct binding_level'. */
|
| 1359 |
|
|
|
| 1360 |
|
|
static struct binding_level *
|
| 1361 |
|
|
make_binding_level (void)
|
| 1362 |
|
|
{
|
| 1363 |
|
|
/* NOSTRICT */
|
| 1364 |
|
|
return GGC_CNEW (struct binding_level);
|
| 1365 |
|
|
}
|
| 1366 |
|
|
|
| 1367 |
|
|
void
|
| 1368 |
|
|
pushlevel (int unused ATTRIBUTE_UNUSED)
|
| 1369 |
|
|
{
|
| 1370 |
|
|
struct binding_level *newlevel = NULL_BINDING_LEVEL;
|
| 1371 |
|
|
|
| 1372 |
|
|
/* Reuse or create a struct for this binding level. */
|
| 1373 |
|
|
|
| 1374 |
|
|
if (free_binding_level)
|
| 1375 |
|
|
{
|
| 1376 |
|
|
newlevel = free_binding_level;
|
| 1377 |
|
|
free_binding_level = free_binding_level->level_chain;
|
| 1378 |
|
|
}
|
| 1379 |
|
|
else
|
| 1380 |
|
|
{
|
| 1381 |
|
|
newlevel = make_binding_level ();
|
| 1382 |
|
|
}
|
| 1383 |
|
|
|
| 1384 |
|
|
/* Add this level to the front of the chain (stack) of levels that
|
| 1385 |
|
|
are active. */
|
| 1386 |
|
|
|
| 1387 |
|
|
*newlevel = clear_binding_level;
|
| 1388 |
|
|
newlevel->level_chain = current_binding_level;
|
| 1389 |
|
|
newlevel->loc = input_location;
|
| 1390 |
|
|
current_binding_level = newlevel;
|
| 1391 |
|
|
#if defined(DEBUG_JAVA_BINDING_LEVELS)
|
| 1392 |
|
|
newlevel->binding_depth = binding_depth;
|
| 1393 |
|
|
indent ();
|
| 1394 |
|
|
fprintf (stderr, "push %s level %p pc %d\n",
|
| 1395 |
|
|
(is_class_level) ? "class" : "block", newlevel, current_pc);
|
| 1396 |
|
|
is_class_level = 0;
|
| 1397 |
|
|
binding_depth++;
|
| 1398 |
|
|
#endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */
|
| 1399 |
|
|
}
|
| 1400 |
|
|
|
| 1401 |
|
|
/* Exit a binding level.
|
| 1402 |
|
|
Pop the level off, and restore the state of the identifier-decl mappings
|
| 1403 |
|
|
that were in effect when this level was entered.
|
| 1404 |
|
|
|
| 1405 |
|
|
If KEEP is nonzero, this level had explicit declarations, so
|
| 1406 |
|
|
and create a "block" (a BLOCK node) for the level
|
| 1407 |
|
|
to record its declarations and subblocks for symbol table output.
|
| 1408 |
|
|
|
| 1409 |
|
|
If FUNCTIONBODY is nonzero, this level is the body of a function,
|
| 1410 |
|
|
so create a block as if KEEP were set and also clear out all
|
| 1411 |
|
|
label names.
|
| 1412 |
|
|
|
| 1413 |
|
|
If REVERSE is nonzero, reverse the order of decls before putting
|
| 1414 |
|
|
them into the BLOCK. */
|
| 1415 |
|
|
|
| 1416 |
|
|
tree
|
| 1417 |
|
|
poplevel (int keep, int reverse, int functionbody)
|
| 1418 |
|
|
{
|
| 1419 |
|
|
tree link;
|
| 1420 |
|
|
/* The chain of decls was accumulated in reverse order.
|
| 1421 |
|
|
Put it into forward order, just for cleanliness. */
|
| 1422 |
|
|
tree decls;
|
| 1423 |
|
|
tree subblocks = current_binding_level->blocks;
|
| 1424 |
|
|
tree block = 0;
|
| 1425 |
|
|
tree decl;
|
| 1426 |
|
|
tree bind = 0;
|
| 1427 |
|
|
|
| 1428 |
|
|
#if defined(DEBUG_JAVA_BINDING_LEVELS)
|
| 1429 |
|
|
binding_depth--;
|
| 1430 |
|
|
indent ();
|
| 1431 |
|
|
if (current_binding_level->end_pc != LARGEST_PC)
|
| 1432 |
|
|
fprintf (stderr, "pop %s level %p pc %d (end pc %d)\n",
|
| 1433 |
|
|
(is_class_level) ? "class" : "block", current_binding_level, current_pc,
|
| 1434 |
|
|
current_binding_level->end_pc);
|
| 1435 |
|
|
else
|
| 1436 |
|
|
fprintf (stderr, "pop %s level %p pc %d\n",
|
| 1437 |
|
|
(is_class_level) ? "class" : "block", current_binding_level, current_pc);
|
| 1438 |
|
|
#endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */
|
| 1439 |
|
|
|
| 1440 |
|
|
/* Get the decls in the order they were written.
|
| 1441 |
|
|
Usually current_binding_level->names is in reverse order.
|
| 1442 |
|
|
But parameter decls were previously put in forward order. */
|
| 1443 |
|
|
|
| 1444 |
|
|
if (reverse)
|
| 1445 |
|
|
current_binding_level->names
|
| 1446 |
|
|
= decls = nreverse (current_binding_level->names);
|
| 1447 |
|
|
else
|
| 1448 |
|
|
decls = current_binding_level->names;
|
| 1449 |
|
|
|
| 1450 |
|
|
for (decl = decls; decl; decl = TREE_CHAIN (decl))
|
| 1451 |
|
|
if (TREE_CODE (decl) == VAR_DECL
|
| 1452 |
|
|
&& DECL_LANG_SPECIFIC (decl) != NULL
|
| 1453 |
|
|
&& DECL_LOCAL_SLOT_NUMBER (decl))
|
| 1454 |
|
|
LOCAL_VAR_OUT_OF_SCOPE_P (decl) = 1;
|
| 1455 |
|
|
|
| 1456 |
|
|
/* If there were any declarations in that level,
|
| 1457 |
|
|
or if this level is a function body,
|
| 1458 |
|
|
create a BLOCK to record them for the life of this function. */
|
| 1459 |
|
|
|
| 1460 |
|
|
block = 0;
|
| 1461 |
|
|
if (keep || functionbody)
|
| 1462 |
|
|
{
|
| 1463 |
|
|
block = make_node (BLOCK);
|
| 1464 |
|
|
TREE_TYPE (block) = void_type_node;
|
| 1465 |
|
|
}
|
| 1466 |
|
|
|
| 1467 |
|
|
if (current_binding_level->exception_range)
|
| 1468 |
|
|
expand_end_java_handler (current_binding_level->exception_range);
|
| 1469 |
|
|
|
| 1470 |
|
|
if (block != 0)
|
| 1471 |
|
|
{
|
| 1472 |
|
|
/* If any statements have been generated at this level, create a
|
| 1473 |
|
|
BIND_EXPR to hold them and copy the variables to it. This
|
| 1474 |
|
|
only applies to the bytecode compiler. */
|
| 1475 |
|
|
if (current_binding_level->stmts)
|
| 1476 |
|
|
{
|
| 1477 |
|
|
tree decl = decls;
|
| 1478 |
|
|
tree *var = &BLOCK_VARS (block);
|
| 1479 |
|
|
|
| 1480 |
|
|
/* Copy decls from names list, ignoring labels. */
|
| 1481 |
|
|
while (decl)
|
| 1482 |
|
|
{
|
| 1483 |
|
|
tree next = TREE_CHAIN (decl);
|
| 1484 |
|
|
if (TREE_CODE (decl) != LABEL_DECL)
|
| 1485 |
|
|
{
|
| 1486 |
|
|
*var = decl;
|
| 1487 |
|
|
var = &TREE_CHAIN (decl);
|
| 1488 |
|
|
}
|
| 1489 |
|
|
decl = next;
|
| 1490 |
|
|
}
|
| 1491 |
|
|
*var = NULL;
|
| 1492 |
|
|
|
| 1493 |
|
|
bind = build3 (BIND_EXPR, TREE_TYPE (block), BLOCK_VARS (block),
|
| 1494 |
|
|
BLOCK_EXPR_BODY (block), block);
|
| 1495 |
|
|
BIND_EXPR_BODY (bind) = current_binding_level->stmts;
|
| 1496 |
|
|
|
| 1497 |
|
|
if (BIND_EXPR_BODY (bind)
|
| 1498 |
|
|
&& TREE_SIDE_EFFECTS (BIND_EXPR_BODY (bind)))
|
| 1499 |
|
|
TREE_SIDE_EFFECTS (bind) = 1;
|
| 1500 |
|
|
|
| 1501 |
|
|
/* FIXME: gimplifier brain damage. */
|
| 1502 |
|
|
if (BIND_EXPR_BODY (bind) == NULL)
|
| 1503 |
|
|
BIND_EXPR_BODY (bind) = build_java_empty_stmt ();
|
| 1504 |
|
|
|
| 1505 |
|
|
SET_EXPR_LOCATION (bind, current_binding_level->loc);
|
| 1506 |
|
|
|
| 1507 |
|
|
current_binding_level->stmts = NULL;
|
| 1508 |
|
|
}
|
| 1509 |
|
|
else
|
| 1510 |
|
|
{
|
| 1511 |
|
|
BLOCK_VARS (block) = decls;
|
| 1512 |
|
|
}
|
| 1513 |
|
|
BLOCK_SUBBLOCKS (block) = subblocks;
|
| 1514 |
|
|
}
|
| 1515 |
|
|
|
| 1516 |
|
|
/* In each subblock, record that this is its superior. */
|
| 1517 |
|
|
|
| 1518 |
|
|
for (link = subblocks; link; link = TREE_CHAIN (link))
|
| 1519 |
|
|
BLOCK_SUPERCONTEXT (link) = block;
|
| 1520 |
|
|
|
| 1521 |
|
|
/* Clear out the meanings of the local variables of this level. */
|
| 1522 |
|
|
|
| 1523 |
|
|
for (link = decls; link; link = TREE_CHAIN (link))
|
| 1524 |
|
|
{
|
| 1525 |
|
|
tree name = DECL_NAME (link);
|
| 1526 |
|
|
if (name != 0 && IDENTIFIER_LOCAL_VALUE (name) == link)
|
| 1527 |
|
|
{
|
| 1528 |
|
|
/* If the ident. was used or addressed via a local extern decl,
|
| 1529 |
|
|
don't forget that fact. */
|
| 1530 |
|
|
if (DECL_EXTERNAL (link))
|
| 1531 |
|
|
{
|
| 1532 |
|
|
if (TREE_USED (link))
|
| 1533 |
|
|
TREE_USED (name) = 1;
|
| 1534 |
|
|
if (TREE_ADDRESSABLE (link))
|
| 1535 |
|
|
TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (link)) = 1;
|
| 1536 |
|
|
}
|
| 1537 |
|
|
IDENTIFIER_LOCAL_VALUE (name) = 0;
|
| 1538 |
|
|
}
|
| 1539 |
|
|
}
|
| 1540 |
|
|
|
| 1541 |
|
|
/* Restore all name-meanings of the outer levels
|
| 1542 |
|
|
that were shadowed by this level. */
|
| 1543 |
|
|
|
| 1544 |
|
|
for (link = current_binding_level->shadowed; link; link = TREE_CHAIN (link))
|
| 1545 |
|
|
IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
|
| 1546 |
|
|
|
| 1547 |
|
|
/* If the level being exited is the top level of a function,
|
| 1548 |
|
|
check over all the labels, and clear out the current
|
| 1549 |
|
|
(function local) meanings of their names. */
|
| 1550 |
|
|
|
| 1551 |
|
|
if (functionbody)
|
| 1552 |
|
|
{
|
| 1553 |
|
|
/* If this is the top level block of a function,
|
| 1554 |
|
|
the vars are the function's parameters.
|
| 1555 |
|
|
Don't leave them in the BLOCK because they are
|
| 1556 |
|
|
found in the FUNCTION_DECL instead. */
|
| 1557 |
|
|
|
| 1558 |
|
|
BLOCK_VARS (block) = 0;
|
| 1559 |
|
|
}
|
| 1560 |
|
|
|
| 1561 |
|
|
/* Pop the current level, and free the structure for reuse. */
|
| 1562 |
|
|
|
| 1563 |
|
|
{
|
| 1564 |
|
|
struct binding_level *level = current_binding_level;
|
| 1565 |
|
|
current_binding_level = current_binding_level->level_chain;
|
| 1566 |
|
|
|
| 1567 |
|
|
level->level_chain = free_binding_level;
|
| 1568 |
|
|
free_binding_level = level;
|
| 1569 |
|
|
}
|
| 1570 |
|
|
|
| 1571 |
|
|
/* Dispose of the block that we just made inside some higher level. */
|
| 1572 |
|
|
if (functionbody)
|
| 1573 |
|
|
{
|
| 1574 |
|
|
DECL_INITIAL (current_function_decl) = block;
|
| 1575 |
|
|
DECL_SAVED_TREE (current_function_decl) = bind;
|
| 1576 |
|
|
}
|
| 1577 |
|
|
else
|
| 1578 |
|
|
{
|
| 1579 |
|
|
if (block)
|
| 1580 |
|
|
{
|
| 1581 |
|
|
current_binding_level->blocks
|
| 1582 |
|
|
= chainon (current_binding_level->blocks, block);
|
| 1583 |
|
|
}
|
| 1584 |
|
|
/* If we did not make a block for the level just exited,
|
| 1585 |
|
|
any blocks made for inner levels
|
| 1586 |
|
|
(since they cannot be recorded as subblocks in that level)
|
| 1587 |
|
|
must be carried forward so they will later become subblocks
|
| 1588 |
|
|
of something else. */
|
| 1589 |
|
|
else if (subblocks)
|
| 1590 |
|
|
current_binding_level->blocks
|
| 1591 |
|
|
= chainon (current_binding_level->blocks, subblocks);
|
| 1592 |
|
|
|
| 1593 |
|
|
if (bind)
|
| 1594 |
|
|
java_add_stmt (bind);
|
| 1595 |
|
|
}
|
| 1596 |
|
|
|
| 1597 |
|
|
if (block)
|
| 1598 |
|
|
TREE_USED (block) = 1;
|
| 1599 |
|
|
return block;
|
| 1600 |
|
|
}
|
| 1601 |
|
|
|
| 1602 |
|
|
void
|
| 1603 |
|
|
maybe_pushlevels (int pc)
|
| 1604 |
|
|
{
|
| 1605 |
|
|
#if defined(DEBUG_JAVA_BINDING_LEVELS)
|
| 1606 |
|
|
current_pc = pc;
|
| 1607 |
|
|
#endif
|
| 1608 |
|
|
|
| 1609 |
|
|
while (pending_local_decls != NULL_TREE &&
|
| 1610 |
|
|
DECL_LOCAL_START_PC (pending_local_decls) <= pc)
|
| 1611 |
|
|
{
|
| 1612 |
|
|
tree *ptr = &pending_local_decls;
|
| 1613 |
|
|
tree decl = *ptr, next;
|
| 1614 |
|
|
int end_pc = DECL_LOCAL_END_PC (decl);
|
| 1615 |
|
|
|
| 1616 |
|
|
while (*ptr != NULL_TREE
|
| 1617 |
|
|
&& DECL_LOCAL_START_PC (*ptr) <= pc
|
| 1618 |
|
|
&& DECL_LOCAL_END_PC (*ptr) == end_pc)
|
| 1619 |
|
|
ptr = &TREE_CHAIN (*ptr);
|
| 1620 |
|
|
pending_local_decls = *ptr;
|
| 1621 |
|
|
*ptr = NULL_TREE;
|
| 1622 |
|
|
|
| 1623 |
|
|
/* Force non-nested range to be nested in current range by
|
| 1624 |
|
|
truncating variable lifetimes. */
|
| 1625 |
|
|
if (end_pc > current_binding_level->end_pc)
|
| 1626 |
|
|
{
|
| 1627 |
|
|
tree t;
|
| 1628 |
|
|
end_pc = current_binding_level->end_pc;
|
| 1629 |
|
|
for (t = decl; t != NULL_TREE; t = TREE_CHAIN (t))
|
| 1630 |
|
|
DECL_LOCAL_END_PC (t) = end_pc;
|
| 1631 |
|
|
}
|
| 1632 |
|
|
|
| 1633 |
|
|
maybe_start_try (pc, end_pc);
|
| 1634 |
|
|
|
| 1635 |
|
|
pushlevel (1);
|
| 1636 |
|
|
|
| 1637 |
|
|
current_binding_level->end_pc = end_pc;
|
| 1638 |
|
|
current_binding_level->start_pc = pc;
|
| 1639 |
|
|
current_binding_level->names = NULL;
|
| 1640 |
|
|
for ( ; decl != NULL_TREE; decl = next)
|
| 1641 |
|
|
{
|
| 1642 |
|
|
int index = DECL_LOCAL_SLOT_NUMBER (decl);
|
| 1643 |
|
|
tree base_decl;
|
| 1644 |
|
|
next = TREE_CHAIN (decl);
|
| 1645 |
|
|
push_jvm_slot (index, decl);
|
| 1646 |
|
|
pushdecl (decl);
|
| 1647 |
|
|
base_decl
|
| 1648 |
|
|
= find_local_variable (index, TREE_TYPE (decl), pc);
|
| 1649 |
|
|
if (TREE_CODE (TREE_TYPE (base_decl)) == POINTER_TYPE)
|
| 1650 |
|
|
base_decl = TREE_VEC_ELT (base_decl_map, index);
|
| 1651 |
|
|
SET_DECL_VALUE_EXPR (decl, base_decl);
|
| 1652 |
|
|
DECL_HAS_VALUE_EXPR_P (decl) = 1;
|
| 1653 |
|
|
}
|
| 1654 |
|
|
}
|
| 1655 |
|
|
|
| 1656 |
|
|
maybe_start_try (pc, 0);
|
| 1657 |
|
|
}
|
| 1658 |
|
|
|
| 1659 |
|
|
void
|
| 1660 |
|
|
maybe_poplevels (int pc)
|
| 1661 |
|
|
{
|
| 1662 |
|
|
#if defined(DEBUG_JAVA_BINDING_LEVELS)
|
| 1663 |
|
|
current_pc = pc;
|
| 1664 |
|
|
#endif
|
| 1665 |
|
|
|
| 1666 |
|
|
/* FIXME: I'm pretty sure that this is wrong. Variable scopes are
|
| 1667 |
|
|
inclusive, so a variable is live if pc == end_pc. Here, we
|
| 1668 |
|
|
terminate a range if the current pc is equal to the end of the
|
| 1669 |
|
|
range, and this is *before* we have generated code for the
|
| 1670 |
|
|
instruction at end_pc. We're closing a binding level one
|
| 1671 |
|
|
instruction too early.*/
|
| 1672 |
|
|
while (current_binding_level->end_pc <= pc)
|
| 1673 |
|
|
poplevel (1, 0, 0);
|
| 1674 |
|
|
}
|
| 1675 |
|
|
|
| 1676 |
|
|
/* Terminate any binding which began during the range beginning at
|
| 1677 |
|
|
start_pc. This tidies up improperly nested local variable ranges
|
| 1678 |
|
|
and exception handlers; a variable declared within an exception
|
| 1679 |
|
|
range is forcibly terminated when that exception ends. */
|
| 1680 |
|
|
|
| 1681 |
|
|
void
|
| 1682 |
|
|
force_poplevels (int start_pc)
|
| 1683 |
|
|
{
|
| 1684 |
|
|
while (current_binding_level->start_pc > start_pc)
|
| 1685 |
|
|
{
|
| 1686 |
|
|
if (pedantic && current_binding_level->start_pc > start_pc)
|
| 1687 |
|
|
warning (0, "In %+D: overlapped variable and exception ranges at %d",
|
| 1688 |
|
|
current_function_decl,
|
| 1689 |
|
|
current_binding_level->start_pc);
|
| 1690 |
|
|
poplevel (1, 0, 0);
|
| 1691 |
|
|
}
|
| 1692 |
|
|
}
|
| 1693 |
|
|
|
| 1694 |
|
|
/* integrate_decl_tree calls this function. */
|
| 1695 |
|
|
|
| 1696 |
|
|
void
|
| 1697 |
|
|
java_dup_lang_specific_decl (tree node)
|
| 1698 |
|
|
{
|
| 1699 |
|
|
int lang_decl_size;
|
| 1700 |
|
|
struct lang_decl *x;
|
| 1701 |
|
|
|
| 1702 |
|
|
if (!DECL_LANG_SPECIFIC (node))
|
| 1703 |
|
|
return;
|
| 1704 |
|
|
|
| 1705 |
|
|
lang_decl_size = sizeof (struct lang_decl);
|
| 1706 |
|
|
x = GGC_NEW (struct lang_decl);
|
| 1707 |
|
|
memcpy (x, DECL_LANG_SPECIFIC (node), lang_decl_size);
|
| 1708 |
|
|
DECL_LANG_SPECIFIC (node) = x;
|
| 1709 |
|
|
}
|
| 1710 |
|
|
|
| 1711 |
|
|
void
|
| 1712 |
|
|
give_name_to_locals (JCF *jcf)
|
| 1713 |
|
|
{
|
| 1714 |
|
|
int i, n = DECL_LOCALVARIABLES_OFFSET (current_function_decl);
|
| 1715 |
|
|
int code_offset = DECL_CODE_OFFSET (current_function_decl);
|
| 1716 |
|
|
tree parm;
|
| 1717 |
|
|
pending_local_decls = NULL_TREE;
|
| 1718 |
|
|
if (n == 0)
|
| 1719 |
|
|
return;
|
| 1720 |
|
|
JCF_SEEK (jcf, n);
|
| 1721 |
|
|
n = JCF_readu2 (jcf);
|
| 1722 |
|
|
for (i = 0; i < n; i++)
|
| 1723 |
|
|
{
|
| 1724 |
|
|
int start_pc = JCF_readu2 (jcf);
|
| 1725 |
|
|
int length = JCF_readu2 (jcf);
|
| 1726 |
|
|
int name_index = JCF_readu2 (jcf);
|
| 1727 |
|
|
int signature_index = JCF_readu2 (jcf);
|
| 1728 |
|
|
int slot = JCF_readu2 (jcf);
|
| 1729 |
|
|
tree name = get_name_constant (jcf, name_index);
|
| 1730 |
|
|
tree type = parse_signature (jcf, signature_index);
|
| 1731 |
|
|
if (slot < DECL_ARG_SLOT_COUNT (current_function_decl)
|
| 1732 |
|
|
&& start_pc == 0
|
| 1733 |
|
|
&& length == DECL_CODE_LENGTH (current_function_decl))
|
| 1734 |
|
|
{
|
| 1735 |
|
|
tree decl = TREE_VEC_ELT (decl_map, slot);
|
| 1736 |
|
|
DECL_NAME (decl) = name;
|
| 1737 |
|
|
if (TREE_CODE (decl) != PARM_DECL || TREE_TYPE (decl) != type)
|
| 1738 |
|
|
warning (0, "bad type in parameter debug info");
|
| 1739 |
|
|
}
|
| 1740 |
|
|
else
|
| 1741 |
|
|
{
|
| 1742 |
|
|
tree *ptr;
|
| 1743 |
|
|
int end_pc = start_pc + length;
|
| 1744 |
|
|
tree decl = build_decl (input_location, VAR_DECL, name, type);
|
| 1745 |
|
|
if (end_pc > DECL_CODE_LENGTH (current_function_decl))
|
| 1746 |
|
|
{
|
| 1747 |
|
|
warning (0, "bad PC range for debug info for local %q+D",
|
| 1748 |
|
|
decl);
|
| 1749 |
|
|
end_pc = DECL_CODE_LENGTH (current_function_decl);
|
| 1750 |
|
|
}
|
| 1751 |
|
|
|
| 1752 |
|
|
/* Adjust start_pc if necessary so that the local's first
|
| 1753 |
|
|
store operation will use the relevant DECL as a
|
| 1754 |
|
|
destination. Fore more information, read the leading
|
| 1755 |
|
|
comments for expr.c:maybe_adjust_start_pc. */
|
| 1756 |
|
|
start_pc = maybe_adjust_start_pc (jcf, code_offset, start_pc, slot);
|
| 1757 |
|
|
|
| 1758 |
|
|
MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl);
|
| 1759 |
|
|
DECL_LOCAL_SLOT_NUMBER (decl) = slot;
|
| 1760 |
|
|
DECL_LOCAL_START_PC (decl) = start_pc;
|
| 1761 |
|
|
DECL_LOCAL_END_PC (decl) = end_pc;
|
| 1762 |
|
|
|
| 1763 |
|
|
/* Now insert the new decl in the proper place in
|
| 1764 |
|
|
pending_local_decls. We are essentially doing an insertion sort,
|
| 1765 |
|
|
which works fine, since the list input will normally already
|
| 1766 |
|
|
be sorted. */
|
| 1767 |
|
|
ptr = &pending_local_decls;
|
| 1768 |
|
|
while (*ptr != NULL_TREE
|
| 1769 |
|
|
&& (DECL_LOCAL_START_PC (*ptr) > start_pc
|
| 1770 |
|
|
|| (DECL_LOCAL_START_PC (*ptr) == start_pc
|
| 1771 |
|
|
&& DECL_LOCAL_END_PC (*ptr) < end_pc)))
|
| 1772 |
|
|
ptr = &TREE_CHAIN (*ptr);
|
| 1773 |
|
|
TREE_CHAIN (decl) = *ptr;
|
| 1774 |
|
|
*ptr = decl;
|
| 1775 |
|
|
}
|
| 1776 |
|
|
}
|
| 1777 |
|
|
|
| 1778 |
|
|
pending_local_decls = nreverse (pending_local_decls);
|
| 1779 |
|
|
|
| 1780 |
|
|
/* Fill in default names for the parameters. */
|
| 1781 |
|
|
for (parm = DECL_ARGUMENTS (current_function_decl), i = 0;
|
| 1782 |
|
|
parm != NULL_TREE; parm = TREE_CHAIN (parm), i++)
|
| 1783 |
|
|
{
|
| 1784 |
|
|
if (DECL_NAME (parm) == NULL_TREE)
|
| 1785 |
|
|
{
|
| 1786 |
|
|
int arg_i = METHOD_STATIC (current_function_decl) ? i+1 : i;
|
| 1787 |
|
|
if (arg_i == 0)
|
| 1788 |
|
|
DECL_NAME (parm) = get_identifier ("this");
|
| 1789 |
|
|
else
|
| 1790 |
|
|
{
|
| 1791 |
|
|
char buffer[12];
|
| 1792 |
|
|
sprintf (buffer, "ARG_%d", arg_i);
|
| 1793 |
|
|
DECL_NAME (parm) = get_identifier (buffer);
|
| 1794 |
|
|
}
|
| 1795 |
|
|
}
|
| 1796 |
|
|
}
|
| 1797 |
|
|
}
|
| 1798 |
|
|
|
| 1799 |
|
|
tree
|
| 1800 |
|
|
build_result_decl (tree fndecl)
|
| 1801 |
|
|
{
|
| 1802 |
|
|
tree restype = TREE_TYPE (TREE_TYPE (fndecl));
|
| 1803 |
|
|
tree result = DECL_RESULT (fndecl);
|
| 1804 |
|
|
if (! result)
|
| 1805 |
|
|
{
|
| 1806 |
|
|
result = build_decl (DECL_SOURCE_LOCATION (fndecl),
|
| 1807 |
|
|
RESULT_DECL, NULL_TREE, restype);
|
| 1808 |
|
|
DECL_ARTIFICIAL (result) = 1;
|
| 1809 |
|
|
DECL_IGNORED_P (result) = 1;
|
| 1810 |
|
|
DECL_CONTEXT (result) = fndecl;
|
| 1811 |
|
|
DECL_RESULT (fndecl) = result;
|
| 1812 |
|
|
}
|
| 1813 |
|
|
return result;
|
| 1814 |
|
|
}
|
| 1815 |
|
|
|
| 1816 |
|
|
void
|
| 1817 |
|
|
start_java_method (tree fndecl)
|
| 1818 |
|
|
{
|
| 1819 |
|
|
tree tem, *ptr;
|
| 1820 |
|
|
int i;
|
| 1821 |
|
|
|
| 1822 |
|
|
uniq = 0;
|
| 1823 |
|
|
|
| 1824 |
|
|
current_function_decl = fndecl;
|
| 1825 |
|
|
announce_function (fndecl);
|
| 1826 |
|
|
|
| 1827 |
|
|
i = DECL_MAX_LOCALS(fndecl) + DECL_MAX_STACK(fndecl);
|
| 1828 |
|
|
decl_map = make_tree_vec (i);
|
| 1829 |
|
|
base_decl_map = make_tree_vec (i);
|
| 1830 |
|
|
type_map = XRESIZEVEC (tree, type_map, i);
|
| 1831 |
|
|
|
| 1832 |
|
|
#if defined(DEBUG_JAVA_BINDING_LEVELS)
|
| 1833 |
|
|
fprintf (stderr, "%s:\n", lang_printable_name (fndecl, 2));
|
| 1834 |
|
|
current_pc = 0;
|
| 1835 |
|
|
#endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */
|
| 1836 |
|
|
pushlevel (1); /* Push parameters. */
|
| 1837 |
|
|
|
| 1838 |
|
|
ptr = &DECL_ARGUMENTS (fndecl);
|
| 1839 |
|
|
for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0;
|
| 1840 |
|
|
tem != end_params_node; tem = TREE_CHAIN (tem), i++)
|
| 1841 |
|
|
{
|
| 1842 |
|
|
tree parm_name = NULL_TREE, parm_decl;
|
| 1843 |
|
|
tree parm_type = TREE_VALUE (tem);
|
| 1844 |
|
|
gcc_assert (i < DECL_MAX_LOCALS (fndecl));
|
| 1845 |
|
|
|
| 1846 |
|
|
parm_decl = build_decl (input_location, PARM_DECL, parm_name, parm_type);
|
| 1847 |
|
|
DECL_CONTEXT (parm_decl) = fndecl;
|
| 1848 |
|
|
if (targetm.calls.promote_prototypes (parm_type)
|
| 1849 |
|
|
&& TYPE_PRECISION (parm_type) < TYPE_PRECISION (integer_type_node)
|
| 1850 |
|
|
&& INTEGRAL_TYPE_P (parm_type))
|
| 1851 |
|
|
parm_type = integer_type_node;
|
| 1852 |
|
|
DECL_ARG_TYPE (parm_decl) = parm_type;
|
| 1853 |
|
|
|
| 1854 |
|
|
*ptr = parm_decl;
|
| 1855 |
|
|
ptr = &TREE_CHAIN (parm_decl);
|
| 1856 |
|
|
|
| 1857 |
|
|
/* Add parm_decl to the decl_map. */
|
| 1858 |
|
|
push_jvm_slot (i, parm_decl);
|
| 1859 |
|
|
|
| 1860 |
|
|
type_map[i] = TREE_TYPE (parm_decl);
|
| 1861 |
|
|
if (TYPE_IS_WIDE (TREE_TYPE (parm_decl)))
|
| 1862 |
|
|
{
|
| 1863 |
|
|
i++;
|
| 1864 |
|
|
type_map[i] = void_type_node;
|
| 1865 |
|
|
}
|
| 1866 |
|
|
}
|
| 1867 |
|
|
*ptr = NULL_TREE;
|
| 1868 |
|
|
DECL_ARG_SLOT_COUNT (current_function_decl) = i;
|
| 1869 |
|
|
|
| 1870 |
|
|
while (i < DECL_MAX_LOCALS(fndecl))
|
| 1871 |
|
|
type_map[i++] = NULL_TREE;
|
| 1872 |
|
|
|
| 1873 |
|
|
build_result_decl (fndecl);
|
| 1874 |
|
|
DECL_SOURCE_LOCATION (fndecl) = input_location;
|
| 1875 |
|
|
|
| 1876 |
|
|
/* Push local variables. */
|
| 1877 |
|
|
pushlevel (2);
|
| 1878 |
|
|
|
| 1879 |
|
|
function_binding_level = current_binding_level;
|
| 1880 |
|
|
}
|
| 1881 |
|
|
|
| 1882 |
|
|
void
|
| 1883 |
|
|
end_java_method (void)
|
| 1884 |
|
|
{
|
| 1885 |
|
|
tree fndecl = current_function_decl;
|
| 1886 |
|
|
|
| 1887 |
|
|
/* pop out of function */
|
| 1888 |
|
|
poplevel (1, 1, 0);
|
| 1889 |
|
|
|
| 1890 |
|
|
/* pop out of its parameters */
|
| 1891 |
|
|
poplevel (1, 0, 1);
|
| 1892 |
|
|
|
| 1893 |
|
|
BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
|
| 1894 |
|
|
|
| 1895 |
|
|
if (DECL_SAVED_TREE (fndecl))
|
| 1896 |
|
|
{
|
| 1897 |
|
|
tree fbody, block_body;
|
| 1898 |
|
|
/* Before we check initialization, attached all class initialization
|
| 1899 |
|
|
variable to the block_body */
|
| 1900 |
|
|
fbody = DECL_SAVED_TREE (fndecl);
|
| 1901 |
|
|
block_body = BIND_EXPR_BODY (fbody);
|
| 1902 |
|
|
htab_traverse (DECL_FUNCTION_INIT_TEST_TABLE (fndecl),
|
| 1903 |
|
|
attach_init_test_initialization_flags, block_body);
|
| 1904 |
|
|
}
|
| 1905 |
|
|
|
| 1906 |
|
|
finish_method (fndecl);
|
| 1907 |
|
|
|
| 1908 |
|
|
current_function_decl = NULL_TREE;
|
| 1909 |
|
|
base_decl_map = NULL_TREE;
|
| 1910 |
|
|
}
|
| 1911 |
|
|
|
| 1912 |
|
|
/* Prepare a method for expansion. */
|
| 1913 |
|
|
|
| 1914 |
|
|
void
|
| 1915 |
|
|
finish_method (tree fndecl)
|
| 1916 |
|
|
{
|
| 1917 |
|
|
tree *tp = &DECL_SAVED_TREE (fndecl);
|
| 1918 |
|
|
|
| 1919 |
|
|
/* Wrap body of synchronized methods in a monitorenter,
|
| 1920 |
|
|
plus monitorexit cleanup. */
|
| 1921 |
|
|
if (METHOD_SYNCHRONIZED (fndecl))
|
| 1922 |
|
|
{
|
| 1923 |
|
|
tree enter, exit, lock;
|
| 1924 |
|
|
if (METHOD_STATIC (fndecl))
|
| 1925 |
|
|
lock = build_class_ref (DECL_CONTEXT (fndecl));
|
| 1926 |
|
|
else
|
| 1927 |
|
|
lock = DECL_ARGUMENTS (fndecl);
|
| 1928 |
|
|
BUILD_MONITOR_ENTER (enter, lock);
|
| 1929 |
|
|
BUILD_MONITOR_EXIT (exit, lock);
|
| 1930 |
|
|
*tp = build2 (COMPOUND_EXPR, void_type_node, enter,
|
| 1931 |
|
|
build2 (TRY_FINALLY_EXPR, void_type_node, *tp, exit));
|
| 1932 |
|
|
}
|
| 1933 |
|
|
|
| 1934 |
|
|
/* Convert function tree to GENERIC prior to inlining. */
|
| 1935 |
|
|
java_genericize (fndecl);
|
| 1936 |
|
|
|
| 1937 |
|
|
/* Store the end of the function, so that we get good line number
|
| 1938 |
|
|
info for the epilogue. */
|
| 1939 |
|
|
if (DECL_STRUCT_FUNCTION (fndecl))
|
| 1940 |
|
|
set_cfun (DECL_STRUCT_FUNCTION (fndecl));
|
| 1941 |
|
|
else
|
| 1942 |
|
|
allocate_struct_function (fndecl, false);
|
| 1943 |
|
|
cfun->function_end_locus = DECL_FUNCTION_LAST_LINE (fndecl);
|
| 1944 |
|
|
|
| 1945 |
|
|
/* Defer inlining and expansion to the cgraph optimizers. */
|
| 1946 |
|
|
cgraph_finalize_function (fndecl, false);
|
| 1947 |
|
|
}
|
| 1948 |
|
|
|
| 1949 |
|
|
/* We pessimistically marked all methods and fields external until we
|
| 1950 |
|
|
knew what set of classes we were planning to compile. Now mark those
|
| 1951 |
|
|
associated with CLASS to be generated locally as not external. */
|
| 1952 |
|
|
|
| 1953 |
|
|
static void
|
| 1954 |
|
|
java_mark_decl_local (tree decl)
|
| 1955 |
|
|
{
|
| 1956 |
|
|
DECL_EXTERNAL (decl) = 0;
|
| 1957 |
|
|
|
| 1958 |
|
|
#ifdef ENABLE_CHECKING
|
| 1959 |
|
|
/* Double check that we didn't pass the function to the callgraph early. */
|
| 1960 |
|
|
if (TREE_CODE (decl) == FUNCTION_DECL)
|
| 1961 |
|
|
gcc_assert (!cgraph_node (decl)->local.finalized);
|
| 1962 |
|
|
#endif
|
| 1963 |
|
|
gcc_assert (!DECL_RTL_SET_P (decl));
|
| 1964 |
|
|
}
|
| 1965 |
|
|
|
| 1966 |
|
|
/* Given appropriate target support, G++ will emit hidden aliases for native
|
| 1967 |
|
|
methods. Using this hidden name is required for proper operation of
|
| 1968 |
|
|
_Jv_Method::ncode, but it doesn't hurt to use it everywhere. Look for
|
| 1969 |
|
|
proper target support, then mark the method for aliasing. */
|
| 1970 |
|
|
|
| 1971 |
|
|
static void
|
| 1972 |
|
|
java_mark_cni_decl_local (tree decl)
|
| 1973 |
|
|
{
|
| 1974 |
|
|
#if !defined(HAVE_GAS_HIDDEN) || !defined(ASM_OUTPUT_DEF)
|
| 1975 |
|
|
return;
|
| 1976 |
|
|
#endif
|
| 1977 |
|
|
|
| 1978 |
|
|
DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN;
|
| 1979 |
|
|
DECL_LOCAL_CNI_METHOD_P (decl) = 1;
|
| 1980 |
|
|
|
| 1981 |
|
|
/* Setting DECL_LOCAL_CNI_METHOD_P changes the behavior of the
|
| 1982 |
|
|
mangler. We might have already referenced this native method and
|
| 1983 |
|
|
therefore created its name, but even if we have it won't hurt.
|
| 1984 |
|
|
We'll just go via its externally visible name, rather than its
|
| 1985 |
|
|
hidden alias. However, we must force things so that the correct
|
| 1986 |
|
|
mangling is done. */
|
| 1987 |
|
|
|
| 1988 |
|
|
if (DECL_ASSEMBLER_NAME_SET_P (decl))
|
| 1989 |
|
|
java_mangle_decl (decl);
|
| 1990 |
|
|
if (DECL_RTL_SET_P (decl))
|
| 1991 |
|
|
{
|
| 1992 |
|
|
SET_DECL_RTL (decl, 0);
|
| 1993 |
|
|
make_decl_rtl (decl);
|
| 1994 |
|
|
}
|
| 1995 |
|
|
}
|
| 1996 |
|
|
|
| 1997 |
|
|
/* Use the preceding two functions and mark all members of the class. */
|
| 1998 |
|
|
|
| 1999 |
|
|
void
|
| 2000 |
|
|
java_mark_class_local (tree klass)
|
| 2001 |
|
|
{
|
| 2002 |
|
|
tree t;
|
| 2003 |
|
|
|
| 2004 |
|
|
for (t = TYPE_FIELDS (klass); t ; t = TREE_CHAIN (t))
|
| 2005 |
|
|
if (FIELD_STATIC (t))
|
| 2006 |
|
|
java_mark_decl_local (t);
|
| 2007 |
|
|
|
| 2008 |
|
|
for (t = TYPE_METHODS (klass); t ; t = TREE_CHAIN (t))
|
| 2009 |
|
|
if (!METHOD_ABSTRACT (t))
|
| 2010 |
|
|
{
|
| 2011 |
|
|
if (METHOD_NATIVE (t) && !flag_jni)
|
| 2012 |
|
|
java_mark_cni_decl_local (t);
|
| 2013 |
|
|
else
|
| 2014 |
|
|
java_mark_decl_local (t);
|
| 2015 |
|
|
}
|
| 2016 |
|
|
}
|
| 2017 |
|
|
|
| 2018 |
|
|
/* Add a statement to a compound_expr. */
|
| 2019 |
|
|
|
| 2020 |
|
|
tree
|
| 2021 |
|
|
add_stmt_to_compound (tree existing, tree type, tree stmt)
|
| 2022 |
|
|
{
|
| 2023 |
|
|
if (!stmt)
|
| 2024 |
|
|
return existing;
|
| 2025 |
|
|
else if (existing)
|
| 2026 |
|
|
{
|
| 2027 |
|
|
tree expr = build2 (COMPOUND_EXPR, type, existing, stmt);
|
| 2028 |
|
|
TREE_SIDE_EFFECTS (expr) = TREE_SIDE_EFFECTS (existing)
|
| 2029 |
|
|
| TREE_SIDE_EFFECTS (stmt);
|
| 2030 |
|
|
return expr;
|
| 2031 |
|
|
}
|
| 2032 |
|
|
else
|
| 2033 |
|
|
return stmt;
|
| 2034 |
|
|
}
|
| 2035 |
|
|
|
| 2036 |
|
|
/* If this node is an expr, mark its input location. Called from
|
| 2037 |
|
|
walk_tree(). */
|
| 2038 |
|
|
|
| 2039 |
|
|
static tree
|
| 2040 |
|
|
set_input_location (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
|
| 2041 |
|
|
void *data ATTRIBUTE_UNUSED)
|
| 2042 |
|
|
{
|
| 2043 |
|
|
tree t = *tp;
|
| 2044 |
|
|
|
| 2045 |
|
|
if (CAN_HAVE_LOCATION_P (t))
|
| 2046 |
|
|
{
|
| 2047 |
|
|
if (EXPR_HAS_LOCATION(t))
|
| 2048 |
|
|
return t; /* Don't walk any further into this expr. */
|
| 2049 |
|
|
else
|
| 2050 |
|
|
SET_EXPR_LOCATION (t, input_location);
|
| 2051 |
|
|
}
|
| 2052 |
|
|
|
| 2053 |
|
|
return NULL_TREE; /* Continue walking this expr. */
|
| 2054 |
|
|
}
|
| 2055 |
|
|
|
| 2056 |
|
|
/* Add a statement to the statement_list currently being constructed.
|
| 2057 |
|
|
If the statement_list is null, we don't create a singleton list.
|
| 2058 |
|
|
This is necessary because poplevel() assumes that adding a
|
| 2059 |
|
|
statement to a null statement_list returns the statement. */
|
| 2060 |
|
|
|
| 2061 |
|
|
tree
|
| 2062 |
|
|
java_add_stmt (tree new_stmt)
|
| 2063 |
|
|
{
|
| 2064 |
|
|
tree stmts = current_binding_level->stmts;
|
| 2065 |
|
|
tree_stmt_iterator i;
|
| 2066 |
|
|
|
| 2067 |
|
|
if (input_filename)
|
| 2068 |
|
|
walk_tree (&new_stmt, set_input_location, NULL, NULL);
|
| 2069 |
|
|
|
| 2070 |
|
|
if (stmts == NULL)
|
| 2071 |
|
|
return current_binding_level->stmts = new_stmt;
|
| 2072 |
|
|
|
| 2073 |
|
|
/* Force STMTS to be a statement_list. */
|
| 2074 |
|
|
if (TREE_CODE (stmts) != STATEMENT_LIST)
|
| 2075 |
|
|
{
|
| 2076 |
|
|
tree t = make_node (STATEMENT_LIST);
|
| 2077 |
|
|
i = tsi_last (t);
|
| 2078 |
|
|
tsi_link_after (&i, stmts, TSI_CONTINUE_LINKING);
|
| 2079 |
|
|
stmts = t;
|
| 2080 |
|
|
}
|
| 2081 |
|
|
|
| 2082 |
|
|
i = tsi_last (stmts);
|
| 2083 |
|
|
tsi_link_after (&i, new_stmt, TSI_CONTINUE_LINKING);
|
| 2084 |
|
|
TREE_TYPE (stmts) = void_type_node;
|
| 2085 |
|
|
|
| 2086 |
|
|
return current_binding_level->stmts = stmts;
|
| 2087 |
|
|
}
|
| 2088 |
|
|
|
| 2089 |
|
|
/* Add a variable to the current scope. */
|
| 2090 |
|
|
|
| 2091 |
|
|
tree
|
| 2092 |
|
|
java_add_local_var (tree decl)
|
| 2093 |
|
|
{
|
| 2094 |
|
|
tree *vars = ¤t_binding_level->names;
|
| 2095 |
|
|
tree next = *vars;
|
| 2096 |
|
|
TREE_CHAIN (decl) = next;
|
| 2097 |
|
|
*vars = decl;
|
| 2098 |
|
|
DECL_CONTEXT (decl) = current_function_decl;
|
| 2099 |
|
|
MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl);
|
| 2100 |
|
|
return decl;
|
| 2101 |
|
|
}
|
| 2102 |
|
|
|
| 2103 |
|
|
/* Return a pointer to the compound_expr currently being
|
| 2104 |
|
|
constructed. */
|
| 2105 |
|
|
|
| 2106 |
|
|
tree *
|
| 2107 |
|
|
get_stmts (void)
|
| 2108 |
|
|
{
|
| 2109 |
|
|
return ¤t_binding_level->stmts;
|
| 2110 |
|
|
}
|
| 2111 |
|
|
|
| 2112 |
|
|
/* Register an exception range as belonging to the current binding
|
| 2113 |
|
|
level. There may only be one: if there are more, we'll create more
|
| 2114 |
|
|
binding levels. However, each range can have multiple handlers,
|
| 2115 |
|
|
and these are expanded when we call expand_end_java_handler(). */
|
| 2116 |
|
|
|
| 2117 |
|
|
void
|
| 2118 |
|
|
register_exception_range (struct eh_range *range, int pc, int end_pc)
|
| 2119 |
|
|
{
|
| 2120 |
|
|
gcc_assert (! current_binding_level->exception_range);
|
| 2121 |
|
|
current_binding_level->exception_range = range;
|
| 2122 |
|
|
current_binding_level->end_pc = end_pc;
|
| 2123 |
|
|
current_binding_level->start_pc = pc;
|
| 2124 |
|
|
}
|
| 2125 |
|
|
|
| 2126 |
|
|
#include "gt-java-decl.h"
|