Path: blob/master/src/hotspot/share/oops/cpCache.inline.hpp
40951 views
/*1* Copyright (c) 2018, 2020, 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_OOPS_CPCACHE_INLINE_HPP25#define SHARE_OOPS_CPCACHE_INLINE_HPP2627#include "oops/cpCache.hpp"2829#include "oops/oopHandle.inline.hpp"30#include "runtime/atomic.hpp"3132inline int ConstantPoolCacheEntry::indices_ord() const { return Atomic::load_acquire(&_indices); }3334inline Bytecodes::Code ConstantPoolCacheEntry::bytecode_1() const {35return Bytecodes::cast((indices_ord() >> bytecode_1_shift) & bytecode_1_mask);36}3738inline Bytecodes::Code ConstantPoolCacheEntry::bytecode_2() const {39return Bytecodes::cast((indices_ord() >> bytecode_2_shift) & bytecode_2_mask);40}4142// Has this bytecode been resolved? Only valid for invokes and get/put field/static.43inline bool ConstantPoolCacheEntry::is_resolved(Bytecodes::Code code) const {44switch (bytecode_number(code)) {45case 1: return (bytecode_1() == code);46case 2: return (bytecode_2() == code);47}48return false; // default: not resolved49}5051inline Method* ConstantPoolCacheEntry::f2_as_interface_method() const {52assert(bytecode_1() == Bytecodes::_invokeinterface, "");53return (Method*)_f2;54}5556inline Metadata* ConstantPoolCacheEntry::f1_ord() const { return (Metadata *)Atomic::load_acquire(&_f1); }5758inline Method* ConstantPoolCacheEntry::f1_as_method() const {59Metadata* f1 = f1_ord(); assert(f1 == NULL || f1->is_method(), "");60return (Method*)f1;61}6263inline Klass* ConstantPoolCacheEntry::f1_as_klass() const {64Metadata* f1 = f1_ord(); assert(f1 == NULL || f1->is_klass(), "");65return (Klass*)f1;66}6768inline bool ConstantPoolCacheEntry::is_f1_null() const { Metadata* f1 = f1_ord(); return f1 == NULL; }6970inline bool ConstantPoolCacheEntry::has_appendix() const {71return (!is_f1_null()) && (_flags & (1 << has_appendix_shift)) != 0;72}7374inline bool ConstantPoolCacheEntry::has_local_signature() const {75return (!is_f1_null()) && (_flags & (1 << has_local_signature_shift)) != 0;76}7778inline intx ConstantPoolCacheEntry::flags_ord() const { return (intx)Atomic::load_acquire(&_flags); }7980inline bool ConstantPoolCacheEntry::indy_resolution_failed() const {81intx flags = flags_ord();82return (flags & (1 << indy_resolution_failed_shift)) != 0;83}8485// Constructor86inline ConstantPoolCache::ConstantPoolCache(int length,87const intStack& inverse_index_map,88const intStack& invokedynamic_inverse_index_map,89const intStack& invokedynamic_references_map) :90_length(length),91_constant_pool(NULL) {92CDS_JAVA_HEAP_ONLY(_archived_references_index = -1;)93initialize(inverse_index_map, invokedynamic_inverse_index_map,94invokedynamic_references_map);95for (int i = 0; i < length; i++) {96assert(entry_at(i)->is_f1_null(), "Failed to clear?");97}98}99100inline oop ConstantPoolCache::resolved_references() { return _resolved_references.resolve(); }101102#endif // SHARE_OOPS_CPCACHE_INLINE_HPP103104105