Path: blob/master/src/hotspot/share/interpreter/bootstrapInfo.hpp
40949 views
/*1* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_INTERPRETER_BOOTSTRAPINFO_HPP25#define SHARE_INTERPRETER_BOOTSTRAPINFO_HPP2627#include "oops/constantPool.hpp"28#include "oops/instanceKlass.hpp"2930// BootstrapInfo provides condensed information from the constant pool31// necessary to invoke a bootstrap method.32class BootstrapInfo : public StackObj {33constantPoolHandle _pool; // constant pool containing the bootstrap specifier34const int _bss_index; // index of bootstrap specifier in CP (condy or indy)35const int _indy_index; // internal index of indy call site, or -1 if a condy call36const int _argc; // number of static arguments37Symbol* _name; // extracted from JVM_CONSTANT_NameAndType38Symbol* _signature;3940// pre-bootstrap resolution state:41Handle _bsm; // resolved bootstrap method42Handle _name_arg; // resolved String43Handle _type_arg; // resolved Class or MethodType44Handle _arg_values; // array of static arguments; null implies either45// uresolved or zero static arguments are specified4647// post-bootstrap resolution state:48bool _is_resolved; // set true when any of the next fields are set49Handle _resolved_value; // bind this as condy constant50methodHandle _resolved_method; // bind this as indy behavior51Handle _resolved_appendix; // extra opaque static argument for _resolved_method5253public:54BootstrapInfo(const constantPoolHandle& pool, int bss_index, int indy_index = -1);5556// accessors57const constantPoolHandle& pool() const{ return _pool; }58int bss_index() const { return _bss_index; }59int indy_index() const { return _indy_index; }60int argc() const { return _argc; }61bool is_method_call() const { return (_indy_index != -1); }62Symbol* name() const { return _name; }63Symbol* signature() const { return _signature; }6465// accessors to lazy state66Handle bsm() const { return _bsm; }67Handle name_arg() const { return _name_arg; }68Handle type_arg() const { return _type_arg; }69Handle arg_values() const { return _arg_values; }70bool is_resolved() const { return _is_resolved; }71Handle resolved_value() const { assert(!is_method_call(), ""); return _resolved_value; }72methodHandle resolved_method() const { assert(is_method_call(), ""); return _resolved_method; }73Handle resolved_appendix() const { assert(is_method_call(), ""); return _resolved_appendix; }7475// derived accessors76InstanceKlass* caller() const { return _pool->pool_holder(); }77oop caller_mirror() const { return caller()->java_mirror(); }78int decode_indy_index() const { return ConstantPool::decode_invokedynamic_index(_indy_index); }79int bsms_attr_index() const { return _pool->bootstrap_methods_attribute_index(_bss_index); }80int bsm_index() const { return _pool->bootstrap_method_ref_index_at(_bss_index); }81//int argc() is eagerly cached in _argc82int arg_index(int i) const { return _pool->bootstrap_argument_index_at(_bss_index, i); }8384// CP cache entry for call site (indy only)85ConstantPoolCacheEntry* invokedynamic_cp_cache_entry() const {86assert(is_method_call(), "");87return _pool->invokedynamic_cp_cache_entry_at(_indy_index);88}8990// If there is evidence this call site was already linked, set the91// existing linkage data into result, or throw previous exception.92// Return true if either action is taken, else false.93bool resolve_previously_linked_invokedynamic(CallInfo& result, TRAPS);94bool save_and_throw_indy_exc(TRAPS);95void resolve_newly_linked_invokedynamic(CallInfo& result, TRAPS);9697// pre-bootstrap resolution actions:98Handle resolve_bsm(TRAPS); // lazily compute _bsm and return it99void resolve_bss_name_and_type(TRAPS); // lazily compute _name/_type100void resolve_args(TRAPS); // compute arguments101102// setters for post-bootstrap results:103void set_resolved_value(Handle value) {104assert(!is_resolved() && !is_method_call(), "");105_is_resolved = true;106_resolved_value = value;107}108void set_resolved_method(methodHandle method, Handle appendix) {109assert(!is_resolved() && is_method_call(), "");110_is_resolved = true;111_resolved_method = method;112_resolved_appendix = appendix;113}114115void print() { print_msg_on(tty); }116void print_msg_on(outputStream* st, const char* msg = NULL);117};118119#endif // SHARE_INTERPRETER_BOOTSTRAPINFO_HPP120121122