Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (235988 => 235989)
--- trunk/Source/_javascript_Core/ChangeLog 2018-09-13 20:52:34 UTC (rev 235988)
+++ trunk/Source/_javascript_Core/ChangeLog 2018-09-13 21:49:47 UTC (rev 235989)
@@ -1,3 +1,28 @@
+2018-09-13 Yusuke Suzuki <[email protected]>
+
+ [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.
+
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * Sources.txt:
+ * interpreter/CallFrame.cpp:
+ * jit/AssemblyHelpers.cpp:
+ * wasm/WasmB3IRGenerator.cpp:
+ * wasm/WasmContextInlines.h: Renamed from Source/_javascript_Core/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 <[email protected]>
Move _javascript_Core files to match Xcode project hierarchy
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (235988 => 235989)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2018-09-13 20:52:34 UTC (rev 235988)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2018-09-13 21:49:47 UTC (rev 235989)
@@ -1523,6 +1523,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 */; };
@@ -4344,8 +4345,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>"; };
@@ -6318,8 +6319,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 */,
@@ -9601,6 +9602,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 */,
Modified: trunk/Source/_javascript_Core/Sources.txt (235988 => 235989)
--- trunk/Source/_javascript_Core/Sources.txt 2018-09-13 20:52:34 UTC (rev 235988)
+++ trunk/Source/_javascript_Core/Sources.txt 2018-09-13 21:49:47 UTC (rev 235989)
@@ -971,7 +971,6 @@
wasm/WasmCallee.cpp
wasm/WasmCallingConvention.cpp
wasm/WasmCodeBlock.cpp
-wasm/WasmContext.cpp
wasm/WasmEmbedder.h
wasm/WasmFaultSignalHandler.cpp
wasm/WasmFormat.cpp
Modified: trunk/Source/_javascript_Core/interpreter/CallFrame.cpp (235988 => 235989)
--- trunk/Source/_javascript_Core/interpreter/CallFrame.cpp 2018-09-13 20:52:34 UTC (rev 235988)
+++ trunk/Source/_javascript_Core/interpreter/CallFrame.cpp 2018-09-13 21:49:47 UTC (rev 235989)
@@ -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>
Modified: trunk/Source/_javascript_Core/jit/AssemblyHelpers.cpp (235988 => 235989)
--- trunk/Source/_javascript_Core/jit/AssemblyHelpers.cpp 2018-09-13 20:52:34 UTC (rev 235988)
+++ trunk/Source/_javascript_Core/jit/AssemblyHelpers.cpp 2018-09-13 21:49:47 UTC (rev 235989)
@@ -36,7 +36,7 @@
#include "ThunkGenerators.h"
#if ENABLE(WEBASSEMBLY)
-#include "WasmContext.h"
+#include "WasmContextInlines.h"
#include "WasmMemoryInformation.h"
#endif
Modified: trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp (235988 => 235989)
--- trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp 2018-09-13 20:52:34 UTC (rev 235988)
+++ trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp 2018-09-13 21:49:47 UTC (rev 235989)
@@ -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"
Deleted: trunk/Source/_javascript_Core/wasm/WasmContext.cpp (235988 => 235989)
--- trunk/Source/_javascript_Core/wasm/WasmContext.cpp 2018-09-13 20:52:34 UTC (rev 235988)
+++ trunk/Source/_javascript_Core/wasm/WasmContext.cpp 2018-09-13 21:49:47 UTC (rev 235989)
@@ -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)
Copied: trunk/Source/_javascript_Core/wasm/WasmContextInlines.h (from rev 235988, trunk/Source/_javascript_Core/wasm/WasmContext.cpp) (0 => 235989)
--- trunk/Source/_javascript_Core/wasm/WasmContextInlines.h (rev 0)
+++ trunk/Source/_javascript_Core/wasm/WasmContextInlines.h 2018-09-13 21:49:47 UTC (rev 235989)
@@ -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)
Modified: trunk/Source/_javascript_Core/wasm/WasmMemoryInformation.cpp (235988 => 235989)
--- trunk/Source/_javascript_Core/wasm/WasmMemoryInformation.cpp 2018-09-13 20:52:34 UTC (rev 235988)
+++ trunk/Source/_javascript_Core/wasm/WasmMemoryInformation.cpp 2018-09-13 21:49:47 UTC (rev 235989)
@@ -29,7 +29,7 @@
#if ENABLE(WEBASSEMBLY)
#include "WasmCallingConvention.h"
-#include "WasmContext.h"
+#include "WasmContextInlines.h"
#include "WasmMemory.h"
#include <wtf/NeverDestroyed.h>
Modified: trunk/Source/_javascript_Core/wasm/WasmModuleParser.cpp (235988 => 235989)
--- trunk/Source/_javascript_Core/wasm/WasmModuleParser.cpp 2018-09-13 20:52:34 UTC (rev 235988)
+++ trunk/Source/_javascript_Core/wasm/WasmModuleParser.cpp 2018-09-13 21:49:47 UTC (rev 235989)
@@ -34,6 +34,7 @@
#include "WasmOps.h"
#include "WasmSectionParser.h"
#include "WasmSections.h"
+#include <wtf/SHA1.h>
namespace JSC { namespace Wasm {
Modified: trunk/Source/_javascript_Core/wasm/js/JSToWasm.cpp (235988 => 235989)
--- trunk/Source/_javascript_Core/wasm/js/JSToWasm.cpp 2018-09-13 20:52:34 UTC (rev 235988)
+++ trunk/Source/_javascript_Core/wasm/js/JSToWasm.cpp 2018-09-13 21:49:47 UTC (rev 235989)
@@ -31,6 +31,7 @@
#include "CCallHelpers.h"
#include "JSWebAssemblyInstance.h"
#include "WasmCallingConvention.h"
+#include "WasmContextInlines.h"
#include "WasmSignatureInlines.h"
namespace JSC { namespace Wasm {
Modified: trunk/Source/_javascript_Core/wasm/js/WebAssemblyFunction.cpp (235988 => 235989)
--- trunk/Source/_javascript_Core/wasm/js/WebAssemblyFunction.cpp 2018-09-13 20:52:34 UTC (rev 235988)
+++ trunk/Source/_javascript_Core/wasm/js/WebAssemblyFunction.cpp 2018-09-13 21:49:47 UTC (rev 235989)
@@ -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"