Path: blob/master/src/hotspot/cpu/s390/jniFastGetField_s390.cpp
40930 views
/*1* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2016 SAP SE. All rights reserved.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#include "precompiled.hpp"26#include "asm/macroAssembler.inline.hpp"27#include "gc/shared/barrierSet.hpp"28#include "gc/shared/barrierSetAssembler.hpp"29#include "memory/resourceArea.hpp"30#include "prims/jniFastGetField.hpp"31#include "prims/jvm_misc.hpp"32#include "prims/jvmtiExport.hpp"33#include "runtime/safepoint.hpp"3435// TSO ensures that loads are blocking and ordered with respect to36// to earlier loads, so we don't need LoadLoad membars.3738#define __ masm->3940#define BUFFER_SIZE 30*sizeof(jint)4142// Common register usage:43// Z_RET/Z_FRET: result44// Z_ARG1: jni env45// Z_ARG2: obj46// Z_ARG3: jfield id4748address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) {49const char *name;50switch (type) {51case T_BOOLEAN: name = "jni_fast_GetBooleanField"; break;52case T_BYTE: name = "jni_fast_GetByteField"; break;53case T_CHAR: name = "jni_fast_GetCharField"; break;54case T_SHORT: name = "jni_fast_GetShortField"; break;55case T_INT: name = "jni_fast_GetIntField"; break;56case T_LONG: name = "jni_fast_GetLongField"; break;57case T_FLOAT: name = "jni_fast_GetFloatField"; break;58case T_DOUBLE: name = "jni_fast_GetDoubleField"; break;59default: ShouldNotReachHere();60name = NULL; // unreachable61}62ResourceMark rm;63BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE);64CodeBuffer cbuf(blob);65MacroAssembler* masm = new MacroAssembler(&cbuf);66address fast_entry = __ pc();6768Label slow;6970// We can only kill the remaining volatile registers.71const Register Rcounter = Z_ARG4,72Robj = Z_R1_scratch,73Rtmp = Z_R0_scratch;74__ load_const_optimized(Robj, SafepointSynchronize::safepoint_counter_addr());75__ z_lg(Rcounter, Address(Robj));76__ z_tmll(Rcounter, 1);77__ z_brnaz(slow);7879if (JvmtiExport::can_post_field_access()) {80// Check to see if a field access watch has been set before we81// take the fast path.82__ load_const_optimized(Robj, JvmtiExport::get_field_access_count_addr());83__ z_lt(Robj, Address(Robj));84__ z_brne(slow);85}8687__ z_lgr(Robj, Z_ARG2);88BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();89bs->try_resolve_jobject_in_native(masm, Z_ARG1, Robj, Rtmp, slow);9091__ z_srlg(Rtmp, Z_ARG3, 2); // offset92__ z_agr(Robj, Rtmp);9394assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");95speculative_load_pclist[count] = __ pc(); // Used by the segfault handler96bool is_fp = false;97switch (type) {98case T_BOOLEAN: __ z_llgc(Rtmp, Address(Robj)); break;99case T_BYTE: __ z_lgb( Rtmp, Address(Robj)); break;100case T_CHAR: __ z_llgh(Rtmp, Address(Robj)); break;101case T_SHORT: __ z_lgh( Rtmp, Address(Robj)); break;102case T_INT: __ z_lgf( Rtmp, Address(Robj)); break;103case T_LONG: __ z_lg( Rtmp, Address(Robj)); break;104case T_FLOAT: __ mem2freg_opt(Z_FRET, Address(Robj), false); is_fp = true; break;105case T_DOUBLE: __ mem2freg_opt(Z_FRET, Address(Robj), true ); is_fp = true; break;106default: ShouldNotReachHere();107}108109__ load_const_optimized(Robj, SafepointSynchronize::safepoint_counter_addr());110__ z_cg(Rcounter, Address(Robj));111__ z_brne(slow);112113if (!is_fp) {114__ z_lgr(Z_RET, Rtmp);115}116__ z_br(Z_R14);117118slowcase_entry_pclist[count++] = __ pc();119__ bind(slow);120address slow_case_addr;121switch (type) {122case T_BOOLEAN: slow_case_addr = jni_GetBooleanField_addr(); break;123case T_BYTE: slow_case_addr = jni_GetByteField_addr(); break;124case T_CHAR: slow_case_addr = jni_GetCharField_addr(); break;125case T_SHORT: slow_case_addr = jni_GetShortField_addr(); break;126case T_INT: slow_case_addr = jni_GetIntField_addr(); break;127case T_LONG: slow_case_addr = jni_GetLongField_addr(); break;128case T_FLOAT: slow_case_addr = jni_GetFloatField_addr(); break;129case T_DOUBLE: slow_case_addr = jni_GetDoubleField_addr(); break;130default: ShouldNotReachHere();131slow_case_addr = NULL; // unreachable132}133__ load_const_optimized(Robj, slow_case_addr);134__ z_br(Robj); // tail call135136__ flush();137138return fast_entry;139}140141address JNI_FastGetField::generate_fast_get_boolean_field() {142return generate_fast_get_int_field0(T_BOOLEAN);143}144145address JNI_FastGetField::generate_fast_get_byte_field() {146return generate_fast_get_int_field0(T_BYTE);147}148149address JNI_FastGetField::generate_fast_get_char_field() {150return generate_fast_get_int_field0(T_CHAR);151}152153address JNI_FastGetField::generate_fast_get_short_field() {154return generate_fast_get_int_field0(T_SHORT);155}156157address JNI_FastGetField::generate_fast_get_int_field() {158return generate_fast_get_int_field0(T_INT);159}160161address JNI_FastGetField::generate_fast_get_long_field() {162return generate_fast_get_int_field0(T_LONG);163}164165address JNI_FastGetField::generate_fast_get_float_field() {166return generate_fast_get_int_field0(T_FLOAT);167}168169address JNI_FastGetField::generate_fast_get_double_field() {170return generate_fast_get_int_field0(T_DOUBLE);171}172173174