8289780: Avoid formatting stub names when Forte is not enabled

Reviewed-by: dholmes, coleenp, sspitsyn
This commit is contained in:
Ioi Lam 2022-07-09 03:47:20 +00:00
parent 54b4576f78
commit 3c08e6b311
5 changed files with 33 additions and 18 deletions

View File

@ -195,7 +195,9 @@ void RuntimeBlob::trace_new_stub(RuntimeBlob* stub, const char* name1, const cha
// Do not hold the CodeCache lock during name formatting. // Do not hold the CodeCache lock during name formatting.
assert(!CodeCache_lock->owned_by_self(), "release CodeCache before registering the stub"); assert(!CodeCache_lock->owned_by_self(), "release CodeCache before registering the stub");
if (stub != NULL) { if (stub != NULL && (PrintStubCode ||
Forte::is_enabled() ||
JvmtiExport::should_post_dynamic_code_generated())) {
char stub_id[256]; char stub_id[256];
assert(strlen(name1) + strlen(name2) < sizeof(stub_id), ""); assert(strlen(name1) + strlen(name2) < sizeof(stub_id), "");
jio_snprintf(stub_id, sizeof(stub_id), "%s%s", name1, name2); jio_snprintf(stub_id, sizeof(stub_id), "%s%s", name1, name2);
@ -212,7 +214,9 @@ void RuntimeBlob::trace_new_stub(RuntimeBlob* stub, const char* name1, const cha
tty->print_cr("- - - [END] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"); tty->print_cr("- - - [END] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
tty->cr(); tty->cr();
} }
if (Forte::is_enabled()) {
Forte::register_stub(stub_id, stub->code_begin(), stub->code_end()); Forte::register_stub(stub_id, stub->code_begin(), stub->code_end());
}
if (JvmtiExport::should_post_dynamic_code_generated()) { if (JvmtiExport::should_post_dynamic_code_generated()) {
const char* stub_name = name2; const char* stub_name = name2;

View File

@ -41,7 +41,6 @@
#include "oops/methodData.hpp" #include "oops/methodData.hpp"
#include "oops/method.inline.hpp" #include "oops/method.inline.hpp"
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
#include "prims/forte.hpp"
#include "prims/jvmtiExport.hpp" #include "prims/jvmtiExport.hpp"
#include "prims/methodHandles.hpp" #include "prims/methodHandles.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"

View File

@ -71,8 +71,6 @@ enum {
// Native interfaces for use by Forte tools. // Native interfaces for use by Forte tools.
#if !defined(IA64)
class vframeStreamForte : public vframeStreamCommon { class vframeStreamForte : public vframeStreamCommon {
public: public:
// constructor that starts with sender of frame fr (top_frame) // constructor that starts with sender of frame fr (top_frame)
@ -673,6 +671,7 @@ void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) {
// XXXDARWIN: Link errors occur even when __attribute__((weak_import)) // XXXDARWIN: Link errors occur even when __attribute__((weak_import))
// is added // is added
#define collector_func_load(x0,x1,x2,x3,x4,x5,x6) ((void) 0) #define collector_func_load(x0,x1,x2,x3,x4,x5,x6) ((void) 0)
#define collector_func_load_enabled() false
#else #else
void collector_func_load(char* name, void collector_func_load(char* name,
void* null_argument_1, void* null_argument_1,
@ -684,20 +683,28 @@ void collector_func_load(char* name,
#pragma weak collector_func_load #pragma weak collector_func_load
#define collector_func_load(x0,x1,x2,x3,x4,x5,x6) \ #define collector_func_load(x0,x1,x2,x3,x4,x5,x6) \
( collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6),(void)0 : (void)0 ) ( collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6),(void)0 : (void)0 )
#define collector_func_load_enabled() (collector_func_load ? true : false)
#endif // __APPLE__ #endif // __APPLE__
#endif // !_WINDOWS #endif // !_WINDOWS
} // end extern "C" } // end extern "C"
#endif // !IA64
bool Forte::is_enabled() {
#if !defined(_WINDOWS)
return collector_func_load_enabled();
#else
return false;
#endif
}
void Forte::register_stub(const char* name, address start, address end) { void Forte::register_stub(const char* name, address start, address end) {
#if !defined(_WINDOWS) && !defined(IA64) #if !defined(_WINDOWS)
assert(pointer_delta(end, start, sizeof(jbyte)) < INT_MAX, assert(pointer_delta(end, start, sizeof(jbyte)) < INT_MAX,
"Code size exceeds maximum range"); "Code size exceeds maximum range");
collector_func_load((char*)name, NULL, NULL, start, collector_func_load((char*)name, NULL, NULL, start,
pointer_delta(end, start, sizeof(jbyte)), 0, NULL); pointer_delta(end, start, sizeof(jbyte)), 0, NULL);
#endif // !_WINDOWS && !IA64 #endif // !_WINDOWS
} }
#else // INCLUDE_JVMTI #else // INCLUDE_JVMTI

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -29,6 +29,7 @@
class Forte : AllStatic { class Forte : AllStatic {
public: public:
static bool is_enabled() NOT_JVMTI_RETURN_(false);
static void register_stub(const char* name, address start, address end) static void register_stub(const char* name, address start, address end)
NOT_JVMTI_RETURN; NOT_JVMTI_RETURN;
// register internal VM stub // register internal VM stub

View File

@ -2713,18 +2713,22 @@ extern "C" void unexpected_adapter_call() {
} }
static void post_adapter_creation(const AdapterBlob* new_adapter, const AdapterHandlerEntry* entry) { static void post_adapter_creation(const AdapterBlob* new_adapter, const AdapterHandlerEntry* entry) {
if (Forte::is_enabled() || JvmtiExport::should_post_dynamic_code_generated()) {
char blob_id[256]; char blob_id[256];
jio_snprintf(blob_id, jio_snprintf(blob_id,
sizeof(blob_id), sizeof(blob_id),
"%s(%s)", "%s(%s)",
new_adapter->name(), new_adapter->name(),
entry->fingerprint()->as_string()); entry->fingerprint()->as_string());
if (Forte::is_enabled()) {
Forte::register_stub(blob_id, new_adapter->content_begin(), new_adapter->content_end()); Forte::register_stub(blob_id, new_adapter->content_begin(), new_adapter->content_end());
}
if (JvmtiExport::should_post_dynamic_code_generated()) { if (JvmtiExport::should_post_dynamic_code_generated()) {
JvmtiExport::post_dynamic_code_generated(blob_id, new_adapter->content_begin(), new_adapter->content_end()); JvmtiExport::post_dynamic_code_generated(blob_id, new_adapter->content_begin(), new_adapter->content_end());
} }
} }
}
void AdapterHandlerLibrary::initialize() { void AdapterHandlerLibrary::initialize() {
ResourceMark rm; ResourceMark rm;