src/share/vm/prims/jniFastGetField.hpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 2314
f95d63e2154a
parent 0
f90c822e73f8
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_PRIMS_JNIFASTGETFIELD_HPP
aoqi@0 26 #define SHARE_VM_PRIMS_JNIFASTGETFIELD_HPP
aoqi@0 27
aoqi@0 28 #include "memory/allocation.hpp"
aoqi@0 29 #include "prims/jvm_misc.hpp"
aoqi@0 30
aoqi@0 31 // Basic logic of a fast version of jni_Get<Primitive>Field:
aoqi@0 32 //
aoqi@0 33 // (See safepoint.hpp for a description of _safepoint_counter)
aoqi@0 34 //
aoqi@0 35 // load _safepoint_counter into old_counter
aoqi@0 36 // IF old_counter is odd THEN
aoqi@0 37 // a safepoint is going on, return jni_GetXXXField
aoqi@0 38 // ELSE
aoqi@0 39 // load the primitive field value into result (speculatively)
aoqi@0 40 // load _safepoint_counter into new_counter
aoqi@0 41 // IF (old_counter == new_counter) THEN
aoqi@0 42 // no safepoint happened during the field access, return result
aoqi@0 43 // ELSE
aoqi@0 44 // a safepoint might have happened in-between, return jni_GetXXXField()
aoqi@0 45 // ENDIF
aoqi@0 46 // ENDIF
aoqi@0 47 //
aoqi@0 48 // LoadLoad membars to maintain the load order may be necessary
aoqi@0 49 // for some platforms.
aoqi@0 50 //
aoqi@0 51 // The fast versions don't check for pending suspension request.
aoqi@0 52 // This is fine since it's totally read-only and doesn't create new race.
aoqi@0 53 //
aoqi@0 54 // There is a hypothetical safepoint counter wraparound. But it's not
aoqi@0 55 // a practical concern.
aoqi@0 56
aoqi@0 57 class JNI_FastGetField : AllStatic {
aoqi@0 58 private:
aoqi@0 59 enum { LIST_CAPACITY = 40 }; // a conservative number for the number of
aoqi@0 60 // speculative loads on all the platforms
aoqi@0 61 static address speculative_load_pclist [];
aoqi@0 62 static address slowcase_entry_pclist [];
aoqi@0 63 static int count;
aoqi@0 64
aoqi@0 65 static address generate_fast_get_int_field0(BasicType type);
aoqi@0 66 static address generate_fast_get_float_field0(BasicType type);
aoqi@0 67
aoqi@0 68 public:
aoqi@0 69 #if defined(_WINDOWS) && !defined(_WIN64)
aoqi@0 70 static GetBooleanField_t jni_fast_GetBooleanField_fp;
aoqi@0 71 static GetByteField_t jni_fast_GetByteField_fp;
aoqi@0 72 static GetCharField_t jni_fast_GetCharField_fp;
aoqi@0 73 static GetShortField_t jni_fast_GetShortField_fp;
aoqi@0 74 static GetIntField_t jni_fast_GetIntField_fp;
aoqi@0 75 static GetLongField_t jni_fast_GetLongField_fp;
aoqi@0 76 static GetFloatField_t jni_fast_GetFloatField_fp;
aoqi@0 77 static GetDoubleField_t jni_fast_GetDoubleField_fp;
aoqi@0 78 #endif
aoqi@0 79
aoqi@0 80 static address generate_fast_get_boolean_field();
aoqi@0 81 static address generate_fast_get_byte_field();
aoqi@0 82 static address generate_fast_get_char_field();
aoqi@0 83 static address generate_fast_get_short_field();
aoqi@0 84 static address generate_fast_get_int_field();
aoqi@0 85 static address generate_fast_get_long_field();
aoqi@0 86 static address generate_fast_get_float_field();
aoqi@0 87 static address generate_fast_get_double_field();
aoqi@0 88
aoqi@0 89 // If pc is in speculative_load_pclist, return the corresponding
aoqi@0 90 // slow case entry pc. Otherwise, return -1.
aoqi@0 91 // This is used by signal/exception handler to handle such case:
aoqi@0 92 // After an even safepoint counter is loaded and a fast field access
aoqi@0 93 // is about to begin, a GC kicks in and shrinks the heap. Then the
aoqi@0 94 // field access may fault. The signal/exception handler needs to
aoqi@0 95 // return to the slow case.
aoqi@0 96 //
aoqi@0 97 // The GC may decide to temporarily stuff some bad values into handles,
aoqi@0 98 // for example, for debugging purpose, in which case we need the mapping also.
aoqi@0 99 static address find_slowcase_pc(address pc);
aoqi@0 100 };
aoqi@0 101
aoqi@0 102 #endif // SHARE_VM_PRIMS_JNIFASTGETFIELD_HPP

mercurial