src/cpu/sparc/vm/jniFastGetField_sparc.cpp

Fri, 30 Apr 2010 08:37:24 -0700

author
twisti
date
Fri, 30 Apr 2010 08:37:24 -0700
changeset 1861
2338d41fbd81
parent 1162
6b2273dd6fa9
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6943304: remove tagged stack interpreter
Reviewed-by: coleenp, never, gbenson

     1 /*
     2  * Copyright 2004-2009 Sun Microsystems, Inc.  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 it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 # include "incls/_precompiled.incl"
    26 # include "incls/_jniFastGetField_sparc.cpp.incl"
    28 // TSO ensures that loads are blocking and ordered with respect to
    29 // to earlier loads, so we don't need LoadLoad membars.
    31 #define __ masm->
    33 #define BUFFER_SIZE 30*sizeof(jint)
    35 // Common register usage:
    36 // O0: env
    37 // O1: obj
    38 // O2: jfieldID
    39 // O4: offset (O2 >> 2)
    40 // G4: old safepoint counter
    42 address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) {
    43   const char *name;
    44   switch (type) {
    45     case T_BOOLEAN: name = "jni_fast_GetBooleanField"; break;
    46     case T_BYTE:    name = "jni_fast_GetByteField";    break;
    47     case T_CHAR:    name = "jni_fast_GetCharField";    break;
    48     case T_SHORT:   name = "jni_fast_GetShortField";   break;
    49     case T_INT:     name = "jni_fast_GetIntField";     break;
    50     default:        ShouldNotReachHere();
    51   }
    52   ResourceMark rm;
    53   BufferBlob* b = BufferBlob::create(name, BUFFER_SIZE*wordSize);
    54   address fast_entry = b->instructions_begin();
    55   CodeBuffer cbuf(fast_entry, b->instructions_size());
    56   MacroAssembler* masm = new MacroAssembler(&cbuf);
    58   Label label1, label2;
    60   AddressLiteral cnt_addrlit(SafepointSynchronize::safepoint_counter_addr());
    61   __ sethi (cnt_addrlit, O3);
    62   Address cnt_addr(O3, cnt_addrlit.low10());
    63   __ ld (cnt_addr, G4);
    64   __ andcc (G4, 1, G0);
    65   __ br (Assembler::notZero, false, Assembler::pn, label1);
    66   __ delayed()->srl (O2, 2, O4);
    67   __ ld_ptr (O1, 0, O5);
    69   assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
    70   speculative_load_pclist[count] = __ pc();
    71   switch (type) {
    72     case T_BOOLEAN: __ ldub (O5, O4, G3);  break;
    73     case T_BYTE:    __ ldsb (O5, O4, G3);  break;
    74     case T_CHAR:    __ lduh (O5, O4, G3);  break;
    75     case T_SHORT:   __ ldsh (O5, O4, G3);  break;
    76     case T_INT:     __ ld (O5, O4, G3);    break;
    77     default:        ShouldNotReachHere();
    78   }
    80   __ ld (cnt_addr, O5);
    81   __ cmp (O5, G4);
    82   __ br (Assembler::notEqual, false, Assembler::pn, label2);
    83   __ delayed()->mov (O7, G1);
    84   __ retl ();
    85   __ delayed()->mov (G3, O0);
    87   slowcase_entry_pclist[count++] = __ pc();
    88   __ bind (label1);
    89   __ mov (O7, G1);
    91   address slow_case_addr;
    92   switch (type) {
    93     case T_BOOLEAN: slow_case_addr = jni_GetBooleanField_addr(); break;
    94     case T_BYTE:    slow_case_addr = jni_GetByteField_addr();    break;
    95     case T_CHAR:    slow_case_addr = jni_GetCharField_addr();    break;
    96     case T_SHORT:   slow_case_addr = jni_GetShortField_addr();   break;
    97     case T_INT:     slow_case_addr = jni_GetIntField_addr();     break;
    98     default:        ShouldNotReachHere();
    99   }
   100   __ bind (label2);
   101   __ call (slow_case_addr, relocInfo::none);
   102   __ delayed()->mov (G1, O7);
   104   __ flush ();
   106   return fast_entry;
   107 }
   109 address JNI_FastGetField::generate_fast_get_boolean_field() {
   110   return generate_fast_get_int_field0(T_BOOLEAN);
   111 }
   113 address JNI_FastGetField::generate_fast_get_byte_field() {
   114   return generate_fast_get_int_field0(T_BYTE);
   115 }
   117 address JNI_FastGetField::generate_fast_get_char_field() {
   118   return generate_fast_get_int_field0(T_CHAR);
   119 }
   121 address JNI_FastGetField::generate_fast_get_short_field() {
   122   return generate_fast_get_int_field0(T_SHORT);
   123 }
   125 address JNI_FastGetField::generate_fast_get_int_field() {
   126   return generate_fast_get_int_field0(T_INT);
   127 }
   129 address JNI_FastGetField::generate_fast_get_long_field() {
   130   const char *name = "jni_fast_GetLongField";
   131   ResourceMark rm;
   132   BufferBlob* b = BufferBlob::create(name, BUFFER_SIZE*wordSize);
   133   address fast_entry = b->instructions_begin();
   134   CodeBuffer cbuf(fast_entry, b->instructions_size());
   135   MacroAssembler* masm = new MacroAssembler(&cbuf);
   137   Label label1, label2;
   139   AddressLiteral cnt_addrlit(SafepointSynchronize::safepoint_counter_addr());
   140   __ sethi (cnt_addrlit, G3);
   141   Address cnt_addr(G3, cnt_addrlit.low10());
   142   __ ld (cnt_addr, G4);
   143   __ andcc (G4, 1, G0);
   144   __ br (Assembler::notZero, false, Assembler::pn, label1);
   145   __ delayed()->srl (O2, 2, O4);
   146   __ ld_ptr (O1, 0, O5);
   147   __ add (O5, O4, O5);
   149 #ifndef _LP64
   150   assert(count < LIST_CAPACITY-1, "LIST_CAPACITY too small");
   151   speculative_load_pclist[count++] = __ pc();
   152   __ ld (O5, 0, G2);
   154   speculative_load_pclist[count] = __ pc();
   155   __ ld (O5, 4, O3);
   156 #else
   157   assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
   158   speculative_load_pclist[count] = __ pc();
   159   __ ldx (O5, 0, O3);
   160 #endif
   162   __ ld (cnt_addr, G1);
   163   __ cmp (G1, G4);
   164   __ br (Assembler::notEqual, false, Assembler::pn, label2);
   165   __ delayed()->mov (O7, G1);
   167 #ifndef _LP64
   168   __ mov (G2, O0);
   169   __ retl ();
   170   __ delayed()->mov (O3, O1);
   171 #else
   172   __ retl ();
   173   __ delayed()->mov (O3, O0);
   174 #endif
   176 #ifndef _LP64
   177   slowcase_entry_pclist[count-1] = __ pc();
   178   slowcase_entry_pclist[count++] = __ pc() ;
   179 #else
   180   slowcase_entry_pclist[count++] = __ pc();
   181 #endif
   183   __ bind (label1);
   184   __ mov (O7, G1);
   186   address slow_case_addr = jni_GetLongField_addr();
   187   __ bind (label2);
   188   __ call (slow_case_addr, relocInfo::none);
   189   __ delayed()->mov (G1, O7);
   191   __ flush ();
   193   return fast_entry;
   194 }
   196 address JNI_FastGetField::generate_fast_get_float_field0(BasicType type) {
   197   const char *name;
   198   switch (type) {
   199     case T_FLOAT:  name = "jni_fast_GetFloatField";  break;
   200     case T_DOUBLE: name = "jni_fast_GetDoubleField"; break;
   201     default:       ShouldNotReachHere();
   202   }
   203   ResourceMark rm;
   204   BufferBlob* b = BufferBlob::create(name, BUFFER_SIZE*wordSize);
   205   address fast_entry = b->instructions_begin();
   206   CodeBuffer cbuf(fast_entry, b->instructions_size());
   207   MacroAssembler* masm = new MacroAssembler(&cbuf);
   209   Label label1, label2;
   211   AddressLiteral cnt_addrlit(SafepointSynchronize::safepoint_counter_addr());
   212   __ sethi (cnt_addrlit, O3);
   213   Address cnt_addr(O3, cnt_addrlit.low10());
   214   __ ld (cnt_addr, G4);
   215   __ andcc (G4, 1, G0);
   216   __ br (Assembler::notZero, false, Assembler::pn, label1);
   217   __ delayed()->srl (O2, 2, O4);
   218   __ ld_ptr (O1, 0, O5);
   220   assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
   221   speculative_load_pclist[count] = __ pc();
   222   switch (type) {
   223     case T_FLOAT:  __ ldf (FloatRegisterImpl::S, O5, O4, F0); break;
   224     case T_DOUBLE: __ ldf (FloatRegisterImpl::D, O5, O4, F0); break;
   225     default:       ShouldNotReachHere();
   226   }
   228   __ ld (cnt_addr, O5);
   229   __ cmp (O5, G4);
   230   __ br (Assembler::notEqual, false, Assembler::pn, label2);
   231   __ delayed()->mov (O7, G1);
   233   __ retl ();
   234   __ delayed()-> nop ();
   236   slowcase_entry_pclist[count++] = __ pc();
   237   __ bind (label1);
   238   __ mov (O7, G1);
   240   address slow_case_addr;
   241   switch (type) {
   242     case T_FLOAT:  slow_case_addr = jni_GetFloatField_addr();  break;
   243     case T_DOUBLE: slow_case_addr = jni_GetDoubleField_addr(); break;
   244     default:       ShouldNotReachHere();
   245   }
   246   __ bind (label2);
   247   __ call (slow_case_addr, relocInfo::none);
   248   __ delayed()->mov (G1, O7);
   250   __ flush ();
   252   return fast_entry;
   253 }
   255 address JNI_FastGetField::generate_fast_get_float_field() {
   256   return generate_fast_get_float_field0(T_FLOAT);
   257 }
   259 address JNI_FastGetField::generate_fast_get_double_field() {
   260   return generate_fast_get_float_field0(T_DOUBLE);
   261 }

mercurial