Switch VMTraps to use halt instructions rather than breakpoint instructions
authorkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Jun 2017 02:54:02 +0000 (02:54 +0000)
committerkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Jun 2017 02:54:02 +0000 (02:54 +0000)
commitc21509870f39590cc8058df923fcaa92e212311b
tree64d4cc079dd5783ee64123e0d123a8552e0302ce
parent29e1705c8eb94467f470e4e77045378894caa268
Switch VMTraps to use halt instructions rather than breakpoint instructions
https://bugs.webkit.org/show_bug.cgi?id=173677
Source/JavaScriptCore:

<rdar://problem/32178892>

Reviewed by JF Bastien.

Using the breakpoint instruction for VMTraps caused issues with lldb.
Since we only need some way to stop execution we can, in theory, use
any exceptioning instruction we want. I went with the halt instruction
on X86 since that is the only one byte instruction that does not
breakpoint (in my tests both 0xf1 and 0xd6 produced EXC_BREAKPOINT).
On ARM we use the data cache clearing instruction with the zero register,
which triggers a segmentation fault.

Also, update the platform code to only use signaling VMTraps
on where we have an appropriate instruction (x86 and ARM64).

* API/tests/ExecutionTimeLimitTest.cpp:
(testExecutionTimeLimit):
* assembler/ARM64Assembler.h:
(JSC::ARM64Assembler::replaceWithVMHalt):
(JSC::ARM64Assembler::dataCacheZeroVirtualAddress):
(JSC::ARM64Assembler::replaceWithBkpt): Deleted.
* assembler/ARMAssembler.h:
(JSC::ARMAssembler::replaceWithBkpt): Deleted.
* assembler/ARMv7Assembler.h:
(JSC::ARMv7Assembler::replaceWithBkpt): Deleted.
* assembler/MIPSAssembler.h:
(JSC::MIPSAssembler::replaceWithBkpt): Deleted.
* assembler/MacroAssemblerARM.h:
(JSC::MacroAssemblerARM::replaceWithBreakpoint): Deleted.
* assembler/MacroAssemblerARM64.h:
(JSC::MacroAssemblerARM64::replaceWithVMHalt):
(JSC::MacroAssemblerARM64::replaceWithBreakpoint): Deleted.
* assembler/MacroAssemblerARMv7.h:
(JSC::MacroAssemblerARMv7::storeFence):
(JSC::MacroAssemblerARMv7::replaceWithBreakpoint): Deleted.
* assembler/MacroAssemblerMIPS.h:
(JSC::MacroAssemblerMIPS::replaceWithBreakpoint): Deleted.
* assembler/MacroAssemblerX86Common.h:
(JSC::MacroAssemblerX86Common::replaceWithVMHalt):
(JSC::MacroAssemblerX86Common::replaceWithBreakpoint): Deleted.
* assembler/X86Assembler.h:
(JSC::X86Assembler::replaceWithHlt):
(JSC::X86Assembler::replaceWithInt3): Deleted.
* dfg/DFGJumpReplacement.cpp:
(JSC::DFG::JumpReplacement::installVMTrapBreakpoint):
* runtime/VMTraps.cpp:
(JSC::SignalContext::SignalContext):
(JSC::installSignalHandler):
(JSC::SignalContext::adjustPCToPointToTrappingInstruction): Deleted.
* wasm/WasmFaultSignalHandler.cpp:
(JSC::Wasm::enableFastMemory):

Source/WTF:

<rdar://problem/32178892>

Reviewed by JF Bastien.

Remove the Trap signal handler code since it plays badly with lldb and combine
SIGBUS with SIGSEGV since distiguishing them is generally non-portable.

Also, update the platform code to only use signaling VMTraps
on where we have an appropriate instruction (x86 and ARM64).

* wtf/Platform.h:
* wtf/threads/Signals.cpp:
(WTF::fromMachException):
(WTF::toMachMask):
(WTF::installSignalHandler):
(WTF::jscSignalHandler):
* wtf/threads/Signals.h:
(WTF::toSystemSignal):
(WTF::fromSystemSignal):

Tools:

Reviewed by JF Bastien.

* TestWebKitAPI/Tests/WTF/ThreadMessages.cpp:
(TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218782 268f45cc-cd09-0410-ab3c-d52691b4dbfc
22 files changed:
Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp
Source/JavaScriptCore/API/tests/testapi.c
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/assembler/ARM64Assembler.h
Source/JavaScriptCore/assembler/ARMAssembler.h
Source/JavaScriptCore/assembler/ARMv7Assembler.h
Source/JavaScriptCore/assembler/MIPSAssembler.h
Source/JavaScriptCore/assembler/MacroAssemblerARM.h
Source/JavaScriptCore/assembler/MacroAssemblerARM64.h
Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h
Source/JavaScriptCore/assembler/MacroAssemblerMIPS.h
Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h
Source/JavaScriptCore/assembler/X86Assembler.h
Source/JavaScriptCore/dfg/DFGJumpReplacement.cpp
Source/JavaScriptCore/runtime/VMTraps.cpp
Source/JavaScriptCore/wasm/WasmFaultSignalHandler.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WTF/wtf/threads/Signals.cpp
Source/WTF/wtf/threads/Signals.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/ThreadMessages.cpp