Bug 251421 - Remove unnecessary add when loading a JSCConfig field.
Summary: Remove unnecessary add when loading a JSCConfig field.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Lam
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-01-30 23:31 PST by Mark Lam
Modified: 2023-01-31 08:05 PST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Lam 2023-01-30 23:31:06 PST
Currently, to load a JSCConfig field, our LLInt asm does something like this:
```
    leap JSCConfig + constexpr JSC::offsetOfJSCConfigGateMap + (constexpr Gate::%opcodeName%) * PtrSize, ws1
    jmp [ws1], NativeToJITGatePtrTag # JSEntrySlowPathPtrTag
```
... and generates this:
```
                  #if OS(DARWIN)
".loc 1 1\n"          "Ljsc_llint_loh_adrp_1508: \n"       // LowLevelInterpreter.asm:1
                      "adrp x10, " LOCAL_REFERENCE(g_config) "@GOTPAGE \n"
                      "Ljsc_llint_loh_ldr_1508: \n"
                      "ldr x10, [x10, " LOCAL_REFERENCE(g_config) "@GOTPAGEOFF] \n"
                  #elif OS(LINUX)
                      ...
                  #endif
".loc 1 1\n"          "add x10, x10, #3592 \n"   // <---- this add can be applied as an offset to the ldr below.
".loc 6 1034\n"       "movz x13, #57366 \n"                // WebAssembly.asm:1034
                      "ldr x17, [x10] \n"
                      "brab x17, x13 \n"
```

This patch re-arranges the LLInt assembly to look like this instead:
```
    leap _g_config, ws1
    jmp JSCConfigGateMapOffset + (constexpr Gate::%opcodeName%) * PtrSize[ws1], NativeToJITGatePtrTag # JSEntrySlowPathPtrTag
```
... resulting in the removal of the unnecessary add instruction:
```
                  #if OS(DARWIN)
".loc 1 1\n"          "Ljsc_llint_loh_adrp_1508: \n"       // LowLevelInterpreter.asm:1
                      "adrp x10, " LOCAL_REFERENCE(g_config) "@GOTPAGE \n"
                      "Ljsc_llint_loh_ldr_1508: \n"
                      "ldr x10, [x10, " LOCAL_REFERENCE(g_config) "@GOTPAGEOFF] \n"
                  #elif OS(LINUX)
                      ...
                  #endif
".loc 6 1034\n"       "movz x13, #57366 \n"                // WebAssembly.asm:1034
                      "ldr x17, [x10, #3592] \n"
                      "brab x17, x13 \n"
```
Comment 1 Radar WebKit Bug Importer 2023-01-30 23:31:32 PST
<rdar://problem/104854843>
Comment 2 Mark Lam 2023-01-30 23:35:24 PST
Pull request: https://github.com/WebKit/WebKit/pull/9368
Comment 3 EWS 2023-01-31 08:05:21 PST
Committed 259629@main (95dcffb800f8): <https://commits.webkit.org/259629@main>

Reviewed commits have been landed. Closing PR #9368 and removing active labels.