Title: [207222] trunk/Source/_javascript_Core
Revision
207222
Author
fpi...@apple.com
Date
2016-10-12 09:56:34 -0700 (Wed, 12 Oct 2016)

Log Message

Remove JITWriteBarrier.h
https://bugs.webkit.org/show_bug.cgi?id=163334

Reviewed by Mark Lam.
        
I guess that the idea of JITWriteBarrier was to make sure that if you slap some heap pointer
bits into machine code, then you better execute a barrier on the code block. But it's a
complicated piece of code, and I can never remember how it quite works. These days it looks
vestigial, particularly since only the CallLinkInfo patchable callee immediate uses it. It's
not really necessary to have something like this, since our convention is that any pointer
stored in machine code must always be shadowed in the GC heap. I think that convention has
won by overwhelming majority, so we should finally remove JITWriteBarrier.
        
A practical outcome of this change is that it makes it easier to implement DirectCall ICs,
which will have to store the callee in the CallLinkInfo but not in the machine code.

* _javascript_Core.xcodeproj/project.pbxproj:
* assembler/AbstractMacroAssembler.h:
* bytecode/CallLinkInfo.cpp:
(JSC::CallLinkInfo::setCallee):
(JSC::CallLinkInfo::clearCallee):
* bytecode/CallLinkInfo.h:
(JSC::CallLinkInfo::setCallee): Deleted.
(JSC::CallLinkInfo::clearCallee): Deleted.
* heap/SlotVisitor.h:
* jit/JITWriteBarrier.h: Removed.

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (207221 => 207222)


--- trunk/Source/_javascript_Core/ChangeLog	2016-10-12 16:50:24 UTC (rev 207221)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-10-12 16:56:34 UTC (rev 207222)
@@ -1,3 +1,32 @@
+2016-10-12  Filip Pizlo  <fpi...@apple.com>
+
+        Remove JITWriteBarrier.h
+        https://bugs.webkit.org/show_bug.cgi?id=163334
+
+        Reviewed by Mark Lam.
+        
+        I guess that the idea of JITWriteBarrier was to make sure that if you slap some heap pointer
+        bits into machine code, then you better execute a barrier on the code block. But it's a
+        complicated piece of code, and I can never remember how it quite works. These days it looks
+        vestigial, particularly since only the CallLinkInfo patchable callee immediate uses it. It's
+        not really necessary to have something like this, since our convention is that any pointer
+        stored in machine code must always be shadowed in the GC heap. I think that convention has
+        won by overwhelming majority, so we should finally remove JITWriteBarrier.
+        
+        A practical outcome of this change is that it makes it easier to implement DirectCall ICs,
+        which will have to store the callee in the CallLinkInfo but not in the machine code.
+
+        * _javascript_Core.xcodeproj/project.pbxproj:
+        * assembler/AbstractMacroAssembler.h:
+        * bytecode/CallLinkInfo.cpp:
+        (JSC::CallLinkInfo::setCallee):
+        (JSC::CallLinkInfo::clearCallee):
+        * bytecode/CallLinkInfo.h:
+        (JSC::CallLinkInfo::setCallee): Deleted.
+        (JSC::CallLinkInfo::clearCallee): Deleted.
+        * heap/SlotVisitor.h:
+        * jit/JITWriteBarrier.h: Removed.
+
 2016-10-12  Csaba Osztrogonác  <o...@webkit.org>
 
         Unreviewed buildfix for GCC 4.9 after r207186.

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (207221 => 207222)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2016-10-12 16:50:24 UTC (rev 207221)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2016-10-12 16:56:34 UTC (rev 207222)
@@ -1769,7 +1769,6 @@
 		A767B5B617A0B9650063D940 /* DFGLoopPreHeaderCreationPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = A767B5B417A0B9650063D940 /* DFGLoopPreHeaderCreationPhase.h */; };
 		A76C51761182748D00715B05 /* JSInterfaceJIT.h in Headers */ = {isa = PBXBuildFile; fileRef = A76C51741182748D00715B05 /* JSInterfaceJIT.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A76F279415F13C9600517D67 /* UnlinkedCodeBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A79E781E15EECBA80047C855 /* UnlinkedCodeBlock.cpp */; };
-		A76F54A313B28AAB00EF2BCE /* JITWriteBarrier.h in Headers */ = {isa = PBXBuildFile; fileRef = A76F54A213B28AAB00EF2BCE /* JITWriteBarrier.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A77A423D17A0BBFD00A8DB81 /* DFGAbstractHeap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A77A423617A0BBFD00A8DB81 /* DFGAbstractHeap.cpp */; };
 		A77A423E17A0BBFD00A8DB81 /* DFGAbstractHeap.h in Headers */ = {isa = PBXBuildFile; fileRef = A77A423717A0BBFD00A8DB81 /* DFGAbstractHeap.h */; };
 		A77A423F17A0BBFD00A8DB81 /* DFGClobberize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A77A423817A0BBFD00A8DB81 /* DFGClobberize.cpp */; };
@@ -4077,7 +4076,6 @@
 		A767B5B317A0B9650063D940 /* DFGLoopPreHeaderCreationPhase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGLoopPreHeaderCreationPhase.cpp; path = dfg/DFGLoopPreHeaderCreationPhase.cpp; sourceTree = "<group>"; };
 		A767B5B417A0B9650063D940 /* DFGLoopPreHeaderCreationPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGLoopPreHeaderCreationPhase.h; path = dfg/DFGLoopPreHeaderCreationPhase.h; sourceTree = "<group>"; };
 		A76C51741182748D00715B05 /* JSInterfaceJIT.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInterfaceJIT.h; sourceTree = "<group>"; };
-		A76F54A213B28AAB00EF2BCE /* JITWriteBarrier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITWriteBarrier.h; sourceTree = "<group>"; };
 		A77A423617A0BBFD00A8DB81 /* DFGAbstractHeap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGAbstractHeap.cpp; path = dfg/DFGAbstractHeap.cpp; sourceTree = "<group>"; };
 		A77A423717A0BBFD00A8DB81 /* DFGAbstractHeap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGAbstractHeap.h; path = dfg/DFGAbstractHeap.h; sourceTree = "<group>"; };
 		A77A423817A0BBFD00A8DB81 /* DFGClobberize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGClobberize.cpp; path = dfg/DFGClobberize.cpp; sourceTree = "<group>"; };
@@ -5279,7 +5277,6 @@
 				0FC712E117CD878F008CC93C /* JITToDFGDeferredCompilationCallback.h */,
 				DC0184171D10C1870057B053 /* JITWorklist.cpp */,
 				DC0184181D10C1870057B053 /* JITWorklist.h */,
-				A76F54A213B28AAB00EF2BCE /* JITWriteBarrier.h */,
 				A76C51741182748D00715B05 /* JSInterfaceJIT.h */,
 				792CB3471C4EED5C00D13AF3 /* PCToCodeOriginMap.cpp */,
 				792CB3481C4EED5C00D13AF3 /* PCToCodeOriginMap.h */,
@@ -7945,7 +7942,6 @@
 				0F766D2C15A8CC3A008F363E /* JITStubRoutineSet.h in Headers */,
 				0F5EF91F16878F7D003E5C25 /* JITThunks.h in Headers */,
 				0FC712E317CD8793008CC93C /* JITToDFGDeferredCompilationCallback.h in Headers */,
-				A76F54A313B28AAB00EF2BCE /* JITWriteBarrier.h in Headers */,
 				840480131021A1D9008E7F01 /* JSAPIValueWrapper.h in Headers */,
 				C2CF39C216E15A8100DD69BE /* JSAPIWrapperObject.h in Headers */,
 				BC18C4170E16F5CD00B34460 /* JSArray.h in Headers */,

Modified: trunk/Source/_javascript_Core/assembler/AbstractMacroAssembler.h (207221 => 207222)


--- trunk/Source/_javascript_Core/assembler/AbstractMacroAssembler.h	2016-10-12 16:50:24 UTC (rev 207221)
+++ trunk/Source/_javascript_Core/assembler/AbstractMacroAssembler.h	2016-10-12 16:56:34 UTC (rev 207222)
@@ -52,7 +52,6 @@
 template <class AssemblerType, class MacroAssemblerType>
 class AbstractMacroAssembler {
 public:
-    friend class JITWriteBarrierBase;
     typedef AbstractMacroAssembler<AssemblerType, MacroAssemblerType> AbstractMacroAssemblerType;
     typedef AssemblerType AssemblerType_T;
 

Modified: trunk/Source/_javascript_Core/bytecode/CallLinkInfo.cpp (207221 => 207222)


--- trunk/Source/_javascript_Core/bytecode/CallLinkInfo.cpp	2016-10-12 16:50:24 UTC (rev 207221)
+++ trunk/Source/_javascript_Core/bytecode/CallLinkInfo.cpp	2016-10-12 16:56:34 UTC (rev 207222)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012, 2013, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2014, 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,6 +30,7 @@
 #include "DFGOperations.h"
 #include "DFGThunks.h"
 #include "JSCInlines.h"
+#include "MacroAssembler.h"
 #include "Opcode.h"
 #include "Repatch.h"
 #include <wtf/ListDump.h>
@@ -97,6 +98,18 @@
         remove();
 }
 
+void CallLinkInfo::setCallee(VM& vm, JSCell* owner, JSFunction* callee)
+{
+    MacroAssembler::repatchPointer(m_hotPathBegin, callee);
+    m_callee.set(vm, owner, callee);
+}
+
+void CallLinkInfo::clearCallee()
+{
+    MacroAssembler::repatchPointer(m_hotPathBegin, nullptr);
+    m_callee.clear();
+}
+
 void CallLinkInfo::visitWeak(VM& vm)
 {
     auto handleSpecificCallee = [&] (JSFunction* callee) {

Modified: trunk/Source/_javascript_Core/bytecode/CallLinkInfo.h (207221 => 207222)


--- trunk/Source/_javascript_Core/bytecode/CallLinkInfo.h	2016-10-12 16:50:24 UTC (rev 207221)
+++ trunk/Source/_javascript_Core/bytecode/CallLinkInfo.h	2016-10-12 16:56:34 UTC (rev 207222)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012, 2014, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2014-2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -28,7 +28,6 @@
 #include "CallMode.h"
 #include "CodeLocation.h"
 #include "CodeSpecializationKind.h"
-#include "JITWriteBarrier.h"
 #include "JSFunction.h"
 #include "PolymorphicCallStubRoutine.h"
 #include "WriteBarrier.h"
@@ -158,15 +157,9 @@
         return m_hotPathOther;
     }
 
-    void setCallee(VM& vm, CodeLocationDataLabelPtr location, JSCell* owner, JSFunction* callee)
-    {
-        m_callee.set(vm, location, owner, callee);
-    }
+    void setCallee(VM&, JSCell*, JSFunction* callee);
 
-    void clearCallee()
-    {
-        m_callee.clear();
-    }
+    void clearCallee();
 
     JSFunction* callee()
     {
@@ -314,7 +307,7 @@
     CodeLocationNearCall m_callReturnLocation;
     CodeLocationDataLabelPtr m_hotPathBegin;
     CodeLocationNearCall m_hotPathOther;
-    JITWriteBarrier<JSFunction> m_callee;
+    WriteBarrier<JSFunction> m_callee;
     WriteBarrier<JSFunction> m_lastSeenCallee;
     RefPtr<PolymorphicCallStubRoutine> m_stub;
     RefPtr<JITStubRoutine> m_slowStub;

Modified: trunk/Source/_javascript_Core/heap/SlotVisitor.h (207221 => 207222)


--- trunk/Source/_javascript_Core/heap/SlotVisitor.h	2016-10-12 16:50:24 UTC (rev 207221)
+++ trunk/Source/_javascript_Core/heap/SlotVisitor.h	2016-10-12 16:56:34 UTC (rev 207222)
@@ -37,7 +37,6 @@
 class Heap;
 class HeapCell;
 class HeapSnapshotBuilder;
-template<typename T> class JITWriteBarrier;
 class MarkedBlock;
 class UnconditionalFinalizer;
 template<typename T> class Weak;

Deleted: trunk/Source/_javascript_Core/jit/JITWriteBarrier.h (207221 => 207222)


--- trunk/Source/_javascript_Core/jit/JITWriteBarrier.h	2016-10-12 16:50:24 UTC (rev 207221)
+++ trunk/Source/_javascript_Core/jit/JITWriteBarrier.h	2016-10-12 16:56:34 UTC (rev 207222)
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2011, 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if ENABLE(JIT)
-
-#include "MacroAssembler.h"
-#include "SlotVisitor.h"
-#include "UnusedPointer.h"
-#include "VM.h"
-#include "WriteBarrier.h"
-
-namespace JSC {
-
-class JSCell;
-class VM;
-
-// Needs to be even to appease some of the backends.
-#define JITWriteBarrierFlag ((void*)2)
-class JITWriteBarrierBase {
-public:
-    explicit operator bool() const { return get(); }
-    bool operator!() const { return !get(); }
-
-    void setFlagOnBarrier()
-    {
-        ASSERT(!m_location);
-        m_location = CodeLocationDataLabelPtr(JITWriteBarrierFlag);
-    }
-
-    bool isFlagged() const
-    {
-        return !!m_location;
-    }
-
-    void setLocation(CodeLocationDataLabelPtr location)
-    {
-        ASSERT(!m_location);
-        m_location = location;
-    }
-
-    CodeLocationDataLabelPtr location() const
-    {
-        ASSERT((!!m_location) && m_location.executableAddress() != JITWriteBarrierFlag);
-        return m_location;
-    }
-    
-    void clear() { clear(0); }
-    void clearToUnusedPointer() { clear(reinterpret_cast<void*>(unusedPointer)); }
-
-protected:
-    JITWriteBarrierBase()
-    {
-    }
-
-    void set(VM& vm, CodeLocationDataLabelPtr location, JSCell* owner, JSCell* value)
-    {
-        vm.heap.writeBarrier(owner, value);
-        m_location = location;
-        ASSERT(((!!m_location) && m_location.executableAddress() != JITWriteBarrierFlag) || (location.executableAddress() == m_location.executableAddress()));
-        MacroAssembler::repatchPointer(m_location, value);
-        ASSERT(get() == value);
-    }
-
-    JSCell* get() const
-    {
-        if (!m_location || m_location.executableAddress() == JITWriteBarrierFlag)
-            return 0;
-        void* result = static_cast<JSCell*>(MacroAssembler::readPointer(m_location));
-        if (result == reinterpret_cast<void*>(unusedPointer))
-            return 0;
-        return static_cast<JSCell*>(result);
-    }
-
-private:
-    void clear(void* clearedValue)
-    {
-        if (!m_location)
-            return;
-        if (m_location.executableAddress() != JITWriteBarrierFlag)
-            MacroAssembler::repatchPointer(m_location, clearedValue);
-    }
-
-    CodeLocationDataLabelPtr m_location;
-};
-
-#undef JITWriteBarrierFlag
-
-template <typename T> class JITWriteBarrier : public JITWriteBarrierBase {
-public:
-    JITWriteBarrier()
-    {
-    }
-
-    void set(VM& vm, CodeLocationDataLabelPtr location, JSCell* owner, T* value)
-    {
-        validateCell(owner);
-        validateCell(value);
-        JITWriteBarrierBase::set(vm, location, owner, value);
-    }
-    void set(VM& vm, JSCell* owner, T* value)
-    {
-        set(vm, location(), owner, value);
-    }
-    T* get() const
-    {
-        T* result = static_cast<T*>(JITWriteBarrierBase::get());
-        if (result)
-            validateCell(result);
-        return result;
-    }
-};
-
-} // namespace JSC
-
-#endif // ENABLE(JIT)

Modified: trunk/Source/_javascript_Core/jit/Repatch.cpp (207221 => 207222)


--- trunk/Source/_javascript_Core/jit/Repatch.cpp	2016-10-12 16:50:24 UTC (rev 207221)
+++ trunk/Source/_javascript_Core/jit/Repatch.cpp	2016-10-12 16:56:34 UTC (rev 207222)
@@ -566,7 +566,7 @@
     VM* vm = callerCodeBlock->vm();
     
     ASSERT(!callLinkInfo.isLinked());
-    callLinkInfo.setCallee(exec->callerFrame()->vm(), callLinkInfo.hotPathBegin(), callerCodeBlock, callee);
+    callLinkInfo.setCallee(exec->callerFrame()->vm(), callerCodeBlock, callee);
     callLinkInfo.setLastSeenCallee(exec->callerFrame()->vm(), callerCodeBlock, callee);
     if (shouldDumpDisassemblyFor(callerCodeBlock))
         dataLog("Linking call in ", *callerCodeBlock, " at ", callLinkInfo.codeOrigin(), " to ", pointerDump(calleeCodeBlock), ", entrypoint at ", codePtr, "\n");
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to