/* * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
class GraphBuilder { friendclass JfrResolution; private: // Per-scope data. These are pushed and popped as we descend into // inlined methods. Currently in order to generate good code in the // inliner we have to attempt to inline methods directly into the // basic block we are parsing; this adds complexity. class ScopeData: public CompilationResourceObj { private:
ScopeData* _parent; // bci-to-block mapping
BlockList* _bci2block; // Scope
IRScope* _scope; // Whether this scope or any parent scope has exception handlers bool _has_handler; // The bytecodes
ciBytecodeStream* _stream;
// Work list
BlockList* _work_list;
// Maximum inline size for this scope
intx _max_inline_size; // Expression stack depth at point where inline occurred int _caller_stack_size;
// The continuation point for the inline. Currently only used in // multi-block inlines, but eventually would like to use this for // all inlines for uniformity and simplicity; in this case would // get the continuation point from the BlockList instead of // fabricating it anew because Invokes would be considered to be // BlockEnds.
BlockBegin* _continuation;
// Was this ScopeData created only for the parsing and inlining of // a jsr? bool _parsing_jsr; // We track the destination bci of the jsr only to determine // bailout conditions, since we only handle a subset of all of the // possible jsr-ret control structures. Recursive invocations of a // jsr are disallowed by the verifier. int _jsr_entry_bci; // We need to track the local variable in which the return address // was stored to ensure we can handle inlining the jsr, because we // don't handle arbitrary jsr/ret constructs. int _jsr_ret_addr_local; // If we are parsing a jsr, the continuation point for rets
BlockBegin* _jsr_continuation; // Cloned XHandlers for jsr-related ScopeDatas
XHandlers* _jsr_xhandlers;
// Number of returns seen in this scope int _num_returns;
// In order to generate profitable code for inlining, we currently // have to perform an optimization for single-block inlined // methods where we continue parsing into the same block. This // allows us to perform CSE across inlined scopes and to avoid // storing parameters to the stack. Having a global register // allocator and being able to perform global CSE would allow this // code to be removed and thereby simplify the inliner.
BlockBegin* _cleanup_block; // The block to which the return was added
Instruction* _cleanup_return_prev; // Instruction before return instruction
ValueStack* _cleanup_state; // State of that block (not yet pinned)
// When inlining do not push the result on the stack bool _ignore_return;
// NOTE: this has a different effect when parsing jsrs
BlockBegin* block_at(int bci);
IRScope* scope() const { return _scope; } // Has side-effect of setting has_handler flag void set_scope(IRScope* scope);
// Whether this or any parent scope has exception handlers bool has_handler() const { return _has_handler; } void set_has_handler() { _has_handler = true; }
// Exception handlers list to be used for this scope
XHandlers* xhandlers() const;
// How to get a block to be parsed void add_to_work_list(BlockBegin* block); // How to remove the next block to be parsed; returns NULL if none left
BlockBegin* remove_from_work_list(); // Indicates parse is over bool is_work_list_empty() const;
// Indicates whether this ScopeData was pushed only for the // parsing and inlining of a jsr bool parsing_jsr() const { return _parsing_jsr; } void set_parsing_jsr() { _parsing_jsr = true; } int jsr_entry_bci() const { return _jsr_entry_bci; } void set_jsr_entry_bci(int bci) { _jsr_entry_bci = bci; } void set_jsr_return_address_local(int local_no){ _jsr_ret_addr_local = local_no; } int jsr_return_address_local() const { return _jsr_ret_addr_local; } // Must be called after scope is set up for jsr ScopeData void setup_jsr_xhandlers();
// The jsr continuation is only used when parsing_jsr is true, and // is different from the "normal" continuation since we can end up // doing a return (rather than a ret) from within a subroutine
BlockBegin* jsr_continuation() const { return _jsr_continuation; } void set_jsr_continuation(BlockBegin* cont) { _jsr_continuation = cont; }
// for all GraphBuilders staticbool _can_trap[Bytecodes::number_of_java_codes];
// for each instance of GraphBuilder
ScopeData* _scope_data; // Per-scope data; used for inlining
Compilation* _compilation; // the current compilation
ValueMap* _vmap; // the map of values encountered (for CSE)
MemoryBuffer* _memory; constchar* _inline_bailout_msg; // non-null if most recent inline attempt failed int _instruction_count; // for bailing out in pathological jsr/ret cases
BlockBegin* _start; // the start block
BlockBegin* _osr_entry; // the osr entry block block
ValueStack* _initial_state; // The state for the start block
// for each call to connect_to_end; can also be set by inliner
BlockBegin* _block; // the current block
ValueStack* _state; // the current execution state
Instruction* _last; // the last instruction added bool _skip_block; // skip processing of the rest of this block
// use of state copy routines (try to minimize unnecessary state // object allocations):
// - if the instruction unconditionally needs a full copy of the // state (for patching for example), then use copy_state_before*
// - if the instruction needs a full copy of the state only for // handler generation (Instruction::needs_exception_state() returns // false) then use copy_state_exhandling*
// - if the instruction needs either a full copy of the state for // handler generation and a least a minimal copy of the state (as // returned by Instruction::exception_state()) for debug info // generation (that is when Instruction::needs_exception_state() // returns true) then use copy_state_for_exception*
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.