Use a more specific PtrTag for PlatformRegisters PC and LR.
authormark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Aug 2018 13:11:49 +0000 (13:11 +0000)
committermark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Aug 2018 13:11:49 +0000 (13:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188366
<rdar://problem/42984123>

Reviewed by Keith Miller.

Also fixed a bug in linkRegister(), which was previously returning the PC instead
of LR.  It now returns LR.

* runtime/JSCPtrTag.h:
* runtime/MachineContext.h:
(JSC::MachineContext::instructionPointer):
(JSC::MachineContext::linkRegister):
* runtime/VMTraps.cpp:
(JSC::SignalContext::SignalContext):
* tools/SigillCrashAnalyzer.cpp:
(JSC::SignalContext::SignalContext):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234649 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSCPtrTag.h
Source/JavaScriptCore/runtime/MachineContext.h
Source/JavaScriptCore/runtime/VMTraps.cpp
Source/JavaScriptCore/tools/SigillCrashAnalyzer.cpp

index e7e8cf1..78fd246 100644 (file)
@@ -1,3 +1,23 @@
+2018-08-07  Mark Lam  <mark.lam@apple.com>
+
+        Use a more specific PtrTag for PlatformRegisters PC and LR.
+        https://bugs.webkit.org/show_bug.cgi?id=188366
+        <rdar://problem/42984123>
+
+        Reviewed by Keith Miller.
+
+        Also fixed a bug in linkRegister(), which was previously returning the PC instead
+        of LR.  It now returns LR.
+
+        * runtime/JSCPtrTag.h:
+        * runtime/MachineContext.h:
+        (JSC::MachineContext::instructionPointer):
+        (JSC::MachineContext::linkRegister):
+        * runtime/VMTraps.cpp:
+        (JSC::SignalContext::SignalContext):
+        * tools/SigillCrashAnalyzer.cpp:
+        (JSC::SignalContext::SignalContext):
+
 2018-08-07  Karo Gyoker  <karogyoker2+webkit@gmail.com>
 
         Hardcoded LFENCE instruction
index 9a1460a..b8eefc8 100644 (file)
@@ -46,6 +46,8 @@ using PtrTag = WTF::PtrTag;
     v(LinkBufferPtrTag) \
     v(OperationPtrTag) \
     v(OSRExitPtrTag) \
+    v(PlatformRegistersLRPtrTag) \
+    v(PlatformRegistersPCPtrTag) \
     v(SlowPathPtrTag) \
     v(WasmEntryPtrTag) \
     v(Yarr8BitPtrTag) \
index 0a8d257..836d755 100644 (file)
@@ -43,9 +43,9 @@ template<typename T = void*> T stackPointer(const PlatformRegisters&);
 template<typename T = void*> void setStackPointer(PlatformRegisters&, T);
 template<typename T = void*> T framePointer(const PlatformRegisters&);
 template<typename T = void*> void setFramePointer(PlatformRegisters&, T);
-inline MacroAssemblerCodePtr<CFunctionPtrTag> linkRegister(const PlatformRegisters&);
+inline MacroAssemblerCodePtr<PlatformRegistersLRPtrTag> linkRegister(const PlatformRegisters&);
 inline void setLinkRegister(PlatformRegisters&, MacroAssemblerCodePtr<CFunctionPtrTag>);
-inline std::optional<MacroAssemblerCodePtr<CFunctionPtrTag>> instructionPointer(const PlatformRegisters&);
+inline std::optional<MacroAssemblerCodePtr<PlatformRegistersPCPtrTag>> instructionPointer(const PlatformRegisters&);
 inline void setInstructionPointer(PlatformRegisters&, MacroAssemblerCodePtr<CFunctionPtrTag>);
 
 template<size_t N> void*& argumentPointer(PlatformRegisters&);
@@ -67,7 +67,7 @@ template<typename T = void*> T stackPointer(const mcontext_t&);
 template<typename T = void*> void setStackPointer(mcontext_t&, T);
 template<typename T = void*> T framePointer(const mcontext_t&);
 template<typename T = void*> void setFramePointer(mcontext_t&, T);
-inline MacroAssemblerCodePtr<CFunctionPtrTag> instructionPointer(const mcontext_t&);
+inline MacroAssemblerCodePtr<PlatformRegistersPCPtrTag> instructionPointer(const mcontext_t&);
 inline void setInstructionPointer(mcontext_t&, MacroAssemblerCodePtr<CFunctionPtrTag>);
 
 template<size_t N> void*& argumentPointer(mcontext_t&);
@@ -432,7 +432,7 @@ static inline void*& instructionPointerImpl(PlatformRegisters& regs)
 }
 #endif // !USE(PLATFORM_REGISTERS_WITH_PROFILE)
 
-inline std::optional<MacroAssemblerCodePtr<CFunctionPtrTag>> instructionPointer(const PlatformRegisters& regs)
+inline std::optional<MacroAssemblerCodePtr<PlatformRegistersPCPtrTag>> instructionPointer(const PlatformRegisters& regs)
 {
 #if USE(PLATFORM_REGISTERS_WITH_PROFILE)
     void* value = WTF_READ_PLATFORM_REGISTERS_PC_WITH_PROFILE(regs);
@@ -440,11 +440,11 @@ inline std::optional<MacroAssemblerCodePtr<CFunctionPtrTag>> instructionPointer(
     void* value = instructionPointerImpl(const_cast<PlatformRegisters&>(regs));
 #endif
     if (!value)
-        return MacroAssemblerCodePtr<CFunctionPtrTag>(nullptr);
+        return MacroAssemblerCodePtr<PlatformRegistersPCPtrTag>(nullptr);
     if (!usesPointerTagging())
-        return MacroAssemblerCodePtr<CFunctionPtrTag>(value);
-    if (isTaggedWith(value, CFunctionPtrTag))
-        return MacroAssemblerCodePtr<CFunctionPtrTag>(value);
+        return MacroAssemblerCodePtr<PlatformRegistersPCPtrTag>(value);
+    if (isTaggedWith(value, PlatformRegistersPCPtrTag))
+        return MacroAssemblerCodePtr<PlatformRegistersPCPtrTag>(value);
     return std::nullopt;
 }
 
@@ -505,14 +505,14 @@ static inline void*& instructionPointerImpl(mcontext_t& machineContext)
 }
 #endif // !USE(PLATFORM_REGISTERS_WITH_PROFILE)
 
-inline MacroAssemblerCodePtr<CFunctionPtrTag> instructionPointer(const mcontext_t& machineContext)
+inline MacroAssemblerCodePtr<PlatformRegistersPCPtrTag> instructionPointer(const mcontext_t& machineContext)
 {
 #if USE(PLATFORM_REGISTERS_WITH_PROFILE)
     void* value = WTF_READ_MACHINE_CONTEXT_PC_WITH_PROFILE(machineContext);
 #else
     void* value = instructionPointerImpl(const_cast<mcontext_t&>(machineContext));
 #endif
-    return MacroAssemblerCodePtr<CFunctionPtrTag>(value);
+    return MacroAssemblerCodePtr<PlatformRegistersPCPtrTag>(value);
 }
 
 inline void setInstructionPointer(mcontext_t& machineContext, MacroAssemblerCodePtr<CFunctionPtrTag> value)
@@ -537,14 +537,14 @@ inline void*& linkRegisterImpl(PlatformRegisters& regs)
 #endif // USE(PLATFORM_REGISTERS_WITH_PROFILE)
 
 
-inline MacroAssemblerCodePtr<CFunctionPtrTag> linkRegister(const PlatformRegisters& regs)
+inline MacroAssemblerCodePtr<PlatformRegistersLRPtrTag> linkRegister(const PlatformRegisters& regs)
 {
 #if USE(PLATFORM_REGISTERS_WITH_PROFILE)
-    void* value = WTF_READ_PLATFORM_REGISTERS_PC_WITH_PROFILE(regs);
+    void* value = WTF_READ_PLATFORM_REGISTERS_LR_WITH_PROFILE(regs);
 #else
     void* value = linkRegisterImpl(const_cast<PlatformRegisters&>(regs));
 #endif
-    return MacroAssemblerCodePtr<CFunctionPtrTag>(value);
+    return MacroAssemblerCodePtr<PlatformRegistersLRPtrTag>(value);
 }
 
 inline void setLinkRegister(PlatformRegisters& regs, MacroAssemblerCodePtr<CFunctionPtrTag> value)
index cf5ade1..2cd6055 100644 (file)
@@ -56,7 +56,7 @@ ALWAYS_INLINE VM& VMTraps::vm() const
 
 struct SignalContext {
 private:
-    SignalContext(PlatformRegisters& registers, MacroAssemblerCodePtr<CFunctionPtrTag> trapPC)
+    SignalContext(PlatformRegisters& registers, MacroAssemblerCodePtr<PlatformRegistersPCPtrTag> trapPC)
         : registers(registers)
         , trapPC(trapPC)
         , stackPointer(MachineContext::stackPointer(registers))
@@ -73,7 +73,7 @@ public:
     }
 
     PlatformRegisters& registers;
-    MacroAssemblerCodePtr<CFunctionPtrTag> trapPC;
+    MacroAssemblerCodePtr<PlatformRegistersPCPtrTag> trapPC;
     void* stackPointer;
     void* framePointer;
 };
index 9cb9d0f..ef753f5 100644 (file)
@@ -79,7 +79,7 @@ private:
 
 struct SignalContext {
 private:
-    SignalContext(PlatformRegisters& registers, MacroAssemblerCodePtr<CFunctionPtrTag> machinePC)
+    SignalContext(PlatformRegisters& registers, MacroAssemblerCodePtr<PlatformRegistersPCPtrTag> machinePC)
         : registers(registers)
         , machinePC(machinePC)
         , stackPointer(MachineContext::stackPointer(registers))
@@ -148,7 +148,7 @@ public:
     }
 
     PlatformRegisters& registers;
-    MacroAssemblerCodePtr<CFunctionPtrTag> machinePC;
+    MacroAssemblerCodePtr<PlatformRegistersPCPtrTag> machinePC;
     void* stackPointer;
     void* framePointer;
 };
@@ -181,7 +181,7 @@ struct SignalContext {
 
     void dump() { }
 
-    MacroAssemblerCodePtr<CFunctionPtrTag> machinePC;
+    MacroAssemblerCodePtr<PlatformRegistersPCPtrTag> machinePC;
     void* stackPointer;
     void* framePointer;
 };