comparison src/share/vm/interpreter/bytecodes.hpp @ 1579:e9ff18c4ace7

Merge
author jrose
date Wed, 02 Jun 2010 22:45:42 -0700
parents c18cbe5936b8 de91a2f25c7e
children 136b78722a08
comparison
equal deleted inserted replaced
1562:dfe27f03244a 1579:e9ff18c4ace7
1 /* 1 /*
2 * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
278 #include "incls/_bytecodes_pd.hpp.incl" 278 #include "incls/_bytecodes_pd.hpp.incl"
279 279
280 number_of_codes 280 number_of_codes
281 }; 281 };
282 282
283 // Flag bits derived from format strings, can_trap, can_rewrite, etc.:
284 enum Flags {
285 // semantic flags:
286 _bc_can_trap = 1<<0, // bytecode execution can trap or block
287 _bc_can_rewrite = 1<<1, // bytecode execution has an alternate form
288
289 // format bits (determined only by the format string):
290 _fmt_has_c = 1<<2, // constant, such as sipush "bcc"
291 _fmt_has_j = 1<<3, // constant pool cache index, such as getfield "bjj"
292 _fmt_has_k = 1<<4, // constant pool index, such as ldc "bk"
293 _fmt_has_i = 1<<5, // local index, such as iload
294 _fmt_has_o = 1<<6, // offset, such as ifeq
295 _fmt_has_nbo = 1<<7, // contains native-order field(s)
296 _fmt_has_u2 = 1<<8, // contains double-byte field(s)
297 _fmt_has_u4 = 1<<9, // contains quad-byte field
298 _fmt_not_variable = 1<<10, // not of variable length (simple or wide)
299 _fmt_not_simple = 1<<11, // either wide or variable length
300 _all_fmt_bits = (_fmt_not_simple*2 - _fmt_has_c),
301
302 // Example derived format syndromes:
303 _fmt_b = _fmt_not_variable,
304 _fmt_bc = _fmt_b | _fmt_has_c,
305 _fmt_bi = _fmt_b | _fmt_has_i,
306 _fmt_bkk = _fmt_b | _fmt_has_k | _fmt_has_u2,
307 _fmt_bJJ = _fmt_b | _fmt_has_j | _fmt_has_u2 | _fmt_has_nbo,
308 _fmt_bo2 = _fmt_b | _fmt_has_o | _fmt_has_u2,
309 _fmt_bo4 = _fmt_b | _fmt_has_o | _fmt_has_u4
310 };
311
283 private: 312 private:
284 static bool _is_initialized; 313 static bool _is_initialized;
285 static const char* _name [number_of_codes]; 314 static const char* _name [number_of_codes];
286 static const char* _format [number_of_codes];
287 static const char* _wide_format [number_of_codes];
288 static BasicType _result_type [number_of_codes]; 315 static BasicType _result_type [number_of_codes];
289 static s_char _depth [number_of_codes]; 316 static s_char _depth [number_of_codes];
290 static u_char _length [number_of_codes]; 317 static u_char _lengths [number_of_codes];
291 static bool _can_trap [number_of_codes];
292 static Code _java_code [number_of_codes]; 318 static Code _java_code [number_of_codes];
293 static bool _can_rewrite [number_of_codes]; 319 static jchar _flags [(1<<BitsPerByte)*2]; // all second page for wide formats
294 320
295 static void def(Code code, const char* name, const char* format, const char* wide_format, BasicType result_type, int depth, bool can_trap); 321 static void def(Code code, const char* name, const char* format, const char* wide_format, BasicType result_type, int depth, bool can_trap);
296 static void def(Code code, const char* name, const char* format, const char* wide_format, BasicType result_type, int depth, bool can_trap, Code java_code); 322 static void def(Code code, const char* name, const char* format, const char* wide_format, BasicType result_type, int depth, bool can_trap, Code java_code);
297 static void pd_initialize(); // platform specific initialization 323 static void pd_initialize(); // platform specific initialization
298 static Code pd_base_code_for(Code code); // platform specific base_code_for implementation 324 static Code pd_base_code_for(Code code); // platform specific base_code_for implementation
320 346
321 // find a bytecode, behind a breakpoint if necessary: 347 // find a bytecode, behind a breakpoint if necessary:
322 static Code non_breakpoint_code_at(address bcp, methodOop method = NULL); 348 static Code non_breakpoint_code_at(address bcp, methodOop method = NULL);
323 349
324 // Bytecode attributes 350 // Bytecode attributes
325 static bool is_defined (int code) { return 0 <= code && code < number_of_codes && _format[code] != NULL; } 351 static bool is_defined (int code) { return 0 <= code && code < number_of_codes && flags(code, false) != 0; }
326 static bool wide_is_defined(int code) { return is_defined(code) && _wide_format[code] != NULL; } 352 static bool wide_is_defined(int code) { return is_defined(code) && flags(code, true) != 0; }
327 static const char* name (Code code) { check(code); return _name [code]; } 353 static const char* name (Code code) { check(code); return _name [code]; }
328 static const char* format (Code code) { check(code); return _format [code]; }
329 static const char* wide_format (Code code) { return _wide_format[code]; }
330 static BasicType result_type (Code code) { check(code); return _result_type [code]; } 354 static BasicType result_type (Code code) { check(code); return _result_type [code]; }
331 static int depth (Code code) { check(code); return _depth [code]; } 355 static int depth (Code code) { check(code); return _depth [code]; }
332 static int length_for (Code code) { return _length[code]; } 356 // Note: Length functions must return <=0 for invalid bytecodes.
333 static bool can_trap (Code code) { check(code); return _can_trap [code]; } 357 // Calling check(code) in length functions would throw an unwanted assert.
358 static int length_for (Code code) { /*no check*/ return _lengths [code] & 0xF; }
359 static int wide_length_for(Code code) { /*no check*/ return _lengths [code] >> 4; }
360 static bool can_trap (Code code) { check(code); return has_all_flags(code, _bc_can_trap, false); }
334 static Code java_code (Code code) { check(code); return _java_code [code]; } 361 static Code java_code (Code code) { check(code); return _java_code [code]; }
335 static bool can_rewrite (Code code) { check(code); return _can_rewrite [code]; } 362 static bool can_rewrite (Code code) { check(code); return has_all_flags(code, _bc_can_rewrite, false); }
336 static int wide_length_for(Code code) { 363 static bool native_byte_order(Code code) { check(code); return has_all_flags(code, _fmt_has_nbo, false); }
337 if (!is_defined(code)) { 364 static bool uses_cp_cache (Code code) { check(code); return has_all_flags(code, _fmt_has_j, false); }
338 return 0;
339 }
340 const char* wf = wide_format(code);
341 return (wf == NULL) ? 0 : (int)strlen(wf);
342 }
343 // if 'end' is provided, it indicates the end of the code buffer which 365 // if 'end' is provided, it indicates the end of the code buffer which
344 // should not be read past when parsing. 366 // should not be read past when parsing.
345 static int special_length_at(address bcp, address end = NULL); 367 static int special_length_at(address bcp, address end = NULL);
346 static int raw_special_length_at(address bcp, address end = NULL); 368 static int raw_special_length_at(address bcp, address end = NULL);
347 static int length_at (address bcp) { int l = length_for(code_at(bcp)); return l > 0 ? l : special_length_at(bcp); } 369 static int length_at (address bcp) { int l = length_for(code_at(bcp)); return l > 0 ? l : special_length_at(bcp); }
353 static bool is_astore (Code code) { return (code == _astore || code == _astore_0 || code == _astore_1 375 static bool is_astore (Code code) { return (code == _astore || code == _astore_0 || code == _astore_1
354 || code == _astore_2 || code == _astore_3); } 376 || code == _astore_2 || code == _astore_3); }
355 377
356 static bool is_zero_const (Code code) { return (code == _aconst_null || code == _iconst_0 378 static bool is_zero_const (Code code) { return (code == _aconst_null || code == _iconst_0
357 || code == _fconst_0 || code == _dconst_0); } 379 || code == _fconst_0 || code == _dconst_0); }
380 static int compute_flags (const char* format, int more_flags = 0); // compute the flags
381 static int flags (int code, bool is_wide) {
382 assert(code == (u_char)code, "must be a byte");
383 return _flags[code + (is_wide ? (1<<BitsPerByte) : 0)];
384 }
385 static int format_bits (Code code, bool is_wide) { return flags(code, is_wide) & _all_fmt_bits; }
386 static bool has_all_flags (Code code, int test_flags, bool is_wide) {
387 return (flags(code, is_wide) & test_flags) == test_flags;
388 }
389
358 // Initialization 390 // Initialization
359 static void initialize (); 391 static void initialize ();
360 }; 392 };