26
#include "precompiled.hpp"
27
#include "interpreter/interpreter.hpp"
28
#include "interpreter/interpreterRuntime.hpp"
29
#include "memory/allocation.inline.hpp"
30
#include "oops/method.hpp"
31
#include "oops/oop.inline.hpp"
32
#include "runtime/handles.inline.hpp"
33
#include "runtime/icache.hpp"
34
#include "runtime/interfaceSupport.inline.hpp"
35
#include "runtime/signature.hpp"
36
#include "stack_zero.inline.hpp"
37
#include "utilities/align.hpp"
39
void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_int() {
44
void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_long() {
49
void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_float() {
54
void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_double() {
59
void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_object() {
64
void InterpreterRuntime::SignatureHandlerGeneratorBase::push(BasicType type) {
65
ffi_type *ftype = nullptr;
68
ftype = &ffi_type_void;
72
ftype = &ffi_type_uint8;
76
ftype = &ffi_type_uint16;
80
ftype = &ffi_type_sint8;
84
ftype = &ffi_type_sint16;
88
ftype = &ffi_type_sint32;
92
ftype = &ffi_type_sint64;
96
ftype = &ffi_type_float;
100
ftype = &ffi_type_double;
105
ftype = &ffi_type_pointer;
109
ShouldNotReachHere();
111
push((intptr_t) ftype);
119
void InterpreterRuntime::SignatureHandlerGeneratorBase::generate(
120
uint64_t fingerprint) {
124
if (method()->is_static())
126
iterate(fingerprint);
129
push(method()->result_type());
132
InterpreterRuntime::SignatureHandlerGenerator::SignatureHandlerGenerator(const methodHandle& method, CodeBuffer* buffer)
133
: SignatureHandlerGeneratorBase(method, (ffi_cif *) buffer->insts_end()),
135
_cb->set_insts_end((address) (cif() + 1));
138
void InterpreterRuntime::SignatureHandlerGenerator::push(intptr_t value) {
139
intptr_t *dst = (intptr_t *) _cb->insts_end();
140
_cb->set_insts_end((address) (dst + 1));
144
void InterpreterRuntime::SignatureHandler::finalize() {
152
assert(status == FFI_OK, "should be");
156
InterpreterRuntime::slow_signature_handler(JavaThread* current,
160
ZeroStack *stack = current->zero_stack();
163
(align_up(sizeof(ffi_cif), wordSize) >> LogBytesPerWord) +
164
(method->is_static() ? 2 : 1) + method->size_of_parameters() + 1;
166
stack->overflow_check(required_words, CHECK_NULL);
168
intptr_t *buf = (intptr_t *) stack->alloc(required_words * wordSize);
169
SlowSignatureHandlerGenerator sshg(methodHandle(current, method), buf);
170
sshg.generate((uint64_t)CONST64(-1));
172
SignatureHandler *handler = sshg.handler();
175
return (address) handler;
178
void SignatureHandlerLibrary::pd_set_handler(address handlerAddr) {
179
InterpreterRuntime::SignatureHandler *handler =
180
InterpreterRuntime::SignatureHandler::from_handlerAddr(handlerAddr);