Changeset 252975 in webkit


Ignore:
Timestamp:
Dec 1, 2019 6:57:43 PM (4 years ago)
Author:
Caio Lima
Message:

[JSC][MIPS] CallFrame is being clobbered on InternalFunction execution
https://bugs.webkit.org/show_bug.cgi?id=203739

Reviewed by Saam Barati.

JSTests:

  • stress/has-instance-exception-check.js:
  • stress/regress-176485.js:

Source/JavaScriptCore:

MIPS calling conventions requires that we have stack space reserved
for 4 (16-bytes) arguments ($a0-$a3). The caller doesn't use
this space, but callee can still use it in case where they need to save
arguments or even reuse to another allocation. Since we were not
allocationg it during makeHostFunctionCall, the caller frame slot
was being clobberred by callGenericTypedArrayView execution,
resulting in a corrupted call frame stack. This patch is adjusting
this convention into ThunkGenerator and on makeHostFunctionCall.

  • jit/ThunkGenerators.cpp:

(JSC::nativeForGenerator):

  • llint/LowLevelInterpreter32_64.asm:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r252964 r252975  
     12019-12-01  Caio Lima  <ticaiolima@gmail.com>
     2
     3        [JSC][MIPS] CallFrame is being clobbered on InternalFunction execution
     4        https://bugs.webkit.org/show_bug.cgi?id=203739
     5
     6        Reviewed by Saam Barati.
     7
     8        * stress/has-instance-exception-check.js:
     9        * stress/regress-176485.js:
     10
    1112019-11-30  Ross Kirsling  <ross.kirsling@sony.com>
    212
  • trunk/JSTests/stress/has-instance-exception-check.js

    r251923 r252975  
    1 //@ skip if $architecture == "mips"
    2 
    31function assert(b) {
    42    if (!b)
  • trunk/JSTests/stress/regress-176485.js

    r251923 r252975  
    1 //@ skip if $architecture == "mips"
    2 
    31var exception;
    42try {
  • trunk/Source/JavaScriptCore/ChangeLog

    r252974 r252975  
     12019-12-01  Caio Lima  <ticaiolima@gmail.com>
     2
     3        [JSC][MIPS] CallFrame is being clobbered on InternalFunction execution
     4        https://bugs.webkit.org/show_bug.cgi?id=203739
     5
     6        Reviewed by Saam Barati.
     7
     8        MIPS calling conventions requires that we have stack space reserved
     9        for 4 (16-bytes) arguments ($a0-$a3). The caller doesn't use
     10        this space, but callee can still use it in case where they need to save
     11        arguments or even reuse to another allocation. Since we were not
     12        allocationg it during `makeHostFunctionCall`, the caller frame slot
     13        was being clobberred by `callGenericTypedArrayView` execution,
     14        resulting in a corrupted call frame stack. This patch is adjusting
     15        this convention into ThunkGenerator and on  `makeHostFunctionCall`.
     16
     17        * jit/ThunkGenerators.cpp:
     18        (JSC::nativeForGenerator):
     19        * llint/LowLevelInterpreter32_64.asm:
     20
    1212019-12-01  Caio Lima  <ticaiolima@gmail.com>
    222
  • trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp

    r251518 r252975  
    327327    // Allocate space on stack for the 4 parameter registers.
    328328    jit.subPtr(JSInterfaceJIT::TrustedImm32(4 * sizeof(int64_t)), JSInterfaceJIT::stackPointerRegister);
     329#elif CPU(MIPS)
     330    // Allocate stack space for (unused) 16 bytes (8-byte aligned) for 4 arguments.
     331    jit.subPtr(CCallHelpers::TrustedImm32(16), CCallHelpers::stackPointerRegister);
    329332#endif
    330333    jit.move(CCallHelpers::TrustedImmPtr(&vm), JSInterfaceJIT::argumentGPR0);
     
    333336#if OS(WINDOWS)
    334337    jit.addPtr(JSInterfaceJIT::TrustedImm32(4 * sizeof(int64_t)), JSInterfaceJIT::stackPointerRegister);
     338#elif CPU(MIPS)
     339    jit.addPtr(CCallHelpers::TrustedImm32(16), CCallHelpers::stackPointerRegister);
    335340#endif
    336341
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm

    r252789 r252975  
    353353        call temp1
    354354        addp 8, sp
     355    elsif MIPS
     356        move sp, a1
     357        # We need to allocate stack space for 16 bytes (8-byte aligned)
     358        # for 4 arguments, since callee can use this space.
     359        subp 16, sp
     360        loadp ProtoCallFrame::globalObject[protoCallFrame], a0
     361        call temp1
     362        addp 16, sp
    355363    else
    356364        loadp ProtoCallFrame::globalObject[protoCallFrame], a0
Note: See TracChangeset for help on using the changeset viewer.