Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/prims/jniFastGetField.hpp
32285 views
/*1* Copyright (c) 2004, 2010, 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_VM_PRIMS_JNIFASTGETFIELD_HPP25#define SHARE_VM_PRIMS_JNIFASTGETFIELD_HPP2627#include "memory/allocation.hpp"28#include "prims/jvm_misc.hpp"2930// Basic logic of a fast version of jni_Get<Primitive>Field:31//32// (See safepoint.hpp for a description of _safepoint_counter)33//34// load _safepoint_counter into old_counter35// IF old_counter is odd THEN36// a safepoint is going on, return jni_GetXXXField37// ELSE38// load the primitive field value into result (speculatively)39// load _safepoint_counter into new_counter40// IF (old_counter == new_counter) THEN41// no safepoint happened during the field access, return result42// ELSE43// a safepoint might have happened in-between, return jni_GetXXXField()44// ENDIF45// ENDIF46//47// LoadLoad membars to maintain the load order may be necessary48// for some platforms.49//50// The fast versions don't check for pending suspension request.51// This is fine since it's totally read-only and doesn't create new race.52//53// There is a hypothetical safepoint counter wraparound. But it's not54// a practical concern.5556class JNI_FastGetField : AllStatic {57private:58enum { LIST_CAPACITY = 40 }; // a conservative number for the number of59// speculative loads on all the platforms60static address speculative_load_pclist [];61static address slowcase_entry_pclist [];62static int count;6364static address generate_fast_get_int_field0(BasicType type);65static address generate_fast_get_float_field0(BasicType type);6667public:68#if defined(_WINDOWS) && !defined(_WIN64)69static GetBooleanField_t jni_fast_GetBooleanField_fp;70static GetByteField_t jni_fast_GetByteField_fp;71static GetCharField_t jni_fast_GetCharField_fp;72static GetShortField_t jni_fast_GetShortField_fp;73static GetIntField_t jni_fast_GetIntField_fp;74static GetLongField_t jni_fast_GetLongField_fp;75static GetFloatField_t jni_fast_GetFloatField_fp;76static GetDoubleField_t jni_fast_GetDoubleField_fp;77#endif7879static address generate_fast_get_boolean_field();80static address generate_fast_get_byte_field();81static address generate_fast_get_char_field();82static address generate_fast_get_short_field();83static address generate_fast_get_int_field();84static address generate_fast_get_long_field();85static address generate_fast_get_float_field();86static address generate_fast_get_double_field();8788// If pc is in speculative_load_pclist, return the corresponding89// slow case entry pc. Otherwise, return -1.90// This is used by signal/exception handler to handle such case:91// After an even safepoint counter is loaded and a fast field access92// is about to begin, a GC kicks in and shrinks the heap. Then the93// field access may fault. The signal/exception handler needs to94// return to the slow case.95//96// The GC may decide to temporarily stuff some bad values into handles,97// for example, for debugging purpose, in which case we need the mapping also.98static address find_slowcase_pc(address pc);99};100101#endif // SHARE_VM_PRIMS_JNIFASTGETFIELD_HPP102103104