1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/c1/c1_LIRGenerator.hpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,634 @@ 1.4 +/* 1.5 + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef SHARE_VM_C1_C1_LIRGENERATOR_HPP 1.29 +#define SHARE_VM_C1_C1_LIRGENERATOR_HPP 1.30 + 1.31 +#include "c1/c1_Instruction.hpp" 1.32 +#include "c1/c1_LIR.hpp" 1.33 +#include "ci/ciMethodData.hpp" 1.34 +#include "utilities/sizes.hpp" 1.35 + 1.36 +// The classes responsible for code emission and register allocation 1.37 + 1.38 + 1.39 +class LIRGenerator; 1.40 +class LIREmitter; 1.41 +class Invoke; 1.42 +class SwitchRange; 1.43 +class LIRItem; 1.44 + 1.45 +define_array(LIRItemArray, LIRItem*) 1.46 +define_stack(LIRItemList, LIRItemArray) 1.47 + 1.48 +class SwitchRange: public CompilationResourceObj { 1.49 + private: 1.50 + int _low_key; 1.51 + int _high_key; 1.52 + BlockBegin* _sux; 1.53 + public: 1.54 + SwitchRange(int start_key, BlockBegin* sux): _low_key(start_key), _high_key(start_key), _sux(sux) {} 1.55 + void set_high_key(int key) { _high_key = key; } 1.56 + 1.57 + int high_key() const { return _high_key; } 1.58 + int low_key() const { return _low_key; } 1.59 + BlockBegin* sux() const { return _sux; } 1.60 +}; 1.61 + 1.62 +define_array(SwitchRangeArray, SwitchRange*) 1.63 +define_stack(SwitchRangeList, SwitchRangeArray) 1.64 + 1.65 + 1.66 +class ResolveNode; 1.67 + 1.68 +define_array(NodeArray, ResolveNode*); 1.69 +define_stack(NodeList, NodeArray); 1.70 + 1.71 + 1.72 +// Node objects form a directed graph of LIR_Opr 1.73 +// Edges between Nodes represent moves from one Node to its destinations 1.74 +class ResolveNode: public CompilationResourceObj { 1.75 + private: 1.76 + LIR_Opr _operand; // the source or destinaton 1.77 + NodeList _destinations; // for the operand 1.78 + bool _assigned; // Value assigned to this Node? 1.79 + bool _visited; // Node already visited? 1.80 + bool _start_node; // Start node already visited? 1.81 + 1.82 + public: 1.83 + ResolveNode(LIR_Opr operand) 1.84 + : _operand(operand) 1.85 + , _assigned(false) 1.86 + , _visited(false) 1.87 + , _start_node(false) {}; 1.88 + 1.89 + // accessors 1.90 + LIR_Opr operand() const { return _operand; } 1.91 + int no_of_destinations() const { return _destinations.length(); } 1.92 + ResolveNode* destination_at(int i) { return _destinations[i]; } 1.93 + bool assigned() const { return _assigned; } 1.94 + bool visited() const { return _visited; } 1.95 + bool start_node() const { return _start_node; } 1.96 + 1.97 + // modifiers 1.98 + void append(ResolveNode* dest) { _destinations.append(dest); } 1.99 + void set_assigned() { _assigned = true; } 1.100 + void set_visited() { _visited = true; } 1.101 + void set_start_node() { _start_node = true; } 1.102 +}; 1.103 + 1.104 + 1.105 +// This is shared state to be used by the PhiResolver so the operand 1.106 +// arrays don't have to be reallocated for reach resolution. 1.107 +class PhiResolverState: public CompilationResourceObj { 1.108 + friend class PhiResolver; 1.109 + 1.110 + private: 1.111 + NodeList _virtual_operands; // Nodes where the operand is a virtual register 1.112 + NodeList _other_operands; // Nodes where the operand is not a virtual register 1.113 + NodeList _vreg_table; // Mapping from virtual register to Node 1.114 + 1.115 + public: 1.116 + PhiResolverState() {} 1.117 + 1.118 + void reset(int max_vregs); 1.119 +}; 1.120 + 1.121 + 1.122 +// class used to move value of phi operand to phi function 1.123 +class PhiResolver: public CompilationResourceObj { 1.124 + private: 1.125 + LIRGenerator* _gen; 1.126 + PhiResolverState& _state; // temporary state cached by LIRGenerator 1.127 + 1.128 + ResolveNode* _loop; 1.129 + LIR_Opr _temp; 1.130 + 1.131 + // access to shared state arrays 1.132 + NodeList& virtual_operands() { return _state._virtual_operands; } 1.133 + NodeList& other_operands() { return _state._other_operands; } 1.134 + NodeList& vreg_table() { return _state._vreg_table; } 1.135 + 1.136 + ResolveNode* create_node(LIR_Opr opr, bool source); 1.137 + ResolveNode* source_node(LIR_Opr opr) { return create_node(opr, true); } 1.138 + ResolveNode* destination_node(LIR_Opr opr) { return create_node(opr, false); } 1.139 + 1.140 + void emit_move(LIR_Opr src, LIR_Opr dest); 1.141 + void move_to_temp(LIR_Opr src); 1.142 + void move_temp_to(LIR_Opr dest); 1.143 + void move(ResolveNode* src, ResolveNode* dest); 1.144 + 1.145 + LIRGenerator* gen() { 1.146 + return _gen; 1.147 + } 1.148 + 1.149 + public: 1.150 + PhiResolver(LIRGenerator* _lir_gen, int max_vregs); 1.151 + ~PhiResolver(); 1.152 + 1.153 + void move(LIR_Opr src, LIR_Opr dest); 1.154 +}; 1.155 + 1.156 + 1.157 +// only the classes below belong in the same file 1.158 +class LIRGenerator: public InstructionVisitor, public BlockClosure { 1.159 + 1.160 + private: 1.161 + Compilation* _compilation; 1.162 + ciMethod* _method; // method that we are compiling 1.163 + PhiResolverState _resolver_state; 1.164 + BlockBegin* _block; 1.165 + int _virtual_register_number; 1.166 + Values _instruction_for_operand; 1.167 + BitMap2D _vreg_flags; // flags which can be set on a per-vreg basis 1.168 + LIR_List* _lir; 1.169 + BarrierSet* _bs; 1.170 + 1.171 + LIRGenerator* gen() { 1.172 + return this; 1.173 + } 1.174 + 1.175 +#ifdef ASSERT 1.176 + LIR_List* lir(const char * file, int line) const { 1.177 + _lir->set_file_and_line(file, line); 1.178 + return _lir; 1.179 + } 1.180 +#endif 1.181 + LIR_List* lir() const { 1.182 + return _lir; 1.183 + } 1.184 + 1.185 + // a simple cache of constants used within a block 1.186 + GrowableArray<LIR_Const*> _constants; 1.187 + LIR_OprList _reg_for_constants; 1.188 + Values _unpinned_constants; 1.189 + 1.190 + friend class PhiResolver; 1.191 + 1.192 + // unified bailout support 1.193 + void bailout(const char* msg) const { compilation()->bailout(msg); } 1.194 + bool bailed_out() const { return compilation()->bailed_out(); } 1.195 + 1.196 + void block_do_prolog(BlockBegin* block); 1.197 + void block_do_epilog(BlockBegin* block); 1.198 + 1.199 + // register allocation 1.200 + LIR_Opr rlock(Value instr); // lock a free register 1.201 + LIR_Opr rlock_result(Value instr); 1.202 + LIR_Opr rlock_result(Value instr, BasicType type); 1.203 + LIR_Opr rlock_byte(BasicType type); 1.204 + LIR_Opr rlock_callee_saved(BasicType type); 1.205 + 1.206 + // get a constant into a register and get track of what register was used 1.207 + LIR_Opr load_constant(Constant* x); 1.208 + LIR_Opr load_constant(LIR_Const* constant); 1.209 + 1.210 + // Given an immediate value, return an operand usable in logical ops. 1.211 + LIR_Opr load_immediate(int x, BasicType type); 1.212 + 1.213 + void set_result(Value x, LIR_Opr opr) { 1.214 + assert(opr->is_valid(), "must set to valid value"); 1.215 + assert(x->operand()->is_illegal(), "operand should never change"); 1.216 + assert(!opr->is_register() || opr->is_virtual(), "should never set result to a physical register"); 1.217 + x->set_operand(opr); 1.218 + assert(opr == x->operand(), "must be"); 1.219 + if (opr->is_virtual()) { 1.220 + _instruction_for_operand.at_put_grow(opr->vreg_number(), x, NULL); 1.221 + } 1.222 + } 1.223 + void set_no_result(Value x) { assert(!x->has_uses(), "can't have use"); x->clear_operand(); } 1.224 + 1.225 + friend class LIRItem; 1.226 + 1.227 + LIR_Opr round_item(LIR_Opr opr); 1.228 + LIR_Opr force_to_spill(LIR_Opr value, BasicType t); 1.229 + 1.230 + PhiResolverState& resolver_state() { return _resolver_state; } 1.231 + 1.232 + void move_to_phi(PhiResolver* resolver, Value cur_val, Value sux_val); 1.233 + void move_to_phi(ValueStack* cur_state); 1.234 + 1.235 + // code emission 1.236 + void do_ArithmeticOp_Long (ArithmeticOp* x); 1.237 + void do_ArithmeticOp_Int (ArithmeticOp* x); 1.238 + void do_ArithmeticOp_FPU (ArithmeticOp* x); 1.239 + 1.240 + // platform dependent 1.241 + LIR_Opr getThreadPointer(); 1.242 + 1.243 + void do_RegisterFinalizer(Intrinsic* x); 1.244 + void do_isInstance(Intrinsic* x); 1.245 + void do_getClass(Intrinsic* x); 1.246 + void do_currentThread(Intrinsic* x); 1.247 + void do_MathIntrinsic(Intrinsic* x); 1.248 + void do_ArrayCopy(Intrinsic* x); 1.249 + void do_CompareAndSwap(Intrinsic* x, ValueType* type); 1.250 + void do_NIOCheckIndex(Intrinsic* x); 1.251 + void do_FPIntrinsics(Intrinsic* x); 1.252 + void do_Reference_get(Intrinsic* x); 1.253 + void do_update_CRC32(Intrinsic* x); 1.254 + 1.255 + void do_UnsafePrefetch(UnsafePrefetch* x, bool is_store); 1.256 + 1.257 + LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info); 1.258 + LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info); 1.259 + 1.260 + // convenience functions 1.261 + LIR_Opr call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info); 1.262 + LIR_Opr call_runtime(Value arg1, Value arg2, address entry, ValueType* result_type, CodeEmitInfo* info); 1.263 + 1.264 + // GC Barriers 1.265 + 1.266 + // generic interface 1.267 + 1.268 + void pre_barrier(LIR_Opr addr_opr, LIR_Opr pre_val, bool do_load, bool patch, CodeEmitInfo* info); 1.269 + void post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val); 1.270 + 1.271 + // specific implementations 1.272 + // pre barriers 1.273 + 1.274 + void G1SATBCardTableModRef_pre_barrier(LIR_Opr addr_opr, LIR_Opr pre_val, 1.275 + bool do_load, bool patch, CodeEmitInfo* info); 1.276 + 1.277 + // post barriers 1.278 + 1.279 + void G1SATBCardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val); 1.280 + void CardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val); 1.281 + 1.282 + 1.283 + static LIR_Opr result_register_for(ValueType* type, bool callee = false); 1.284 + 1.285 + ciObject* get_jobject_constant(Value value); 1.286 + 1.287 + LIRItemList* invoke_visit_arguments(Invoke* x); 1.288 + void invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list); 1.289 + 1.290 + void trace_block_entry(BlockBegin* block); 1.291 + 1.292 + // volatile field operations are never patchable because a klass 1.293 + // must be loaded to know it's volatile which means that the offset 1.294 + // it always known as well. 1.295 + void volatile_field_store(LIR_Opr value, LIR_Address* address, CodeEmitInfo* info); 1.296 + void volatile_field_load(LIR_Address* address, LIR_Opr result, CodeEmitInfo* info); 1.297 + 1.298 + void put_Object_unsafe(LIR_Opr src, LIR_Opr offset, LIR_Opr data, BasicType type, bool is_volatile); 1.299 + void get_Object_unsafe(LIR_Opr dest, LIR_Opr src, LIR_Opr offset, BasicType type, bool is_volatile); 1.300 + 1.301 + void arithmetic_call_op (Bytecodes::Code code, LIR_Opr result, LIR_OprList* args); 1.302 + 1.303 + void increment_counter(address counter, BasicType type, int step = 1); 1.304 + void increment_counter(LIR_Address* addr, int step = 1); 1.305 + 1.306 + // is_strictfp is only needed for mul and div (and only generates different code on i486) 1.307 + void arithmetic_op(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp, CodeEmitInfo* info = NULL); 1.308 + // machine dependent. returns true if it emitted code for the multiply 1.309 + bool strength_reduce_multiply(LIR_Opr left, int constant, LIR_Opr result, LIR_Opr tmp); 1.310 + 1.311 + void store_stack_parameter (LIR_Opr opr, ByteSize offset_from_sp_in_bytes); 1.312 + 1.313 + void klass2reg_with_patching(LIR_Opr r, ciMetadata* obj, CodeEmitInfo* info); 1.314 + 1.315 + // this loads the length and compares against the index 1.316 + void array_range_check (LIR_Opr array, LIR_Opr index, CodeEmitInfo* null_check_info, CodeEmitInfo* range_check_info); 1.317 + // For java.nio.Buffer.checkIndex 1.318 + void nio_range_check (LIR_Opr buffer, LIR_Opr index, LIR_Opr result, CodeEmitInfo* info); 1.319 + 1.320 + void arithmetic_op_int (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr tmp); 1.321 + void arithmetic_op_long (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, CodeEmitInfo* info = NULL); 1.322 + void arithmetic_op_fpu (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp = LIR_OprFact::illegalOpr); 1.323 + 1.324 + void shift_op (Bytecodes::Code code, LIR_Opr dst_reg, LIR_Opr value, LIR_Opr count, LIR_Opr tmp); 1.325 + 1.326 + void logic_op (Bytecodes::Code code, LIR_Opr dst_reg, LIR_Opr left, LIR_Opr right); 1.327 + 1.328 + void monitor_enter (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no, CodeEmitInfo* info_for_exception, CodeEmitInfo* info); 1.329 + void monitor_exit (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no); 1.330 + 1.331 + void new_instance (LIR_Opr dst, ciInstanceKlass* klass, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr klass_reg, CodeEmitInfo* info); 1.332 + 1.333 + // machine dependent 1.334 + void cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info); 1.335 + void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, int disp, BasicType type, CodeEmitInfo* info); 1.336 + void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, LIR_Opr disp, BasicType type, CodeEmitInfo* info); 1.337 + 1.338 + void arraycopy_helper(Intrinsic* x, int* flags, ciArrayKlass** expected_type); 1.339 + 1.340 + // returns a LIR_Address to address an array location. May also 1.341 + // emit some code as part of address calculation. If 1.342 + // needs_card_mark is true then compute the full address for use by 1.343 + // both the store and the card mark. 1.344 + LIR_Address* generate_address(LIR_Opr base, 1.345 + LIR_Opr index, int shift, 1.346 + int disp, 1.347 + BasicType type); 1.348 + LIR_Address* generate_address(LIR_Opr base, int disp, BasicType type) { 1.349 + return generate_address(base, LIR_OprFact::illegalOpr, 0, disp, type); 1.350 + } 1.351 + LIR_Address* emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr, BasicType type, bool needs_card_mark); 1.352 + 1.353 + // the helper for generate_address 1.354 + void add_large_constant(LIR_Opr src, int c, LIR_Opr dest); 1.355 + 1.356 + // machine preferences and characteristics 1.357 + bool can_inline_as_constant(Value i) const; 1.358 + bool can_inline_as_constant(LIR_Const* c) const; 1.359 + bool can_store_as_constant(Value i, BasicType type) const; 1.360 + 1.361 + LIR_Opr safepoint_poll_register(); 1.362 + 1.363 + void profile_branch(If* if_instr, If::Condition cond); 1.364 + void increment_event_counter_impl(CodeEmitInfo* info, 1.365 + ciMethod *method, int frequency, 1.366 + int bci, bool backedge, bool notify); 1.367 + void increment_event_counter(CodeEmitInfo* info, int bci, bool backedge); 1.368 + void increment_invocation_counter(CodeEmitInfo *info) { 1.369 + if (compilation()->count_invocations()) { 1.370 + increment_event_counter(info, InvocationEntryBci, false); 1.371 + } 1.372 + } 1.373 + void increment_backedge_counter(CodeEmitInfo* info, int bci) { 1.374 + if (compilation()->count_backedges()) { 1.375 + increment_event_counter(info, bci, true); 1.376 + } 1.377 + } 1.378 + 1.379 + CodeEmitInfo* state_for(Instruction* x, ValueStack* state, bool ignore_xhandler = false); 1.380 + CodeEmitInfo* state_for(Instruction* x); 1.381 + 1.382 + // allocates a virtual register for this instruction if 1.383 + // one isn't already allocated. Only for Phi and Local. 1.384 + LIR_Opr operand_for_instruction(Instruction *x); 1.385 + 1.386 + void set_block(BlockBegin* block) { _block = block; } 1.387 + 1.388 + void block_prolog(BlockBegin* block); 1.389 + void block_epilog(BlockBegin* block); 1.390 + 1.391 + void do_root (Instruction* instr); 1.392 + void walk (Instruction* instr); 1.393 + 1.394 + void bind_block_entry(BlockBegin* block); 1.395 + void start_block(BlockBegin* block); 1.396 + 1.397 + LIR_Opr new_register(BasicType type); 1.398 + LIR_Opr new_register(Value value) { return new_register(as_BasicType(value->type())); } 1.399 + LIR_Opr new_register(ValueType* type) { return new_register(as_BasicType(type)); } 1.400 + 1.401 + // returns a register suitable for doing pointer math 1.402 + LIR_Opr new_pointer_register() { 1.403 +#ifdef _LP64 1.404 + return new_register(T_LONG); 1.405 +#else 1.406 + return new_register(T_INT); 1.407 +#endif 1.408 + } 1.409 + 1.410 + static LIR_Condition lir_cond(If::Condition cond) { 1.411 + LIR_Condition l; 1.412 + switch (cond) { 1.413 + case If::eql: l = lir_cond_equal; break; 1.414 + case If::neq: l = lir_cond_notEqual; break; 1.415 + case If::lss: l = lir_cond_less; break; 1.416 + case If::leq: l = lir_cond_lessEqual; break; 1.417 + case If::geq: l = lir_cond_greaterEqual; break; 1.418 + case If::gtr: l = lir_cond_greater; break; 1.419 + case If::aeq: l = lir_cond_aboveEqual; break; 1.420 + case If::beq: l = lir_cond_belowEqual; break; 1.421 + }; 1.422 + return l; 1.423 + } 1.424 + 1.425 +#ifdef __SOFTFP__ 1.426 + void do_soft_float_compare(If *x); 1.427 +#endif // __SOFTFP__ 1.428 + 1.429 + void init(); 1.430 + 1.431 + SwitchRangeArray* create_lookup_ranges(TableSwitch* x); 1.432 + SwitchRangeArray* create_lookup_ranges(LookupSwitch* x); 1.433 + void do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux); 1.434 + 1.435 + void do_RuntimeCall(address routine, int expected_arguments, Intrinsic* x); 1.436 +#ifdef TRACE_HAVE_INTRINSICS 1.437 + void do_ThreadIDIntrinsic(Intrinsic* x); 1.438 + void do_ClassIDIntrinsic(Intrinsic* x); 1.439 +#endif 1.440 + ciKlass* profile_type(ciMethodData* md, int md_first_offset, int md_offset, intptr_t profiled_k, 1.441 + Value arg, LIR_Opr& mdp, bool not_null, ciKlass* signature_at_call_k, 1.442 + ciKlass* callee_signature_k); 1.443 + void profile_arguments(ProfileCall* x); 1.444 + void profile_parameters(Base* x); 1.445 + void profile_parameters_at_call(ProfileCall* x); 1.446 + 1.447 + public: 1.448 + Compilation* compilation() const { return _compilation; } 1.449 + FrameMap* frame_map() const { return _compilation->frame_map(); } 1.450 + ciMethod* method() const { return _method; } 1.451 + BlockBegin* block() const { return _block; } 1.452 + IRScope* scope() const { return block()->scope(); } 1.453 + 1.454 + int max_virtual_register_number() const { return _virtual_register_number; } 1.455 + 1.456 + void block_do(BlockBegin* block); 1.457 + 1.458 + // Flags that can be set on vregs 1.459 + enum VregFlag { 1.460 + must_start_in_memory = 0 // needs to be assigned a memory location at beginning, but may then be loaded in a register 1.461 + , callee_saved = 1 // must be in a callee saved register 1.462 + , byte_reg = 2 // must be in a byte register 1.463 + , num_vreg_flags 1.464 + 1.465 + }; 1.466 + 1.467 + LIRGenerator(Compilation* compilation, ciMethod* method) 1.468 + : _compilation(compilation) 1.469 + , _method(method) 1.470 + , _virtual_register_number(LIR_OprDesc::vreg_base) 1.471 + , _vreg_flags(NULL, 0, num_vreg_flags) { 1.472 + init(); 1.473 + } 1.474 + 1.475 + // for virtual registers, maps them back to Phi's or Local's 1.476 + Instruction* instruction_for_opr(LIR_Opr opr); 1.477 + Instruction* instruction_for_vreg(int reg_num); 1.478 + 1.479 + void set_vreg_flag (int vreg_num, VregFlag f); 1.480 + bool is_vreg_flag_set(int vreg_num, VregFlag f); 1.481 + void set_vreg_flag (LIR_Opr opr, VregFlag f) { set_vreg_flag(opr->vreg_number(), f); } 1.482 + bool is_vreg_flag_set(LIR_Opr opr, VregFlag f) { return is_vreg_flag_set(opr->vreg_number(), f); } 1.483 + 1.484 + // statics 1.485 + static LIR_Opr exceptionOopOpr(); 1.486 + static LIR_Opr exceptionPcOpr(); 1.487 + static LIR_Opr divInOpr(); 1.488 + static LIR_Opr divOutOpr(); 1.489 + static LIR_Opr remOutOpr(); 1.490 + static LIR_Opr shiftCountOpr(); 1.491 + LIR_Opr syncTempOpr(); 1.492 + LIR_Opr atomicLockOpr(); 1.493 + 1.494 + // returns a register suitable for saving the thread in a 1.495 + // call_runtime_leaf if one is needed. 1.496 + LIR_Opr getThreadTemp(); 1.497 + 1.498 + // visitor functionality 1.499 + virtual void do_Phi (Phi* x); 1.500 + virtual void do_Local (Local* x); 1.501 + virtual void do_Constant (Constant* x); 1.502 + virtual void do_LoadField (LoadField* x); 1.503 + virtual void do_StoreField (StoreField* x); 1.504 + virtual void do_ArrayLength (ArrayLength* x); 1.505 + virtual void do_LoadIndexed (LoadIndexed* x); 1.506 + virtual void do_StoreIndexed (StoreIndexed* x); 1.507 + virtual void do_NegateOp (NegateOp* x); 1.508 + virtual void do_ArithmeticOp (ArithmeticOp* x); 1.509 + virtual void do_ShiftOp (ShiftOp* x); 1.510 + virtual void do_LogicOp (LogicOp* x); 1.511 + virtual void do_CompareOp (CompareOp* x); 1.512 + virtual void do_IfOp (IfOp* x); 1.513 + virtual void do_Convert (Convert* x); 1.514 + virtual void do_NullCheck (NullCheck* x); 1.515 + virtual void do_TypeCast (TypeCast* x); 1.516 + virtual void do_Invoke (Invoke* x); 1.517 + virtual void do_NewInstance (NewInstance* x); 1.518 + virtual void do_NewTypeArray (NewTypeArray* x); 1.519 + virtual void do_NewObjectArray (NewObjectArray* x); 1.520 + virtual void do_NewMultiArray (NewMultiArray* x); 1.521 + virtual void do_CheckCast (CheckCast* x); 1.522 + virtual void do_InstanceOf (InstanceOf* x); 1.523 + virtual void do_MonitorEnter (MonitorEnter* x); 1.524 + virtual void do_MonitorExit (MonitorExit* x); 1.525 + virtual void do_Intrinsic (Intrinsic* x); 1.526 + virtual void do_BlockBegin (BlockBegin* x); 1.527 + virtual void do_Goto (Goto* x); 1.528 + virtual void do_If (If* x); 1.529 + virtual void do_IfInstanceOf (IfInstanceOf* x); 1.530 + virtual void do_TableSwitch (TableSwitch* x); 1.531 + virtual void do_LookupSwitch (LookupSwitch* x); 1.532 + virtual void do_Return (Return* x); 1.533 + virtual void do_Throw (Throw* x); 1.534 + virtual void do_Base (Base* x); 1.535 + virtual void do_OsrEntry (OsrEntry* x); 1.536 + virtual void do_ExceptionObject(ExceptionObject* x); 1.537 + virtual void do_RoundFP (RoundFP* x); 1.538 + virtual void do_UnsafeGetRaw (UnsafeGetRaw* x); 1.539 + virtual void do_UnsafePutRaw (UnsafePutRaw* x); 1.540 + virtual void do_UnsafeGetObject(UnsafeGetObject* x); 1.541 + virtual void do_UnsafePutObject(UnsafePutObject* x); 1.542 + virtual void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x); 1.543 + virtual void do_UnsafePrefetchRead (UnsafePrefetchRead* x); 1.544 + virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x); 1.545 + virtual void do_ProfileCall (ProfileCall* x); 1.546 + virtual void do_ProfileReturnType (ProfileReturnType* x); 1.547 + virtual void do_ProfileInvoke (ProfileInvoke* x); 1.548 + virtual void do_RuntimeCall (RuntimeCall* x); 1.549 + virtual void do_MemBar (MemBar* x); 1.550 + virtual void do_RangeCheckPredicate(RangeCheckPredicate* x); 1.551 +#ifdef ASSERT 1.552 + virtual void do_Assert (Assert* x); 1.553 +#endif 1.554 +}; 1.555 + 1.556 + 1.557 +class LIRItem: public CompilationResourceObj { 1.558 + private: 1.559 + Value _value; 1.560 + LIRGenerator* _gen; 1.561 + LIR_Opr _result; 1.562 + bool _destroys_register; 1.563 + LIR_Opr _new_result; 1.564 + 1.565 + LIRGenerator* gen() const { return _gen; } 1.566 + 1.567 + public: 1.568 + LIRItem(Value value, LIRGenerator* gen) { 1.569 + _destroys_register = false; 1.570 + _gen = gen; 1.571 + set_instruction(value); 1.572 + } 1.573 + 1.574 + LIRItem(LIRGenerator* gen) { 1.575 + _destroys_register = false; 1.576 + _gen = gen; 1.577 + _result = LIR_OprFact::illegalOpr; 1.578 + set_instruction(NULL); 1.579 + } 1.580 + 1.581 + void set_instruction(Value value) { 1.582 + _value = value; 1.583 + _result = LIR_OprFact::illegalOpr; 1.584 + if (_value != NULL) { 1.585 + _gen->walk(_value); 1.586 + _result = _value->operand(); 1.587 + } 1.588 + _new_result = LIR_OprFact::illegalOpr; 1.589 + } 1.590 + 1.591 + Value value() const { return _value; } 1.592 + ValueType* type() const { return value()->type(); } 1.593 + LIR_Opr result() { 1.594 + assert(!_destroys_register || (!_result->is_register() || _result->is_virtual()), 1.595 + "shouldn't use set_destroys_register with physical regsiters"); 1.596 + if (_destroys_register && _result->is_register()) { 1.597 + if (_new_result->is_illegal()) { 1.598 + _new_result = _gen->new_register(type()); 1.599 + gen()->lir()->move(_result, _new_result); 1.600 + } 1.601 + return _new_result; 1.602 + } else { 1.603 + return _result; 1.604 + } 1.605 + return _result; 1.606 + } 1.607 + 1.608 + void set_result(LIR_Opr opr); 1.609 + 1.610 + void load_item(); 1.611 + void load_byte_item(); 1.612 + void load_nonconstant(); 1.613 + // load any values which can't be expressed as part of a single store instruction 1.614 + void load_for_store(BasicType store_type); 1.615 + void load_item_force(LIR_Opr reg); 1.616 + 1.617 + void dont_load_item() { 1.618 + // do nothing 1.619 + } 1.620 + 1.621 + void set_destroys_register() { 1.622 + _destroys_register = true; 1.623 + } 1.624 + 1.625 + bool is_constant() const { return value()->as_Constant() != NULL; } 1.626 + bool is_stack() { return result()->is_stack(); } 1.627 + bool is_register() { return result()->is_register(); } 1.628 + 1.629 + ciObject* get_jobject_constant() const; 1.630 + jint get_jint_constant() const; 1.631 + jlong get_jlong_constant() const; 1.632 + jfloat get_jfloat_constant() const; 1.633 + jdouble get_jdouble_constant() const; 1.634 + jint get_address_constant() const; 1.635 +}; 1.636 + 1.637 +#endif // SHARE_VM_C1_C1_LIRGENERATOR_HPP