Wrapper for codegen_emit_stub_builtin.
- Returns:
- Pointer to the entrypoint of the stub.
-
*******************************************************************************/
void codegen_generate_stub_builtin(methodinfo *m, builtintable_entry *bte)
# if defined(ENABLE_INTRP)
if (!opt_intrp) {
# endif
- /* XXX This is only a hack for builtin_arraycopy and should be done better! */
- if (bte->flags & BUILTINTABLE_FLAG_EXCEPTION) {
- assert(bte->md->returntype.type == TYPE_VOID);
- bte->md->returntype.type = TYPE_INT;
- }
-
- codegen_emit_stub_builtin(jd, bte);
-
- /* XXX see above */
- if (bte->flags & BUILTINTABLE_FLAG_EXCEPTION) {
- bte->md->returntype.type = TYPE_VOID;
- }
+ assert(bte->fp != NULL);
+ codegen_emit_stub_native(jd, bte->md, bte->fp);
# if defined(ENABLE_INTRP)
}
# endif
size_stub_native += code->mcodelength;
#endif
+#if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER)
+ /* disassemble native stub */
+
+ if (opt_DisassembleStubs) {
+ codegen_disassemble_stub(m,
+ (u1 *) (ptrint) code->entrypoint,
+ (u1 *) (ptrint) code->entrypoint + (code->mcodelength - jd->cd->dseglen));
+
+ /* show data segment */
+
+ if (opt_showddatasegment)
+ dseg_display(jd);
+ }
+#endif /* !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) */
+
/* release memory */
dump_release(dumpsize);
size_stub_native += code->mcodelength;
#endif
-#if !defined(NDEBUG)
+#if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER)
/* disassemble native stub */
- if (opt_shownativestub) {
-#if defined(ENABLE_DEBUG_FILTER)
+ if (opt_DisassembleStubs) {
+# if defined(ENABLE_DEBUG_FILTER)
if (m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD)
-#endif
+# endif
{
-#if defined(ENABLE_DISASSEMBLER)
- codegen_disassemble_nativestub(m,
- (u1 *) (ptrint) code->entrypoint,
- (u1 *) (ptrint) code->entrypoint + (code->mcodelength - jd->cd->dseglen));
-#endif
+ codegen_disassemble_stub(m,
+ (u1 *) (ptrint) code->entrypoint,
+ (u1 *) (ptrint) code->entrypoint + (code->mcodelength - jd->cd->dseglen));
/* show data segment */
dseg_display(jd);
}
}
-#endif /* !defined(NDEBUG) */
+#endif /* !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) */
/* release memory */
/* codegen_disassemble_nativestub **********************************************
- Disassembles the generated native stub.
+ Disassembles the generated builtin or native stub.
*******************************************************************************/
#if defined(ENABLE_DISASSEMBLER)
-void codegen_disassemble_nativestub(methodinfo *m, u1 *start, u1 *end)
+void codegen_disassemble_stub(methodinfo *m, u1 *start, u1 *end)
{
- printf("Native stub: ");
- utf_fprint_printable_ascii_classname(stdout, m->class->name);
+ printf("Stub code: ");
+ if (m->class != NULL)
+ utf_fprint_printable_ascii_classname(stdout, m->class->name);
+ else
+ printf("NULL");
printf(".");
utf_fprint_printable_ascii(stdout, m->name);
utf_fprint_printable_ascii(stdout, m->descriptor);
- printf("\n\nLength: %d\n\n", (s4) (end - start));
+ printf("\nLength: %d\n\n", (s4) (end - start));
DISASSEMBLE(start, end);
}
#endif
-/* codegen_stub_builtin_enter **************************************************
-
- Prepares the stuff required for a builtin function call:
-
- - adds a stackframe info structure to the chain, for stacktraces
-
- The layout of the builtin stub stackframe should look like this:
-
- +---------------------------+ <- SP (of parent Java function)
- | return address |
- +---------------------------+
- | |
- | stackframe info structure |
- | |
- +---------------------------+
- | |
- | arguments (if any) |
- | |
- +---------------------------+ <- SP (native stub)
-
-*******************************************************************************/
-
-void codegen_stub_builtin_enter(u1 *datasp, u1 *pv, u1 *sp, u1 *ra)
-{
- stackframeinfo *sfi;
-
- /* get data structures from stack */
-
- sfi = (stackframeinfo *) (datasp - sizeof(stackframeinfo));
-
- /* add a stackframeinfo to the chain */
-
- stacktrace_create_native_stackframeinfo(sfi, pv, sp, ra);
-}
-
-
-/* codegen_stub_builtin_exit ***************************************************
-
- Removes the stuff required for a builtin function call.
-
-*******************************************************************************/
-
-void codegen_stub_builtin_exit(u1 *datasp)
-{
- stackframeinfo *sfi;
-
- /* get data structures from stack */
-
- sfi = (stackframeinfo *) (datasp - sizeof(stackframeinfo));
-
- /* remove current stackframeinfo from chain */
-
- stacktrace_remove_stackframeinfo(sfi);
-}
-
-
/* codegen_start_native_call ***************************************************
Prepares the stuff required for a native (JNI) function call:
stacktrace_create_native_stackframeinfo(sfi, pv, javasp, javara);
- /* return a wrapped classinfo for static methods */
+ /* return a wrapped classinfo for static native methods */
if (m->flags & ACC_STATIC)
return LLNI_classinfo_wrap(m->class);