Thu, 24 May 2018 20:03:11 +0800
Increase MaxHeapSize for better performance on MIPS
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@1 | 25 | /* |
aoqi@1 | 26 | * This file has been modified by Loongson Technology in 2015. These |
aoqi@1 | 27 | * modifications are Copyright (c) 2015 Loongson Technology, and are made |
aoqi@1 | 28 | * available on the same license terms set forth above. |
aoqi@1 | 29 | */ |
aoqi@1 | 30 | |
aoqi@0 | 31 | #ifndef SHARE_VM_RUNTIME_JAVACALLS_HPP |
aoqi@0 | 32 | #define SHARE_VM_RUNTIME_JAVACALLS_HPP |
aoqi@0 | 33 | |
aoqi@0 | 34 | #include "memory/allocation.hpp" |
aoqi@0 | 35 | #include "oops/method.hpp" |
aoqi@0 | 36 | #include "runtime/handles.hpp" |
aoqi@0 | 37 | #include "runtime/javaFrameAnchor.hpp" |
aoqi@0 | 38 | #include "runtime/thread.inline.hpp" |
aoqi@0 | 39 | #include "runtime/vmThread.hpp" |
aoqi@0 | 40 | #ifdef TARGET_ARCH_x86 |
aoqi@0 | 41 | # include "jniTypes_x86.hpp" |
aoqi@0 | 42 | #endif |
aoqi@0 | 43 | #ifdef TARGET_ARCH_sparc |
aoqi@0 | 44 | # include "jniTypes_sparc.hpp" |
aoqi@0 | 45 | #endif |
aoqi@0 | 46 | #ifdef TARGET_ARCH_zero |
aoqi@0 | 47 | # include "jniTypes_zero.hpp" |
aoqi@0 | 48 | #endif |
aoqi@0 | 49 | #ifdef TARGET_ARCH_arm |
aoqi@0 | 50 | # include "jniTypes_arm.hpp" |
aoqi@0 | 51 | #endif |
aoqi@0 | 52 | #ifdef TARGET_ARCH_ppc |
aoqi@0 | 53 | # include "jniTypes_ppc.hpp" |
aoqi@0 | 54 | #endif |
aoqi@1 | 55 | #ifdef TARGET_ARCH_mips |
aoqi@1 | 56 | # include "jniTypes_mips.hpp" |
aoqi@1 | 57 | #endif |
aoqi@0 | 58 | |
aoqi@0 | 59 | // A JavaCallWrapper is constructed before each JavaCall and destructed after the call. |
aoqi@0 | 60 | // Its purpose is to allocate/deallocate a new handle block and to save/restore the last |
aoqi@0 | 61 | // Java fp/sp. A pointer to the JavaCallWrapper is stored on the stack. |
aoqi@0 | 62 | |
aoqi@0 | 63 | class JavaCallWrapper: StackObj { |
aoqi@0 | 64 | friend class VMStructs; |
aoqi@0 | 65 | private: |
aoqi@0 | 66 | JavaThread* _thread; // the thread to which this call belongs |
aoqi@0 | 67 | JNIHandleBlock* _handles; // the saved handle block |
aoqi@0 | 68 | Method* _callee_method; // to be able to collect arguments if entry frame is top frame |
aoqi@0 | 69 | oop _receiver; // the receiver of the call (if a non-static call) |
aoqi@0 | 70 | |
aoqi@0 | 71 | JavaFrameAnchor _anchor; // last thread anchor state that we must restore |
aoqi@0 | 72 | |
aoqi@0 | 73 | JavaValue* _result; // result value |
aoqi@0 | 74 | |
aoqi@0 | 75 | public: |
aoqi@0 | 76 | // Construction/destruction |
aoqi@0 | 77 | JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS); |
aoqi@0 | 78 | ~JavaCallWrapper(); |
aoqi@0 | 79 | |
aoqi@0 | 80 | // Accessors |
aoqi@0 | 81 | JavaThread* thread() const { return _thread; } |
aoqi@0 | 82 | JNIHandleBlock* handles() const { return _handles; } |
aoqi@0 | 83 | |
aoqi@0 | 84 | JavaFrameAnchor* anchor(void) { return &_anchor; } |
aoqi@0 | 85 | |
aoqi@0 | 86 | JavaValue* result() const { return _result; } |
aoqi@0 | 87 | // GC support |
aoqi@0 | 88 | Method* callee_method() { return _callee_method; } |
aoqi@0 | 89 | oop receiver() { return _receiver; } |
aoqi@0 | 90 | void oops_do(OopClosure* f); |
aoqi@0 | 91 | |
aoqi@0 | 92 | bool is_first_frame() const { return _anchor.last_Java_sp() == NULL; } |
aoqi@0 | 93 | |
aoqi@0 | 94 | }; |
aoqi@0 | 95 | |
aoqi@0 | 96 | |
aoqi@0 | 97 | // Encapsulates arguments to a JavaCall (faster, safer, and more convenient than using var-args) |
aoqi@0 | 98 | class JavaCallArguments : public StackObj { |
aoqi@0 | 99 | private: |
aoqi@0 | 100 | enum Constants { |
aoqi@0 | 101 | _default_size = 8 // Must be at least # of arguments in JavaCalls methods |
aoqi@0 | 102 | }; |
aoqi@0 | 103 | |
aoqi@0 | 104 | intptr_t _value_buffer [_default_size + 1]; |
aoqi@0 | 105 | bool _is_oop_buffer[_default_size + 1]; |
aoqi@0 | 106 | |
aoqi@0 | 107 | intptr_t* _value; |
aoqi@0 | 108 | bool* _is_oop; |
aoqi@0 | 109 | int _size; |
aoqi@0 | 110 | int _max_size; |
aoqi@0 | 111 | bool _start_at_zero; // Support late setting of receiver |
aoqi@0 | 112 | |
aoqi@0 | 113 | void initialize() { |
aoqi@0 | 114 | // Starts at first element to support set_receiver. |
aoqi@0 | 115 | _value = &_value_buffer[1]; |
aoqi@0 | 116 | _is_oop = &_is_oop_buffer[1]; |
aoqi@0 | 117 | |
aoqi@0 | 118 | _max_size = _default_size; |
aoqi@0 | 119 | _size = 0; |
aoqi@0 | 120 | _start_at_zero = false; |
aoqi@0 | 121 | } |
aoqi@0 | 122 | |
aoqi@0 | 123 | public: |
aoqi@0 | 124 | JavaCallArguments() { initialize(); } |
aoqi@0 | 125 | |
aoqi@0 | 126 | JavaCallArguments(Handle receiver) { |
aoqi@0 | 127 | initialize(); |
aoqi@0 | 128 | push_oop(receiver); |
aoqi@0 | 129 | } |
aoqi@0 | 130 | |
aoqi@0 | 131 | JavaCallArguments(int max_size) { |
aoqi@0 | 132 | if (max_size > _default_size) { |
aoqi@0 | 133 | _value = NEW_RESOURCE_ARRAY(intptr_t, max_size + 1); |
aoqi@0 | 134 | _is_oop = NEW_RESOURCE_ARRAY(bool, max_size + 1); |
aoqi@0 | 135 | |
aoqi@0 | 136 | // Reserve room for potential receiver in value and is_oop |
aoqi@0 | 137 | _value++; _is_oop++; |
aoqi@0 | 138 | |
aoqi@0 | 139 | _max_size = max_size; |
aoqi@0 | 140 | _size = 0; |
aoqi@0 | 141 | _start_at_zero = false; |
aoqi@0 | 142 | } else { |
aoqi@0 | 143 | initialize(); |
aoqi@0 | 144 | } |
aoqi@0 | 145 | } |
aoqi@0 | 146 | |
aoqi@0 | 147 | inline void push_oop(Handle h) { _is_oop[_size] = true; |
aoqi@0 | 148 | JNITypes::put_obj((oop)h.raw_value(), _value, _size); } |
aoqi@0 | 149 | |
aoqi@0 | 150 | inline void push_int(int i) { _is_oop[_size] = false; |
aoqi@0 | 151 | JNITypes::put_int(i, _value, _size); } |
aoqi@0 | 152 | |
aoqi@0 | 153 | inline void push_double(double d) { _is_oop[_size] = false; _is_oop[_size + 1] = false; |
aoqi@0 | 154 | JNITypes::put_double(d, _value, _size); } |
aoqi@0 | 155 | |
aoqi@0 | 156 | inline void push_long(jlong l) { _is_oop[_size] = false; _is_oop[_size + 1] = false; |
aoqi@0 | 157 | JNITypes::put_long(l, _value, _size); } |
aoqi@0 | 158 | |
aoqi@0 | 159 | inline void push_float(float f) { _is_oop[_size] = false; |
aoqi@0 | 160 | JNITypes::put_float(f, _value, _size); } |
aoqi@0 | 161 | |
aoqi@0 | 162 | // receiver |
aoqi@0 | 163 | Handle receiver() { |
aoqi@0 | 164 | assert(_size > 0, "must at least be one argument"); |
aoqi@0 | 165 | assert(_is_oop[0], "first argument must be an oop"); |
aoqi@0 | 166 | assert(_value[0] != 0, "receiver must be not-null"); |
aoqi@0 | 167 | return Handle((oop*)_value[0], false); |
aoqi@0 | 168 | } |
aoqi@0 | 169 | |
aoqi@0 | 170 | void set_receiver(Handle h) { |
aoqi@0 | 171 | assert(_start_at_zero == false, "can only be called once"); |
aoqi@0 | 172 | _start_at_zero = true; |
aoqi@0 | 173 | _is_oop--; |
aoqi@0 | 174 | _value--; |
aoqi@0 | 175 | _size++; |
aoqi@0 | 176 | _is_oop[0] = true; |
aoqi@0 | 177 | _value[0] = (intptr_t)h.raw_value(); |
aoqi@0 | 178 | } |
aoqi@0 | 179 | |
aoqi@0 | 180 | // Converts all Handles to oops, and returns a reference to parameter vector |
aoqi@0 | 181 | intptr_t* parameters() ; |
aoqi@0 | 182 | int size_of_parameters() const { return _size; } |
aoqi@0 | 183 | |
aoqi@0 | 184 | // Verify that pushed arguments fits a given method |
aoqi@0 | 185 | void verify(methodHandle method, BasicType return_type, Thread *thread); |
aoqi@0 | 186 | }; |
aoqi@0 | 187 | |
aoqi@0 | 188 | // All calls to Java have to go via JavaCalls. Sets up the stack frame |
aoqi@0 | 189 | // and makes sure that the last_Java_frame pointers are chained correctly. |
aoqi@0 | 190 | // |
aoqi@0 | 191 | |
aoqi@0 | 192 | class JavaCalls: AllStatic { |
aoqi@0 | 193 | static void call_helper(JavaValue* result, methodHandle* method, JavaCallArguments* args, TRAPS); |
aoqi@0 | 194 | public: |
aoqi@0 | 195 | // Optimized Constuctor call |
aoqi@0 | 196 | static void call_default_constructor(JavaThread* thread, methodHandle method, Handle receiver, TRAPS); |
aoqi@0 | 197 | |
aoqi@0 | 198 | // call_special |
aoqi@0 | 199 | // ------------ |
aoqi@0 | 200 | // The receiver must be first oop in argument list |
aoqi@0 | 201 | static void call_special(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS); |
aoqi@0 | 202 | |
aoqi@0 | 203 | static void call_special(JavaValue* result, Handle receiver, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); // No args |
aoqi@0 | 204 | static void call_special(JavaValue* result, Handle receiver, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS); |
aoqi@0 | 205 | static void call_special(JavaValue* result, Handle receiver, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS); |
aoqi@0 | 206 | |
aoqi@0 | 207 | // virtual call |
aoqi@0 | 208 | // ------------ |
aoqi@0 | 209 | |
aoqi@0 | 210 | // The receiver must be first oop in argument list |
aoqi@0 | 211 | static void call_virtual(JavaValue* result, KlassHandle spec_klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS); |
aoqi@0 | 212 | |
aoqi@0 | 213 | static void call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, Symbol* name, Symbol* signature, TRAPS); // No args |
aoqi@0 | 214 | static void call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS); |
aoqi@0 | 215 | static void call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS); |
aoqi@0 | 216 | |
aoqi@0 | 217 | // Static call |
aoqi@0 | 218 | // ----------- |
aoqi@0 | 219 | static void call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS); |
aoqi@0 | 220 | |
aoqi@0 | 221 | static void call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); |
aoqi@0 | 222 | static void call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS); |
aoqi@0 | 223 | static void call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS); |
aoqi@0 | 224 | |
aoqi@0 | 225 | // Low-level interface |
aoqi@0 | 226 | static void call(JavaValue* result, methodHandle method, JavaCallArguments* args, TRAPS); |
aoqi@0 | 227 | }; |
aoqi@0 | 228 | |
aoqi@0 | 229 | #endif // SHARE_VM_RUNTIME_JAVACALLS_HPP |