Skip to content
Browse files
Use the Clang .alt_entry directive to allow use of global labels in L…
…LInt asm.

Reviewed by Geoffrey Garen.

With this, debugging LLInt code will be easier.  LLInt code will no longer all be at an
offset from vmEntryToJavaScript.  They will instead be broken up into different sections
under human readable labels.

Secondly, crash traces of LLInt crashes will now be able to give us the nearest label
for a crash site, as opposed to everything being an offset from vmEntryToJavaScript.

For example, instead of this:

        0x1026525b8 <+0>:   pacibsp
        0x1026525bc <+4>:   stp    x29, x30, [sp, #-0x10]!
        0x1026525c0 <+8>:   mov    x29, sp
        0x1026525c4 <+12>:  sub    sp, x29, #0xb0
        0x1026525c8 <+16>:  mov    x13, #0xc800
        0x1026525cc <+20>:  add    x17, x1, x13
        0x1026525d0 <+24>:  ldr    w4, [x17]
        0x1026525d4 <+28>:  cbnz   w4, 0x10265275c           ; vmEntryToJavaScriptGateAfter + 120
        0x1026525d8 <+32>:  str    x1, [sp]
        0x1026525dc <+36>:  mov    x17, #0x9e78
        0x1026525e0 <+40>:  add    x13, x1, x17
        0x1026525e4 <+44>:  ldr    x4, [x13]
        0x1026525e8 <+48>:  str    x4, [sp, #0x8]
        0x1026525ec <+52>:  mov    x13, #0x9e70
        0x1026525f0 <+56>:  add    x17, x1, x13
        0x1026525f4 <+60>:  ldr    x4, [x17]
        0x1026525f8 <+64>:  str    x4, [sp, #0x10]
        0x1026525fc <+68>:  ldr    x4, [x2, #0x8]
        0x102652600 <+72>:  str    x4, [sp, #0x18]
        0x102652604 <+76>:  ldr    w4, [x2, #0x20]
        0x102652608 <+80>:  add    x4, x4, #0x5
        0x10265260c <+84>:  lsl    x4, x4, #3
        0x102652610 <+88>:  sub    x3, sp, x4
        0x102652614 <+92>:  cmp    sp, x3
        0x102652618 <+96>:   0x10265271c               ; vmEntryToJavaScriptGateAfter + 56
        0x10265261c <+100>: mov    x17, #0xca00
        0x102652620 <+104>: add    x13, x1, x17
        0x102652624 <+108>: ldr    x17, [x13]
        0x102652628 <+112>: cmp    x3, x17
        0x10265262c <+116>: b.lo   0x10265271c               ; vmEntryToJavaScriptGateAfter + 56
        0x102652630 <+120>: mov    sp, x3
        0x102652634 <+124>: mov    x3, #0x4
        0x102652638 <+128>: sub    w3, w3, #0x1
        0x10265263c <+132>: add    x17, x2, x3, lsl #3
        0x102652640 <+136>: ldr    x5, [x17]

We now get this:

        0x1028b5d90 <+0>:   pacibsp
        0x1028b5d94 <+4>:   stp    x29, x30, [sp, #-0x10]!
        0x1028b5d98 <+8>:   mov    x29, sp
        0x1028b5d9c <+12>:  sub    sp, x29, #0xb0
        0x1028b5da0 <+16>:  mov    x13, #0xc800
        0x1028b5da4 <+20>:  add    x17, x1, x13
        0x1028b5da8 <+24>:  ldr    w4, [x17]
        0x1028b5dac <+28>:  cbnz   w4, 0x1028b5f34           ; _offlineasm_doVMEntry__checkVMEntryPermission
        0x1028b5db0 <+32>:  str    x1, [sp]
        0x1028b5db4 <+36>:  mov    x17, #0x9e78
        0x1028b5db8 <+40>:  add    x13, x1, x17
        0x1028b5dbc <+44>:  ldr    x4, [x13]
        0x1028b5dc0 <+48>:  str    x4, [sp, #0x8]
        0x1028b5dc4 <+52>:  mov    x13, #0x9e70
        0x1028b5dc8 <+56>:  add    x17, x1, x13
        0x1028b5dcc <+60>:  ldr    x4, [x17]
        0x1028b5dd0 <+64>:  str    x4, [sp, #0x10]
        0x1028b5dd4 <+68>:  ldr    x4, [x2, #0x8]
        0x1028b5dd8 <+72>:  str    x4, [sp, #0x18]
        0x1028b5ddc <+76>:  ldr    w4, [x2, #0x20]
        0x1028b5de0 <+80>:  add    x4, x4, #0x5
        0x1028b5de4 <+84>:  lsl    x4, x4, #3
        0x1028b5de8 <+88>:  sub    x3, sp, x4
        0x1028b5dec <+92>:  cmp    sp, x3
        0x1028b5df0 <+96>:   0x1028b5ef4               ; _offlineasm_doVMEntry__throwStackOverflow
        0x1028b5df4 <+100>: mov    x17, #0xca00
        0x1028b5df8 <+104>: add    x13, x1, x17
        0x1028b5dfc <+108>: ldr    x17, [x13]
        0x1028b5e00 <+112>: cmp    x3, x17
        0x1028b5e04 <+116>: b.lo   0x1028b5ef4               ; _offlineasm_doVMEntry__throwStackOverflow

        0x1028b5e08 <+0>:   mov    sp, x3
        0x1028b5e0c <+4>:   mov    x3, #0x4

        0x1028b5e10 <+0>:   sub    w3, w3, #0x1
        0x1028b5e14 <+4>:   add    x17, x2, x3, lsl #3
        0x1028b5e18 <+8>:   ldr    x5, [x17]

This feature is only available when COMPILER(CLANG) is true.

* Source/JavaScriptCore/llint/LowLevelInterpreter.cpp:

Canonical link:
git-svn-id: 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Mark Lam committed May 24, 2022
1 parent db21fa5 commit 5f4ebedda0897afe59b886f369f830e60ca9c976
Showing 1 changed file with 12 additions and 2 deletions.
@@ -1,5 +1,5 @@
* Copyright (C) 2012-2020 Apple Inc. All rights reserved.
* Copyright (C) 2012-2022 Apple Inc. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -521,7 +521,17 @@ JSValue CLoop::execute(OpcodeID entryOpcodeID, void* executableAddress, VM* vm,
SYMBOL_STRING(label) ":\n"

".alt_entry " SYMBOL_STRING(label) "\n" \

#define OFFLINE_ASM_LOCAL_LABEL(label) \
LOCAL_LABEL_STRING(label) ":\n" \

#define OFFLINE_ASM_OPCODE_DEBUG_LABEL(label) #label ":\n"

0 comments on commit 5f4ebed

Please sign in to comment.