Title: [284868] trunk/Source/_javascript_Core
Revision
284868
Author
[email protected]
Date
2021-10-26 08:52:37 -0700 (Tue, 26 Oct 2021)

Log Message

[JSC] Improve offlineasm debug annotations for Linux/ELF
https://bugs.webkit.org/show_bug.cgi?id=232303

Patch by Xan López <[email protected]> on 2021-10-26
Reviewed by Mark Lam.

This patch does two things:

Add the .size and .type directives to every llint "function"
(global, llint opcode, 'glue'). This allows a debugger to tell you
in what logical function you are inside the giant chunk of code
that is the llint interpreter. So instead of something like this:

(gdb) x/5i $pc
  => 0xf5f8af60 <wasmLLIntPCRangeStart+3856>:  b.n     0xf5f8af6c <wasmLLIntPCRangeStart+3868>
     0xf5f8af62 <wasmLLIntPCRangeStart+3858>:  ldr     r2, [r7, #8]
     0xf5f8af64 <wasmLLIntPCRangeStart+3860>:  ldr     r2, [r2, #28]
     0xf5f8af66 <wasmLLIntPCRangeStart+3862>:  subs    r0, #16
     0xf5f8af68 <wasmLLIntPCRangeStart+3864>:  ldr.w   r0, [r2, r0, lsl #3]

you get something like this:

(gdb) x/5i $pc
  => 0xf5f8c770 <wasm_f32_add+12>:      bge.n   0xf5f8c77c <wasm_f32_add+24>
     0xf5f8c772 <wasm_f32_add+14>:      add.w   r6, r7, r9, lsl #3
     0xf5f8c776 <wasm_f32_add+18>:      vldr    d0, [r6]
     0xf5f8c77a <wasm_f32_add+22>:      b.n     0xf5f8c78c <wasm_f32_add+40>
     0xf5f8c77c <wasm_f32_add+24>:      ldr     r2, [r7, #8]

The other change adds a local symbol (in addition to an internal
label) to all the "glue" labels. That allows wasm opcodes to be
seen by the debugger (and the user to break on them), among other
things.

* CMakeLists.txt: tell offlineasm we use the ELF binary format on Linux.
* llint/LowLevelInterpreter.cpp: emit a non-local label for "glue" labels.
* offlineasm/asm.rb: emit the .size and .type directives for every
llint "function" on ELF systems.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/CMakeLists.txt (284867 => 284868)


--- trunk/Source/_javascript_Core/CMakeLists.txt	2021-10-26 15:23:12 UTC (rev 284867)
+++ trunk/Source/_javascript_Core/CMakeLists.txt	2021-10-26 15:52:37 UTC (rev 284868)
@@ -441,6 +441,10 @@
     set(LLIntOutput LLIntAssembly.h)
 endif ()
 
+if (CMAKE_SYSTEM_NAME MATCHES "Linux")
+    set(OFFLINE_ASM_ARGS --binary-format=ELF)
+endif ()
+
 add_custom_command(
     OUTPUT ${_javascript_Core_DERIVED_SOURCES_DIR}/${LLIntOutput}
     MAIN_DEPENDENCY ${_javascript_CORE_DIR}/offlineasm/asm.rb

Modified: trunk/Source/_javascript_Core/ChangeLog (284867 => 284868)


--- trunk/Source/_javascript_Core/ChangeLog	2021-10-26 15:23:12 UTC (rev 284867)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-10-26 15:52:37 UTC (rev 284868)
@@ -1,3 +1,43 @@
+2021-10-26  Xan López  <[email protected]>
+
+        [JSC] Improve offlineasm debug annotations for Linux/ELF
+        https://bugs.webkit.org/show_bug.cgi?id=232303
+
+        Reviewed by Mark Lam.
+
+        This patch does two things:
+
+        Add the .size and .type directives to every llint "function"
+        (global, llint opcode, 'glue'). This allows a debugger to tell you
+        in what logical function you are inside the giant chunk of code
+        that is the llint interpreter. So instead of something like this:
+
+        (gdb) x/5i $pc
+          => 0xf5f8af60 <wasmLLIntPCRangeStart+3856>:  b.n     0xf5f8af6c <wasmLLIntPCRangeStart+3868>
+             0xf5f8af62 <wasmLLIntPCRangeStart+3858>:  ldr     r2, [r7, #8]
+             0xf5f8af64 <wasmLLIntPCRangeStart+3860>:  ldr     r2, [r2, #28]
+             0xf5f8af66 <wasmLLIntPCRangeStart+3862>:  subs    r0, #16
+             0xf5f8af68 <wasmLLIntPCRangeStart+3864>:  ldr.w   r0, [r2, r0, lsl #3]
+
+        you get something like this:
+
+        (gdb) x/5i $pc
+          => 0xf5f8c770 <wasm_f32_add+12>:      bge.n   0xf5f8c77c <wasm_f32_add+24>
+             0xf5f8c772 <wasm_f32_add+14>:      add.w   r6, r7, r9, lsl #3
+             0xf5f8c776 <wasm_f32_add+18>:      vldr    d0, [r6]
+             0xf5f8c77a <wasm_f32_add+22>:      b.n     0xf5f8c78c <wasm_f32_add+40>
+             0xf5f8c77c <wasm_f32_add+24>:      ldr     r2, [r7, #8]
+
+        The other change adds a local symbol (in addition to an internal
+        label) to all the "glue" labels. That allows wasm opcodes to be
+        seen by the debugger (and the user to break on them), among other
+        things.
+
+        * CMakeLists.txt: tell offlineasm we use the ELF binary format on Linux.
+        * llint/LowLevelInterpreter.cpp: emit a non-local label for "glue" labels.
+        * offlineasm/asm.rb: emit the .size and .type directives for every
+        llint "function" on ELF systems.
+
 2021-10-25  Yusuke Suzuki  <[email protected]>
 
         [JSC] Fix stale assertion in InternalFunctionAllocationProfile after r284757

Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter.cpp (284867 => 284868)


--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter.cpp	2021-10-26 15:23:12 UTC (rev 284867)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter.cpp	2021-10-26 15:52:37 UTC (rev 284868)
@@ -490,7 +490,9 @@
     OFFLINE_ASM_OPCODE_DEBUG_LABEL(llint_##__opcode) \
     OFFLINE_ASM_LOCAL_LABEL(llint_##__opcode)
 
-#define OFFLINE_ASM_GLUE_LABEL(__opcode)   OFFLINE_ASM_LOCAL_LABEL(__opcode)
+#define OFFLINE_ASM_GLUE_LABEL(__opcode) \
+    OFFLINE_ASM_OPCODE_DEBUG_LABEL(__opcode) \
+    OFFLINE_ASM_LOCAL_LABEL(__opcode)
 
 #if CPU(ARM_THUMB2)
 #define OFFLINE_ASM_GLOBAL_LABEL(label)          \

Modified: trunk/Source/_javascript_Core/offlineasm/asm.rb (284867 => 284868)


--- trunk/Source/_javascript_Core/offlineasm/asm.rb	2021-10-26 15:23:12 UTC (rev 284867)
+++ trunk/Source/_javascript_Core/offlineasm/asm.rb	2021-10-26 15:52:37 UTC (rev 284868)
@@ -264,6 +264,12 @@
                 @outp.puts(formatDump("  _#{labelName}:", lastComment))
             end
         end
+        if $emitELFDebugDirectives
+            deferNextLabelAction {
+                putStr("    \".size #{labelName} , . - #{labelName} \\n\"")
+                putStr("    \".type #{labelName} , function \\n\"")
+            }
+        end
         @newlineSpacerState = :none # After a global label, we can use another spacer.
     end
     
@@ -341,7 +347,7 @@
 
 $options = {}
 OptionParser.new do |opts|
-    opts.banner = "Usage: asm.rb asmFile offsetsFile outputFileName [--assembler=<ASM>] [--webkit-additions-path=<path>]"
+    opts.banner = "Usage: asm.rb asmFile offsetsFile outputFileName [--assembler=<ASM>] [--webkit-additions-path=<path>] [--binary-format=<format>]"
     # This option is currently only used to specify the masm assembler
     opts.on("--assembler=[ASM]", "Specify an assembler to use.") do |assembler|
         $options[:assembler] = assembler
@@ -349,6 +355,9 @@
     opts.on("--webkit-additions-path=PATH", "WebKitAdditions path.") do |path|
         $options[:webkit_additions_path] = path
     end
+    opts.on("--binary-format=FORMAT", "Specify the binary format used by the target system.") do |format|
+        $options[:binary_format] = format
+    end
 end.parse!
 
 begin
@@ -366,6 +375,9 @@
 $emitWinAsm = isMSVC ? outputFlnm.index(".asm") != nil : false
 $commentPrefix = $emitWinAsm ? ";" : "//"
 
+# We want this in all ELF systems we support, except for C_LOOP (we'll disable it later on if we are building cloop)
+$emitELFDebugDirectives = $options.has_key?(:binary_format) && $options[:binary_format] == "ELF"
+
 inputHash =
     $commentPrefix + " offlineasm input hash: " + parseHash(asmFile, $options) +
     " " + Digest::SHA1.hexdigest(configurationList.map{|v| (v[0] + [v[1]]).join(' ')}.join(' ')) +
@@ -412,6 +424,7 @@
             if backend == "C_LOOP" || backend == "C_LOOP_WIN"
                 $enableDebugAnnotations = false
                 $preferredCommentStartColumn = 60
+                $emitELFDebugDirectives = false
             end
 
             lowLevelAST = lowLevelAST.demacroify({})
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to