/* * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2010, 2015 Red Hat, Inc. * 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. *
*/
// Declaration and definition of StubGenerator (no .hpp file). // For a more detailed description of the stub routine structure // see the comment in stubRoutines.hpp
class StubGenerator: public StubCodeGenerator { private: // The call stub is used to call Java from C staticvoid call_stub(
JavaCallWrapper *call_wrapper,
intptr_t* result,
BasicType result_type,
Method* method,
address entry_point,
intptr_t* parameters, int parameter_words,
TRAPS) {
JavaThread *thread = THREAD;
ZeroStack *stack = thread->zero_stack();
// Make sure we have no pending exceptions
assert(!HAS_PENDING_EXCEPTION, "call_stub called with pending exception");
// Set up the stack if necessary bool stack_needs_teardown = false; if (stack->needs_setup()) {
size_t zero_stack_size = stack->suggest_size(thread);
stack->setup(alloca(zero_stack_size), zero_stack_size);
stack_needs_teardown = true;
}
if (!HAS_PENDING_EXCEPTION) { // Push the frame
thread->push_zero_frame(frame);
// Make the call
Interpreter::invoke_method(method, entry_point, THREAD);
// Store the result if (!HAS_PENDING_EXCEPTION) { switch (result_type) { case T_INT:
*(jint *) result = *(jint *) stack->sp(); break; case T_LONG:
*(jlong *) result = *(jlong *) stack->sp(); break; case T_FLOAT:
*(jfloat *) result = *(jfloat *) stack->sp(); break; case T_DOUBLE:
*(jdouble *) result = *(jdouble *) stack->sp(); break; case T_OBJECT:
*(oop *) result = *(oop *) stack->sp(); break; default:
ShouldNotReachHere();
}
}
// Unwind the frame
thread->pop_zero_frame();
}
// Tear down the stack if necessary if (stack_needs_teardown)
stack->teardown();
}
// These stubs get called from some dumb test routine. // I'll write them properly when they're called from // something that's actually doing something. staticvoid fake_arraycopy_stub(address src, address dst, int count) {
assert(count == 0, "huh?");
}
void generate_arraycopy_stubs() { // Call the conjoint generation methods immediately after // the disjoint ones so that short branches from the former // to the latter can be generated.
StubRoutines::_jbyte_disjoint_arraycopy = (address) fake_arraycopy_stub;
StubRoutines::_jbyte_arraycopy = (address) fake_arraycopy_stub;
// Shared code tests for "NULL" to discover the stub is not generated.
StubRoutines::_unsafe_arraycopy = NULL;
// We don't generate specialized code for HeapWord-aligned source // arrays, so just use the code we've already generated
StubRoutines::_arrayof_jbyte_disjoint_arraycopy =
StubRoutines::_jbyte_disjoint_arraycopy;
StubRoutines::_arrayof_jbyte_arraycopy =
StubRoutines::_jbyte_arraycopy;
void generate_initial() { // Generates all stubs and initializes the entry points
// entry points that exist in all platforms Note: This is code // that could be shared among different platforms - however the // benefit seems to be smaller than the disadvantage of having a // much more complicated generator structure. See also comment in // stubRoutines.hpp.
void generate_all() { // Generates all stubs and initializes the entry points
// These entry points require SharedInfo::stack0 to be set up in // non-core builds and need to be relocatable, so they each // fabricate a RuntimeStub internally.
StubRoutines::_throw_AbstractMethodError_entry =
ShouldNotCallThisStub();
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.