forked from openjdk/jdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
1,044 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include "precompiled.hpp" | ||
#include "jfrContext.hpp" | ||
#include "jfr/support/jfrThreadLocal.hpp" | ||
#include "runtime/thread.hpp" | ||
|
||
#ifndef MIN | ||
#define MIN(a,b) ((a) < (b) ? (a) : (b)) | ||
#endif | ||
|
||
uint8_t JfrContext::_size = 0; | ||
|
||
JfrThreadLocal* getThreadLocal() { | ||
Thread* thrd = Thread::current_or_null_safe(); | ||
return thrd != nullptr ? thrd->jfr_thread_local() : nullptr; | ||
} | ||
|
||
void JfrContext::set_used_context_size(uint8_t size) { | ||
assert(size <= 8, "max context size is 8"); | ||
_size = size; | ||
} | ||
|
||
uint64_t JfrContext::get_and_set_context(uint8_t idx, uint64_t value) { | ||
JfrThreadLocal* jfrTLocal = getThreadLocal(); | ||
if (jfrTLocal != nullptr) { | ||
uint64_t old_value = 0; | ||
jfrTLocal->get_context(&old_value, 1, idx); | ||
jfrTLocal->set_context(&value, 1, idx); | ||
return old_value; | ||
} | ||
return 0; | ||
} | ||
|
||
uint8_t JfrContext::get_all_context(uint64_t* data, uint8_t length) { | ||
JfrThreadLocal* jfrTLocal = getThreadLocal(); | ||
if (jfrTLocal != nullptr) { | ||
return jfrTLocal->get_context(data, MIN(_size, length), 0); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
uint8_t JfrContext::get_context(uint64_t** data) { | ||
void* buffer = get_thread_context_buffer(); | ||
if (buffer) { | ||
*data = (uint64_t*) buffer; | ||
return _size; | ||
} | ||
return 0; | ||
} | ||
|
||
uint8_t JfrContext::set_all_context(uint64_t* data, uint8_t length) { | ||
JfrThreadLocal* jfrTLocal = getThreadLocal(); | ||
if (jfrTLocal != nullptr) { | ||
jfrTLocal->set_context(data, MIN(_size, length), 0); | ||
return length; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
void* JfrContext::get_thread_context_buffer() { | ||
JfrThreadLocal* jfrTLocal = getThreadLocal(); | ||
if (jfrTLocal != nullptr) { | ||
return (void*)jfrTLocal->get_context_buffer(); | ||
} | ||
return nullptr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef SHARE_JFR_SUPPORT_CONTEXT_HPP | ||
#define SHARE_JFR_SUPPORT_CONTEXT_HPP | ||
|
||
#include "memory/allStatic.hpp" | ||
#include "utilities/globalDefinitions.hpp" | ||
|
||
class JfrContext : AllStatic { | ||
private: | ||
static uint8_t _size; | ||
public: | ||
static void set_used_context_size(uint8_t size); | ||
static inline uint8_t get_used_context_size() { return _size; } | ||
static uint64_t get_and_set_context(uint8_t idx, uint64_t value); | ||
static uint8_t get_all_context(uint64_t* data, uint8_t length); | ||
static uint8_t set_all_context(uint64_t* data, uint8_t length); | ||
static uint8_t get_context(uint64_t** data); | ||
static void* get_thread_context_buffer(); | ||
}; | ||
|
||
#endif // SHARE_JFR_SUPPORT_CONTEXT_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.