aoqi@0: /* aoqi@0: * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #ifndef SHARE_VM_OPTO_MACRO_HPP aoqi@0: #define SHARE_VM_OPTO_MACRO_HPP aoqi@0: aoqi@0: #include "opto/phase.hpp" aoqi@0: aoqi@0: class AllocateNode; aoqi@0: class AllocateArrayNode; aoqi@0: class CallNode; aoqi@0: class Node; aoqi@0: class PhaseIterGVN; aoqi@0: aoqi@0: class PhaseMacroExpand : public Phase { aoqi@0: private: aoqi@0: PhaseIterGVN &_igvn; aoqi@0: aoqi@0: // Helper methods roughly modelled after GraphKit: aoqi@0: Node* top() const { return C->top(); } aoqi@0: Node* intcon(jint con) const { return _igvn.intcon(con); } aoqi@0: Node* longcon(jlong con) const { return _igvn.longcon(con); } aoqi@0: Node* makecon(const Type *t) const { return _igvn.makecon(t); } aoqi@0: Node* basic_plus_adr(Node* base, int offset) { aoqi@0: return (offset == 0)? base: basic_plus_adr(base, MakeConX(offset)); aoqi@0: } aoqi@0: Node* basic_plus_adr(Node* base, Node* ptr, int offset) { aoqi@0: return (offset == 0)? ptr: basic_plus_adr(base, ptr, MakeConX(offset)); aoqi@0: } aoqi@0: Node* basic_plus_adr(Node* base, Node* offset) { aoqi@0: return basic_plus_adr(base, base, offset); aoqi@0: } aoqi@0: Node* basic_plus_adr(Node* base, Node* ptr, Node* offset) { aoqi@0: Node* adr = new (C) AddPNode(base, ptr, offset); aoqi@0: return transform_later(adr); aoqi@0: } aoqi@0: Node* transform_later(Node* n) { aoqi@0: // equivalent to _gvn.transform in GraphKit, Ideal, etc. aoqi@0: _igvn.register_new_node_with_optimizer(n); aoqi@0: return n; aoqi@0: } aoqi@0: void set_eden_pointers(Node* &eden_top_adr, Node* &eden_end_adr); aoqi@0: Node* make_load( Node* ctl, Node* mem, Node* base, int offset, aoqi@0: const Type* value_type, BasicType bt); aoqi@0: Node* make_store(Node* ctl, Node* mem, Node* base, int offset, aoqi@0: Node* value, BasicType bt); aoqi@0: aoqi@0: // projections extracted from a call node aoqi@0: ProjNode *_fallthroughproj; aoqi@0: ProjNode *_fallthroughcatchproj; aoqi@0: ProjNode *_ioproj_fallthrough; aoqi@0: ProjNode *_ioproj_catchall; aoqi@0: ProjNode *_catchallcatchproj; aoqi@0: ProjNode *_memproj_fallthrough; aoqi@0: ProjNode *_memproj_catchall; aoqi@0: ProjNode *_resproj; aoqi@0: aoqi@0: // Additional data collected during macro expansion aoqi@0: bool _has_locks; aoqi@0: aoqi@0: void expand_allocate(AllocateNode *alloc); aoqi@0: void expand_allocate_array(AllocateArrayNode *alloc); aoqi@0: void expand_allocate_common(AllocateNode* alloc, aoqi@0: Node* length, aoqi@0: const TypeFunc* slow_call_type, aoqi@0: address slow_call_address); aoqi@0: Node *value_from_mem(Node *mem, BasicType ft, const Type *ftype, const TypeOopPtr *adr_t, Node *alloc); aoqi@0: Node *value_from_mem_phi(Node *mem, BasicType ft, const Type *ftype, const TypeOopPtr *adr_t, Node *alloc, Node_Stack *value_phis, int level); aoqi@0: aoqi@0: bool eliminate_boxing_node(CallStaticJavaNode *boxing); aoqi@0: bool eliminate_allocate_node(AllocateNode *alloc); aoqi@0: bool can_eliminate_allocation(AllocateNode *alloc, GrowableArray & safepoints); aoqi@0: bool scalar_replacement(AllocateNode *alloc, GrowableArray & safepoints_done); aoqi@0: void process_users_of_allocation(CallNode *alloc); aoqi@0: aoqi@0: void eliminate_card_mark(Node *cm); aoqi@0: void mark_eliminated_box(Node* box, Node* obj); aoqi@0: void mark_eliminated_locking_nodes(AbstractLockNode *alock); aoqi@0: bool eliminate_locking_node(AbstractLockNode *alock); aoqi@0: void expand_lock_node(LockNode *lock); aoqi@0: void expand_unlock_node(UnlockNode *unlock); aoqi@0: aoqi@0: int replace_input(Node *use, Node *oldref, Node *newref); aoqi@0: void copy_call_debug_info(CallNode *oldcall, CallNode * newcall); aoqi@0: Node* opt_bits_test(Node* ctrl, Node* region, int edge, Node* word, int mask, int bits, bool return_fast_path = false); aoqi@0: void copy_predefined_input_for_runtime_call(Node * ctrl, CallNode* oldcall, CallNode* call); aoqi@0: CallNode* make_slow_call(CallNode *oldcall, const TypeFunc* slow_call_type, address slow_call, aoqi@0: const char* leaf_name, Node* slow_path, Node* parm0, Node* parm1); aoqi@0: void extract_call_projections(CallNode *call); aoqi@0: aoqi@0: Node* initialize_object(AllocateNode* alloc, aoqi@0: Node* control, Node* rawmem, Node* object, aoqi@0: Node* klass_node, Node* length, aoqi@0: Node* size_in_bytes); aoqi@0: aoqi@0: Node* prefetch_allocation(Node* i_o, aoqi@0: Node*& needgc_false, Node*& contended_phi_rawmem, aoqi@0: Node* old_eden_top, Node* new_eden_top, aoqi@0: Node* length); aoqi@0: aoqi@0: public: aoqi@0: PhaseMacroExpand(PhaseIterGVN &igvn) : Phase(Macro_Expand), _igvn(igvn), _has_locks(false) { aoqi@0: _igvn.set_delay_transform(true); aoqi@0: } aoqi@0: void eliminate_macro_nodes(); aoqi@0: bool expand_macro_nodes(); aoqi@0: aoqi@0: }; aoqi@0: aoqi@0: #endif // SHARE_VM_OPTO_MACRO_HPP