src/share/vm/runtime/javaCalls.hpp

Thu, 24 May 2018 20:03:11 +0800

author
aoqi
date
Thu, 24 May 2018 20:03:11 +0800
changeset 8868
91ddc23482a4
parent 6876
710a3c8b516e
child 9703
2fdf635bcf28
permissions
-rw-r--r--

Increase MaxHeapSize for better performance on MIPS

     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_RUNTIME_JAVACALLS_HPP
    32 #define SHARE_VM_RUNTIME_JAVACALLS_HPP
    34 #include "memory/allocation.hpp"
    35 #include "oops/method.hpp"
    36 #include "runtime/handles.hpp"
    37 #include "runtime/javaFrameAnchor.hpp"
    38 #include "runtime/thread.inline.hpp"
    39 #include "runtime/vmThread.hpp"
    40 #ifdef TARGET_ARCH_x86
    41 # include "jniTypes_x86.hpp"
    42 #endif
    43 #ifdef TARGET_ARCH_sparc
    44 # include "jniTypes_sparc.hpp"
    45 #endif
    46 #ifdef TARGET_ARCH_zero
    47 # include "jniTypes_zero.hpp"
    48 #endif
    49 #ifdef TARGET_ARCH_arm
    50 # include "jniTypes_arm.hpp"
    51 #endif
    52 #ifdef TARGET_ARCH_ppc
    53 # include "jniTypes_ppc.hpp"
    54 #endif
    55 #ifdef TARGET_ARCH_mips
    56 # include "jniTypes_mips.hpp"
    57 #endif
    59 // A JavaCallWrapper is constructed before each JavaCall and destructed after the call.
    60 // Its purpose is to allocate/deallocate a new handle block and to save/restore the last
    61 // Java fp/sp. A pointer to the JavaCallWrapper is stored on the stack.
    63 class JavaCallWrapper: StackObj {
    64   friend class VMStructs;
    65  private:
    66   JavaThread*      _thread;                 // the thread to which this call belongs
    67   JNIHandleBlock*  _handles;                // the saved handle block
    68   Method*          _callee_method;          // to be able to collect arguments if entry frame is top frame
    69   oop              _receiver;               // the receiver of the call (if a non-static call)
    71   JavaFrameAnchor  _anchor;                 // last thread anchor state that we must restore
    73   JavaValue*       _result;                 // result value
    75  public:
    76   // Construction/destruction
    77    JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS);
    78   ~JavaCallWrapper();
    80   // Accessors
    81   JavaThread*      thread() const           { return _thread; }
    82   JNIHandleBlock*  handles() const          { return _handles; }
    84   JavaFrameAnchor* anchor(void)             { return &_anchor; }
    86   JavaValue*       result() const           { return _result; }
    87   // GC support
    88   Method*          callee_method()          { return _callee_method; }
    89   oop              receiver()               { return _receiver; }
    90   void             oops_do(OopClosure* f);
    92   bool             is_first_frame() const   { return _anchor.last_Java_sp() == NULL; }
    94 };
    97 // Encapsulates arguments to a JavaCall (faster, safer, and more convenient than using var-args)
    98 class JavaCallArguments : public StackObj {
    99  private:
   100   enum Constants {
   101    _default_size = 8    // Must be at least # of arguments in JavaCalls methods
   102   };
   104   intptr_t    _value_buffer [_default_size + 1];
   105   bool        _is_oop_buffer[_default_size + 1];
   107   intptr_t*   _value;
   108   bool*       _is_oop;
   109   int         _size;
   110   int         _max_size;
   111   bool        _start_at_zero;      // Support late setting of receiver
   113   void initialize() {
   114     // Starts at first element to support set_receiver.
   115     _value    = &_value_buffer[1];
   116     _is_oop   = &_is_oop_buffer[1];
   118     _max_size = _default_size;
   119     _size = 0;
   120     _start_at_zero = false;
   121   }
   123  public:
   124   JavaCallArguments() { initialize(); }
   126   JavaCallArguments(Handle receiver) {
   127     initialize();
   128     push_oop(receiver);
   129   }
   131   JavaCallArguments(int max_size) {
   132     if (max_size > _default_size) {
   133       _value  = NEW_RESOURCE_ARRAY(intptr_t, max_size + 1);
   134       _is_oop = NEW_RESOURCE_ARRAY(bool, max_size + 1);
   136       // Reserve room for potential receiver in value and is_oop
   137       _value++; _is_oop++;
   139       _max_size = max_size;
   140       _size = 0;
   141       _start_at_zero = false;
   142     } else {
   143       initialize();
   144     }
   145   }
   147   inline void push_oop(Handle h)    { _is_oop[_size] = true;
   148                                JNITypes::put_obj((oop)h.raw_value(), _value, _size); }
   150   inline void push_int(int i)       { _is_oop[_size] = false;
   151                                JNITypes::put_int(i, _value, _size); }
   153   inline void push_double(double d) { _is_oop[_size] = false; _is_oop[_size + 1] = false;
   154                                JNITypes::put_double(d, _value, _size); }
   156   inline void push_long(jlong l)    { _is_oop[_size] = false; _is_oop[_size + 1] = false;
   157                                JNITypes::put_long(l, _value, _size); }
   159   inline void push_float(float f)   { _is_oop[_size] = false;
   160                                JNITypes::put_float(f, _value, _size); }
   162   // receiver
   163   Handle receiver() {
   164     assert(_size > 0, "must at least be one argument");
   165     assert(_is_oop[0], "first argument must be an oop");
   166     assert(_value[0] != 0, "receiver must be not-null");
   167     return Handle((oop*)_value[0], false);
   168   }
   170   void set_receiver(Handle h) {
   171     assert(_start_at_zero == false, "can only be called once");
   172     _start_at_zero = true;
   173     _is_oop--;
   174     _value--;
   175     _size++;
   176     _is_oop[0] = true;
   177     _value[0] = (intptr_t)h.raw_value();
   178   }
   180   // Converts all Handles to oops, and returns a reference to parameter vector
   181   intptr_t* parameters() ;
   182   int   size_of_parameters() const { return _size; }
   184   // Verify that pushed arguments fits a given method
   185   void verify(methodHandle method, BasicType return_type, Thread *thread);
   186 };
   188 // All calls to Java have to go via JavaCalls. Sets up the stack frame
   189 // and makes sure that the last_Java_frame pointers are chained correctly.
   190 //
   192 class JavaCalls: AllStatic {
   193   static void call_helper(JavaValue* result, methodHandle* method, JavaCallArguments* args, TRAPS);
   194  public:
   195   // Optimized Constuctor call
   196   static void call_default_constructor(JavaThread* thread, methodHandle method, Handle receiver, TRAPS);
   198   // call_special
   199   // ------------
   200   // The receiver must be first oop in argument list
   201   static void call_special(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS);
   203   static void call_special(JavaValue* result, Handle receiver, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); // No args
   204   static void call_special(JavaValue* result, Handle receiver, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS);
   205   static void call_special(JavaValue* result, Handle receiver, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS);
   207   // virtual call
   208   // ------------
   210   // The receiver must be first oop in argument list
   211   static void call_virtual(JavaValue* result, KlassHandle spec_klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS);
   213   static void call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, Symbol* name, Symbol* signature, TRAPS); // No args
   214   static void call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS);
   215   static void call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS);
   217   // Static call
   218   // -----------
   219   static void call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS);
   221   static void call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS);
   222   static void call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS);
   223   static void call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS);
   225   // Low-level interface
   226   static void call(JavaValue* result, methodHandle method, JavaCallArguments* args, TRAPS);
   227 };
   229 #endif // SHARE_VM_RUNTIME_JAVACALLS_HPP

mercurial