diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-07-21 23:50:50 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-07-22 13:07:02 -0700 |
| commit | 25198810c88d474c63ff537e3647f12e7df6297c (patch) | |
| tree | f92e3b6dcf75aa653df9786fb6c17360291a8e4c /src/InternPool.zig | |
| parent | 7930efc60becd7624471419b8fd49800512d4e10 (diff) | |
| download | zig-25198810c88d474c63ff537e3647f12e7df6297c.tar.gz zig-25198810c88d474c63ff537e3647f12e7df6297c.zip | |
add new builtin: `@disableInstrumentation`
This is needed to ensure that start code does not try to access thread
local storage before it has set up thread local storage.
Diffstat (limited to 'src/InternPool.zig')
| -rw-r--r-- | src/InternPool.zig | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/InternPool.zig b/src/InternPool.zig index c3cee5852b..2934340034 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -5184,11 +5184,11 @@ pub const FuncAnalysis = packed struct(u32) { is_noinline: bool, calls_or_awaits_errorable_fn: bool, stack_alignment: Alignment, - /// True if this function has an inferred error set. inferred_error_set: bool, + disable_instrumentation: bool, - _: u14 = 0, + _: u13 = 0, pub const State = enum(u8) { /// This function has not yet undergone analysis, because we have not @@ -8111,6 +8111,7 @@ pub fn getFuncDecl( .calls_or_awaits_errorable_fn = false, .stack_alignment = .none, .inferred_error_set = false, + .disable_instrumentation = false, }, .owner_decl = key.owner_decl, .ty = key.ty, @@ -8214,6 +8215,7 @@ pub fn getFuncDeclIes( .calls_or_awaits_errorable_fn = false, .stack_alignment = .none, .inferred_error_set = true, + .disable_instrumentation = false, }, .owner_decl = key.owner_decl, .ty = func_ty, @@ -8405,6 +8407,7 @@ pub fn getFuncInstance( .calls_or_awaits_errorable_fn = false, .stack_alignment = .none, .inferred_error_set = false, + .disable_instrumentation = false, }, // This is populated after we create the Decl below. It is not read // by equality or hashing functions. @@ -8504,6 +8507,7 @@ pub fn getFuncInstanceIes( .calls_or_awaits_errorable_fn = false, .stack_alignment = .none, .inferred_error_set = true, + .disable_instrumentation = false, }, // This is populated after we create the Decl below. It is not read // by equality or hashing functions. @@ -11225,6 +11229,18 @@ pub fn funcSetCallsOrAwaitsErrorableFn(ip: *InternPool, func: Index) void { @atomicStore(FuncAnalysis, analysis_ptr, analysis, .release); } +pub fn funcSetDisableInstrumentation(ip: *InternPool, func: Index) void { + const unwrapped_func = func.unwrap(ip); + const extra_mutex = &ip.getLocal(unwrapped_func.tid).mutate.extra.mutex; + extra_mutex.lock(); + defer extra_mutex.unlock(); + + const analysis_ptr = ip.funcAnalysisPtr(func); + var analysis = analysis_ptr.*; + analysis.disable_instrumentation = true; + @atomicStore(FuncAnalysis, analysis_ptr, analysis, .release); +} + pub fn funcSetCold(ip: *InternPool, func: Index, is_cold: bool) void { const unwrapped_func = func.unwrap(ip); const extra_mutex = &ip.getLocal(unwrapped_func.tid).mutate.extra.mutex; |
