src/cpu/x86/vm/interpreter_x86_32.cpp

Sat, 29 Sep 2012 06:40:00 -0400

author
coleenp
date
Sat, 29 Sep 2012 06:40:00 -0400
changeset 4142
d8ce2825b193
parent 4037
da91efe96a93
child 4318
cd3d6a6b95d9
permissions
-rw-r--r--

8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
Summary: Capitalize these metadata types (and objArrayKlass)
Reviewed-by: stefank, twisti, kvn

     1 /*
     2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #include "precompiled.hpp"
    26 #include "asm/assembler.hpp"
    27 #include "interpreter/bytecodeHistogram.hpp"
    28 #include "interpreter/interpreter.hpp"
    29 #include "interpreter/interpreterGenerator.hpp"
    30 #include "interpreter/interpreterRuntime.hpp"
    31 #include "interpreter/templateTable.hpp"
    32 #include "oops/arrayOop.hpp"
    33 #include "oops/methodData.hpp"
    34 #include "oops/method.hpp"
    35 #include "oops/oop.inline.hpp"
    36 #include "prims/jvmtiExport.hpp"
    37 #include "prims/jvmtiThreadState.hpp"
    38 #include "prims/methodHandles.hpp"
    39 #include "runtime/arguments.hpp"
    40 #include "runtime/deoptimization.hpp"
    41 #include "runtime/frame.inline.hpp"
    42 #include "runtime/sharedRuntime.hpp"
    43 #include "runtime/stubRoutines.hpp"
    44 #include "runtime/synchronizer.hpp"
    45 #include "runtime/timer.hpp"
    46 #include "runtime/vframeArray.hpp"
    47 #include "utilities/debug.hpp"
    48 #ifdef COMPILER1
    49 #include "c1/c1_Runtime1.hpp"
    50 #endif
    52 #define __ _masm->
    54 //------------------------------------------------------------------------------------------------------------------------
    56 address AbstractInterpreterGenerator::generate_slow_signature_handler() {
    57   address entry = __ pc();
    58   // rbx,: method
    59   // rcx: temporary
    60   // rdi: pointer to locals
    61   // rsp: end of copied parameters area
    62   __ mov(rcx, rsp);
    63   __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), rbx, rdi, rcx);
    64   __ ret(0);
    65   return entry;
    66 }
    69 //
    70 // Various method entries (that c++ and asm interpreter agree upon)
    71 //------------------------------------------------------------------------------------------------------------------------
    72 //
    73 //
    75 // Empty method, generate a very fast return.
    77 address InterpreterGenerator::generate_empty_entry(void) {
    79   // rbx,: Method*
    80   // rcx: receiver (unused)
    81   // rsi: previous interpreter state (C++ interpreter) must preserve
    82   // rsi: sender sp must set sp to this value on return
    84   if (!UseFastEmptyMethods) return NULL;
    86   address entry_point = __ pc();
    88   // If we need a safepoint check, generate full interpreter entry.
    89   Label slow_path;
    90   ExternalAddress state(SafepointSynchronize::address_of_state());
    91   __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
    92            SafepointSynchronize::_not_synchronized);
    93   __ jcc(Assembler::notEqual, slow_path);
    95   // do nothing for empty methods (do not even increment invocation counter)
    96   // Code: _return
    97   // _return
    98   // return w/o popping parameters
    99   __ pop(rax);
   100   __ mov(rsp, rsi);
   101   __ jmp(rax);
   103   __ bind(slow_path);
   104   (void) generate_normal_entry(false);
   105   return entry_point;
   106 }
   108 address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
   110   // rbx,: Method*
   111   // rcx: scratrch
   112   // rsi: sender sp
   114   if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
   116   address entry_point = __ pc();
   118   // These don't need a safepoint check because they aren't virtually
   119   // callable. We won't enter these intrinsics from compiled code.
   120   // If in the future we added an intrinsic which was virtually callable
   121   // we'd have to worry about how to safepoint so that this code is used.
   123   // mathematical functions inlined by compiler
   124   // (interpreter must provide identical implementation
   125   // in order to avoid monotonicity bugs when switching
   126   // from interpreter to compiler in the middle of some
   127   // computation)
   128   //
   129   // stack: [ ret adr ] <-- rsp
   130   //        [ lo(arg) ]
   131   //        [ hi(arg) ]
   132   //
   134   // Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are
   135   //       native methods. Interpreter::method_kind(...) does a check for
   136   //       native methods first before checking for intrinsic methods and
   137   //       thus will never select this entry point. Make sure it is not
   138   //       called accidentally since the SharedRuntime entry points will
   139   //       not work for JDK 1.2.
   140   //
   141   // We no longer need to check for JDK 1.2 since it's EOL'ed.
   142   // The following check existed in pre 1.6 implementation,
   143   //    if (Universe::is_jdk12x_version()) {
   144   //      __ should_not_reach_here();
   145   //    }
   146   // Universe::is_jdk12x_version() always returns false since
   147   // the JDK version is not yet determined when this method is called.
   148   // This method is called during interpreter_init() whereas
   149   // JDK version is only determined when universe2_init() is called.
   151   // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
   152   //       java methods.  Interpreter::method_kind(...) will select
   153   //       this entry point for the corresponding methods in JDK 1.3.
   154   // get argument
   155   __ fld_d(Address(rsp, 1*wordSize));
   156   switch (kind) {
   157     case Interpreter::java_lang_math_sin :
   158         __ trigfunc('s');
   159         break;
   160     case Interpreter::java_lang_math_cos :
   161         __ trigfunc('c');
   162         break;
   163     case Interpreter::java_lang_math_tan :
   164         __ trigfunc('t');
   165         break;
   166     case Interpreter::java_lang_math_sqrt:
   167         __ fsqrt();
   168         break;
   169     case Interpreter::java_lang_math_abs:
   170         __ fabs();
   171         break;
   172     case Interpreter::java_lang_math_log:
   173         __ flog();
   174         // Store to stack to convert 80bit precision back to 64bits
   175         __ push_fTOS();
   176         __ pop_fTOS();
   177         break;
   178     case Interpreter::java_lang_math_log10:
   179         __ flog10();
   180         // Store to stack to convert 80bit precision back to 64bits
   181         __ push_fTOS();
   182         __ pop_fTOS();
   183         break;
   184     case Interpreter::java_lang_math_pow:
   185       __ fld_d(Address(rsp, 3*wordSize)); // second argument
   186       __ pow_with_fallback(0);
   187       // Store to stack to convert 80bit precision back to 64bits
   188       __ push_fTOS();
   189       __ pop_fTOS();
   190       break;
   191     case Interpreter::java_lang_math_exp:
   192       __ exp_with_fallback(0);
   193       // Store to stack to convert 80bit precision back to 64bits
   194       __ push_fTOS();
   195       __ pop_fTOS();
   196       break;
   197     default                              :
   198         ShouldNotReachHere();
   199   }
   201   // return double result in xmm0 for interpreter and compilers.
   202   if (UseSSE >= 2) {
   203     __ subptr(rsp, 2*wordSize);
   204     __ fstp_d(Address(rsp, 0));
   205     __ movdbl(xmm0, Address(rsp, 0));
   206     __ addptr(rsp, 2*wordSize);
   207   }
   209   // done, result in FPU ST(0) or XMM0
   210   __ pop(rdi);                               // get return address
   211   __ mov(rsp, rsi);                          // set sp to sender sp
   212   __ jmp(rdi);
   214   return entry_point;
   215 }
   218 // Abstract method entry
   219 // Attempt to execute abstract method. Throw exception
   220 address InterpreterGenerator::generate_abstract_entry(void) {
   222   // rbx,: Method*
   223   // rcx: receiver (unused)
   224   // rsi: previous interpreter state (C++ interpreter) must preserve
   226   // rsi: sender SP
   228   address entry_point = __ pc();
   230   // abstract method entry
   232   //  pop return address, reset last_sp to NULL
   233   __ empty_expression_stack();
   234   __ restore_bcp();      // rsi must be correct for exception handler   (was destroyed)
   235   __ restore_locals();   // make sure locals pointer is correct as well (was destroyed)
   237   // throw exception
   238   __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
   239   // the call_VM checks for exception, so we should never return here.
   240   __ should_not_reach_here();
   242   return entry_point;
   243 }
   246 void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) {
   248   // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in
   249   // the days we had adapter frames. When we deoptimize a situation where a
   250   // compiled caller calls a compiled caller will have registers it expects
   251   // to survive the call to the callee. If we deoptimize the callee the only
   252   // way we can restore these registers is to have the oldest interpreter
   253   // frame that we create restore these values. That is what this routine
   254   // will accomplish.
   256   // At the moment we have modified c2 to not have any callee save registers
   257   // so this problem does not exist and this routine is just a place holder.
   259   assert(f->is_interpreted_frame(), "must be interpreted");
   260 }

mercurial