WebKit Bugzilla
Attachment 349157 Details for
Bug 189416
: [WebAssembly] Inline WasmContext accessor functions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-189416-20180908024317.patch (text/plain), 15.13 KB, created by
Yusuke Suzuki
on 2018-09-07 10:43:18 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2018-09-07 10:43:18 PDT
Size:
15.13 KB
patch
obsolete
>Subversion Revision: 235786 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 99f72dd49f9a62dd5c818060612884eefd272453..6ce38cdb146532ac6d96dda5715df01796de800c 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,28 @@ >+2018-09-07 Yusuke Suzuki <yusukesuzuki@slowstart.org> >+ >+ [WebAssembly] Inline WasmContext accessor functions >+ https://bugs.webkit.org/show_bug.cgi?id=189416 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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-07 Yusuke Suzuki <yusukesuzuki@slowstart.org> > > [WebAssembly] Optimize JS to Wasm call by using pointer of Signature as SignatureIndex >diff --git a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj >index f5bb055fe6c6d8c0b25ddc673b2d62376b52b0bb..d9b717e0c1f3ca86ad48670852b955c2b6832c16 100644 >--- a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj >+++ b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj >@@ -1522,6 +1522,7 @@ > 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 */; }; >@@ -4341,8 +4342,8 @@ > 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>"; }; >@@ -6315,8 +6316,8 @@ > 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 */, >@@ -9595,6 +9596,7 @@ > 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 */, >diff --git a/Source/JavaScriptCore/Sources.txt b/Source/JavaScriptCore/Sources.txt >index 38830768efbb63a4fdc3fb311ab06ebd636f64f2..bc83e8edccbf37225d1b2e28ada8fca06c7d5122 100644 >--- a/Source/JavaScriptCore/Sources.txt >+++ b/Source/JavaScriptCore/Sources.txt >@@ -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 >diff --git a/Source/JavaScriptCore/interpreter/CallFrame.cpp b/Source/JavaScriptCore/interpreter/CallFrame.cpp >index 622f7141a5e2c6a9750fd4939e688f0f6d8e33b8..b45e3a266b350c2c8740cb76c4cb6bf5b2b90ba0 100644 >--- a/Source/JavaScriptCore/interpreter/CallFrame.cpp >+++ b/Source/JavaScriptCore/interpreter/CallFrame.cpp >@@ -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> > >diff --git a/Source/JavaScriptCore/jit/AssemblyHelpers.cpp b/Source/JavaScriptCore/jit/AssemblyHelpers.cpp >index 7bb9e3eca49aa203ed073a1209b4e777715181bc..c6bac12d826d1eb1d3e5693d81361e8c37010fed 100644 >--- a/Source/JavaScriptCore/jit/AssemblyHelpers.cpp >+++ b/Source/JavaScriptCore/jit/AssemblyHelpers.cpp >@@ -36,7 +36,7 @@ > #include "ThunkGenerators.h" > > #if ENABLE(WEBASSEMBLY) >-#include "WasmContext.h" >+#include "WasmContextInlines.h" > #include "WasmMemoryInformation.h" > #endif > >diff --git a/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp b/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp >index e0bc1599320c0e276da65803fad2e4d3298bc05f..86c3a8f8298d834d3311fc5de55d192b30d04c61 100644 >--- a/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp >+++ b/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp >@@ -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" >diff --git a/Source/JavaScriptCore/wasm/WasmContext.cpp b/Source/JavaScriptCore/wasm/WasmContext.cpp >deleted file mode 100644 >index af12b227d3577cb4a2305e6c7041cabd87830b39..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/wasm/WasmContext.cpp >+++ /dev/null >@@ -1,70 +0,0 @@ >-/* >- * Copyright (C) 2017 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. ``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 >- * 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. >- */ >- >-#include "config.h" >-#include "WasmContext.h" >- >-#if ENABLE(WEBASSEMBLY) >- >-#include "Options.h" >-#include "WasmInstance.h" >- >-#include <mutex> >-#include <wtf/FastTLS.h> >- >-namespace JSC { namespace Wasm { >- >-bool Context::useFastTLS() >-{ >-#if ENABLE(FAST_TLS_JIT) >- return Options::useFastTLSForWasmContext(); >-#else >- return false; >-#endif >-} >- >-Instance* Context::load() const >-{ >-#if ENABLE(FAST_TLS_JIT) >- if (useFastTLS()) >- return bitwise_cast<Instance*>(_pthread_getspecific_direct(WTF_WASM_CONTEXT_KEY)); >-#endif >- return instance; >-} >- >-void Context::store(Instance* inst, void* softStackLimit) >-{ >-#if ENABLE(FAST_TLS_JIT) >- if (useFastTLS()) >- _pthread_setspecific_direct(WTF_WASM_CONTEXT_KEY, bitwise_cast<void*>(inst)); >-#endif >- instance = inst; >- if (instance) >- instance->setCachedStackLimit(softStackLimit); >-} >- >-} } // namespace JSC::Wasm >- >-#endif // ENABLE(WEBASSEMBLY) >diff --git a/Source/JavaScriptCore/wasm/WasmContextInlines.h b/Source/JavaScriptCore/wasm/WasmContextInlines.h >new file mode 100644 >index 0000000000000000000000000000000000000000..713be67525ca1493e27235145c819cd45f956104 >--- /dev/null >+++ b/Source/JavaScriptCore/wasm/WasmContextInlines.h >@@ -0,0 +1,69 @@ >+/* >+ * Copyright (C) 2017 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. ``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 >+ * 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(WEBASSEMBLY) >+ >+#include "Options.h" >+#include "WasmContext.h" >+#include "WasmInstance.h" >+#include <mutex> >+#include <wtf/FastTLS.h> >+ >+namespace JSC { namespace Wasm { >+ >+inline bool Context::useFastTLS() >+{ >+#if ENABLE(FAST_TLS_JIT) >+ return Options::useFastTLSForWasmContext(); >+#else >+ return false; >+#endif >+} >+ >+inline Instance* Context::load() const >+{ >+#if ENABLE(FAST_TLS_JIT) >+ if (useFastTLS()) >+ return bitwise_cast<Instance*>(_pthread_getspecific_direct(WTF_WASM_CONTEXT_KEY)); >+#endif >+ return instance; >+} >+ >+inline void Context::store(Instance* inst, void* softStackLimit) >+{ >+#if ENABLE(FAST_TLS_JIT) >+ if (useFastTLS()) >+ _pthread_setspecific_direct(WTF_WASM_CONTEXT_KEY, bitwise_cast<void*>(inst)); >+#endif >+ instance = inst; >+ if (instance) >+ instance->setCachedStackLimit(softStackLimit); >+} >+ >+} } // namespace JSC::Wasm >+ >+#endif // ENABLE(WEBASSEMBLY) >diff --git a/Source/JavaScriptCore/wasm/WasmMemoryInformation.cpp b/Source/JavaScriptCore/wasm/WasmMemoryInformation.cpp >index b5c34bdbf4a735288994927e38a9afaa25226530..c3a4041321d4b28ede33b41f44031877430b9f1e 100644 >--- a/Source/JavaScriptCore/wasm/WasmMemoryInformation.cpp >+++ b/Source/JavaScriptCore/wasm/WasmMemoryInformation.cpp >@@ -29,7 +29,7 @@ > #if ENABLE(WEBASSEMBLY) > > #include "WasmCallingConvention.h" >-#include "WasmContext.h" >+#include "WasmContextInlines.h" > #include "WasmMemory.h" > #include <wtf/NeverDestroyed.h> > >diff --git a/Source/JavaScriptCore/wasm/WasmModuleParser.cpp b/Source/JavaScriptCore/wasm/WasmModuleParser.cpp >index 225dba63138c25a5eabe6ab222a3fb4b4dc191bd..7bc8ead899786b36dd1c35d2ff2f1e89bc1b1087 100644 >--- a/Source/JavaScriptCore/wasm/WasmModuleParser.cpp >+++ b/Source/JavaScriptCore/wasm/WasmModuleParser.cpp >@@ -34,6 +34,7 @@ > #include "WasmOps.h" > #include "WasmSectionParser.h" > #include "WasmSections.h" >+#include <wtf/SHA1.h> > > namespace JSC { namespace Wasm { > >diff --git a/Source/JavaScriptCore/wasm/js/JSToWasm.cpp b/Source/JavaScriptCore/wasm/js/JSToWasm.cpp >index 364f7c74bc19fc55bf2ad69bad490eceeee919da..a603f4b7110d98c49248e5d36cd5d64cb82bd4dd 100644 >--- a/Source/JavaScriptCore/wasm/js/JSToWasm.cpp >+++ b/Source/JavaScriptCore/wasm/js/JSToWasm.cpp >@@ -31,6 +31,7 @@ > #include "CCallHelpers.h" > #include "JSWebAssemblyInstance.h" > #include "WasmCallingConvention.h" >+#include "WasmContextInlines.h" > #include "WasmSignatureInlines.h" > > namespace JSC { namespace Wasm { >diff --git a/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp b/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp >index 5db924f8ecfb03a7e0ba6f5d084822b34711bac7..ec619da4ac8bb79a65d581f5d19565fd0d49e770 100644 >--- a/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp >+++ b/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp >@@ -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"
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189416
: 349157