jniFastGetField.hpp revision 0
0N/A * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A// Basic logic of a fast version of jni_Get<Primitive>Field: 0N/A// load _safepoint_counter into old_counter 0N/A// IF old_counter is odd THEN 0N/A// a safepoint is going on, return jni_GetXXXField 0N/A// load the primitive field value into result (speculatively) 0N/A// load _safepoint_counter into new_counter 0N/A// IF (old_counter == new_counter) THEN 0N/A// no safepoint happened during the field access, return result 0N/A// a safepoint might have happened in-between, return jni_GetXXXField() 0N/A// LoadLoad membars to maintain the load order may be necessary 0N/A// for some platforms. 0N/A// The fast versions don't check for pending suspension request. 0N/A// This is fine since it's totally read-only and doesn't create new race. 0N/A// There is a hypothetical safepoint counter wraparound. But it's not 0N/A// a practical concern. 0N/A // speculative loads on all the platforms 0N/A // If pc is in speculative_load_pclist, return the corresponding 0N/A // slow case entry pc. Otherwise, return -1. 0N/A // After an even safepoint counter is loaded and a fast field access 0N/A // is about to begin, a GC kicks in and shrinks the heap. Then the 0N/A // return to the slow case. 0N/A // The GC may decide to temporarily stuff some bad values into handles, 0N/A // for example, for debugging purpose, in which case we need the mapping also.