-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathjitCodeCache.cpp
More file actions
54 lines (46 loc) · 2 KB
/
Copy pathjitCodeCache.cpp
File metadata and controls
54 lines (46 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* Copyright 2026, Datadog, Inc.
* SPDX-License-Identifier: Apache-2.0
*/
#include "jitCodeCache.h"
#include "hotspot/vmStructs.h"
#include "threadLocalData.h"
SpinLock JitCodeCache::_stubs_lock;
CodeCache JitCodeCache::_runtime_stubs("[stubs]");
std::atomic<const void *> JitCodeCache::_call_stub_begin = { nullptr };
std::atomic<const void *> JitCodeCache::_call_stub_end = { nullptr };
// CompiledMethodLoad is also needed to enable DebugNonSafepoints info by
// default
void JNICALL JitCodeCache::CompiledMethodLoad(jvmtiEnv *jvmti, jmethodID method,
jint code_size, const void *code_addr,
jint map_length,
const jvmtiAddrLocationMap *map,
const void *compile_info) {
ProfiledThread::initCurrentThreadSignalSafe();
CodeHeap::updateBounds(code_addr, (const char *)code_addr + code_size);
}
void JNICALL JitCodeCache::DynamicCodeGenerated(jvmtiEnv *jvmti, const char *name,
const void *address, jint length) {
ProfiledThread::initCurrentThreadSignalSafe();
_stubs_lock.lock();
_runtime_stubs.add(address, length, name, true);
_stubs_lock.unlock();
if (name[0] == 'I' && strcmp(name, "Interpreter") == 0) {
CodeHeap::setInterpreterStart(address);
} else if (strcmp(name, "call_stub") == 0) {
_call_stub_begin.store(address, std::memory_order_relaxed);
// This fence ensures that _call_stub_begin is visible before _call_stub_end, so that isCallStub() works correctly
std::atomic_thread_fence(std::memory_order_release);
_call_stub_end.store((const char *)address + length, std::memory_order_relaxed);
}
CodeHeap::updateBounds(address, (const char *)address + length);
}
CodeBlob* JitCodeCache::findRuntimeStub(const void *address) {
CodeBlob *stub = nullptr;
_stubs_lock.lockShared();
if (_runtime_stubs.contains(address)) {
stub = _runtime_stubs.findBlobByAddress(address);
}
_stubs_lock.unlockShared();
return stub;
}