src/share/vm/oops/generateOopMap.hpp

Fri, 27 Feb 2009 13:27:09 -0800

author
twisti
date
Fri, 27 Feb 2009 13:27:09 -0800
changeset 1040
98cb887364d3
parent 777
37f87013dfd8
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6810672: Comment typos
Summary: I have collected some typos I have found while looking at the code.
Reviewed-by: kvn, never

duke@435 1 /*
duke@435 2 * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 // Forward definition
duke@435 26 class MethodOopMap;
duke@435 27 class GenerateOopMap;
duke@435 28 class BasicBlock;
duke@435 29 class CellTypeState;
duke@435 30 class StackMap;
duke@435 31
duke@435 32 // These two should be removed. But requires som code to be cleaned up
duke@435 33 #define MAXARGSIZE 256 // This should be enough
duke@435 34 #define MAX_LOCAL_VARS 65536 // 16-bit entry
duke@435 35
duke@435 36 typedef void (*jmpFct_t)(GenerateOopMap *c, int bcpDelta, int* data);
duke@435 37
duke@435 38
duke@435 39 // RetTable
duke@435 40 //
duke@435 41 // Contains maping between jsr targets and there return addresses. One-to-many mapping
duke@435 42 //
duke@435 43 class RetTableEntry : public ResourceObj {
duke@435 44 private:
duke@435 45 static int _init_nof_jsrs; // Default size of jsrs list
duke@435 46 int _target_bci; // Target PC address of jump (bytecode index)
duke@435 47 GrowableArray<intptr_t> * _jsrs; // List of return addresses (bytecode index)
duke@435 48 RetTableEntry *_next; // Link to next entry
duke@435 49 public:
duke@435 50 RetTableEntry(int target, RetTableEntry *next) { _target_bci=target; _jsrs = new GrowableArray<intptr_t>(_init_nof_jsrs); _next = next; }
duke@435 51
duke@435 52 // Query
duke@435 53 int target_bci() const { return _target_bci; }
duke@435 54 int nof_jsrs() const { return _jsrs->length(); }
duke@435 55 int jsrs(int i) const { assert(i>=0 && i<nof_jsrs(), "Index out of bounds"); return _jsrs->at(i); }
duke@435 56
duke@435 57 // Update entry
duke@435 58 void add_jsr (int return_bci) { _jsrs->append(return_bci); }
duke@435 59 void add_delta (int bci, int delta);
duke@435 60 RetTableEntry * next() const { return _next; }
duke@435 61 };
duke@435 62
duke@435 63
duke@435 64 class RetTable VALUE_OBJ_CLASS_SPEC {
duke@435 65 private:
duke@435 66 RetTableEntry *_first;
duke@435 67 static int _init_nof_entries;
duke@435 68
duke@435 69 void add_jsr(int return_bci, int target_bci); // Adds entry to list
duke@435 70 public:
duke@435 71 RetTable() { _first = NULL; }
duke@435 72 void compute_ret_table(methodHandle method);
duke@435 73 void update_ret_table(int bci, int delta);
duke@435 74 RetTableEntry* find_jsrs_for_target(int targBci);
duke@435 75 };
duke@435 76
duke@435 77 //
duke@435 78 // CellTypeState
duke@435 79 //
duke@435 80 class CellTypeState VALUE_OBJ_CLASS_SPEC {
duke@435 81 private:
duke@435 82 unsigned int _state;
duke@435 83
duke@435 84 // Masks for separating the BITS and INFO portions of a CellTypeState
duke@435 85 enum { info_mask = right_n_bits(28),
duke@435 86 bits_mask = (int)(~info_mask) };
duke@435 87
duke@435 88 // These constant are used for manipulating the BITS portion of a
duke@435 89 // CellTypeState
duke@435 90 enum { uninit_bit = (int)(nth_bit(31)),
duke@435 91 ref_bit = nth_bit(30),
duke@435 92 val_bit = nth_bit(29),
duke@435 93 addr_bit = nth_bit(28),
duke@435 94 live_bits_mask = (int)(bits_mask & ~uninit_bit) };
duke@435 95
duke@435 96 // These constants are used for manipulating the INFO portion of a
duke@435 97 // CellTypeState
duke@435 98 enum { top_info_bit = nth_bit(27),
duke@435 99 not_bottom_info_bit = nth_bit(26),
duke@435 100 info_data_mask = right_n_bits(26),
duke@435 101 info_conflict = info_mask };
duke@435 102
duke@435 103 // Within the INFO data, these values are used to distinguish different
duke@435 104 // kinds of references.
duke@435 105 enum { ref_not_lock_bit = nth_bit(25), // 0 if this reference is locked as a monitor
duke@435 106 ref_slot_bit = nth_bit(24), // 1 if this reference is a "slot" reference,
duke@435 107 // 0 if it is a "line" reference.
duke@435 108 ref_data_mask = right_n_bits(24) };
duke@435 109
duke@435 110
duke@435 111 // These values are used to initialize commonly used CellTypeState
duke@435 112 // constants.
duke@435 113 enum { bottom_value = 0,
duke@435 114 uninit_value = (int)(uninit_bit | info_conflict),
duke@435 115 ref_value = ref_bit,
duke@435 116 ref_conflict = ref_bit | info_conflict,
duke@435 117 val_value = val_bit | info_conflict,
duke@435 118 addr_value = addr_bit,
duke@435 119 addr_conflict = addr_bit | info_conflict };
duke@435 120
duke@435 121 public:
duke@435 122
duke@435 123 // Since some C++ constructors generate poor code for declarations of the
duke@435 124 // form...
duke@435 125 //
duke@435 126 // CellTypeState vector[length];
duke@435 127 //
duke@435 128 // ...we avoid making a constructor for this class. CellTypeState values
duke@435 129 // should be constructed using one of the make_* methods:
duke@435 130
duke@435 131 static CellTypeState make_any(int state) {
duke@435 132 CellTypeState s;
duke@435 133 s._state = state;
duke@435 134 // Causes SS10 warning.
duke@435 135 // assert(s.is_valid_state(), "check to see if CellTypeState is valid");
duke@435 136 return s;
duke@435 137 }
duke@435 138
duke@435 139 static CellTypeState make_bottom() {
duke@435 140 return make_any(0);
duke@435 141 }
duke@435 142
duke@435 143 static CellTypeState make_top() {
duke@435 144 return make_any(AllBits);
duke@435 145 }
duke@435 146
duke@435 147 static CellTypeState make_addr(int bci) {
duke@435 148 assert((bci >= 0) && (bci < info_data_mask), "check to see if ret addr is valid");
duke@435 149 return make_any(addr_bit | not_bottom_info_bit | (bci & info_data_mask));
duke@435 150 }
duke@435 151
duke@435 152 static CellTypeState make_slot_ref(int slot_num) {
duke@435 153 assert(slot_num >= 0 && slot_num < ref_data_mask, "slot out of range");
duke@435 154 return make_any(ref_bit | not_bottom_info_bit | ref_not_lock_bit | ref_slot_bit |
duke@435 155 (slot_num & ref_data_mask));
duke@435 156 }
duke@435 157
duke@435 158 static CellTypeState make_line_ref(int bci) {
duke@435 159 assert(bci >= 0 && bci < ref_data_mask, "line out of range");
duke@435 160 return make_any(ref_bit | not_bottom_info_bit | ref_not_lock_bit |
duke@435 161 (bci & ref_data_mask));
duke@435 162 }
duke@435 163
duke@435 164 static CellTypeState make_lock_ref(int bci) {
duke@435 165 assert(bci >= 0 && bci < ref_data_mask, "line out of range");
duke@435 166 return make_any(ref_bit | not_bottom_info_bit | (bci & ref_data_mask));
duke@435 167 }
duke@435 168
duke@435 169 // Query methods:
duke@435 170 bool is_bottom() const { return _state == 0; }
duke@435 171 bool is_live() const { return ((_state & live_bits_mask) != 0); }
duke@435 172 bool is_valid_state() const {
duke@435 173 // Uninitialized and value cells must contain no data in their info field:
duke@435 174 if ((can_be_uninit() || can_be_value()) && !is_info_top()) {
duke@435 175 return false;
duke@435 176 }
duke@435 177 // The top bit is only set when all info bits are set:
duke@435 178 if (is_info_top() && ((_state & info_mask) != info_mask)) {
duke@435 179 return false;
duke@435 180 }
duke@435 181 // The not_bottom_bit must be set when any other info bit is set:
duke@435 182 if (is_info_bottom() && ((_state & info_mask) != 0)) {
duke@435 183 return false;
duke@435 184 }
duke@435 185 return true;
duke@435 186 }
duke@435 187
duke@435 188 bool is_address() const { return ((_state & bits_mask) == addr_bit); }
duke@435 189 bool is_reference() const { return ((_state & bits_mask) == ref_bit); }
duke@435 190 bool is_value() const { return ((_state & bits_mask) == val_bit); }
duke@435 191 bool is_uninit() const { return ((_state & bits_mask) == (uint)uninit_bit); }
duke@435 192
duke@435 193 bool can_be_address() const { return ((_state & addr_bit) != 0); }
duke@435 194 bool can_be_reference() const { return ((_state & ref_bit) != 0); }
duke@435 195 bool can_be_value() const { return ((_state & val_bit) != 0); }
duke@435 196 bool can_be_uninit() const { return ((_state & uninit_bit) != 0); }
duke@435 197
duke@435 198 bool is_info_bottom() const { return ((_state & not_bottom_info_bit) == 0); }
duke@435 199 bool is_info_top() const { return ((_state & top_info_bit) != 0); }
duke@435 200 int get_info() const {
duke@435 201 assert((!is_info_top() && !is_info_bottom()),
duke@435 202 "check to make sure top/bottom info is not used");
duke@435 203 return (_state & info_data_mask);
duke@435 204 }
duke@435 205
duke@435 206 bool is_good_address() const { return is_address() && !is_info_top(); }
duke@435 207 bool is_lock_reference() const {
duke@435 208 return ((_state & (bits_mask | top_info_bit | ref_not_lock_bit)) == ref_bit);
duke@435 209 }
duke@435 210 bool is_nonlock_reference() const {
duke@435 211 return ((_state & (bits_mask | top_info_bit | ref_not_lock_bit)) == (ref_bit | ref_not_lock_bit));
duke@435 212 }
duke@435 213
duke@435 214 bool equal(CellTypeState a) const { return _state == a._state; }
duke@435 215 bool equal_kind(CellTypeState a) const {
duke@435 216 return (_state & bits_mask) == (a._state & bits_mask);
duke@435 217 }
duke@435 218
duke@435 219 char to_char() const;
duke@435 220
duke@435 221 // Merge
duke@435 222 CellTypeState merge (CellTypeState cts, int slot) const;
duke@435 223
duke@435 224 // Debugging output
duke@435 225 void print(outputStream *os);
duke@435 226
duke@435 227 // Default values of common values
duke@435 228 static CellTypeState bottom;
duke@435 229 static CellTypeState uninit;
duke@435 230 static CellTypeState ref;
duke@435 231 static CellTypeState value;
duke@435 232 static CellTypeState refUninit;
duke@435 233 static CellTypeState varUninit;
duke@435 234 static CellTypeState top;
duke@435 235 static CellTypeState addr;
duke@435 236 };
duke@435 237
duke@435 238
duke@435 239 //
duke@435 240 // BasicBlockStruct
duke@435 241 //
duke@435 242 class BasicBlock: ResourceObj {
duke@435 243 private:
duke@435 244 bool _changed; // Reached a fixpoint or not
duke@435 245 public:
duke@435 246 enum Constants {
duke@435 247 _dead_basic_block = -2,
duke@435 248 _unreached = -1 // Alive but not yet reached by analysis
duke@435 249 // >=0 // Alive and has a merged state
duke@435 250 };
duke@435 251
duke@435 252 int _bci; // Start of basic block
duke@435 253 int _end_bci; // Bci of last instruction in basicblock
duke@435 254 int _max_locals; // Determines split between vars and stack
duke@435 255 int _max_stack; // Determines split between stack and monitors
duke@435 256 CellTypeState* _state; // State (vars, stack) at entry.
duke@435 257 int _stack_top; // -1 indicates bottom stack value.
duke@435 258 int _monitor_top; // -1 indicates bottom monitor stack value.
duke@435 259
duke@435 260 CellTypeState* vars() { return _state; }
duke@435 261 CellTypeState* stack() { return _state + _max_locals; }
duke@435 262
duke@435 263 bool changed() { return _changed; }
duke@435 264 void set_changed(bool s) { _changed = s; }
duke@435 265
duke@435 266 bool is_reachable() const { return _stack_top >= 0; } // Analysis has reached this basicblock
duke@435 267
duke@435 268 // All basicblocks that are unreachable are going to have a _stack_top == _dead_basic_block.
duke@435 269 // This info. is setup in a pre-parse before the real abstract interpretation starts.
duke@435 270 bool is_dead() const { return _stack_top == _dead_basic_block; }
duke@435 271 bool is_alive() const { return _stack_top != _dead_basic_block; }
duke@435 272 void mark_as_alive() { assert(is_dead(), "must be dead"); _stack_top = _unreached; }
duke@435 273 };
duke@435 274
duke@435 275
duke@435 276 //
duke@435 277 // GenerateOopMap
duke@435 278 //
duke@435 279 // Main class used to compute the pointer-maps in a MethodOop
duke@435 280 //
duke@435 281 class GenerateOopMap VALUE_OBJ_CLASS_SPEC {
duke@435 282 protected:
duke@435 283
duke@435 284 // _monitor_top is set to this constant to indicate that a monitor matching
duke@435 285 // problem was encountered prior to this point in control flow.
duke@435 286 enum { bad_monitors = -1 };
duke@435 287
duke@435 288 // Main variables
duke@435 289 methodHandle _method; // The method we are examine
duke@435 290 RetTable _rt; // Contains the return address mappings
duke@435 291 int _max_locals; // Cached value of no. of locals
duke@435 292 int _max_stack; // Cached value of max. stack depth
duke@435 293 int _max_monitors; // Cached value of max. monitor stack depth
duke@435 294 int _has_exceptions; // True, if exceptions exist for method
twisti@1040 295 bool _got_error; // True, if an error occurred during interpretation.
duke@435 296 Handle _exception; // Exception if got_error is true.
duke@435 297 bool _did_rewriting; // was bytecodes rewritten
duke@435 298 bool _did_relocation; // was relocation neccessary
duke@435 299 bool _monitor_safe; // The monitors in this method have been determined
duke@435 300 // to be safe.
duke@435 301
duke@435 302 // Working Cell type state
duke@435 303 int _state_len; // Size of states
duke@435 304 CellTypeState *_state; // list of states
duke@435 305 char *_state_vec_buf; // Buffer used to print a readable version of a state
duke@435 306 int _stack_top;
duke@435 307 int _monitor_top;
duke@435 308
duke@435 309 // Timing and statistics
duke@435 310 static elapsedTimer _total_oopmap_time; // Holds cumulative oopmap generation time
duke@435 311 static long _total_byte_count; // Holds cumulative number of bytes inspected
duke@435 312
duke@435 313 // Cell type methods
duke@435 314 void init_state();
duke@435 315 void make_context_uninitialized ();
duke@435 316 int methodsig_to_effect (symbolOop signature, bool isStatic, CellTypeState* effect);
duke@435 317 bool merge_local_state_vectors (CellTypeState* cts, CellTypeState* bbts);
duke@435 318 bool merge_monitor_state_vectors(CellTypeState* cts, CellTypeState* bbts);
duke@435 319 void copy_state (CellTypeState *dst, CellTypeState *src);
duke@435 320 void merge_state_into_bb (BasicBlock *bb);
duke@435 321 static void merge_state (GenerateOopMap *gom, int bcidelta, int* data);
duke@435 322 void set_var (int localNo, CellTypeState cts);
duke@435 323 CellTypeState get_var (int localNo);
duke@435 324 CellTypeState pop ();
duke@435 325 void push (CellTypeState cts);
duke@435 326 CellTypeState monitor_pop ();
duke@435 327 void monitor_push (CellTypeState cts);
duke@435 328 CellTypeState * vars () { return _state; }
duke@435 329 CellTypeState * stack () { return _state+_max_locals; }
duke@435 330 CellTypeState * monitors () { return _state+_max_locals+_max_stack; }
duke@435 331
duke@435 332 void replace_all_CTS_matches (CellTypeState match,
duke@435 333 CellTypeState replace);
duke@435 334 void print_states (outputStream *os, CellTypeState *vector, int num);
duke@435 335 void print_current_state (outputStream *os,
duke@435 336 BytecodeStream *itr,
duke@435 337 bool detailed);
duke@435 338 void report_monitor_mismatch (const char *msg);
duke@435 339
duke@435 340 // Basicblock info
duke@435 341 BasicBlock * _basic_blocks; // Array of basicblock info
duke@435 342 int _gc_points;
duke@435 343 int _bb_count;
ysr@777 344 BitMap _bb_hdr_bits;
duke@435 345
duke@435 346 // Basicblocks methods
duke@435 347 void initialize_bb ();
duke@435 348 void mark_bbheaders_and_count_gc_points();
ysr@777 349 bool is_bb_header (int bci) const {
ysr@777 350 return _bb_hdr_bits.at(bci);
ysr@777 351 }
duke@435 352 int gc_points () const { return _gc_points; }
duke@435 353 int bb_count () const { return _bb_count; }
ysr@777 354 void set_bbmark_bit (int bci) {
ysr@777 355 _bb_hdr_bits.at_put(bci, true);
ysr@777 356 }
ysr@777 357 void clear_bbmark_bit (int bci) {
ysr@777 358 _bb_hdr_bits.at_put(bci, false);
ysr@777 359 }
duke@435 360 BasicBlock * get_basic_block_at (int bci) const;
duke@435 361 BasicBlock * get_basic_block_containing (int bci) const;
duke@435 362 void interp_bb (BasicBlock *bb);
duke@435 363 void restore_state (BasicBlock *bb);
duke@435 364 int next_bb_start_pc (BasicBlock *bb);
duke@435 365 void update_basic_blocks (int bci, int delta, int new_method_size);
duke@435 366 static void bb_mark_fct (GenerateOopMap *c, int deltaBci, int *data);
duke@435 367
duke@435 368 // Dead code detection
duke@435 369 void mark_reachable_code();
duke@435 370 static void reachable_basicblock (GenerateOopMap *c, int deltaBci, int *data);
duke@435 371
duke@435 372 // Interpretation methods (primary)
duke@435 373 void do_interpretation ();
duke@435 374 void init_basic_blocks ();
duke@435 375 void setup_method_entry_state ();
duke@435 376 void interp_all ();
duke@435 377
duke@435 378 // Interpretation methods (secondary)
duke@435 379 void interp1 (BytecodeStream *itr);
duke@435 380 void do_exception_edge (BytecodeStream *itr);
duke@435 381 void check_type (CellTypeState expected, CellTypeState actual);
duke@435 382 void ppstore (CellTypeState *in, int loc_no);
duke@435 383 void ppload (CellTypeState *out, int loc_no);
duke@435 384 void ppush1 (CellTypeState in);
duke@435 385 void ppush (CellTypeState *in);
duke@435 386 void ppop1 (CellTypeState out);
duke@435 387 void ppop (CellTypeState *out);
duke@435 388 void ppop_any (int poplen);
duke@435 389 void pp (CellTypeState *in, CellTypeState *out);
duke@435 390 void pp_new_ref (CellTypeState *in, int bci);
duke@435 391 void ppdupswap (int poplen, const char *out);
duke@435 392 void do_ldc (int idx, int bci);
duke@435 393 void do_astore (int idx);
duke@435 394 void do_jsr (int delta);
duke@435 395 void do_field (int is_get, int is_static, int idx, int bci);
duke@435 396 void do_method (int is_static, int is_interface, int idx, int bci);
duke@435 397 void do_multianewarray (int dims, int bci);
duke@435 398 void do_monitorenter (int bci);
duke@435 399 void do_monitorexit (int bci);
duke@435 400 void do_return_monitor_check ();
duke@435 401 void do_checkcast ();
duke@435 402 CellTypeState *sigchar_to_effect (char sigch, int bci, CellTypeState *out);
duke@435 403 int copy_cts (CellTypeState *dst, CellTypeState *src);
duke@435 404
duke@435 405 // Error handling
duke@435 406 void error_work (const char *format, va_list ap);
duke@435 407 void report_error (const char *format, ...);
duke@435 408 void verify_error (const char *format, ...);
duke@435 409 bool got_error() { return _got_error; }
duke@435 410
duke@435 411 // Create result set
duke@435 412 bool _report_result;
duke@435 413 bool _report_result_for_send; // Unfortunatly, stackmaps for sends are special, so we need some extra
duke@435 414 BytecodeStream *_itr_send; // variables to handle them properly.
duke@435 415
duke@435 416 void report_result ();
duke@435 417
duke@435 418 // Initvars
duke@435 419 GrowableArray<intptr_t> * _init_vars;
duke@435 420
duke@435 421 void initialize_vars ();
duke@435 422 void add_to_ref_init_set (int localNo);
duke@435 423
duke@435 424 // Conflicts rewrite logic
twisti@1040 425 bool _conflict; // True, if a conflict occurred during interpretation
duke@435 426 int _nof_refval_conflicts; // No. of conflicts that require rewrites
duke@435 427 int * _new_var_map;
duke@435 428
duke@435 429 void record_refval_conflict (int varNo);
duke@435 430 void rewrite_refval_conflicts ();
duke@435 431 void rewrite_refval_conflict (int from, int to);
duke@435 432 bool rewrite_refval_conflict_inst (BytecodeStream *i, int from, int to);
duke@435 433 bool rewrite_load_or_store (BytecodeStream *i, Bytecodes::Code bc, Bytecodes::Code bc0, unsigned int varNo);
duke@435 434
duke@435 435 void expand_current_instr (int bci, int ilen, int newIlen, u_char inst_buffer[]);
duke@435 436 bool is_astore (BytecodeStream *itr, int *index);
duke@435 437 bool is_aload (BytecodeStream *itr, int *index);
duke@435 438
duke@435 439 // List of bci's where a return address is on top of the stack
duke@435 440 GrowableArray<intptr_t> *_ret_adr_tos;
duke@435 441
duke@435 442 bool stack_top_holds_ret_addr (int bci);
duke@435 443 void compute_ret_adr_at_TOS ();
duke@435 444 void update_ret_adr_at_TOS (int bci, int delta);
duke@435 445
duke@435 446 int binsToHold (int no) { return ((no+(BitsPerWord-1))/BitsPerWord); }
duke@435 447 char *state_vec_to_string (CellTypeState* vec, int len);
duke@435 448
duke@435 449 // Helper method. Can be used in subclasses to fx. calculate gc_points. If the current instuction
duke@435 450 // is a control transfer, then calls the jmpFct all possible destinations.
duke@435 451 void ret_jump_targets_do (BytecodeStream *bcs, jmpFct_t jmpFct, int varNo,int *data);
duke@435 452 bool jump_targets_do (BytecodeStream *bcs, jmpFct_t jmpFct, int *data);
duke@435 453
duke@435 454 friend class RelocCallback;
duke@435 455 public:
duke@435 456 GenerateOopMap(methodHandle method);
duke@435 457
duke@435 458 // Compute the map.
duke@435 459 void compute_map(TRAPS);
duke@435 460 void result_for_basicblock(int bci); // Do a callback on fill_stackmap_for_opcodes for basicblock containing bci
duke@435 461
duke@435 462 // Query
duke@435 463 int max_locals() const { return _max_locals; }
duke@435 464 methodOop method() const { return _method(); }
duke@435 465 methodHandle method_as_handle() const { return _method; }
duke@435 466
duke@435 467 bool did_rewriting() { return _did_rewriting; }
duke@435 468 bool did_relocation() { return _did_relocation; }
duke@435 469
duke@435 470 static void print_time();
duke@435 471
duke@435 472 // Monitor query
duke@435 473 bool monitor_safe() { return _monitor_safe; }
duke@435 474
duke@435 475 // Specialization methods. Intended use:
duke@435 476 // - possible_gc_point must return true for every bci for which the stackmaps must be returned
duke@435 477 // - fill_stackmap_prolog is called just before the result is reported. The arguments tells the estimated
duke@435 478 // number of gc points
duke@435 479 // - fill_stackmap_for_opcodes is called once for each bytecode index in order (0...code_length-1)
duke@435 480 // - fill_stackmap_epilog is called after all results has been reported. Note: Since the algorithm does not report
duke@435 481 // stackmaps for deadcode, fewer gc_points might have been encounted than assumed during the epilog. It is the
duke@435 482 // responsibility of the subclass to count the correct number.
duke@435 483 // - fill_init_vars are called once with the result of the init_vars computation
duke@435 484 //
duke@435 485 // All these methods are used during a call to: compute_map. Note: Non of the return results are valid
duke@435 486 // after compute_map returns, since all values are allocated as resource objects.
duke@435 487 //
duke@435 488 // All virtual method must be implemented in subclasses
duke@435 489 virtual bool allow_rewrites () const { return false; }
duke@435 490 virtual bool report_results () const { return true; }
duke@435 491 virtual bool report_init_vars () const { return true; }
duke@435 492 virtual bool possible_gc_point (BytecodeStream *bcs) { ShouldNotReachHere(); return false; }
duke@435 493 virtual void fill_stackmap_prolog (int nof_gc_points) { ShouldNotReachHere(); }
duke@435 494 virtual void fill_stackmap_epilog () { ShouldNotReachHere(); }
duke@435 495 virtual void fill_stackmap_for_opcodes (BytecodeStream *bcs,
duke@435 496 CellTypeState* vars,
duke@435 497 CellTypeState* stack,
duke@435 498 int stackTop) { ShouldNotReachHere(); }
duke@435 499 virtual void fill_init_vars (GrowableArray<intptr_t> *init_vars) { ShouldNotReachHere();; }
duke@435 500 };
duke@435 501
duke@435 502 //
duke@435 503 // Subclass of the GenerateOopMap Class that just do rewrites of the method, if needed.
duke@435 504 // It does not store any oopmaps.
duke@435 505 //
duke@435 506 class ResolveOopMapConflicts: public GenerateOopMap {
duke@435 507 private:
duke@435 508
duke@435 509 bool _must_clear_locals;
duke@435 510
duke@435 511 virtual bool report_results() const { return false; }
duke@435 512 virtual bool report_init_vars() const { return true; }
duke@435 513 virtual bool allow_rewrites() const { return true; }
duke@435 514 virtual bool possible_gc_point (BytecodeStream *bcs) { return false; }
duke@435 515 virtual void fill_stackmap_prolog (int nof_gc_points) {}
duke@435 516 virtual void fill_stackmap_epilog () {}
duke@435 517 virtual void fill_stackmap_for_opcodes (BytecodeStream *bcs,
duke@435 518 CellTypeState* vars,
duke@435 519 CellTypeState* stack,
duke@435 520 int stack_top) {}
duke@435 521 virtual void fill_init_vars (GrowableArray<intptr_t> *init_vars) { _must_clear_locals = init_vars->length() > 0; }
duke@435 522
duke@435 523 #ifndef PRODUCT
duke@435 524 // Statistics
duke@435 525 static int _nof_invocations;
duke@435 526 static int _nof_rewrites;
duke@435 527 static int _nof_relocations;
duke@435 528 #endif
duke@435 529
duke@435 530 public:
duke@435 531 ResolveOopMapConflicts(methodHandle method) : GenerateOopMap(method) { _must_clear_locals = false; };
duke@435 532
duke@435 533 methodHandle do_potential_rewrite(TRAPS);
duke@435 534 bool must_clear_locals() const { return _must_clear_locals; }
duke@435 535 };
duke@435 536
duke@435 537
duke@435 538 //
duke@435 539 // Subclass used by the compiler to generate pairing infomation
duke@435 540 //
duke@435 541 class GeneratePairingInfo: public GenerateOopMap {
duke@435 542 private:
duke@435 543
duke@435 544 virtual bool report_results() const { return false; }
duke@435 545 virtual bool report_init_vars() const { return false; }
duke@435 546 virtual bool allow_rewrites() const { return false; }
duke@435 547 virtual bool possible_gc_point (BytecodeStream *bcs) { return false; }
duke@435 548 virtual void fill_stackmap_prolog (int nof_gc_points) {}
duke@435 549 virtual void fill_stackmap_epilog () {}
duke@435 550 virtual void fill_stackmap_for_opcodes (BytecodeStream *bcs,
duke@435 551 CellTypeState* vars,
duke@435 552 CellTypeState* stack,
duke@435 553 int stack_top) {}
duke@435 554 virtual void fill_init_vars (GrowableArray<intptr_t> *init_vars) {}
duke@435 555 public:
duke@435 556 GeneratePairingInfo(methodHandle method) : GenerateOopMap(method) {};
duke@435 557
duke@435 558 // Call compute_map(CHECK) to generate info.
duke@435 559 };

mercurial