Title: [229709] trunk/Source/_javascript_Core
Revision
229709
Author
mark....@apple.com
Date
2018-03-19 13:22:30 -0700 (Mon, 19 Mar 2018)

Log Message

FunctionPtr should be passed by value.
https://bugs.webkit.org/show_bug.cgi?id=183746
<rdar://problem/38625311>

Reviewed by JF Bastien.

It's meant to be an encapsulation of a C/C++ function pointer.  There are cases
where we use it to pass JIT compiled code (e.g. the VM thunks/stubs), but they are
treated as if they are C/C++ functions.

Regardless, there's no need to pass it by reference.

* assembler/MacroAssemblerCodeRef.h:
* dfg/DFGJITCompiler.h:
(JSC::DFG::JITCompiler::appendCall):
* dfg/DFGSpeculativeJIT.h:
(JSC::DFG::SpeculativeJIT::appendCall):
(JSC::DFG::SpeculativeJIT::appendCallWithCallFrameRollbackOnException):
(JSC::DFG::SpeculativeJIT::appendCallWithCallFrameRollbackOnExceptionSetResult):
(JSC::DFG::SpeculativeJIT::appendCallSetResult):
* jit/JIT.h:
(JSC::JIT::appendCall):
(JSC::JIT::appendCallWithSlowPathReturnType):
* jit/JITInlines.h:
(JSC::JIT::appendCallWithExceptionCheck):
(JSC::JIT::appendCallWithExceptionCheckAndSlowPathReturnType):
(JSC::JIT::appendCallWithCallFrameRollbackOnException):
(JSC::JIT::appendCallWithExceptionCheckSetJSValueResult):
(JSC::JIT::appendCallWithExceptionCheckSetJSValueResultWithProfile):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (229708 => 229709)


--- trunk/Source/_javascript_Core/ChangeLog	2018-03-19 20:06:21 UTC (rev 229708)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-03-19 20:22:30 UTC (rev 229709)
@@ -1,3 +1,35 @@
+2018-03-19  Mark Lam  <mark....@apple.com>
+
+        FunctionPtr should be passed by value.
+        https://bugs.webkit.org/show_bug.cgi?id=183746
+        <rdar://problem/38625311>
+
+        Reviewed by JF Bastien.
+
+        It's meant to be an encapsulation of a C/C++ function pointer.  There are cases
+        where we use it to pass JIT compiled code (e.g. the VM thunks/stubs), but they are
+        treated as if they are C/C++ functions.
+
+        Regardless, there's no need to pass it by reference.
+
+        * assembler/MacroAssemblerCodeRef.h:
+        * dfg/DFGJITCompiler.h:
+        (JSC::DFG::JITCompiler::appendCall):
+        * dfg/DFGSpeculativeJIT.h:
+        (JSC::DFG::SpeculativeJIT::appendCall):
+        (JSC::DFG::SpeculativeJIT::appendCallWithCallFrameRollbackOnException):
+        (JSC::DFG::SpeculativeJIT::appendCallWithCallFrameRollbackOnExceptionSetResult):
+        (JSC::DFG::SpeculativeJIT::appendCallSetResult):
+        * jit/JIT.h:
+        (JSC::JIT::appendCall):
+        (JSC::JIT::appendCallWithSlowPathReturnType):
+        * jit/JITInlines.h:
+        (JSC::JIT::appendCallWithExceptionCheck):
+        (JSC::JIT::appendCallWithExceptionCheckAndSlowPathReturnType):
+        (JSC::JIT::appendCallWithCallFrameRollbackOnException):
+        (JSC::JIT::appendCallWithExceptionCheckSetJSValueResult):
+        (JSC::JIT::appendCallWithExceptionCheckSetJSValueResultWithProfile):
+
 2018-03-15  Ross Kirsling  <ross.kirsl...@sony.com>
 
         Fix MSVC run-time check after r229391. 

Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerCodeRef.h (229708 => 229709)


--- trunk/Source/_javascript_Core/assembler/MacroAssemblerCodeRef.h	2018-03-19 20:06:21 UTC (rev 229708)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerCodeRef.h	2018-03-19 20:22:30 UTC (rev 229709)
@@ -126,6 +126,9 @@
     void* m_value { nullptr };
 };
 
+static_assert(sizeof(FunctionPtr) == sizeof(void*), "");
+static_assert(std::is_trivially_copyable<FunctionPtr>::value, "");
+
 // ReturnAddressPtr:
 //
 // ReturnAddressPtr should be used to wrap return addresses generated by processor

Modified: trunk/Source/_javascript_Core/dfg/DFGJITCompiler.h (229708 => 229709)


--- trunk/Source/_javascript_Core/dfg/DFGJITCompiler.h	2018-03-19 20:06:21 UTC (rev 229708)
+++ trunk/Source/_javascript_Core/dfg/DFGJITCompiler.h	2018-03-19 20:22:30 UTC (rev 229709)
@@ -156,7 +156,7 @@
     }
 
     // Add a call out from JIT code, without an exception check.
-    Call appendCall(const FunctionPtr& function)
+    Call appendCall(const FunctionPtr function)
     {
         Call functionCall = call(NoPtrTag);
         m_calls.append(CallLinkRecord(functionCall, function));

Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h (229708 => 229709)


--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h	2018-03-19 20:06:21 UTC (rev 229708)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h	2018-03-19 20:22:30 UTC (rev 229709)
@@ -1007,19 +1007,19 @@
 #endif
 
     // These methods add call instructions, optionally setting results, and optionally rolling back the call frame on an exception.
-    JITCompiler::Call appendCall(const FunctionPtr& function)
+    JITCompiler::Call appendCall(const FunctionPtr function)
     {
         prepareForExternalCall();
         m_jit.emitStoreCodeOrigin(m_currentNode->origin.semantic);
         return m_jit.appendCall(function);
     }
-    JITCompiler::Call appendCallWithCallFrameRollbackOnException(const FunctionPtr& function)
+    JITCompiler::Call appendCallWithCallFrameRollbackOnException(const FunctionPtr function)
     {
         JITCompiler::Call call = appendCall(function);
         m_jit.exceptionCheckWithCallFrameRollback();
         return call;
     }
-    JITCompiler::Call appendCallWithCallFrameRollbackOnExceptionSetResult(const FunctionPtr& function, GPRReg result)
+    JITCompiler::Call appendCallWithCallFrameRollbackOnExceptionSetResult(const FunctionPtr function, GPRReg result)
     {
         JITCompiler::Call call = appendCallWithCallFrameRollbackOnException(function);
         if ((result != InvalidGPRReg) && (result != GPRInfo::returnValueGPR))
@@ -1026,7 +1026,7 @@
             m_jit.move(GPRInfo::returnValueGPR, result);
         return call;
     }
-    JITCompiler::Call appendCallSetResult(const FunctionPtr& function, GPRReg result)
+    JITCompiler::Call appendCallSetResult(const FunctionPtr function, GPRReg result)
     {
         JITCompiler::Call call = appendCall(function);
         if (result != InvalidGPRReg)
@@ -1033,13 +1033,13 @@
             m_jit.move(GPRInfo::returnValueGPR, result);
         return call;
     }
-    JITCompiler::Call appendCallSetResult(const FunctionPtr& function, GPRReg result1, GPRReg result2)
+    JITCompiler::Call appendCallSetResult(const FunctionPtr function, GPRReg result1, GPRReg result2)
     {
         JITCompiler::Call call = appendCall(function);
         m_jit.setupResults(result1, result2);
         return call;
     }
-    JITCompiler::Call appendCallSetResult(const FunctionPtr& function, JSValueRegs resultRegs)
+    JITCompiler::Call appendCallSetResult(const FunctionPtr function, JSValueRegs resultRegs)
     {
 #if USE(JSVALUE64)
         return appendCallSetResult(function, resultRegs.gpr());
@@ -1048,7 +1048,7 @@
 #endif
     }
 #if CPU(X86)
-    JITCompiler::Call appendCallSetResult(const FunctionPtr& function, FPRReg result)
+    JITCompiler::Call appendCallSetResult(const FunctionPtr function, FPRReg result)
     {
         JITCompiler::Call call = appendCall(function);
         if (result != InvalidFPRReg) {
@@ -1058,7 +1058,7 @@
         return call;
     }
 #elif CPU(ARM) && !CPU(ARM_HARDFP)
-    JITCompiler::Call appendCallSetResult(const FunctionPtr& function, FPRReg result)
+    JITCompiler::Call appendCallSetResult(const FunctionPtr function, FPRReg result)
     {
         JITCompiler::Call call = appendCall(function);
         if (result != InvalidFPRReg)
@@ -1066,7 +1066,7 @@
         return call;
     }
 #else // CPU(X86_64) || (CPU(ARM) && CPU(ARM_HARDFP)) || CPU(ARM64) || CPU(MIPS)
-    JITCompiler::Call appendCallSetResult(const FunctionPtr& function, FPRReg result)
+    JITCompiler::Call appendCallSetResult(const FunctionPtr function, FPRReg result)
     {
         JITCompiler::Call call = appendCall(function);
         if (result != InvalidFPRReg)

Modified: trunk/Source/_javascript_Core/jit/JIT.h (229708 => 229709)


--- trunk/Source/_javascript_Core/jit/JIT.h	2018-03-19 20:06:21 UTC (rev 229708)
+++ trunk/Source/_javascript_Core/jit/JIT.h	2018-03-19 20:22:30 UTC (rev 229709)
@@ -267,7 +267,7 @@
         void privateCompilePatchGetArrayLength(ReturnAddressPtr returnAddress);
 
         // Add a call out from JIT code, without an exception check.
-        Call appendCall(const FunctionPtr& function)
+        Call appendCall(const FunctionPtr function)
         {
             Call functionCall = call(NoPtrTag);
             m_calls.append(CallRecord(functionCall, m_bytecodeOffset, function.value()));
@@ -275,7 +275,7 @@
         }
 
 #if OS(WINDOWS) && CPU(X86_64)
-        Call appendCallWithSlowPathReturnType(const FunctionPtr& function)
+        Call appendCallWithSlowPathReturnType(const FunctionPtr function)
         {
             Call functionCall = callWithSlowPathReturnType();
             m_calls.append(CallRecord(functionCall, m_bytecodeOffset, function.value()));
@@ -704,13 +704,13 @@
             linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
         }
 
-        MacroAssembler::Call appendCallWithExceptionCheck(const FunctionPtr&);
+        MacroAssembler::Call appendCallWithExceptionCheck(const FunctionPtr);
 #if OS(WINDOWS) && CPU(X86_64)
-        MacroAssembler::Call appendCallWithExceptionCheckAndSlowPathReturnType(const FunctionPtr&);
+        MacroAssembler::Call appendCallWithExceptionCheckAndSlowPathReturnType(const FunctionPtr);
 #endif
-        MacroAssembler::Call appendCallWithCallFrameRollbackOnException(const FunctionPtr&);
-        MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResult(const FunctionPtr&, int);
-        MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResultWithProfile(const FunctionPtr&, int);
+        MacroAssembler::Call appendCallWithCallFrameRollbackOnException(const FunctionPtr);
+        MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResult(const FunctionPtr, int);
+        MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResultWithProfile(const FunctionPtr, int);
         
         template<typename OperationType, typename... Args>
         std::enable_if_t<FunctionTraits<OperationType>::hasResult, MacroAssembler::Call>

Modified: trunk/Source/_javascript_Core/jit/JITInlines.h (229708 => 229709)


--- trunk/Source/_javascript_Core/jit/JITInlines.h	2018-03-19 20:06:21 UTC (rev 229708)
+++ trunk/Source/_javascript_Core/jit/JITInlines.h	2018-03-19 20:22:30 UTC (rev 229709)
@@ -149,7 +149,7 @@
     storePtr(callFrameRegister, &m_vm->topCallFrame);
 }
 
-ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheck(const FunctionPtr& function)
+ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheck(const FunctionPtr function)
 {
     updateTopCallFrame();
     MacroAssembler::Call call = appendCall(function);
@@ -158,7 +158,7 @@
 }
 
 #if OS(WINDOWS) && CPU(X86_64)
-ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckAndSlowPathReturnType(const FunctionPtr& function)
+ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckAndSlowPathReturnType(const FunctionPtr function)
 {
     updateTopCallFrame();
     MacroAssembler::Call call = appendCallWithSlowPathReturnType(function);
@@ -167,7 +167,7 @@
 }
 #endif
 
-ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithCallFrameRollbackOnException(const FunctionPtr& function)
+ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithCallFrameRollbackOnException(const FunctionPtr function)
 {
     updateTopCallFrame(); // The callee is responsible for setting topCallFrame to their caller
     MacroAssembler::Call call = appendCall(function);
@@ -175,7 +175,7 @@
     return call;
 }
 
-ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckSetJSValueResult(const FunctionPtr& function, int dst)
+ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckSetJSValueResult(const FunctionPtr function, int dst)
 {
     MacroAssembler::Call call = appendCallWithExceptionCheck(function);
 #if USE(JSVALUE64)
@@ -186,7 +186,7 @@
     return call;
 }
 
-ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckSetJSValueResultWithProfile(const FunctionPtr& function, int dst)
+ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckSetJSValueResultWithProfile(const FunctionPtr function, int dst)
 {
     MacroAssembler::Call call = appendCallWithExceptionCheck(function);
     emitValueProfilingSite();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to