src/share/vm/interpreter/interpreterRuntime.hpp

Fri, 29 Apr 2016 00:06:10 +0800

author
aoqi
date
Fri, 29 Apr 2016 00:06:10 +0800
changeset 1
2d8a650513c2
parent 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Added MIPS 64-bit port.

     1 /*
     2  * Copyright (c) 1997, 2013, 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 /*
    26  * This file has been modified by Loongson Technology in 2015. These
    27  * modifications are Copyright (c) 2015 Loongson Technology, and are made
    28  * available on the same license terms set forth above.
    29  */
    31 #ifndef SHARE_VM_INTERPRETER_INTERPRETERRUNTIME_HPP
    32 #define SHARE_VM_INTERPRETER_INTERPRETERRUNTIME_HPP
    34 #include "interpreter/bytecode.hpp"
    35 #include "interpreter/linkResolver.hpp"
    36 #include "memory/universe.hpp"
    37 #include "oops/method.hpp"
    38 #include "runtime/frame.inline.hpp"
    39 #include "runtime/signature.hpp"
    40 #include "runtime/thread.inline.hpp"
    41 #include "utilities/top.hpp"
    43 // The InterpreterRuntime is called by the interpreter for everything
    44 // that cannot/should not be dealt with in assembly and needs C support.
    46 class InterpreterRuntime: AllStatic {
    47   friend class BytecodeClosure; // for method and bcp
    48   friend class PrintingClosure; // for method and bcp
    50  private:
    51   // Helper functions to access current interpreter state
    52   static frame     last_frame(JavaThread *thread)    { return thread->last_frame(); }
    53   static Method*   method(JavaThread *thread)        { return last_frame(thread).interpreter_frame_method(); }
    54   static address   bcp(JavaThread *thread)           { return last_frame(thread).interpreter_frame_bcp(); }
    55   static int       bci(JavaThread *thread)           { return last_frame(thread).interpreter_frame_bci(); }
    56   static void      set_bcp_and_mdp(address bcp, JavaThread*thread);
    57   static Bytecodes::Code code(JavaThread *thread)    {
    58     // pass method to avoid calling unsafe bcp_to_method (partial fix 4926272)
    59     return Bytecodes::code_at(method(thread), bcp(thread));
    60   }
    61   static bool      already_resolved(JavaThread *thread) { return cache_entry(thread)->is_resolved(code(thread)); }
    62   static Bytecode  bytecode(JavaThread *thread)      { return Bytecode(method(thread), bcp(thread)); }
    63   static int       get_index_u1(JavaThread *thread, Bytecodes::Code bc)
    64                                                         { return bytecode(thread).get_index_u1(bc); }
    65   static int       get_index_u2(JavaThread *thread, Bytecodes::Code bc)
    66                                                         { return bytecode(thread).get_index_u2(bc); }
    67   static int       get_index_u2_cpcache(JavaThread *thread, Bytecodes::Code bc)
    68                                                         { return bytecode(thread).get_index_u2_cpcache(bc); }
    69   static int       get_index_u4(JavaThread *thread, Bytecodes::Code bc)
    70                                                         { return bytecode(thread).get_index_u4(bc); }
    71   static int       number_of_dimensions(JavaThread *thread)  { return bcp(thread)[3]; }
    73   static ConstantPoolCacheEntry* cache_entry_at(JavaThread *thread, int i)  { return method(thread)->constants()->cache()->entry_at(i); }
    74   static ConstantPoolCacheEntry* cache_entry(JavaThread *thread)            { return cache_entry_at(thread, Bytes::get_native_u2(bcp(thread) + 1)); }
    75   static void      note_trap_inner(JavaThread* thread, int reason,
    76                                    methodHandle trap_method, int trap_bci, TRAPS);
    77   static void      note_trap(JavaThread *thread, int reason, TRAPS);
    78 #ifdef CC_INTERP
    79   // Profile traps in C++ interpreter.
    80   static void      note_trap(JavaThread* thread, int reason, Method *method, int trap_bci);
    81 #endif // CC_INTERP
    83   // Inner work method for Interpreter's frequency counter overflow.
    84   static nmethod* frequency_counter_overflow_inner(JavaThread* thread, address branch_bcp);
    86  public:
    87   // Constants
    88   static void    ldc           (JavaThread* thread, bool wide);
    89   static void    resolve_ldc   (JavaThread* thread, Bytecodes::Code bytecode);
    91   // Allocation
    92   static void    _new          (JavaThread* thread, ConstantPool* pool, int index);
    93   static void    newarray      (JavaThread* thread, BasicType type, jint size);
    94   static void    anewarray     (JavaThread* thread, ConstantPool* pool, int index, jint size);
    95   static void    multianewarray(JavaThread* thread, jint* first_size_address);
    96   static void    register_finalizer(JavaThread* thread, oopDesc* obj);
    98   // Quicken instance-of and check-cast bytecodes
    99   static void    quicken_io_cc(JavaThread* thread);
   101   // Exceptions thrown by the interpreter
   102   static void    throw_AbstractMethodError(JavaThread* thread);
   103   static void    throw_IncompatibleClassChangeError(JavaThread* thread);
   104   static void    throw_StackOverflowError(JavaThread* thread);
   105   static void    throw_ArrayIndexOutOfBoundsException(JavaThread* thread, char* name, jint index);
   106   static void    throw_ClassCastException(JavaThread* thread, oopDesc* obj);
   107   static void    create_exception(JavaThread* thread, char* name, char* message);
   108   static void    create_klass_exception(JavaThread* thread, char* name, oopDesc* obj);
   109   static address exception_handler_for_exception(JavaThread* thread, oopDesc* exception);
   110 #if INCLUDE_JVMTI
   111   static void    member_name_arg_or_null(JavaThread* thread, address dmh, Method* m, address bcp);
   112 #endif
   113   static void    throw_pending_exception(JavaThread* thread);
   115 #ifdef CC_INTERP
   116   // Profile traps in C++ interpreter.
   117   static void    note_nullCheck_trap (JavaThread* thread, Method *method, int trap_bci);
   118   static void    note_div0Check_trap (JavaThread* thread, Method *method, int trap_bci);
   119   static void    note_rangeCheck_trap(JavaThread* thread, Method *method, int trap_bci);
   120   static void    note_classCheck_trap(JavaThread* thread, Method *method, int trap_bci);
   121   static void    note_arrayCheck_trap(JavaThread* thread, Method *method, int trap_bci);
   122   // A dummy for makros that shall not profile traps.
   123   static void    note_no_trap(JavaThread* thread, Method *method, int trap_bci) {}
   124 #endif // CC_INTERP
   126   // Statics & fields
   127   static void    resolve_get_put(JavaThread* thread, Bytecodes::Code bytecode);
   129   // Synchronization
   130   static void    monitorenter(JavaThread* thread, BasicObjectLock* elem);
   131   static void    monitorexit (JavaThread* thread, BasicObjectLock* elem);
   133   static void    throw_illegal_monitor_state_exception(JavaThread* thread);
   134   static void    new_illegal_monitor_state_exception(JavaThread* thread);
   136   // Calls
   137   static void    resolve_invoke       (JavaThread* thread, Bytecodes::Code bytecode);
   138   static void    resolve_invokehandle (JavaThread* thread);
   139   static void    resolve_invokedynamic(JavaThread* thread);
   141   // Breakpoints
   142   static void _breakpoint(JavaThread* thread, Method* method, address bcp);
   143   static Bytecodes::Code get_original_bytecode_at(JavaThread* thread, Method* method, address bcp);
   144   static void            set_original_bytecode_at(JavaThread* thread, Method* method, address bcp, Bytecodes::Code new_code);
   145   static bool is_breakpoint(JavaThread *thread) { return Bytecodes::code_or_bp_at(bcp(thread)) == Bytecodes::_breakpoint; }
   147   // Safepoints
   148   static void    at_safepoint(JavaThread* thread);
   150   // Debugger support
   151   static void post_field_access(JavaThread *thread, oopDesc* obj,
   152     ConstantPoolCacheEntry *cp_entry);
   153   static void post_field_modification(JavaThread *thread, oopDesc* obj,
   154     ConstantPoolCacheEntry *cp_entry, jvalue *value);
   155   static void post_method_entry(JavaThread *thread);
   156   static void post_method_exit (JavaThread *thread);
   157   static int  interpreter_contains(address pc);
   159   // Native signature handlers
   160   static void prepare_native_call(JavaThread* thread, Method* method);
   161   static address slow_signature_handler(JavaThread* thread,
   162                                         Method* method,
   163                                         intptr_t* from, intptr_t* to);
   165 #if defined(IA32) || defined(AMD64) || defined(ARM) || defined(MIPS64)
   166   // Popframe support (only needed on x86, AMD64 and ARM)
   167   static void popframe_move_outgoing_args(JavaThread* thread, void* src_address, void* dest_address);
   168 #endif
   170   // Platform dependent stuff
   171 #ifdef TARGET_ARCH_x86
   172 # include "interpreterRT_x86.hpp"
   173 #endif
   174 #ifdef TARGET_ARCH_mips
   175 # include "interpreterRT_mips.hpp"
   176 #endif
   177 #ifdef TARGET_ARCH_sparc
   178 # include "interpreterRT_sparc.hpp"
   179 #endif
   180 #ifdef TARGET_ARCH_zero
   181 # include "interpreterRT_zero.hpp"
   182 #endif
   183 #ifdef TARGET_ARCH_arm
   184 # include "interpreterRT_arm.hpp"
   185 #endif
   186 #ifdef TARGET_ARCH_ppc
   187 # include "interpreterRT_ppc.hpp"
   188 #endif
   191   // Interpreter's frequency counter overflow
   192   static nmethod* frequency_counter_overflow(JavaThread* thread, address branch_bcp);
   194   // Interpreter profiling support
   195   static jint    bcp_to_di(Method* method, address cur_bcp);
   196   static void    profile_method(JavaThread* thread);
   197   static void    update_mdp_for_ret(JavaThread* thread, int bci);
   198 #ifdef ASSERT
   199   static void    verify_mdp(Method* method, address bcp, address mdp);
   200 #endif // ASSERT
   201   static MethodCounters* build_method_counters(JavaThread* thread, Method* m);
   202 };
   205 class SignatureHandlerLibrary: public AllStatic {
   206  public:
   207   enum { buffer_size =  1*K }; // the size of the temporary code buffer
   208   enum { blob_size   = 32*K }; // the size of a handler code blob.
   210  private:
   211   static BufferBlob*              _handler_blob; // the current buffer blob containing the generated handlers
   212   static address                  _handler;      // next available address within _handler_blob;
   213   static GrowableArray<uint64_t>* _fingerprints; // the fingerprint collection
   214   static GrowableArray<address>*  _handlers;     // the corresponding handlers
   215   static address                  _buffer;       // the temporary code buffer
   217   static address set_handler_blob();
   218   static void initialize();
   219   static address set_handler(CodeBuffer* buffer);
   220   static void pd_set_handler(address handler);
   222  public:
   223   static void add(methodHandle method);
   224 };
   226 #endif // SHARE_VM_INTERPRETER_INTERPRETERRUNTIME_HPP

mercurial