Skip to content

Commit 3c08e6b

Browse files
committed
8289780: Avoid formatting stub names when Forte is not enabled
Reviewed-by: dholmes, coleenp, sspitsyn
1 parent 54b4576 commit 3c08e6b

File tree

5 files changed

+34
-19
lines changed

5 files changed

+34
-19
lines changed

src/hotspot/share/code/codeBlob.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@ void RuntimeBlob::trace_new_stub(RuntimeBlob* stub, const char* name1, const cha
195195
// Do not hold the CodeCache lock during name formatting.
196196
assert(!CodeCache_lock->owned_by_self(), "release CodeCache before registering the stub");
197197

198-
if (stub != NULL) {
198+
if (stub != NULL && (PrintStubCode ||
199+
Forte::is_enabled() ||
200+
JvmtiExport::should_post_dynamic_code_generated())) {
199201
char stub_id[256];
200202
assert(strlen(name1) + strlen(name2) < sizeof(stub_id), "");
201203
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
212214
tty->print_cr("- - - [END] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
213215
tty->cr();
214216
}
215-
Forte::register_stub(stub_id, stub->code_begin(), stub->code_end());
217+
if (Forte::is_enabled()) {
218+
Forte::register_stub(stub_id, stub->code_begin(), stub->code_end());
219+
}
216220

217221
if (JvmtiExport::should_post_dynamic_code_generated()) {
218222
const char* stub_name = name2;

src/hotspot/share/interpreter/abstractInterpreter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
#include "oops/methodData.hpp"
4242
#include "oops/method.inline.hpp"
4343
#include "oops/oop.inline.hpp"
44-
#include "prims/forte.hpp"
4544
#include "prims/jvmtiExport.hpp"
4645
#include "prims/methodHandles.hpp"
4746
#include "runtime/handles.inline.hpp"

src/hotspot/share/prims/forte.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ enum {
7171
// Native interfaces for use by Forte tools.
7272

7373

74-
#if !defined(IA64)
75-
7674
class vframeStreamForte : public vframeStreamCommon {
7775
public:
7876
// constructor that starts with sender of frame fr (top_frame)
@@ -673,6 +671,7 @@ void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) {
673671
// XXXDARWIN: Link errors occur even when __attribute__((weak_import))
674672
// is added
675673
#define collector_func_load(x0,x1,x2,x3,x4,x5,x6) ((void) 0)
674+
#define collector_func_load_enabled() false
676675
#else
677676
void collector_func_load(char* name,
678677
void* null_argument_1,
@@ -684,20 +683,28 @@ void collector_func_load(char* name,
684683
#pragma weak collector_func_load
685684
#define collector_func_load(x0,x1,x2,x3,x4,x5,x6) \
686685
( collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6),(void)0 : (void)0 )
686+
#define collector_func_load_enabled() (collector_func_load ? true : false)
687687
#endif // __APPLE__
688688
#endif // !_WINDOWS
689689

690690
} // end extern "C"
691-
#endif // !IA64
691+
692+
bool Forte::is_enabled() {
693+
#if !defined(_WINDOWS)
694+
return collector_func_load_enabled();
695+
#else
696+
return false;
697+
#endif
698+
}
692699

693700
void Forte::register_stub(const char* name, address start, address end) {
694-
#if !defined(_WINDOWS) && !defined(IA64)
701+
#if !defined(_WINDOWS)
695702
assert(pointer_delta(end, start, sizeof(jbyte)) < INT_MAX,
696703
"Code size exceeds maximum range");
697704

698705
collector_func_load((char*)name, NULL, NULL, start,
699706
pointer_delta(end, start, sizeof(jbyte)), 0, NULL);
700-
#endif // !_WINDOWS && !IA64
707+
#endif // !_WINDOWS
701708
}
702709

703710
#else // INCLUDE_JVMTI

src/hotspot/share/prims/forte.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
2929

3030
class Forte : AllStatic {
3131
public:
32+
static bool is_enabled() NOT_JVMTI_RETURN_(false);
3233
static void register_stub(const char* name, address start, address end)
3334
NOT_JVMTI_RETURN;
3435
// register internal VM stub

src/hotspot/share/runtime/sharedRuntime.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2713,16 +2713,20 @@ extern "C" void unexpected_adapter_call() {
27132713
}
27142714

27152715
static void post_adapter_creation(const AdapterBlob* new_adapter, const AdapterHandlerEntry* entry) {
2716-
char blob_id[256];
2717-
jio_snprintf(blob_id,
2718-
sizeof(blob_id),
2719-
"%s(%s)",
2720-
new_adapter->name(),
2721-
entry->fingerprint()->as_string());
2722-
Forte::register_stub(blob_id, new_adapter->content_begin(), new_adapter->content_end());
2723-
2724-
if (JvmtiExport::should_post_dynamic_code_generated()) {
2725-
JvmtiExport::post_dynamic_code_generated(blob_id, new_adapter->content_begin(), new_adapter->content_end());
2716+
if (Forte::is_enabled() || JvmtiExport::should_post_dynamic_code_generated()) {
2717+
char blob_id[256];
2718+
jio_snprintf(blob_id,
2719+
sizeof(blob_id),
2720+
"%s(%s)",
2721+
new_adapter->name(),
2722+
entry->fingerprint()->as_string());
2723+
if (Forte::is_enabled()) {
2724+
Forte::register_stub(blob_id, new_adapter->content_begin(), new_adapter->content_end());
2725+
}
2726+
2727+
if (JvmtiExport::should_post_dynamic_code_generated()) {
2728+
JvmtiExport::post_dynamic_code_generated(blob_id, new_adapter->content_begin(), new_adapter->content_end());
2729+
}
27262730
}
27272731
}
27282732

0 commit comments

Comments
 (0)