- Source/JavaScriptCore/ChangeLog +51 lines
Lines 1-3 Source/JavaScriptCore/ChangeLog_sec1
1
2013-10-17  Michael Saboff  <msaboff@apple.com>
2
3
        Change native function call stubs to use JIT operations instead of ctiVMHandleException
4
        https://bugs.webkit.org/show_bug.cgi?id=122982
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Change ctiVMHandleException to operationVMHandleException.  Change all exception operations to
9
        return the catch callFrame and entryPC via vm.callFrameForThrow and vm.targetMachinePCForThrow.
10
        This removed calling convention headaches, fixing https://bugs.webkit.org/show_bug.cgi?id=122980
11
        in the process.
12
13
        * dfg/DFGJITCompiler.cpp:
14
        (JSC::DFG::JITCompiler::compileExceptionHandlers):
15
        * jit/JIT.cpp:
16
        (JSC::JIT::privateCompileExceptionHandlers):
17
        * jit/JIT.h:
18
        * jit/JITExceptions.cpp:
19
        (JSC::uncaughtExceptionHandler):
20
        (JSC::genericUnwind):
21
        * jit/JITExceptions.h:
22
        * jit/JITInlines.h:
23
        (JSC::JIT::callOperationNoExceptionCheck):
24
        * jit/JITOpcodes.cpp:
25
        (JSC::JIT::emit_op_throw):
26
        * jit/JITOpcodes32_64.cpp:
27
        (JSC::JIT::privateCompileCTINativeCall):
28
        (JSC::JIT::emit_op_throw):
29
        * jit/JITOperations.cpp:
30
        * jit/JITOperations.h:
31
        * jit/JITStubs.cpp:
32
        * jit/JITStubs.h:
33
        * jit/JITStubsARM.h:
34
        * jit/JITStubsARM64.h:
35
        * jit/JITStubsARMv7.h:
36
        * jit/JITStubsMIPS.h:
37
        * jit/JITStubsMSVC64.asm:
38
        * jit/JITStubsSH4.h:
39
        * jit/JITStubsX86.h:
40
        * jit/JITStubsX86_64.h:
41
        * jit/Repatch.cpp:
42
        (JSC::tryBuildGetByIDList):
43
        * jit/SlowPathCall.h:
44
        (JSC::JITSlowPathCall::call):
45
        * jit/ThunkGenerators.cpp:
46
        (JSC::throwExceptionFromCallSlowPathGenerator):
47
        (JSC::nativeForGenerator):
48
        * runtime/VM.h:
49
        (JSC::VM::callFrameForThrowOffset):
50
        (JSC::VM::targetMachinePCForThrowOffset):
51
1
2013-10-17  Andreas Kling  <akling@apple.com>
52
2013-10-17  Andreas Kling  <akling@apple.com>
2
53
3
        Pass VM instead of JSGlobalObject to JSONObject constructor.
54
        Pass VM instead of JSGlobalObject to JSONObject constructor.
- Source/JavaScriptCore/dfg/DFGJITCompiler.cpp -3 / +7 lines
Lines 146-154 void JITCompiler::compileExceptionHandle Source/JavaScriptCore/dfg/DFGJITCompiler.cpp_sec1
146
    poke(GPRInfo::argumentGPR0);
146
    poke(GPRInfo::argumentGPR0);
147
#endif
147
#endif
148
    m_calls.append(CallLinkRecord(call(), lookupExceptionHandler));
148
    m_calls.append(CallLinkRecord(call(), lookupExceptionHandler));
149
    // lookupExceptionHandler leaves the handler CallFrame* in the returnValueGPR,
149
150
    // and the address of the handler in returnValueGPR2.
150
    // lookupExceptionHandler leaves the handler CallFrame* in vm->callFrameForThrow,
151
    jump(GPRInfo::returnValueGPR2);
151
    // and the address of the handler in vm->targetMachinePCForThrow.
152
    move(TrustedImmPtr(m_vm), GPRInfo::regT0);
153
    loadPtr(Address(GPRInfo::regT0, VM::targetMachinePCForThrowOffset()), GPRInfo::regT1);
154
    loadPtr(Address(GPRInfo::regT0, VM::callFrameForThrowOffset()), GPRInfo::regT0);
155
    jump(GPRInfo::regT1);
152
}
156
}
153
157
154
void JITCompiler::link(LinkBuffer& linkBuffer)
158
void JITCompiler::link(LinkBuffer& linkBuffer)
- Source/JavaScriptCore/jit/JIT.cpp -3 / +6 lines
Lines 869-877 void JIT::privateCompileExceptionHandler Source/JavaScriptCore/jit/JIT.cpp_sec1
869
    poke(GPRInfo::argumentGPR0);
869
    poke(GPRInfo::argumentGPR0);
870
#endif
870
#endif
871
    m_calls.append(CallRecord(call(), (unsigned)-1, FunctionPtr(lookupExceptionHandler).value()));
871
    m_calls.append(CallRecord(call(), (unsigned)-1, FunctionPtr(lookupExceptionHandler).value()));
872
    // lookupExceptionHandler leaves the handler CallFrame* in the returnValueGPR,
872
    // lookupExceptionHandler leaves the handler CallFrame* in vm->callFrameForThrow,
873
    // and the address of the handler in returnValueGPR2.
873
    // and the address of the handler in vm->targetMachinePCForThrow.
874
    jump(GPRInfo::returnValueGPR2);
874
    move(TrustedImmPtr(m_vm), GPRInfo::regT0);
875
    loadPtr(Address(GPRInfo::regT0, VM::targetMachinePCForThrowOffset()), GPRInfo::regT1);
876
    loadPtr(Address(GPRInfo::regT0, VM::callFrameForThrowOffset()), GPRInfo::regT0);
877
    jump(GPRInfo::regT1);
875
}
878
}
876
879
877
880
- Source/JavaScriptCore/jit/JIT.h -5 / +5 lines
Lines 792-802 namespace JSC { Source/JavaScriptCore/jit/JIT.h_sec1
792
        MacroAssembler::Call callOperation(J_JITOperation_EP, int, void*);
792
        MacroAssembler::Call callOperation(J_JITOperation_EP, int, void*);
793
        MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_EPc, int, Instruction*);
793
        MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_EPc, int, Instruction*);
794
        MacroAssembler::Call callOperation(J_JITOperation_EZ, int, int32_t);
794
        MacroAssembler::Call callOperation(J_JITOperation_EZ, int, int32_t);
795
#if USE(JSVALUE64)
796
        MacroAssembler::Call callOperation(Jhe_JITOperation_EJ, RegisterID);
797
#else
798
        MacroAssembler::Call callOperation(Jhe_JITOperation_EJ, RegisterID, RegisterID);
799
#endif
800
        MacroAssembler::Call callOperation(P_JITOperation_EJS, GPRReg, size_t);
795
        MacroAssembler::Call callOperation(P_JITOperation_EJS, GPRReg, size_t);
801
        MacroAssembler::Call callOperation(P_JITOperation_EZ, int32_t);
796
        MacroAssembler::Call callOperation(P_JITOperation_EZ, int32_t);
802
        MacroAssembler::Call callOperation(S_JITOperation_ECC, RegisterID, RegisterID);
797
        MacroAssembler::Call callOperation(S_JITOperation_ECC, RegisterID, RegisterID);
Lines 809-814 namespace JSC { Source/JavaScriptCore/jit/JIT.h_sec2
809
        MacroAssembler::Call callOperation(V_JITOperation_ECICC, RegisterID, const Identifier*, RegisterID, RegisterID);
804
        MacroAssembler::Call callOperation(V_JITOperation_ECICC, RegisterID, const Identifier*, RegisterID, RegisterID);
810
        MacroAssembler::Call callOperation(V_JITOperation_EIdJZ, const Identifier*, RegisterID, int32_t);
805
        MacroAssembler::Call callOperation(V_JITOperation_EIdJZ, const Identifier*, RegisterID, int32_t);
811
        MacroAssembler::Call callOperation(V_JITOperation_EJ, RegisterID);
806
        MacroAssembler::Call callOperation(V_JITOperation_EJ, RegisterID);
807
#if USE(JSVALUE64)
808
        MacroAssembler::Call callOperationNoExceptionCheck(V_JITOperation_EJ, RegisterID);
809
#else
810
        MacroAssembler::Call callOperationNoExceptionCheck(V_JITOperation_EJ, RegisterID, RegisterID);
811
#endif
812
        MacroAssembler::Call callOperation(V_JITOperation_EJIdJJ, RegisterID, const Identifier*, RegisterID, RegisterID);
812
        MacroAssembler::Call callOperation(V_JITOperation_EJIdJJ, RegisterID, const Identifier*, RegisterID, RegisterID);
813
#if USE(JSVALUE64)
813
#if USE(JSVALUE64)
814
        MacroAssembler::Call callOperation(V_JITOperation_EJJI, RegisterID, RegisterID, StringImpl*);
814
        MacroAssembler::Call callOperation(V_JITOperation_EJJI, RegisterID, RegisterID, StringImpl*);
- Source/JavaScriptCore/jit/JITExceptions.cpp -15 / +4 lines
Lines 38-60 Source/JavaScriptCore/jit/JITExceptions.cpp_sec1
38
38
39
namespace JSC {
39
namespace JSC {
40
40
41
#if USE(JSVALUE32_64)
41
void uncaughtExceptionHandler(VM* vm)
42
EncodedExceptionHandler encode(ExceptionHandler handler)
43
{
44
    ExceptionHandlerUnion u;
45
    u.handler = handler;
46
    return u.encodedHandler;
47
}
48
#endif
49
50
ExceptionHandler uncaughtExceptionHandler()
51
{
42
{
52
    void* catchRoutine = FunctionPtr(LLInt::getCodePtr(ctiOpThrowNotCaught)).value();
43
    void* catchRoutine = FunctionPtr(LLInt::getCodePtr(ctiOpThrowNotCaught)).value();
53
    ExceptionHandler exceptionHandler = { 0, catchRoutine};
44
    vm->callFrameForThrow = 0;
54
    return exceptionHandler;
45
    vm->targetMachinePCForThrow = catchRoutine;
55
}
46
}
56
47
57
ExceptionHandler genericUnwind(VM* vm, ExecState* callFrame, JSValue exceptionValue)
48
void genericUnwind(VM* vm, ExecState* callFrame, JSValue exceptionValue)
58
{
49
{
59
    RELEASE_ASSERT(exceptionValue);
50
    RELEASE_ASSERT(exceptionValue);
60
    HandlerInfo* handler = vm->interpreter->unwind(callFrame, exceptionValue); // This may update callFrame.
51
    HandlerInfo* handler = vm->interpreter->unwind(callFrame, exceptionValue); // This may update callFrame.
Lines 72-79 ExceptionHandler genericUnwind(VM* vm, E Source/JavaScriptCore/jit/JITExceptions.cpp_sec2
72
    vm->targetInterpreterPCForThrow = catchPCForInterpreter;
63
    vm->targetInterpreterPCForThrow = catchPCForInterpreter;
73
    
64
    
74
    RELEASE_ASSERT(catchRoutine);
65
    RELEASE_ASSERT(catchRoutine);
75
    ExceptionHandler exceptionHandler = { callFrame, catchRoutine};
76
    return exceptionHandler;
77
}
66
}
78
67
79
}
68
}
- Source/JavaScriptCore/jit/JITExceptions.h -24 / +2 lines
Lines 27-33 Source/JavaScriptCore/jit/JITExceptions.h_sec1
27
#define JITExceptions_h
27
#define JITExceptions_h
28
28
29
#include "JSCJSValue.h"
29
#include "JSCJSValue.h"
30
#include "MacroAssemblerCodeRef.h"
31
30
32
#if ENABLE(JIT) || ENABLE(LLINT)
31
#if ENABLE(JIT) || ENABLE(LLINT)
33
32
Lines 36-64 namespace JSC { Source/JavaScriptCore/jit/JITExceptions.h_sec2
36
class ExecState;
35
class ExecState;
37
class VM;
36
class VM;
38
37
39
// This header gives other parts of the system access to the JIT's prototocol
38
void uncaughtExceptionHandler(VM*);
40
// for the throwing and handling exceptions.
39
void genericUnwind(VM*, ExecState*, JSValue exceptionValue);
41
42
struct ExceptionHandler {
43
    ExecState* callFrame;
44
    void* catchRoutine;
45
};
46
47
#if USE(JSVALUE32_64)
48
// EncodedExceptionHandler is used to convince the compiler to return an ExceptionHander
49
// struct in two registers for 32 bit builds.
50
typedef int64_t EncodedExceptionHandler;
51
52
union ExceptionHandlerUnion {
53
    ExceptionHandler handler;
54
    EncodedExceptionHandler encodedHandler;
55
};
56
57
EncodedExceptionHandler encode(ExceptionHandler);
58
#endif
59
60
ExceptionHandler uncaughtExceptionHandler();
61
ExceptionHandler genericUnwind(VM*, ExecState*, JSValue exceptionValue);
62
40
63
} // namespace JSC
41
} // namespace JSC
64
42
- Source/JavaScriptCore/jit/JITInlines.h -14 / +2 lines
Lines 292-317 ALWAYS_INLINE MacroAssembler::Call JIT:: Source/JavaScriptCore/jit/JITInlines.h_sec1
292
}
292
}
293
293
294
#if USE(JSVALUE64)
294
#if USE(JSVALUE64)
295
ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(Jhe_JITOperation_EJ operation, GPRReg arg1)
295
ALWAYS_INLINE MacroAssembler::Call JIT::callOperationNoExceptionCheck(V_JITOperation_EJ operation, GPRReg arg1)
296
{
296
{
297
#if COMPILER(MSVC) && CPU(X86)
298
    // Need to make space on stack for return value, use that address as first arg (in register),
299
    // move callFrameRegister to second argument register and push the passed arg1.
300
    updateTopCallFrame();
301
    MacroAssembler::Call call = appendCall(operation);
302
    // These may not be pops:
303
    // pop(regT0); // Restore arg1 slot
304
    // pop(regT0); // Get handler's call frame
305
    // pop(regT1); // Get handler's address
306
    return call;
307
#else
308
    setupArgumentsWithExecState(arg1);
297
    setupArgumentsWithExecState(arg1);
309
    updateTopCallFrame();
298
    updateTopCallFrame();
310
    return appendCall(operation);
299
    return appendCall(operation);
311
#endif
312
}
300
}
313
#else
301
#else
314
ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(Jhe_JITOperation_EJ operation, GPRReg arg1Tag, GPRReg arg1Payload)
302
ALWAYS_INLINE MacroAssembler::Call JIT::callOperationNoExceptionCheck(V_JITOperation_EJ operation, GPRReg arg1Tag, GPRReg arg1Payload)
315
{
303
{
316
    setupArgumentsWithExecState(arg1Payload, arg1Tag);
304
    setupArgumentsWithExecState(arg1Payload, arg1Tag);
317
    updateTopCallFrame();
305
    updateTopCallFrame();
- Source/JavaScriptCore/jit/JITOpcodes32_64.cpp -5 / +29 lines
Lines 30-35 Source/JavaScriptCore/jit/JITOpcodes32_64.cpp_sec1
30
#if USE(JSVALUE32_64)
30
#if USE(JSVALUE32_64)
31
#include "JIT.h"
31
#include "JIT.h"
32
32
33
#include "CCallHelpers.h"
33
#include "JITInlines.h"
34
#include "JITInlines.h"
34
#include "JITStubCall.h"
35
#include "JITStubCall.h"
35
#include "JSArray.h"
36
#include "JSArray.h"
Lines 171-177 JIT::CodeRef JIT::privateCompileCTINativ Source/JavaScriptCore/jit/JITOpcodes32_64.cpp_sec2
171
    storePtr(regT1, regT2);
172
    storePtr(regT1, regT2);
172
    storePtr(callFrameRegister, &m_vm->topCallFrame);
173
    storePtr(callFrameRegister, &m_vm->topCallFrame);
173
174
174
    move(TrustedImmPtr(FunctionPtr(ctiVMHandleException).value()), regT1);
175
#if CPU(X86)
176
    addPtr(TrustedImm32(-8), stackPointerRegister);
177
    push(TrustedImm32(JIT::TrustedImmPtr(vm)));
178
    push(callFrameRegister);
179
#else
180
    move(TrustedImmPtr(vm), secondArgumentRegister);
181
    move(callFrameRegister, firstArgumentRegister);
182
#endif
183
    move(TrustedImmPtr(FunctionPtr(operationVMHandleException).value()), regT3);
184
    call(regT3);
185
186
#if CPU(X86)
187
    addPtr(TrustedImm32(16), stackPointerRegister);
188
#endif
189
190
    // operationVMHandleException leaves the handler CallFrame* in vm->callFrameForThrow,
191
    // and the address of the handler in vm->targetMachinePCForThrow.
192
    move(TrustedImmPtr(vm), regT0);
193
    loadPtr(Address(regT0, VM::targetMachinePCForThrowOffset()), regT1);
194
    loadPtr(Address(regT0, VM::callFrameForThrowOffset()), regT0);
175
    jump(regT1);
195
    jump(regT1);
176
196
177
    // All trampolines constructed! copy the code, link up calls, and set the pointers on the Machine object.
197
    // All trampolines constructed! copy the code, link up calls, and set the pointers on the Machine object.
Lines 814-823 void JIT::emit_op_throw(Instruction* cur Source/JavaScriptCore/jit/JITOpcodes32_64.cpp_sec3
814
{
834
{
815
    ASSERT(regT0 == returnValueRegister);
835
    ASSERT(regT0 == returnValueRegister);
816
    emitLoad(currentInstruction[1].u.operand, regT1, regT0);
836
    emitLoad(currentInstruction[1].u.operand, regT1, regT0);
817
    callOperation(operationThrow, regT1, regT0);
837
    callOperationNoExceptionCheck(operationThrow, regT1, regT0);
818
    // After operationThrow returns, returnValueRegister (regT0) has the handler's callFrame and
838
819
    // returnValue2Register has the handler's entry address.
839
    // After operationThrow returns, vm->callFrameForThrow has the handler's callFrame and
820
    jump(returnValue2Register);
840
    // vm->targetMachinePCForThrow has the handler's entry address.
841
    move(TrustedImmPtr(m_vm), regT0);
842
    load32(Address(regT0, VM::targetMachinePCForThrowOffset()), regT1);
843
    load32(Address(regT0, VM::callFrameForThrowOffset()), regT0);
844
    jump(regT1);
821
}
845
}
822
846
823
void JIT::emit_op_get_pnames(Instruction* currentInstruction)
847
void JIT::emit_op_get_pnames(Instruction* currentInstruction)
- Source/JavaScriptCore/jit/JITOpcodes.cpp -4 / +8 lines
Lines 485-494 void JIT::emit_op_throw(Instruction* cur Source/JavaScriptCore/jit/JITOpcodes.cpp_sec1
485
{
485
{
486
    ASSERT(regT0 == returnValueRegister);
486
    ASSERT(regT0 == returnValueRegister);
487
    emitGetVirtualRegister(currentInstruction[1].u.operand, regT0);
487
    emitGetVirtualRegister(currentInstruction[1].u.operand, regT0);
488
    callOperation(operationThrow, regT0);
488
    callOperationNoExceptionCheck(operationThrow, regT0);
489
    // After operationThrow returns, returnValueRegister (regT0) has the handler's callFrame and
489
490
    // returnValue2Register has the handler's entry address.
490
    // After operationThrow returns, vm->callFrameForThrow has the handler's callFrame and
491
    jump(returnValue2Register);
491
    // vm->targetMachinePCForThrow has the handler's entry address.
492
    move(TrustedImmPtr(m_vm), regT0);
493
    load64(Address(regT0, VM::targetMachinePCForThrowOffset()), regT1);
494
    load64(Address(regT0, VM::callFrameForThrowOffset()), regT0);
495
    jump(regT1);
492
}
496
}
493
497
494
void JIT::emit_op_get_pnames(Instruction* currentInstruction)
498
void JIT::emit_op_get_pnames(Instruction* currentInstruction)
- Source/JavaScriptCore/jit/JITOperations.cpp -7 / +23 lines
Lines 1615-1632 void JIT_OPERATION operationPutToScope(E Source/JavaScriptCore/jit/JITOperations.cpp_sec1
1615
    }
1615
    }
1616
}
1616
}
1617
1617
1618
JITHandlerEncoded JIT_OPERATION operationThrow(ExecState* exec, EncodedJSValue encodedExceptionValue)
1618
void JIT_OPERATION operationThrow(ExecState* exec, EncodedJSValue encodedExceptionValue)
1619
{
1619
{
1620
    VM* vm = &exec->vm();
1620
    VM* vm = &exec->vm();
1621
    NativeCallFrameTracer tracer(vm, exec);
1621
    NativeCallFrameTracer tracer(vm, exec);
1622
1622
1623
    JSValue exceptionValue = JSValue::decode(encodedExceptionValue);
1623
    JSValue exceptionValue = JSValue::decode(encodedExceptionValue);
1624
    vm->throwException(exec, exceptionValue);
1624
    vm->throwException(exec, exceptionValue);
1625
    ExceptionHandler handler = genericUnwind(vm, exec, exceptionValue);
1625
1626
    return dfgHandlerEncoded(handler.callFrame, handler.catchRoutine);
1626
    // Results stored out-of-band in vm.targetMachinePCForThrow & vm.callFrameForThrow
1627
    genericUnwind(vm, exec, exceptionValue);
1627
}
1628
}
1628
1629
1629
JITHandlerEncoded JIT_OPERATION lookupExceptionHandler(ExecState* exec)
1630
void JIT_OPERATION lookupExceptionHandler(ExecState* exec)
1630
{
1631
{
1631
    VM* vm = &exec->vm();
1632
    VM* vm = &exec->vm();
1632
    NativeCallFrameTracer tracer(vm, exec);
1633
    NativeCallFrameTracer tracer(vm, exec);
Lines 1634-1642 JITHandlerEncoded JIT_OPERATION lookupEx Source/JavaScriptCore/jit/JITOperations.cpp_sec2
1634
    JSValue exceptionValue = exec->exception();
1635
    JSValue exceptionValue = exec->exception();
1635
    ASSERT(exceptionValue);
1636
    ASSERT(exceptionValue);
1636
    
1637
    
1637
    ExceptionHandler handler = genericUnwind(vm, exec, exceptionValue);
1638
    genericUnwind(vm, exec, exceptionValue);
1638
    ASSERT(handler.catchRoutine);
1639
    ASSERT(vm->targetMachinePCForThrow);
1639
    return dfgHandlerEncoded(handler.callFrame, handler.catchRoutine);
1640
}
1641
1642
void JIT_OPERATION operationVMHandleException(ExecState* exec, VM* vm)
1643
{
1644
    NativeCallFrameTracer tracer(vm, exec);
1645
1646
    ASSERT(!exec->hasHostCallFrameFlag());
1647
    if (!exec) {
1648
        // The entire stack has already been unwound. Nothing more to handle.
1649
        uncaughtExceptionHandler(vm);
1650
        return;
1651
    }
1652
1653
    ASSERT(vm == &exec->vm());
1654
    vm->topCallFrame = exec;
1655
    genericUnwind(vm, exec, vm->exception());
1640
}
1656
}
1641
1657
1642
} // extern "C"
1658
} // extern "C"
- Source/JavaScriptCore/jit/JITOperations.h -43 / +8 lines
Lines 47-91 class ArrayAllocationProfile; Source/JavaScriptCore/jit/JITOperations.h_sec1
47
47
48
extern "C" {
48
extern "C" {
49
49
50
// This method is used to lookup an exception hander, keyed by faultLocation, which is
51
// the return location from one of the calls out to one of the helper operations above.
52
53
// According to C++ rules, a type used for the return signature of function with C linkage (i.e.
54
// 'extern "C"') needs to be POD; hence putting any constructors into it could cause either compiler
55
// warnings, or worse, a change in the ABI used to return these types.
56
struct JITHandler {
57
    union Union {
58
        struct Struct {
59
            ExecState* exec;
60
            void* handler;
61
        } s;
62
        uint64_t encoded;
63
    } u;
64
};
65
66
inline JITHandler createJITHandler(ExecState* exec, void* handler)
67
{
68
    JITHandler result;
69
    result.u.s.exec = exec;
70
    result.u.s.handler = handler;
71
    return result;
72
}
73
74
#if CPU(X86_64)
75
typedef JITHandler JITHandlerEncoded;
76
inline JITHandlerEncoded dfgHandlerEncoded(ExecState* exec, void* handler)
77
{
78
    return createJITHandler(exec, handler);
79
}
80
#else
81
typedef uint64_t JITHandlerEncoded;
82
inline JITHandlerEncoded dfgHandlerEncoded(ExecState* exec, void* handler)
83
{
84
    COMPILE_ASSERT(sizeof(JITHandler::Union) == sizeof(uint64_t), JITHandler_Union_is_64bit);
85
    return createJITHandler(exec, handler).u.encoded;
86
}
87
#endif
88
89
// These typedefs provide typechecking when generating calls out to helper routines;
50
// These typedefs provide typechecking when generating calls out to helper routines;
90
// this helps prevent calling a helper routine with the wrong arguments!
51
// this helps prevent calling a helper routine with the wrong arguments!
91
/*
52
/*
Lines 102-108 inline JITHandlerEncoded dfgHandlerEncod Source/JavaScriptCore/jit/JITOperations.h_sec2
102
    Idc: const Identifier*
63
    Idc: const Identifier*
103
    J: EncodedJSValue
64
    J: EncodedJSValue
104
    Jcp: const JSValue*
65
    Jcp: const JSValue*
105
    Jhe: JITHandlerEncoded
106
    Jsa: JSActivation*
66
    Jsa: JSActivation*
107
    Jss: JSString*
67
    Jss: JSString*
108
    O: JSObject*
68
    O: JSObject*
Lines 112-117 inline JITHandlerEncoded dfgHandlerEncod Source/JavaScriptCore/jit/JITOperations.h_sec3
112
    S: size_t
72
    S: size_t
113
    St: Structure*
73
    St: Structure*
114
    V: void
74
    V: void
75
    Vm: VM*
115
    W: WatchpointSet*
76
    W: WatchpointSet*
116
    Z: int32_t
77
    Z: int32_t
117
*/
78
*/
Lines 142-148 typedef EncodedJSValue JIT_OPERATION (*J Source/JavaScriptCore/jit/JITOperations.h_sec4
142
typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EZ)(ExecState*, int32_t);
103
typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EZ)(ExecState*, int32_t);
143
typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EZIcfZ)(ExecState*, int32_t, InlineCallFrame*, int32_t);
104
typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EZIcfZ)(ExecState*, int32_t, InlineCallFrame*, int32_t);
144
typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EZZ)(ExecState*, int32_t, int32_t);
105
typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EZZ)(ExecState*, int32_t, int32_t);
145
typedef JITHandlerEncoded JIT_OPERATION (*Jhe_JITOperation_EJ)(ExecState*, EncodedJSValue);
146
typedef JSCell* JIT_OPERATION (*C_JITOperation_E)(ExecState*);
106
typedef JSCell* JIT_OPERATION (*C_JITOperation_E)(ExecState*);
147
typedef JSCell* JIT_OPERATION (*C_JITOperation_EZ)(ExecState*, int32_t);
107
typedef JSCell* JIT_OPERATION (*C_JITOperation_EZ)(ExecState*, int32_t);
148
typedef JSCell* JIT_OPERATION (*C_JITOperation_EC)(ExecState*, JSCell*);
108
typedef JSCell* JIT_OPERATION (*C_JITOperation_EC)(ExecState*, JSCell*);
Lines 191-196 typedef void JIT_OPERATION (*V_JITOperat Source/JavaScriptCore/jit/JITOperations.h_sec5
191
typedef void JIT_OPERATION (*V_JITOperation_EPZJ)(ExecState*, void*, int32_t, EncodedJSValue);
151
typedef void JIT_OPERATION (*V_JITOperation_EPZJ)(ExecState*, void*, int32_t, EncodedJSValue);
192
typedef void JIT_OPERATION (*V_JITOperation_W)(WatchpointSet*);
152
typedef void JIT_OPERATION (*V_JITOperation_W)(WatchpointSet*);
193
typedef void JIT_OPERATION (*V_JITOperation_EZ)(ExecState*, int32_t);
153
typedef void JIT_OPERATION (*V_JITOperation_EZ)(ExecState*, int32_t);
154
typedef void JIT_OPERATION (*V_JITOperation_EVm)(ExecState*, VM*);
194
typedef char* JIT_OPERATION (*P_JITOperation_E)(ExecState*);
155
typedef char* JIT_OPERATION (*P_JITOperation_E)(ExecState*);
195
typedef char* JIT_OPERATION (*P_JITOperation_EC)(ExecState*, JSCell*);
156
typedef char* JIT_OPERATION (*P_JITOperation_EC)(ExecState*, JSCell*);
196
typedef char* JIT_OPERATION (*P_JITOperation_EJS)(ExecState*, EncodedJSValue, size_t);
157
typedef char* JIT_OPERATION (*P_JITOperation_EJS)(ExecState*, EncodedJSValue, size_t);
Lines 210-216 typedef char* JIT_OPERATION (*P_JITOpera Source/JavaScriptCore/jit/JITOperations.h_sec6
210
typedef StringImpl* JIT_OPERATION (*I_JITOperation_EJss)(ExecState*, JSString*);
171
typedef StringImpl* JIT_OPERATION (*I_JITOperation_EJss)(ExecState*, JSString*);
211
typedef JSString* JIT_OPERATION (*Jss_JITOperation_EZ)(ExecState*, int32_t);
172
typedef JSString* JIT_OPERATION (*Jss_JITOperation_EZ)(ExecState*, int32_t);
212
173
213
JITHandlerEncoded JIT_OPERATION lookupExceptionHandler(ExecState*) WTF_INTERNAL;
174
// This method is used to lookup an exception hander, keyed by faultLocation, which is
175
// the return location from one of the calls out to one of the helper operations above.
176
    
177
void JIT_OPERATION lookupExceptionHandler(ExecState*) WTF_INTERNAL;
178
void JIT_OPERATION operationVMHandleException(ExecState*, VM*) WTF_INTERNAL;
214
179
215
void JIT_OPERATION operationStackCheck(ExecState*, CodeBlock*) WTF_INTERNAL;
180
void JIT_OPERATION operationStackCheck(ExecState*, CodeBlock*) WTF_INTERNAL;
216
int32_t JIT_OPERATION operationCallArityCheck(ExecState*) WTF_INTERNAL;
181
int32_t JIT_OPERATION operationCallArityCheck(ExecState*) WTF_INTERNAL;
Lines 264-270 JSCell* JIT_OPERATION operationNewObject Source/JavaScriptCore/jit/JITOperations.h_sec7
264
EncodedJSValue JIT_OPERATION operationNewRegexp(ExecState*, void*) WTF_INTERNAL;
229
EncodedJSValue JIT_OPERATION operationNewRegexp(ExecState*, void*) WTF_INTERNAL;
265
void JIT_OPERATION operationHandleWatchdogTimer(ExecState*) WTF_INTERNAL;
230
void JIT_OPERATION operationHandleWatchdogTimer(ExecState*) WTF_INTERNAL;
266
void JIT_OPERATION operationThrowStaticError(ExecState*, EncodedJSValue, int32_t) WTF_INTERNAL;
231
void JIT_OPERATION operationThrowStaticError(ExecState*, EncodedJSValue, int32_t) WTF_INTERNAL;
267
JITHandlerEncoded JIT_OPERATION operationThrow(ExecState*, EncodedJSValue) WTF_INTERNAL;
232
void JIT_OPERATION operationThrow(ExecState*, EncodedJSValue) WTF_INTERNAL;
268
void JIT_OPERATION operationDebug(ExecState*, int32_t) WTF_INTERNAL;
233
void JIT_OPERATION operationDebug(ExecState*, int32_t) WTF_INTERNAL;
269
#if ENABLE(DFG_JIT)
234
#if ENABLE(DFG_JIT)
270
char* JIT_OPERATION operationOptimize(ExecState*, int32_t) WTF_INTERNAL;
235
char* JIT_OPERATION operationOptimize(ExecState*, int32_t) WTF_INTERNAL;
- Source/JavaScriptCore/jit/JITStubs.cpp -28 lines
Lines 109-142 namespace JSC { Source/JavaScriptCore/jit/JITStubs.cpp_sec1
109
    #define CTI_SAMPLER 0
109
    #define CTI_SAMPLER 0
110
#endif
110
#endif
111
111
112
#if USE(JSVALUE32_64)
113
EncodedExceptionHandler JIT_STUB cti_vm_handle_exception(CallFrame* callFrame)
114
{
115
    ASSERT(!callFrame->hasHostCallFrameFlag());
116
    if (!callFrame) {
117
        // The entire stack has already been unwound. Nothing more to handle.
118
        return encode(uncaughtExceptionHandler());
119
    }
120
121
    VM* vm = callFrame->codeBlock()->vm();
122
    vm->topCallFrame = callFrame;
123
    return encode(genericUnwind(vm, callFrame, vm->exception()));
124
}
125
#else
126
ExceptionHandler JIT_STUB cti_vm_handle_exception(CallFrame* callFrame)
127
{
128
    ASSERT(!callFrame->hasHostCallFrameFlag());
129
    if (!callFrame) {
130
        // The entire stack has already been unwound. Nothing more to handle.
131
        return uncaughtExceptionHandler();
132
    }
133
134
    VM* vm = callFrame->codeBlock()->vm();
135
    vm->topCallFrame = callFrame;
136
    return genericUnwind(vm, callFrame, vm->exception());
137
}
138
#endif
139
140
} // namespace JSC
112
} // namespace JSC
141
113
142
#endif // ENABLE(JIT)
114
#endif // ENABLE(JIT)
- Source/JavaScriptCore/jit/JITStubs.h -10 lines
Lines 351-366 inline bool returnAddressIsInCtiTrampoli Source/JavaScriptCore/jit/JITStubs.h_sec1
351
extern "C" void ctiMasmProbeTrampoline();
351
extern "C" void ctiMasmProbeTrampoline();
352
#endif
352
#endif
353
353
354
extern "C" {
355
356
#if USE(JSVALUE32_64)
357
EncodedExceptionHandler JIT_STUB cti_vm_handle_exception(CallFrame*) REFERENCED_FROM_ASM WTF_INTERNAL;
358
#else
359
ExceptionHandler JIT_STUB cti_vm_handle_exception(CallFrame*) REFERENCED_FROM_ASM WTF_INTERNAL;
360
#endif
361
362
} // extern "C"
363
364
#endif // ENABLE(JIT)
354
#endif // ENABLE(JIT)
365
355
366
} // namespace JSC
356
} // namespace JSC
- Source/JavaScriptCore/jit/JITStubsARM64.h -8 lines
Lines 100-113 SYMBOL_STRING(ctiTrampoline) ":" "\n" Source/JavaScriptCore/jit/JITStubsARM64.h_sec1
100
    "add sp, sp, #" STRINGIZE_VALUE_OF(SIZEOF_JITSTACKFRAME) "\n"
100
    "add sp, sp, #" STRINGIZE_VALUE_OF(SIZEOF_JITSTACKFRAME) "\n"
101
    "ret" "\n"
101
    "ret" "\n"
102
102
103
HIDE_SYMBOL(ctiVMHandleException) "\n"
104
SYMBOL_STRING(ctiVMHandleException) ":" "\n"
105
    "mov x0, x25" "\n"
106
    "bl " LOCAL_REFERENCE(cti_vm_handle_exception) "\n"
107
    // When cti_vm_handle_exception returns, x0 has callFrame and x1 has handler address
108
    "mov x25, x0" "\n"
109
    "br x1" "\n"
110
111
HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
103
HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
112
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
104
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
113
    "ldr x28, [sp, #" STRINGIZE_VALUE_OF(PRESERVED_X28_OFFSET) "]" "\n"
105
    "ldr x28, [sp, #" STRINGIZE_VALUE_OF(PRESERVED_X28_OFFSET) "]" "\n"
- Source/JavaScriptCore/jit/JITStubsARM.h -13 lines
Lines 186-204 SYMBOL_STRING(ctiOpThrowNotCaught) ":" " Source/JavaScriptCore/jit/JITStubsARM.h_sec1
186
    "bx lr" "\n"
186
    "bx lr" "\n"
187
);
187
);
188
188
189
asm (
190
".text" "\n"
191
".globl " SYMBOL_STRING(ctiVMHandleException) "\n"
192
HIDE_SYMBOL(ctiVMHandleException) "\n"
193
INLINE_ARM_FUNCTION(ctiVMHandleException)
194
SYMBOL_STRING(ctiVMHandleException) ":" "\n"
195
    "mov r0, r5" "\n"
196
    "bl " SYMBOL_STRING(cti_vm_handle_exception) "\n"
197
    // When cti_vm_handle_exception returns, r0 has callFrame and r1 has handler address
198
    "mov r5, r0" "\n"
199
    "bx r1" "\n"
200
);
201
202
#if USE(MASM_PROBE)
189
#if USE(MASM_PROBE)
203
asm (
190
asm (
204
".text" "\n"
191
".text" "\n"
- Source/JavaScriptCore/jit/JITStubsARMv7.h -15 lines
Lines 245-265 SYMBOL_STRING(ctiTrampolineEnd) ":" "\n" Source/JavaScriptCore/jit/JITStubsARMv7.h_sec1
245
asm (
245
asm (
246
".text" "\n"
246
".text" "\n"
247
".align 2" "\n"
247
".align 2" "\n"
248
".globl " SYMBOL_STRING(ctiVMHandleException) "\n"
249
HIDE_SYMBOL(ctiVMHandleException) "\n"
250
".thumb" "\n"
251
".thumb_func " THUMB_FUNC_PARAM(ctiVMHandleException) "\n"
252
SYMBOL_STRING(ctiVMHandleException) ":" "\n"
253
    "mov r0, r5" "\n"
254
    "bl " LOCAL_REFERENCE(cti_vm_handle_exception) "\n"
255
    // When cti_vm_handle_exception returns, r0 has callFrame and r1 has handler address
256
    "mov r5, r0" "\n"
257
    "bx r1" "\n"
258
);
259
260
asm (
261
".text" "\n"
262
".align 2" "\n"
263
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
248
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
264
HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
249
HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
265
".thumb" "\n"
250
".thumb" "\n"
- Source/JavaScriptCore/jit/JITStubsMIPS.h -29 lines
Lines 101-135 asm ( Source/JavaScriptCore/jit/JITStubsMIPS.h_sec1
101
".set noreorder" "\n"
101
".set noreorder" "\n"
102
".set nomacro" "\n"
102
".set nomacro" "\n"
103
".set nomips16" "\n"
103
".set nomips16" "\n"
104
".globl " SYMBOL_STRING(ctiVMHandleException) "\n"
105
".ent " SYMBOL_STRING(ctiVMHandleException) "\n"
106
SYMBOL_STRING(ctiVMHandleException) ":" "\n"
107
#if WTF_MIPS_PIC
108
".set macro" "\n"
109
".cpload $25" "\n"
110
    "la    $25," SYMBOL_STRING(cti_vm_handle_exception) "\n"
111
".set nomacro" "\n"
112
    "bal " SYMBOL_STRING(cti_vm_handle_exception) "\n"
113
    "move  $4,$16" "\n"
114
#else
115
    "jal " SYMBOL_STRING(cti_vm_handle_exception) "\n"
116
    "move  $4,$16" "\n"
117
#endif
118
    // When cti_vm_handle_exception returns, v0 has callFrame and v1 has handler address
119
    "move  $31,$3" "\n"
120
    "jr    $31" "\n"
121
    "move  $16,$2 " "\n"
122
".set reorder" "\n"
123
".set macro" "\n"
124
".end " SYMBOL_STRING(ctiVMHandleException) "\n"
125
);
126
127
asm (
128
".text" "\n"
129
".align 2" "\n"
130
".set noreorder" "\n"
131
".set nomacro" "\n"
132
".set nomips16" "\n"
133
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
104
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
134
".ent " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
105
".ent " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
135
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
106
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
- Source/JavaScriptCore/jit/JITStubsMSVC64.asm -12 lines
Lines 65-82 ctiTrampoline PROC Source/JavaScriptCore/jit/JITStubsMSVC64.asm_sec1
65
    ret
65
    ret
66
ctiTrampoline ENDP
66
ctiTrampoline ENDP
67
67
68
ctiVMHandleException PROC
69
	sub rsp, 16
70
    mov rcx, rsp
71
	mov rdx, r13
72
	call cti_vm_handle_exception
73
    ; When cti_vm_handle_exception returns, rax points to the memory we allocated on stack
74
	; It contains the callFrame and handler address
75
	pop rax		; callFrame
76
	pop rdx		; handler
77
    jmp rdx
78
ctiVMHandleException ENDP
79
 
80
ctiOpThrowNotCaught PROC
68
ctiOpThrowNotCaught PROC
81
    add rsp, 58h
69
    add rsp, 58h
82
    pop rbx
70
    pop rbx
- Source/JavaScriptCore/jit/JITStubsSH4.h -18 lines
Lines 83-106 SYMBOL_STRING(ctiTrampolineEnd) ":" "\n" Source/JavaScriptCore/jit/JITStubsSH4.h_sec1
83
);
83
);
84
84
85
asm volatile (
85
asm volatile (
86
".globl " SYMBOL_STRING(ctiVMHandleException) "\n"
87
HIDE_SYMBOL(ctiVMHandleException) "\n"
88
SYMBOL_STRING(ctiVMHandleException) ":" "\n"
89
    "mov.l .L2" SYMBOL_STRING(cti_vm_handle_exception) ",r0" "\n"
90
    "mov r14, r4" "\n"
91
    "mov.l @(r0,r12),r11" "\n"
92
    "jsr @r11" "\n"
93
    // When cti_vm_handle_exception returns, r0 has callFrame and r1 has handler address
94
    "nop" "\n"
95
    "mov r0, r14" "\n"
96
    "lds r1, pr" "\n"
97
    "rts" "\n"
98
    "nop" "\n"
99
    ".align 2" "\n"
100
    ".L2" SYMBOL_STRING(cti_vm_handle_exception) ":.long " SYMBOL_STRING(cti_vm_handle_exception) "@GOT \n"
101
);
102
103
asm volatile (
104
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
86
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
105
HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
87
HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
106
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
88
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
- Source/JavaScriptCore/jit/JITStubsX86.h -10 lines
Lines 70-85 SYMBOL_STRING(ctiTrampolineEnd) ":" "\n" Source/JavaScriptCore/jit/JITStubsX86.h_sec1
70
);
70
);
71
71
72
asm (
72
asm (
73
".globl " SYMBOL_STRING(ctiVMHandleException) "\n"
74
HIDE_SYMBOL(ctiVMHandleException) "\n"
75
SYMBOL_STRING(ctiVMHandleException) ":" "\n"
76
    "movl %edi, %ecx" "\n"
77
    "call " LOCAL_REFERENCE(cti_vm_handle_exception) "\n"
78
    // When cti_vm_handle_exception returns, eax has callFrame and edx has handler address
79
    "jmp *%edx" "\n"
80
);
81
82
asm (
83
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
73
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
84
HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
74
HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
85
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
75
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
- Source/JavaScriptCore/jit/JITStubsX86_64.h -10 lines
Lines 84-99 SYMBOL_STRING(ctiTrampolineEnd) ":" "\n" Source/JavaScriptCore/jit/JITStubsX86_64.h_sec1
84
);
84
);
85
85
86
asm (
86
asm (
87
".globl " SYMBOL_STRING(ctiVMHandleException) "\n"
88
HIDE_SYMBOL(ctiVMHandleException) "\n"
89
SYMBOL_STRING(ctiVMHandleException) ":" "\n"
90
    "movq %r13, %rdi" "\n"
91
    "call " LOCAL_REFERENCE(cti_vm_handle_exception) "\n"
92
    // When cti_vm_handle_exception returns, rax has callFrame and rdx has handler address
93
    "jmp *%rdx" "\n"
94
);
95
96
asm (
97
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
87
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
98
HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
88
HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
99
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
89
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
- Source/JavaScriptCore/jit/Repatch.cpp -1 / +7 lines
Lines 517-523 static bool tryBuildGetByIDList(ExecStat Source/JavaScriptCore/jit/Repatch.cpp_sec1
517
            
517
            
518
            stubJit.setupArgumentsExecState();
518
            stubJit.setupArgumentsExecState();
519
            handlerCall = stubJit.call();
519
            handlerCall = stubJit.call();
520
            stubJit.jump(GPRInfo::returnValueGPR2);
520
            // lookupExceptionHandler leaves the handler CallFrame* in vm->callFrameForThrow,
521
            // and the address of the handler in vm->targetMachinePCForThrow.
522
            stubJit.move(CCallHelpers::TrustedImmPtr(vm), GPRInfo::regT0);
523
            stubJit.loadPtr(CCallHelpers::Address(GPRInfo::regT0, VM::targetMachinePCForThrowOffset()), GPRInfo::regT1);
524
            stubJit.loadPtr(CCallHelpers::Address(GPRInfo::regT0, VM::callFrameForThrowOffset()), GPRInfo::regT0);
525
            stubJit.jump(GPRInfo::regT1);
526
521
        } else {
527
        } else {
522
            if (isInlineOffset(slot.cachedOffset())) {
528
            if (isInlineOffset(slot.cachedOffset())) {
523
#if USE(JSVALUE64)
529
#if USE(JSVALUE64)
- Source/JavaScriptCore/jit/SlowPathCall.h -12 / +2 lines
Lines 81-98 public: Source/JavaScriptCore/jit/SlowPathCall.h_sec1
81
        m_jit->unmap();
81
        m_jit->unmap();
82
#else
82
#else
83
        m_jit->killLastResultRegister();
83
        m_jit->killLastResultRegister();
84
#endif
84
#endif   
85
        
85
        m_jit->exceptionCheck();
86
#if USE(JSVALUE32_64)
87
        JIT::Jump noException = m_jit->branch32(JIT::Equal, JIT::AbsoluteAddress(reinterpret_cast<char*>(m_jit->m_codeBlock->vm()->addressOfException()) + OBJECT_OFFSETOF(JSValue, u.asBits.tag)), JIT::TrustedImm32(JSValue::EmptyValueTag));
88
#else
89
        JIT::Jump noException = m_jit->branchTest64(JIT::Zero, JIT::AbsoluteAddress(m_jit->m_codeBlock->vm()->addressOfException()));
90
#endif
91
        m_jit->updateTopCallFrame();
92
        m_jit->move(JIT::TrustedImmPtr(FunctionPtr(ctiVMHandleException).value()), JIT::regT1);
93
        m_jit->jump(JIT::regT1);
94
        noException.link(m_jit);
95
        
96
        return call;
86
        return call;
97
    }
87
    }
98
88
- Source/JavaScriptCore/jit/ThunkGenerators.cpp -4 / +27 lines
Lines 82-89 MacroAssemblerCodeRef throwExceptionFrom Source/JavaScriptCore/jit/ThunkGenerators.cpp_sec1
82
    jit.move(CCallHelpers::TrustedImmPtr(bitwise_cast<void*>(lookupExceptionHandler)), GPRInfo::nonArgGPR0);
82
    jit.move(CCallHelpers::TrustedImmPtr(bitwise_cast<void*>(lookupExceptionHandler)), GPRInfo::nonArgGPR0);
83
    emitPointerValidation(jit, GPRInfo::nonArgGPR0);
83
    emitPointerValidation(jit, GPRInfo::nonArgGPR0);
84
    jit.call(GPRInfo::nonArgGPR0);
84
    jit.call(GPRInfo::nonArgGPR0);
85
    emitPointerValidation(jit, GPRInfo::returnValueGPR2);
85
86
    jit.jump(GPRInfo::returnValueGPR2);
86
    // lookupExceptionHandler leaves the handler CallFrame* in vm->callFrameForThrow,
87
    // and the address of the handler in vm->targetMachinePCForThrow.
88
    jit.move(CCallHelpers::TrustedImmPtr(vm), GPRInfo::regT0);
89
    jit.loadPtr(CCallHelpers::Address(GPRInfo::regT0, VM::targetMachinePCForThrowOffset()), GPRInfo::regT1);
90
    jit.loadPtr(CCallHelpers::Address(GPRInfo::regT0, VM::callFrameForThrowOffset()), GPRInfo::regT0);
91
    emitPointerValidation(jit, GPRInfo::regT1);
92
    jit.jump(GPRInfo::regT1);
87
    
93
    
88
    LinkBuffer patchBuffer(*vm, &jit, GLOBAL_THUNK_ID);
94
    LinkBuffer patchBuffer(*vm, &jit, GLOBAL_THUNK_ID);
89
    return FINALIZE_CODE(patchBuffer, ("Throw exception from call slow path thunk"));
95
    return FINALIZE_CODE(patchBuffer, ("Throw exception from call slow path thunk"));
Lines 474-482 static MacroAssemblerCodeRef nativeForGe Source/JavaScriptCore/jit/ThunkGenerators.cpp_sec2
474
480
475
    jit.storePtr(JSInterfaceJIT::callFrameRegister, &vm->topCallFrame);
481
    jit.storePtr(JSInterfaceJIT::callFrameRegister, &vm->topCallFrame);
476
482
477
    jit.move(JSInterfaceJIT::TrustedImmPtr(FunctionPtr(ctiVMHandleException).value()), JSInterfaceJIT::regT1);
483
#if CPU(X86) && USE(JSVALUE32_64)
478
    jit.jump(JSInterfaceJIT::regT1);
484
    jit.addPtr(JSInterfaceJIT::TrustedImm32(-8), JSInterfaceJIT::stackPointerRegister);
485
    jit.push(JSInterfaceJIT::TrustedImm32(JSInterfaceJIT::TrustedImmPtr(vm)));
486
    jit.push(JSInterfaceJIT::callFrameRegister);
487
#else
488
    jit.move(JSInterfaceJIT::TrustedImmPtr(vm), JSInterfaceJIT::secondArgumentRegister);
489
    jit.move(JSInterfaceJIT::callFrameRegister, JSInterfaceJIT::firstArgumentRegister);
490
#endif
491
    jit.move(JSInterfaceJIT::TrustedImmPtr(FunctionPtr(operationVMHandleException).value()), JSInterfaceJIT::regT3);
492
    jit.call(JSInterfaceJIT::regT3);
493
#if CPU(X86) && USE(JSVALUE32_64)
494
    jit.addPtr(JSInterfaceJIT::TrustedImm32(16), JSInterfaceJIT::stackPointerRegister);
495
#endif
479
496
497
    // operationVMHandleException leaves the handler CallFrame* in vm->callFrameForThrow,
498
    // and the address of the handler in vm->targetMachinePCForThrow.
499
    jit.move(JSInterfaceJIT::TrustedImmPtr(vm), JSInterfaceJIT::regT0);
500
    jit.loadPtr(JSInterfaceJIT::Address(JSInterfaceJIT::regT0, VM::targetMachinePCForThrowOffset()), JSInterfaceJIT::regT1);
501
    jit.loadPtr(JSInterfaceJIT::Address(JSInterfaceJIT::regT0, VM::callFrameForThrowOffset()), JSInterfaceJIT::regT0);
502
    jit.jump(JSInterfaceJIT::regT1);
480
    LinkBuffer patchBuffer(*vm, &jit, GLOBAL_THUNK_ID);
503
    LinkBuffer patchBuffer(*vm, &jit, GLOBAL_THUNK_ID);
481
    return FINALIZE_CODE(patchBuffer, ("native %s trampoline", toCString(kind).data()));
504
    return FINALIZE_CODE(patchBuffer, ("native %s trampoline", toCString(kind).data()));
482
}
505
}
- Source/JavaScriptCore/runtime/VM.h -1 / +11 lines
Lines 340-346 namespace JSC { Source/JavaScriptCore/runtime/VM.h_sec1
340
        {
340
        {
341
            return OBJECT_OFFSETOF(VM, m_exception);
341
            return OBJECT_OFFSETOF(VM, m_exception);
342
        }
342
        }
343
        
343
344
        static ptrdiff_t callFrameForThrowOffset()
345
        {
346
            return OBJECT_OFFSETOF(VM, callFrameForThrow);
347
        }
348
349
        static ptrdiff_t targetMachinePCForThrowOffset()
350
        {
351
            return OBJECT_OFFSETOF(VM, targetMachinePCForThrow);
352
        }
353
344
        JS_EXPORT_PRIVATE void clearException();
354
        JS_EXPORT_PRIVATE void clearException();
345
        JS_EXPORT_PRIVATE void clearExceptionStack();
355
        JS_EXPORT_PRIVATE void clearExceptionStack();
346
        void getExceptionInfo(JSValue& exception, RefCountedArray<StackFrame>& exceptionStack);
356
        void getExceptionInfo(JSValue& exception, RefCountedArray<StackFrame>& exceptionStack);

Return to Bug 122982