src/share/vm/prims/jniFastGetField.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/prims/jniFastGetField.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,102 @@
     1.4 +/*
     1.5 + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_PRIMS_JNIFASTGETFIELD_HPP
    1.29 +#define SHARE_VM_PRIMS_JNIFASTGETFIELD_HPP
    1.30 +
    1.31 +#include "memory/allocation.hpp"
    1.32 +#include "prims/jvm_misc.hpp"
    1.33 +
    1.34 +// Basic logic of a fast version of jni_Get<Primitive>Field:
    1.35 +//
    1.36 +// (See safepoint.hpp for a description of _safepoint_counter)
    1.37 +//
    1.38 +// load _safepoint_counter into old_counter
    1.39 +// IF old_counter is odd THEN
    1.40 +//   a safepoint is going on, return jni_GetXXXField
    1.41 +// ELSE
    1.42 +//   load the primitive field value into result (speculatively)
    1.43 +//   load _safepoint_counter into new_counter
    1.44 +//   IF (old_counter == new_counter) THEN
    1.45 +//     no safepoint happened during the field access, return result
    1.46 +//   ELSE
    1.47 +//     a safepoint might have happened in-between, return jni_GetXXXField()
    1.48 +//   ENDIF
    1.49 +// ENDIF
    1.50 +//
    1.51 +// LoadLoad membars to maintain the load order may be necessary
    1.52 +// for some platforms.
    1.53 +//
    1.54 +// The fast versions don't check for pending suspension request.
    1.55 +// This is fine since it's totally read-only and doesn't create new race.
    1.56 +//
    1.57 +// There is a hypothetical safepoint counter wraparound. But it's not
    1.58 +// a practical concern.
    1.59 +
    1.60 +class JNI_FastGetField : AllStatic {
    1.61 + private:
    1.62 +  enum { LIST_CAPACITY = 40 };      // a conservative number for the number of
    1.63 +                                    // speculative loads on all the platforms
    1.64 +  static address speculative_load_pclist [];
    1.65 +  static address slowcase_entry_pclist   [];
    1.66 +  static int     count;
    1.67 +
    1.68 +  static address generate_fast_get_int_field0(BasicType type);
    1.69 +  static address generate_fast_get_float_field0(BasicType type);
    1.70 +
    1.71 + public:
    1.72 +#if defined(_WINDOWS) && !defined(_WIN64)
    1.73 +  static GetBooleanField_t jni_fast_GetBooleanField_fp;
    1.74 +  static GetByteField_t    jni_fast_GetByteField_fp;
    1.75 +  static GetCharField_t    jni_fast_GetCharField_fp;
    1.76 +  static GetShortField_t   jni_fast_GetShortField_fp;
    1.77 +  static GetIntField_t     jni_fast_GetIntField_fp;
    1.78 +  static GetLongField_t    jni_fast_GetLongField_fp;
    1.79 +  static GetFloatField_t   jni_fast_GetFloatField_fp;
    1.80 +  static GetDoubleField_t  jni_fast_GetDoubleField_fp;
    1.81 +#endif
    1.82 +
    1.83 +  static address generate_fast_get_boolean_field();
    1.84 +  static address generate_fast_get_byte_field();
    1.85 +  static address generate_fast_get_char_field();
    1.86 +  static address generate_fast_get_short_field();
    1.87 +  static address generate_fast_get_int_field();
    1.88 +  static address generate_fast_get_long_field();
    1.89 +  static address generate_fast_get_float_field();
    1.90 +  static address generate_fast_get_double_field();
    1.91 +
    1.92 +  // If pc is in speculative_load_pclist, return the corresponding
    1.93 +  // slow case entry pc. Otherwise, return -1.
    1.94 +  // This is used by signal/exception handler to handle such case:
    1.95 +  // After an even safepoint counter is loaded and a fast field access
    1.96 +  // is about to begin, a GC kicks in and shrinks the heap. Then the
    1.97 +  // field access may fault. The signal/exception handler needs to
    1.98 +  // return to the slow case.
    1.99 +  //
   1.100 +  // The GC may decide to temporarily stuff some bad values into handles,
   1.101 +  // for example, for debugging purpose, in which case we need the mapping also.
   1.102 +  static address find_slowcase_pc(address pc);
   1.103 +};
   1.104 +
   1.105 +#endif // SHARE_VM_PRIMS_JNIFASTGETFIELD_HPP

mercurial