/* * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
// A JavaCallWrapper is constructed before each JavaCall and destructed after the call. // Its purpose is to allocate/deallocate a new handle block and to save/restore the last // Java fp/sp. A pointer to the JavaCallWrapper is stored on the stack.
class JavaCallWrapper: StackObj { friendclass VMStructs; private:
JavaThread* _thread; // the thread to which this call belongs
JNIHandleBlock* _handles; // the saved handle block
Method* _callee_method; // to be able to collect arguments if entry frame is top frame
oop _receiver; // the receiver of the call (if a non-static call)
JavaFrameAnchor _anchor; // last thread anchor state that we must restore
// Encapsulates arguments to a JavaCall (faster, safer, and more convenient than using var-args) class JavaCallArguments : public StackObj { private: enum Constants {
_default_size = 8 // Must be at least # of arguments in JavaCalls methods
};
intptr_t* _value;
u_char* _value_state; int _size; int _max_size; bool _start_at_zero; // Support late setting of receiver #if INCLUDE_JVMCI
Handle _alternative_target; // HotSpotNmethod wrapping an nmethod whose verified entry point // should be called instead of the normal target #endif
void initialize() { // Starts at first element to support set_receiver.
_value = &_value_buffer[1];
_value_state = &_value_state_buffer[1];
// The possible values for _value_state elements. enum {
value_state_primitive,
value_state_oop,
value_state_handle,
value_state_jobject,
value_state_limit
};
// receiver
Handle receiver() {
assert(_size > 0, "must at least be one argument");
assert(_value_state[0] == value_state_handle, "first argument must be an oop");
assert(_value[0] != 0, "receiver must be not-null"); return Handle((oop*)_value[0], false);
}
void set_receiver(Handle h) {
assert(_start_at_zero == false, "can only be called once");
_start_at_zero = true;
_value_state--;
_value--;
_size++;
_value_state[0] = value_state_handle;
int size = 0;
JNITypes::put_obj(h, _value, size);
}
// Converts all Handles to oops, and returns a reference to parameter vector
intptr_t* parameters() ; int size_of_parameters() const { return _size; }
// Verify that pushed arguments fits a given method void verify(const methodHandle& method, BasicType return_type);
};
// All calls to Java have to go via JavaCalls. Sets up the stack frame // and makes sure that the last_Java_frame pointers are chained correctly. //
class JavaCalls: AllStatic { staticvoid call_helper(JavaValue* result, const methodHandle& method, JavaCallArguments* args, TRAPS); public: // call_special // ------------ // The receiver must be first oop in argument list staticvoid call_special(JavaValue* result, Klass* klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS);
// The receiver must be first oop in argument list staticvoid call_virtual(JavaValue* result, Klass* spec_klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.