src/cpu/x86/vm/interpreter_x86_32.cpp

Fri, 07 Nov 2008 09:29:38 -0800

author
kvn
date
Fri, 07 Nov 2008 09:29:38 -0800
changeset 855
a1980da045cc
parent 772
9ee9cf798b59
child 1145
e5b0439ef4ae
permissions
-rw-r--r--

6462850: generate biased locking code in C2 ideal graph
Summary: Inline biased locking code in C2 ideal graph during macro nodes expansion
Reviewed-by: never

     1 /*
     2  * Copyright 1997-2008 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/_interpreter_x86_32.cpp.incl"
    28 #define __ _masm->
    30 // Initialize the sentinel used to distinguish an interpreter return address.
    31 const int Interpreter::return_sentinel = 0xfeedbeed;
    33 //------------------------------------------------------------------------------------------------------------------------
    35 address AbstractInterpreterGenerator::generate_slow_signature_handler() {
    36   address entry = __ pc();
    37   // rbx,: method
    38   // rcx: temporary
    39   // rdi: pointer to locals
    40   // rsp: end of copied parameters area
    41   __ mov(rcx, rsp);
    42   __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), rbx, rdi, rcx);
    43   __ ret(0);
    44   return entry;
    45 }
    48 //
    49 // Various method entries (that c++ and asm interpreter agree upon)
    50 //------------------------------------------------------------------------------------------------------------------------
    51 //
    52 //
    54 // Empty method, generate a very fast return.
    56 address InterpreterGenerator::generate_empty_entry(void) {
    58   // rbx,: methodOop
    59   // rcx: receiver (unused)
    60   // rsi: previous interpreter state (C++ interpreter) must preserve
    61   // rsi: sender sp must set sp to this value on return
    63   if (!UseFastEmptyMethods) return NULL;
    65   address entry_point = __ pc();
    67   // If we need a safepoint check, generate full interpreter entry.
    68   Label slow_path;
    69   ExternalAddress state(SafepointSynchronize::address_of_state());
    70   __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
    71            SafepointSynchronize::_not_synchronized);
    72   __ jcc(Assembler::notEqual, slow_path);
    74   // do nothing for empty methods (do not even increment invocation counter)
    75   // Code: _return
    76   // _return
    77   // return w/o popping parameters
    78   __ pop(rax);
    79   __ mov(rsp, rsi);
    80   __ jmp(rax);
    82   __ bind(slow_path);
    83   (void) generate_normal_entry(false);
    84   return entry_point;
    85 }
    87 address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
    89   // rbx,: methodOop
    90   // rcx: scratrch
    91   // rsi: sender sp
    93   if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
    95   address entry_point = __ pc();
    97   // These don't need a safepoint check because they aren't virtually
    98   // callable. We won't enter these intrinsics from compiled code.
    99   // If in the future we added an intrinsic which was virtually callable
   100   // we'd have to worry about how to safepoint so that this code is used.
   102   // mathematical functions inlined by compiler
   103   // (interpreter must provide identical implementation
   104   // in order to avoid monotonicity bugs when switching
   105   // from interpreter to compiler in the middle of some
   106   // computation)
   107   //
   108   // stack: [ ret adr ] <-- rsp
   109   //        [ lo(arg) ]
   110   //        [ hi(arg) ]
   111   //
   113   // Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are
   114   //       native methods. Interpreter::method_kind(...) does a check for
   115   //       native methods first before checking for intrinsic methods and
   116   //       thus will never select this entry point. Make sure it is not
   117   //       called accidentally since the SharedRuntime entry points will
   118   //       not work for JDK 1.2.
   119   //
   120   // We no longer need to check for JDK 1.2 since it's EOL'ed.
   121   // The following check existed in pre 1.6 implementation,
   122   //    if (Universe::is_jdk12x_version()) {
   123   //      __ should_not_reach_here();
   124   //    }
   125   // Universe::is_jdk12x_version() always returns false since
   126   // the JDK version is not yet determined when this method is called.
   127   // This method is called during interpreter_init() whereas
   128   // JDK version is only determined when universe2_init() is called.
   130   // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
   131   //       java methods.  Interpreter::method_kind(...) will select
   132   //       this entry point for the corresponding methods in JDK 1.3.
   133   // get argument
   134   if (TaggedStackInterpreter) {
   135     __ pushl(Address(rsp, 3*wordSize));  // push hi (and note rsp -= wordSize)
   136     __ pushl(Address(rsp, 2*wordSize));  // push lo
   137     __ fld_d(Address(rsp, 0));           // get double in ST0
   138     __ addptr(rsp, 2*wordSize);
   139   } else {
   140     __ fld_d(Address(rsp, 1*wordSize));
   141   }
   142   switch (kind) {
   143     case Interpreter::java_lang_math_sin :
   144         __ trigfunc('s');
   145         break;
   146     case Interpreter::java_lang_math_cos :
   147         __ trigfunc('c');
   148         break;
   149     case Interpreter::java_lang_math_tan :
   150         __ trigfunc('t');
   151         break;
   152     case Interpreter::java_lang_math_sqrt:
   153         __ fsqrt();
   154         break;
   155     case Interpreter::java_lang_math_abs:
   156         __ fabs();
   157         break;
   158     case Interpreter::java_lang_math_log:
   159         __ flog();
   160         // Store to stack to convert 80bit precision back to 64bits
   161         __ push_fTOS();
   162         __ pop_fTOS();
   163         break;
   164     case Interpreter::java_lang_math_log10:
   165         __ flog10();
   166         // Store to stack to convert 80bit precision back to 64bits
   167         __ push_fTOS();
   168         __ pop_fTOS();
   169         break;
   170     default                              :
   171         ShouldNotReachHere();
   172   }
   174   // return double result in xmm0 for interpreter and compilers.
   175   if (UseSSE >= 2) {
   176     __ subptr(rsp, 2*wordSize);
   177     __ fstp_d(Address(rsp, 0));
   178     __ movdbl(xmm0, Address(rsp, 0));
   179     __ addptr(rsp, 2*wordSize);
   180   }
   182   // done, result in FPU ST(0) or XMM0
   183   __ pop(rdi);                               // get return address
   184   __ mov(rsp, rsi);                          // set sp to sender sp
   185   __ jmp(rdi);
   187   return entry_point;
   188 }
   191 // Abstract method entry
   192 // Attempt to execute abstract method. Throw exception
   193 address InterpreterGenerator::generate_abstract_entry(void) {
   195   // rbx,: methodOop
   196   // rcx: receiver (unused)
   197   // rsi: previous interpreter state (C++ interpreter) must preserve
   199   // rsi: sender SP
   201   address entry_point = __ pc();
   203   // abstract method entry
   204   // remove return address. Not really needed, since exception handling throws away expression stack
   205   __ pop(rbx);
   207   // adjust stack to what a normal return would do
   208   __ mov(rsp, rsi);
   209   // throw exception
   210   __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
   211   // the call_VM checks for exception, so we should never return here.
   212   __ should_not_reach_here();
   214   return entry_point;
   215 }
   217 // This method tells the deoptimizer how big an interpreted frame must be:
   218 int AbstractInterpreter::size_activation(methodOop method,
   219                                          int tempcount,
   220                                          int popframe_extra_args,
   221                                          int moncount,
   222                                          int callee_param_count,
   223                                          int callee_locals,
   224                                          bool is_top_frame) {
   225   return layout_activation(method,
   226                            tempcount,
   227                            popframe_extra_args,
   228                            moncount,
   229                            callee_param_count,
   230                            callee_locals,
   231                            (frame*) NULL,
   232                            (frame*) NULL,
   233                            is_top_frame);
   234 }
   236 void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) {
   238   // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in
   239   // the days we had adapter frames. When we deoptimize a situation where a
   240   // compiled caller calls a compiled caller will have registers it expects
   241   // to survive the call to the callee. If we deoptimize the callee the only
   242   // way we can restore these registers is to have the oldest interpreter
   243   // frame that we create restore these values. That is what this routine
   244   // will accomplish.
   246   // At the moment we have modified c2 to not have any callee save registers
   247   // so this problem does not exist and this routine is just a place holder.
   249   assert(f->is_interpreted_frame(), "must be interpreted");
   250 }

mercurial