File tree Expand file tree Collapse file tree 4 files changed +21
-12
lines changed
Expand file tree Collapse file tree 4 files changed +21
-12
lines changed Original file line number Diff line number Diff line change 88
99#include " cinderx/Common/log.h"
1010#include " cinderx/Common/ref.h"
11+ #include " cinderx/Jit/config.h"
1112
1213#include < cstdarg>
1314#include < cstdio>
@@ -103,15 +104,14 @@ jit_string_t* ss_sprintf_alloc(const char* format, ...) {
103104
104105namespace jit {
105106
106- static bool s_use_stable_pointers{false };
107-
108107const void * getStablePointer (const void * ptr) {
109- return s_use_stable_pointers ? reinterpret_cast <const void *>(0xdeadbeef )
110- : ptr;
108+ return getConfig ().use_stable_pointers
109+ ? reinterpret_cast <const void *>(0xdeadbeef )
110+ : ptr;
111111}
112112
113113void setUseStablePointers (bool enable) {
114- s_use_stable_pointers = enable;
114+ getMutableConfig (). use_stable_pointers = enable;
115115}
116116
117117std::string unicodeAsString (PyObject* str) {
Original file line number Diff line number Diff line change 66#include < cstdint>
77#include < optional>
88#include < string>
9+ #include < vector>
910
1011namespace jit {
1112
@@ -203,6 +204,12 @@ struct Config {
203204
204205 // The ASM syntax the JIT should use when disassembling.
205206 AsmSyntax asm_syntax{AsmSyntax::ATT};
207+
208+ // List of function name patterns for which to capture compilation times.
209+ std::vector<std::string> capture_compilation_times_for;
210+
211+ // Use stable sentinel pointers in output (for deterministic test output).
212+ bool use_stable_pointers{false };
206213};
207214
208215// Get the JIT's current config object.
Original file line number Diff line number Diff line change 33#include " cinderx/Jit/jit_time_log.h"
44
55#include " cinderx/Common/log.h"
6+ #include " cinderx/Jit/config.h"
67#include " cinderx/Jit/containers.h"
78
89#include < fmt/core.h>
1415
1516namespace jit {
1617
17- static std::vector<std::string> capture_compilation_times_for;
18-
1918void parseAndSetFuncList (const std::string& flag_value) {
20- capture_compilation_times_for.clear ();
19+ auto & func_list = getMutableConfig ().capture_compilation_times_for ;
20+ func_list.clear ();
2121
2222 std::stringstream ss (flag_value);
2323
2424 while (ss.good ()) {
2525 std::string substr;
2626 getline (ss, substr, ' ,' );
2727 if (!substr.empty ()) {
28- capture_compilation_times_for .emplace_back (substr);
28+ func_list .emplace_back (substr);
2929 }
3030 }
3131}
@@ -63,7 +63,7 @@ bool isMatch(const std::string& word, const std::string& pattern) {
6363}
6464
6565bool captureCompilationTimeFor (const std::string& function_name) {
66- for (const std::string& pattern : capture_compilation_times_for) {
66+ for (const std::string& pattern : getConfig (). capture_compilation_times_for ) {
6767 if (isMatch (function_name, pattern)) {
6868 return true ;
6969 }
Original file line number Diff line number Diff line change @@ -3513,13 +3513,15 @@ int initialize() {
35133513 return 0 ;
35143514 }
35153515
3516- // Save the force_init field as it might have be set by test code before
3517- // jit::initialize() is called.
3516+ // Save fields that might have been set by test code before jit::initialize()
3517+ // is called.
35183518 auto force_init = getConfig ().force_init ;
3519+ auto use_stable_pointers = getConfig ().use_stable_pointers ;
35193520 getMutableConfig () = Config{};
35203521 if (force_init.has_value ()) {
35213522 getMutableConfig ().force_init = force_init;
35223523 }
3524+ getMutableConfig ().use_stable_pointers = use_stable_pointers;
35233525
35243526 FlagProcessor flag_processor = initFlagProcessor ();
35253527 if (flag_processor.hasHandled (" jit-help" )) {
You can’t perform that action at this time.
0 commit comments