c1_IR.hpp revision 1484
/*
* Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*
*/
// An XHandler is a C1 internal description for an exception handler
class XHandler: public CompilationResourceObj {
private:
int _entry_pco; // pco where entry_code (or entry_block if no entry_code) starts
int _phi_operand; // For resolving of phi functions at begin of entry_block
int _scope_count; // for filling ExceptionRangeEntry::scope_count
#ifdef ASSERT
int _lir_op_id; // op_id of the LIR-operation throwing to this handler
#endif
public:
// creation
, _entry_block(NULL)
, _entry_code(NULL)
, _entry_pco(-1)
, _phi_operand(-1)
, _scope_count(-1)
#ifdef ASSERT
, _lir_op_id(-1)
#endif
{ }
#ifdef ASSERT
#endif
{ }
// accessors for data of ciExceptionHandler
// accessors for additional fields
int entry_pco() const { return _entry_pco; }
assert(entry_block->is_set(BlockBegin::exception_entry_flag), "must be an exception handler entry");
}
};
// XHandlers is the C1 internal list of exception handlers for a method
class XHandlers: public CompilationResourceObj {
private:
public:
// creation
// accessors
};
class IRScope;
class Compilation;
class IRScope: public CompilationResourceObj {
private:
// hierarchy
int _caller_bci; // the caller bci of the corresponding (inlined) invoke, or < 0
int _level; // the inlining level
// graph
int _number_of_locks; // the number of monitor lock slots needed
bool _monitor_pairing_ok; // the monitor pairing info
// lock stack management
int _lock_stack_size; // number of expression stack elements which, if present,
// must be spilled to the stack because of exception
// handling inside inlined methods
BitMap _requires_phi_function; // bit is set if phi functions at loop headers are necessary for a local variable
// helper functions
public:
// creation
IRScope(Compilation* compilation, IRScope* caller, int caller_bci, ciMethod* method, int osr_bci, bool create_graph = false);
// accessors
int caller_bci() const { return _caller_bci; }
int max_stack() const; // NOTE: expensive
int lock_stack_size() const {
return _lock_stack_size;
}
// mutators
// Needed because caller state is not ready at time of IRScope construction
// Needed because caller state changes after IRScope construction.
// Computes number of expression stack elements whose state must be
// preserved in the case of an exception; these may be seen by
// caller scopes. Zero when inlining of methods containing exception
// handlers is disabled, otherwise a conservative approximation.
void compute_lock_stack_size();
// hierarchy
int top_scope_bci() const;
// accessors, graph
int number_of_locks() const { return _number_of_locks; }
bool monitor_pairing_ok() const { return _monitor_pairing_ok; }
};
//
// IRScopeDebugInfo records the debug information for a particular IRScope
// in a particular CodeEmitInfo. This allows the information to be computed
// once early enough for the OopMap to be available to the LIR and also to be
// reemited for different pcs using the same CodeEmitInfo without recomputing
// everything.
//
class IRScopeDebugInfo: public CompilationResourceObj {
private:
int _bci;
public:
int bci,
//Whether we should reexecute this bytecode for deopt
bool should_reexecute();
void record_debug_info(DebugInformationRecorder* recorder, int pc_offset, bool topmost, bool is_method_handle_invoke = false) {
// Order is significant: Must record caller first.
}
// reexecute allowed only for the topmost frame
bool return_oop = false; // This flag will be ignored since it used only for C2 with escape analysis.
recorder->describe_scope(pc_offset, scope()->method(), bci(), reexecute, is_method_handle_invoke, return_oop, locvals, expvals, monvals);
}
};
class CodeEmitInfo: public CompilationResourceObj {
friend class LinearScan;
private:
int _bci;
int _id;
bool _is_method_handle_invoke; // true if the associated call site is a MethodHandle call site.
public:
// use scope from ValueStack
// used by natives
, _id(-1)
, _is_method_handle_invoke(false) {
}
// make a copy
// accessors
bool is_method_handle_invoke() const { return _is_method_handle_invoke; }
void set_is_method_handle_invoke(bool x) { _is_method_handle_invoke = x; }
};
class IR: public CompilationResourceObj {
private:
int _num_loops; // Total number of loops
public:
// creation
// accessors
int num_loops() const { return _num_loops; }
// ir manipulation
void optimize();
void compute_predecessors();
void split_critical_edges();
void compute_code();
void compute_use_counts();
// The linear-scan order and the code emission order are equal, but
// this may change in future
// iteration
// debugging
void verify() PRODUCT_RETURN;
};
// Globally do instruction substitution and remove substituted
// instructions from the instruction list.
//
class SubstitutionResolver: public BlockClosure {
static void substitute(Value* v);
public:
hir->iterate_preorder(this);
}
block->iterate_preorder(this);
}
};