Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (287011 => 287012)
--- trunk/Source/_javascript_Core/ChangeLog 2021-12-14 04:55:38 UTC (rev 287011)
+++ trunk/Source/_javascript_Core/ChangeLog 2021-12-14 07:07:39 UTC (rev 287012)
@@ -1,3 +1,22 @@
+2021-12-13 Saam Barati <sbar...@apple.com>
+
+ WasmB3IRGenerator should estimate static execution counts
+ https://bugs.webkit.org/show_bug.cgi?id=234284
+
+ Reviewed by Filip Pizlo.
+
+ This enables the register allocator to make better decisions.
+
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * Sources.txt:
+ * b3/B3BasicBlock.h:
+ (JSC::B3::BasicBlock::setFrequency):
+ * b3/B3EstimateStaticExecutionCounts.cpp: Added.
+ (JSC::B3::estimateStaticExecutionCounts):
+ * b3/B3EstimateStaticExecutionCounts.h: Added.
+ * wasm/WasmB3IRGenerator.cpp:
+ (JSC::Wasm::parseAndCompile):
+
2021-12-13 Brady Eidson <beid...@apple.com>
Teach webpushtool to register and "host" the daemon.
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (287011 => 287012)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2021-12-14 04:55:38 UTC (rev 287011)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2021-12-14 07:07:39 UTC (rev 287012)
@@ -906,6 +906,8 @@
52CD0F5E2242F569004A18A5 /* _javascript_Core.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 932F5BD90822A1C700736975 /* _javascript_Core.framework */; };
52CD0F682242F71C004A18A5 /* testdfg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52CD0F672242F71C004A18A5 /* testdfg.cpp */; };
52DD000826E039B90054E408 /* BaselineJITCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 52DD000626E039B30054E408 /* BaselineJITCode.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 52E65A1C27682760002B4C0A /* B3EstimateStaticExecutionCounts.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52E65A1A27682760002B4C0A /* B3EstimateStaticExecutionCounts.cpp */; };
+ 52E65A1E27682771002B4C0A /* B3EstimateStaticExecutionCounts.h in Headers */ = {isa = PBXBuildFile; fileRef = 52E65A1B27682760002B4C0A /* B3EstimateStaticExecutionCounts.h */; };
52EED7942492B870008F4C93 /* FunctionAllowlist.h in Headers */ = {isa = PBXBuildFile; fileRef = 52EED7932492B868008F4C93 /* FunctionAllowlist.h */; };
52F6C35E1E71EB080081F4CC /* WebAssemblyWrapperFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 52F6C35C1E71EB080081F4CC /* WebAssemblyWrapperFunction.h */; };
530A66B91FA3E78B0026A545 /* UnifiedSource3-mm.mm in Sources */ = {isa = PBXBuildFile; fileRef = 530A66B11FA3E77A0026A545 /* UnifiedSource3-mm.mm */; };
@@ -3717,6 +3719,8 @@
52D1308F221CE03A009C836C /* foo.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = foo.js; sourceTree = "<group>"; };
52DD000626E039B30054E408 /* BaselineJITCode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaselineJITCode.h; sourceTree = "<group>"; };
52DD000726E039B40054E408 /* BaselineJITCode.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BaselineJITCode.cpp; sourceTree = "<group>"; };
+ 52E65A1A27682760002B4C0A /* B3EstimateStaticExecutionCounts.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3EstimateStaticExecutionCounts.cpp; path = b3/B3EstimateStaticExecutionCounts.cpp; sourceTree = "<group>"; };
+ 52E65A1B27682760002B4C0A /* B3EstimateStaticExecutionCounts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3EstimateStaticExecutionCounts.h; path = b3/B3EstimateStaticExecutionCounts.h; sourceTree = "<group>"; };
52EED7922492B868008F4C93 /* FunctionAllowlist.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FunctionAllowlist.cpp; sourceTree = "<group>"; };
52EED7932492B868008F4C93 /* FunctionAllowlist.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FunctionAllowlist.h; sourceTree = "<group>"; };
52F6C35B1E71EB080081F4CC /* WebAssemblyWrapperFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebAssemblyWrapperFunction.cpp; path = js/WebAssemblyWrapperFunction.cpp; sourceTree = "<group>"; };
@@ -5978,6 +5982,8 @@
3395C70522555F6D00BDBFAD /* B3EliminateDeadCode.h */,
0F5BF16E1F23A5A10029D91D /* B3EnsureLoopPreHeaders.cpp */,
0F5BF16F1F23A5A10029D91D /* B3EnsureLoopPreHeaders.h */,
+ 52E65A1A27682760002B4C0A /* B3EstimateStaticExecutionCounts.cpp */,
+ 52E65A1B27682760002B4C0A /* B3EstimateStaticExecutionCounts.h */,
5318045D22EAAF0F004A7342 /* B3ExtractValue.cpp */,
5318045B22EAAC4B004A7342 /* B3ExtractValue.h */,
0F6971E81D92F42100BA02A5 /* B3FenceValue.cpp */,
@@ -9912,6 +9918,7 @@
0FFB921D16D02F300055A5DB /* DFGSlowPathGenerator.h in Headers */,
E322E5A31DA64439006E7709 /* DFGSnippetParams.h in Headers */,
86EC9DD31328DF82002B2AD7 /* DFGSpeculativeJIT.h in Headers */,
+ 52E65A1E27682771002B4C0A /* B3EstimateStaticExecutionCounts.h in Headers */,
0F682FB319BCB36400FA3BAD /* DFGSSACalculator.h in Headers */,
A7D89D0017A0B8CC00773AD8 /* DFGSSAConversionPhase.h in Headers */,
0FC20CBA18556A3500C9E954 /* DFGSSALoweringPhase.h in Headers */,
@@ -11783,6 +11790,7 @@
5C3A77BA22F2480F003827FF /* testb3_2.cpp in Sources */,
5C3A77B922F2480B003827FF /* testb3_3.cpp in Sources */,
5C3A77B822F24809003827FF /* testb3_4.cpp in Sources */,
+ 52E65A1C27682760002B4C0A /* B3EstimateStaticExecutionCounts.cpp in Sources */,
5C3A77B722F24806003827FF /* testb3_5.cpp in Sources */,
5C3A77B622F24803003827FF /* testb3_6.cpp in Sources */,
5C3A77B522F24800003827FF /* testb3_7.cpp in Sources */,
Modified: trunk/Source/_javascript_Core/Sources.txt (287011 => 287012)
--- trunk/Source/_javascript_Core/Sources.txt 2021-12-14 04:55:38 UTC (rev 287011)
+++ trunk/Source/_javascript_Core/Sources.txt 2021-12-14 07:07:39 UTC (rev 287012)
@@ -133,6 +133,7 @@
b3/B3EliminateCommonSubexpressions.cpp
b3/B3EliminateDeadCode.cpp
b3/B3EnsureLoopPreHeaders.cpp
+b3/B3EstimateStaticExecutionCounts.cpp
b3/B3ExtractValue.cpp
b3/B3FenceValue.cpp
b3/B3FixSSA.cpp
Modified: trunk/Source/_javascript_Core/b3/B3BasicBlock.h (287011 => 287012)
--- trunk/Source/_javascript_Core/b3/B3BasicBlock.h 2021-12-14 04:55:38 UTC (rev 287011)
+++ trunk/Source/_javascript_Core/b3/B3BasicBlock.h 2021-12-14 07:07:39 UTC (rev 287012)
@@ -144,6 +144,7 @@
// Update predecessors starting with the successors of this block.
void updatePredecessorsAfter();
+ void setFrequency(double frequency) { m_frequency = frequency; }
double frequency() const { return m_frequency; }
void dump(PrintStream&) const;
Added: trunk/Source/_javascript_Core/b3/B3EstimateStaticExecutionCounts.cpp (0 => 287012)
--- trunk/Source/_javascript_Core/b3/B3EstimateStaticExecutionCounts.cpp (rev 0)
+++ trunk/Source/_javascript_Core/b3/B3EstimateStaticExecutionCounts.cpp 2021-12-14 07:07:39 UTC (rev 287012)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2021 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 "B3EstimateStaticExecutionCounts.h"
+
+#if ENABLE(B3_JIT)
+
+#include "B3BasicBlock.h"
+#include "B3NaturalLoops.h"
+#include "B3Procedure.h"
+
+namespace JSC { namespace B3 {
+
+bool estimateStaticExecutionCounts(Procedure& procedure)
+{
+ auto& naturalLoops = procedure.naturalLoops();
+
+ for (BasicBlock* block : procedure) {
+ constexpr double base = 10.0;
+ block->setFrequency(pow(base, naturalLoops.loopDepth(block)));
+ }
+
+ return true;
+}
+
+} } // namespace JSC::B3
+
+#endif // ENABLE(B3_JIT)
Added: trunk/Source/_javascript_Core/b3/B3EstimateStaticExecutionCounts.h (0 => 287012)
--- trunk/Source/_javascript_Core/b3/B3EstimateStaticExecutionCounts.h (rev 0)
+++ trunk/Source/_javascript_Core/b3/B3EstimateStaticExecutionCounts.h 2021-12-14 07:07:39 UTC (rev 287012)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2021 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(B3_JIT)
+
+namespace JSC { namespace B3 {
+
+class Procedure;
+
+bool estimateStaticExecutionCounts(Procedure&);
+
+} } // namespace JSC::B3
+
+#endif // ENABLE(B3_JIT)
Modified: trunk/Source/_javascript_Core/b3/B3Procedure.h (287011 => 287012)
--- trunk/Source/_javascript_Core/b3/B3Procedure.h 2021-12-14 04:55:38 UTC (rev 287011)
+++ trunk/Source/_javascript_Core/b3/B3Procedure.h 2021-12-14 07:07:39 UTC (rev 287012)
@@ -189,7 +189,7 @@
CFG& cfg() const { return *m_cfg; }
Dominators& dominators();
- NaturalLoops& naturalLoops();
+ JS_EXPORT_PRIVATE NaturalLoops& naturalLoops();
BackwardsCFG& backwardsCFG();
BackwardsDominators& backwardsDominators();
Modified: trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp (287011 => 287012)
--- trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp 2021-12-14 04:55:38 UTC (rev 287011)
+++ trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp 2021-12-14 07:07:39 UTC (rev 287012)
@@ -33,6 +33,7 @@
#include "B3BasicBlockInlines.h"
#include "B3CCallValue.h"
#include "B3ConstPtrValue.h"
+#include "B3EstimateStaticExecutionCounts.h"
#include "B3FixSSA.h"
#include "B3Generate.h"
#include "B3InsertionSet.h"
@@ -3294,6 +3295,8 @@
if (ASSERT_ENABLED)
validate(procedure, "After parsing:\n");
+ estimateStaticExecutionCounts(procedure);
+
dataLogIf(WasmB3IRGeneratorInternal::verbose, "Pre SSA: ", procedure);
fixSSA(procedure);
dataLogIf(WasmB3IRGeneratorInternal::verbose, "Post SSA: ", procedure);