[WebAssembly] Inline WasmContext accessor functions
authoryusukesuzuki@slowstart.org <yusukesuzuki@slowstart.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Sep 2018 21:49:47 +0000 (21:49 +0000)
committeryusukesuzuki@slowstart.org <yusukesuzuki@slowstart.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Sep 2018 21:49:47 +0000 (21:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189416

Reviewed by Saam Barati.

WasmContext accessor functions are very small while it resides in the critical path of
JS to Wasm function call. This patch makes them inline to improve performance.
This change improves a small benchmark (calling JS to Wasm function 1e7 times) from 320ms to 270ms.

* JavaScriptCore.xcodeproj/project.pbxproj:
* Sources.txt:
* interpreter/CallFrame.cpp:
* jit/AssemblyHelpers.cpp:
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmContextInlines.h: Renamed from Source/JavaScriptCore/wasm/WasmContext.cpp.
(JSC::Wasm::Context::useFastTLS):
(JSC::Wasm::Context::load const):
(JSC::Wasm::Context::store):
* wasm/WasmMemoryInformation.cpp:
* wasm/WasmModuleParser.cpp: Include <wtf/SHA1.h> due to changes of unified source combinations.
* wasm/js/JSToWasm.cpp:
* wasm/js/WebAssemblyFunction.cpp:

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/Sources.txt
Source/JavaScriptCore/interpreter/CallFrame.cpp
Source/JavaScriptCore/jit/AssemblyHelpers.cpp
Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp
Source/JavaScriptCore/wasm/WasmContextInlines.h [moved from Source/JavaScriptCore/wasm/WasmContext.cpp with 93% similarity]
Source/JavaScriptCore/wasm/WasmMemoryInformation.cpp
Source/JavaScriptCore/wasm/WasmModuleParser.cpp
Source/JavaScriptCore/wasm/js/JSToWasm.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp

index b7934b7..e7d4857 100644 (file)
@@ -1,3 +1,28 @@
+2018-09-13  Yusuke Suzuki  <yusukesuzuki@slowstart.org>
+
+        [WebAssembly] Inline WasmContext accessor functions
+        https://bugs.webkit.org/show_bug.cgi?id=189416
+
+        Reviewed by Saam Barati.
+
+        WasmContext accessor functions are very small while it resides in the critical path of
+        JS to Wasm function call. This patch makes them inline to improve performance.
+        This change improves a small benchmark (calling JS to Wasm function 1e7 times) from 320ms to 270ms.
+
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * Sources.txt:
+        * interpreter/CallFrame.cpp:
+        * jit/AssemblyHelpers.cpp:
+        * wasm/WasmB3IRGenerator.cpp:
+        * wasm/WasmContextInlines.h: Renamed from Source/JavaScriptCore/wasm/WasmContext.cpp.
+        (JSC::Wasm::Context::useFastTLS):
+        (JSC::Wasm::Context::load const):
+        (JSC::Wasm::Context::store):
+        * wasm/WasmMemoryInformation.cpp:
+        * wasm/WasmModuleParser.cpp: Include <wtf/SHA1.h> due to changes of unified source combinations.
+        * wasm/js/JSToWasm.cpp:
+        * wasm/js/WebAssemblyFunction.cpp:
+
 2018-09-12  David Kilzer  <ddkilzer@apple.com>
 
         Move JavaScriptCore files to match Xcode project hierarchy
index b567102..70ca84d 100644 (file)
                AD2FCC211DB59CB200B3E736 /* WebAssemblyTablePrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCC151DB59C5900B3E736 /* WebAssemblyTablePrototype.lut.h */; };
                AD2FCC2D1DB838FD00B3E736 /* WebAssemblyPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCC271DB838C400B3E736 /* WebAssemblyPrototype.h */; settings = {ATTRIBUTES = (Private, ); }; };
                AD412B341E7B2E9E008AF157 /* WasmContext.h in Headers */ = {isa = PBXBuildFile; fileRef = AD412B321E7B2E8A008AF157 /* WasmContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               7593C898BE714A64BE93A6E7 /* WasmContextInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = A27958D7FA1142B0AC9E364D /* WasmContextInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
                AD4252511E5D0E14009D2A97 /* FullCodeOrigin.h in Headers */ = {isa = PBXBuildFile; fileRef = AD4252501E5D0DEB009D2A97 /* FullCodeOrigin.h */; };
                AD4937C41DDBE6140077C807 /* AbstractModuleRecord.h in Headers */ = {isa = PBXBuildFile; fileRef = AD4937C21DDBE60A0077C807 /* AbstractModuleRecord.h */; settings = {ATTRIBUTES = (Private, ); }; };
                AD4937C81DDD0AAE0077C807 /* WebAssemblyModuleRecord.h in Headers */ = {isa = PBXBuildFile; fileRef = AD4937C61DDCDCF00077C807 /* WebAssemblyModuleRecord.h */; };
                AD2FCC261DB838C400B3E736 /* WebAssemblyPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebAssemblyPrototype.cpp; path = js/WebAssemblyPrototype.cpp; sourceTree = "<group>"; };
                AD2FCC271DB838C400B3E736 /* WebAssemblyPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebAssemblyPrototype.h; path = js/WebAssemblyPrototype.h; sourceTree = "<group>"; };
                AD2FCC321DC4045300B3E736 /* WasmFormat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmFormat.cpp; sourceTree = "<group>"; };
-               AD412B311E7B2E8A008AF157 /* WasmContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmContext.cpp; sourceTree = "<group>"; };
                AD412B321E7B2E8A008AF157 /* WasmContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmContext.h; sourceTree = "<group>"; };
+               A27958D7FA1142B0AC9E364D /* WasmContextInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmContextInlines.h; sourceTree = "<group>"; };
                AD412B351E7B57C0008AF157 /* AllowMacroScratchRegisterUsageIf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AllowMacroScratchRegisterUsageIf.h; sourceTree = "<group>"; };
                AD4252501E5D0DEB009D2A97 /* FullCodeOrigin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FullCodeOrigin.h; sourceTree = "<group>"; };
                AD4252521E5D0F22009D2A97 /* FullCodeOrigin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FullCodeOrigin.cpp; sourceTree = "<group>"; };
                                53FD04D21D7AB187003287D3 /* WasmCallingConvention.h */,
                                526AC4B41E977C5D003500E1 /* WasmCodeBlock.cpp */,
                                526AC4B51E977C5D003500E1 /* WasmCodeBlock.h */,
-                               AD412B311E7B2E8A008AF157 /* WasmContext.cpp */,
                                AD412B321E7B2E8A008AF157 /* WasmContext.h */,
+                               A27958D7FA1142B0AC9E364D /* WasmContextInlines.h */,
                                E36CC9462086314F0051FFD6 /* WasmCreationMode.h */,
                                AD5C36DC1F688B5F000BCAAF /* WasmEmbedder.h */,
                                79DAE2791E03C82200B526AA /* WasmExceptionType.h */,
                                53FD04D41D7AB291003287D3 /* WasmCallingConvention.h in Headers */,
                                526AC4B71E977C5D003500E1 /* WasmCodeBlock.h in Headers */,
                                AD412B341E7B2E9E008AF157 /* WasmContext.h in Headers */,
+                               7593C898BE714A64BE93A6E7 /* WasmContextInlines.h in Headers */,
                                E36CC9472086314F0051FFD6 /* WasmCreationMode.h in Headers */,
                                AD5C36DD1F688B65000BCAAF /* WasmEmbedder.h in Headers */,
                                79DAE27A1E03C82200B526AA /* WasmExceptionType.h in Headers */,
index 6db2c37..256e4d7 100644 (file)
@@ -971,7 +971,6 @@ wasm/WasmBinding.cpp
 wasm/WasmCallee.cpp
 wasm/WasmCallingConvention.cpp
 wasm/WasmCodeBlock.cpp
-wasm/WasmContext.cpp
 wasm/WasmEmbedder.h
 wasm/WasmFaultSignalHandler.cpp
 wasm/WasmFormat.cpp
index 622f714..b45e3a2 100644 (file)
@@ -32,7 +32,7 @@
 #include "JSCInlines.h"
 #include "JSWebAssemblyInstance.h"
 #include "VMEntryScope.h"
-#include "WasmContext.h"
+#include "WasmContextInlines.h"
 #include "WasmInstance.h"
 #include <wtf/StringPrintStream.h>
 
index 7bb9e3e..c6bac12 100644 (file)
@@ -36,7 +36,7 @@
 #include "ThunkGenerators.h"
 
 #if ENABLE(WEBASSEMBLY)
-#include "WasmContext.h"
+#include "WasmContextInlines.h"
 #include "WasmMemoryInformation.h"
 #endif
 
index e0bc159..86c3a8f 100644 (file)
@@ -52,7 +52,7 @@
 #include "ScratchRegisterAllocator.h"
 #include "VirtualRegister.h"
 #include "WasmCallingConvention.h"
-#include "WasmContext.h"
+#include "WasmContextInlines.h"
 #include "WasmExceptionType.h"
 #include "WasmFunctionParser.h"
 #include "WasmInstance.h"
similarity index 93%
rename from Source/JavaScriptCore/wasm/WasmContext.cpp
rename to Source/JavaScriptCore/wasm/WasmContextInlines.h
index af12b22..713be67 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "config.h"
-#include "WasmContext.h"
+#pragma once
 
 #if ENABLE(WEBASSEMBLY)
 
 #include "Options.h"
+#include "WasmContext.h"
 #include "WasmInstance.h"
-
 #include <mutex>
 #include <wtf/FastTLS.h>
 
 namespace JSC { namespace Wasm {
 
-bool Context::useFastTLS()
+inline bool Context::useFastTLS()
 {
 #if ENABLE(FAST_TLS_JIT)
     return Options::useFastTLSForWasmContext();
@@ -45,7 +44,7 @@ bool Context::useFastTLS()
 #endif
 }
 
-Instance* Context::load() const
+inline Instance* Context::load() const
 {
 #if ENABLE(FAST_TLS_JIT)
     if (useFastTLS())
@@ -54,7 +53,7 @@ Instance* Context::load() const
     return instance;
 }
 
-void Context::store(Instance* inst, void* softStackLimit)
+inline void Context::store(Instance* inst, void* softStackLimit)
 {
 #if ENABLE(FAST_TLS_JIT)
     if (useFastTLS())
index b5c34bd..c3a4041 100644 (file)
@@ -29,7 +29,7 @@
 #if ENABLE(WEBASSEMBLY)
 
 #include "WasmCallingConvention.h"
-#include "WasmContext.h"
+#include "WasmContextInlines.h"
 #include "WasmMemory.h"
 #include <wtf/NeverDestroyed.h>
 
index 225dba6..7bc8ead 100644 (file)
@@ -34,6 +34,7 @@
 #include "WasmOps.h"
 #include "WasmSectionParser.h"
 #include "WasmSections.h"
+#include <wtf/SHA1.h>
 
 namespace JSC { namespace Wasm {
 
index 364f7c7..a603f4b 100644 (file)
@@ -31,6 +31,7 @@
 #include "CCallHelpers.h"
 #include "JSWebAssemblyInstance.h"
 #include "WasmCallingConvention.h"
+#include "WasmContextInlines.h"
 #include "WasmSignatureInlines.h"
 
 namespace JSC { namespace Wasm {
index 5db924f..ec619da 100644 (file)
@@ -39,7 +39,7 @@
 #include "ProtoCallFrame.h"
 #include "VM.h"
 #include "WasmCallee.h"
-#include "WasmContext.h"
+#include "WasmContextInlines.h"
 #include "WasmFormat.h"
 #include "WasmMemory.h"
 #include "WasmSignatureInlines.h"