avm2: Add new feature tracy_avm, which emits tracy spans for AVM2 methods

This commit is contained in:
TÖRÖK Attila 2024-08-22 15:04:44 +02:00
parent 038a714dbf
commit 52eb5d6614
3 changed files with 32 additions and 0 deletions

1
Cargo.lock generated
View File

@ -4269,6 +4269,7 @@ dependencies = [
"symphonia", "symphonia",
"thiserror", "thiserror",
"tracing", "tracing",
"tracy-client",
"ttf-parser", "ttf-parser",
"unic-segment", "unic-segment",
"url", "url",

View File

@ -68,6 +68,7 @@ unic-segment = "0.9.0"
id3 = "1.14.0" id3 = "1.14.0"
either = "1.13.0" either = "1.13.0"
chardetng = "0.1.17" chardetng = "0.1.17"
tracy-client = { version = "0.17.1", optional = true, default-features = false }
[target.'cfg(not(target_family = "wasm"))'.dependencies.futures] [target.'cfg(not(target_family = "wasm"))'.dependencies.futures]
workspace = true workspace = true
@ -79,6 +80,7 @@ version = "0.4.43"
default = [] default = []
lzma = ["lzma-rs", "swf/lzma"] lzma = ["lzma-rs", "swf/lzma"]
avm_debug = [] avm_debug = []
tracy_avm = ["dep:tracy-client"]
deterministic = [] deterministic = []
timeline_debug = [] timeline_debug = []
mp3 = ["symphonia"] mp3 = ["symphonia"]

View File

@ -184,6 +184,18 @@ pub fn exec<'gc>(
resolved_signature, resolved_signature,
bound_class, bound_class,
)?; )?;
#[cfg(feature = "tracy_avm")]
let _span = {
let mut name = WString::new();
display_function(&mut name, &method, bound_class);
let span = tracy_client::Client::running()
.expect("tracy_client should be running")
.span_alloc(None, &name.to_utf8_lossy(), "rust", 0, 0);
span.emit_color(0x2c4980);
span
};
activation activation
.context .context
.avm2 .avm2
@ -210,6 +222,23 @@ pub fn exec<'gc>(
bound_class, bound_class,
callee, callee,
)?; )?;
#[cfg(feature = "tracy_avm")]
let _span = {
let mut name = WString::new();
display_function(&mut name, &method, bound_class);
let option = tracy_client::Client::running();
let span = option.expect("tracy_client should be running").span_alloc(
None,
&name.to_utf8_lossy(),
bm.owner_movie().url(),
line!(),
0,
);
span.emit_color(0x425fa1);
span
};
activation activation
.context .context
.avm2 .avm2