From 0ce4ebc853d89f19b22a8622304725a7bc423661 Mon Sep 17 00:00:00 2001 From: Thomas Lively <7121787+tlively@users.noreply.github.com> Date: Fri, 3 Sep 2021 17:14:23 -0700 Subject: [wasm-split] Add an option for recording profile data in memory (#4120) To avoid requiring a static memory allocation, wasm-split's instrumentation defaults to recording profile data in Wasm globals. This causes problems for multithreaded applications because the globals are thread-local, but it is not always feasible to arrange for a separate profile to be dumped on each thread. To simplify the profiling of such multithreaded applications, add a new instrumentation mode that stores the profiling data in shared memory instead of in globals. This allows a single profile to be written that correctly reflects the called functions on all threads. This new mode is not on by default because it requires users to ensure that the program will not trample the in-memory profiling data. The data is stored beginning at address zero and occupies one byte per declared function in the instrumented module. Emscripten can be told to leave this memory free using the GLOBAL_BASE option. --- test/lit/help/wasm-split.test | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'test/lit/help/wasm-split.test') diff --git a/test/lit/help/wasm-split.test b/test/lit/help/wasm-split.test index 362c20d84..dd2b5f7e1 100644 --- a/test/lit/help/wasm-split.test +++ b/test/lit/help/wasm-split.test @@ -39,7 +39,7 @@ ;; CHECK-NEXT: of any profile. You can also pass a file ;; CHECK-NEXT: with a list of functions separated by new ;; CHECK-NEXT: lines. To do this, prepend @ before -;; CHECK-NEXT: filename (--keep-funcs @myfile) +;; CHECK-NEXT: filename (--keep-funcs @myfile) ;; CHECK-NEXT: ;; CHECK-NEXT: --split-funcs [split] Comma-separated list of functions ;; CHECK-NEXT: to split into the secondary module, @@ -49,7 +49,7 @@ ;; CHECK-NEXT: also pass a file with a list of functions ;; CHECK-NEXT: separated by new lines. To do this, ;; CHECK-NEXT: prepend @ before filename (--split-funcs -;; CHECK-NEXT: @myfile) +;; CHECK-NEXT: @myfile) ;; CHECK-NEXT: ;; CHECK-NEXT: --primary-output,-o1 [split] Output file for the primary ;; CHECK-NEXT: module. @@ -80,6 +80,15 @@ ;; CHECK-NEXT: profile into memory. Defaults to ;; CHECK-NEXT: `__write_profile`. ;; CHECK-NEXT: +;; CHECK-NEXT: --in-memory [instrument] Store profile information in +;; CHECK-NEXT: memory (starting at address 0 and taking +;; CHECK-NEXT: one byte per function) rather than +;; CHECK-NEXT: globals (the default) so that it can be +;; CHECK-NEXT: shared between multiple threads. Users +;; CHECK-NEXT: are responsible for ensuring that the +;; CHECK-NEXT: module does not use the initial memory +;; CHECK-NEXT: region for anything else. +;; CHECK-NEXT: ;; CHECK-NEXT: --emit-module-names [split, instrument] Emit module names, ;; CHECK-NEXT: even if not emitting the rest of the ;; CHECK-NEXT: names section. Can help differentiate the -- cgit v1.2.3