src/share/vm/prims/jniFastGetField.hpp

changeset 435
a61af66fc99e
child 1907
c18cbe5936b8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/prims/jniFastGetField.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,94 @@
     1.4 +/*
     1.5 + * Copyright 2004 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +// Basic logic of a fast version of jni_Get<Primitive>Field:
    1.29 +//
    1.30 +// (See safepoint.hpp for a description of _safepoint_counter)
    1.31 +//
    1.32 +// load _safepoint_counter into old_counter
    1.33 +// IF old_counter is odd THEN
    1.34 +//   a safepoint is going on, return jni_GetXXXField
    1.35 +// ELSE
    1.36 +//   load the primitive field value into result (speculatively)
    1.37 +//   load _safepoint_counter into new_counter
    1.38 +//   IF (old_counter == new_counter) THEN
    1.39 +//     no safepoint happened during the field access, return result
    1.40 +//   ELSE
    1.41 +//     a safepoint might have happened in-between, return jni_GetXXXField()
    1.42 +//   ENDIF
    1.43 +// ENDIF
    1.44 +//
    1.45 +// LoadLoad membars to maintain the load order may be necessary
    1.46 +// for some platforms.
    1.47 +//
    1.48 +// The fast versions don't check for pending suspension request.
    1.49 +// This is fine since it's totally read-only and doesn't create new race.
    1.50 +//
    1.51 +// There is a hypothetical safepoint counter wraparound. But it's not
    1.52 +// a practical concern.
    1.53 +
    1.54 +class JNI_FastGetField : AllStatic {
    1.55 + private:
    1.56 +  enum { LIST_CAPACITY = 40 };      // a conservative number for the number of
    1.57 +                                    // speculative loads on all the platforms
    1.58 +  static address speculative_load_pclist [];
    1.59 +  static address slowcase_entry_pclist   [];
    1.60 +  static int     count;
    1.61 +
    1.62 +  static address generate_fast_get_int_field0(BasicType type);
    1.63 +  static address generate_fast_get_float_field0(BasicType type);
    1.64 +
    1.65 + public:
    1.66 +#if defined(_WINDOWS) && !defined(_WIN64)
    1.67 +  static GetBooleanField_t jni_fast_GetBooleanField_fp;
    1.68 +  static GetByteField_t    jni_fast_GetByteField_fp;
    1.69 +  static GetCharField_t    jni_fast_GetCharField_fp;
    1.70 +  static GetShortField_t   jni_fast_GetShortField_fp;
    1.71 +  static GetIntField_t     jni_fast_GetIntField_fp;
    1.72 +  static GetLongField_t    jni_fast_GetLongField_fp;
    1.73 +  static GetFloatField_t   jni_fast_GetFloatField_fp;
    1.74 +  static GetDoubleField_t  jni_fast_GetDoubleField_fp;
    1.75 +#endif
    1.76 +
    1.77 +  static address generate_fast_get_boolean_field();
    1.78 +  static address generate_fast_get_byte_field();
    1.79 +  static address generate_fast_get_char_field();
    1.80 +  static address generate_fast_get_short_field();
    1.81 +  static address generate_fast_get_int_field();
    1.82 +  static address generate_fast_get_long_field();
    1.83 +  static address generate_fast_get_float_field();
    1.84 +  static address generate_fast_get_double_field();
    1.85 +
    1.86 +  // If pc is in speculative_load_pclist, return the corresponding
    1.87 +  // slow case entry pc. Otherwise, return -1.
    1.88 +  // This is used by signal/exception handler to handle such case:
    1.89 +  // After an even safepoint counter is loaded and a fast field access
    1.90 +  // is about to begin, a GC kicks in and shrinks the heap. Then the
    1.91 +  // field access may fault. The signal/exception handler needs to
    1.92 +  // return to the slow case.
    1.93 +  //
    1.94 +  // The GC may decide to temporarily stuff some bad values into handles,
    1.95 +  // for example, for debugging purpose, in which case we need the mapping also.
    1.96 +  static address find_slowcase_pc(address pc);
    1.97 +};

mercurial