Title: [286802] trunk/Source/_javascript_Core
Revision
286802
Author
[email protected]
Date
2021-12-09 13:49:45 -0800 (Thu, 09 Dec 2021)

Log Message

Procedure::setNeedsPCToOriginMap should call Code::forcePreservationOfB3Origins
https://bugs.webkit.org/show_bug.cgi?id=234093

Reviewed by Yusuke Suzuki.

We need to do this to ensure the sampling profiler works in FTL.
The reason this was sometimes working was Air::Code's constructor
was looking at Procedure's m_needsPCToOriginMap before it was initialized,
in its constructor. This is because Procedure was constructing Code
before all its fields were initialized. This patch fixes that bug to
construct Code after Procedure has all its fields initialized.

* b3/B3Procedure.cpp:
(JSC::B3::Procedure::Procedure):
(JSC::B3::Procedure::setNeedsPCToOriginMap):
* b3/B3Procedure.h:
(JSC::B3::Procedure::setNeedsPCToOriginMap): Deleted.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (286801 => 286802)


--- trunk/Source/_javascript_Core/ChangeLog	2021-12-09 21:28:22 UTC (rev 286801)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-12-09 21:49:45 UTC (rev 286802)
@@ -1,5 +1,25 @@
 2021-12-09  Saam Barati  <[email protected]>
 
+        Procedure::setNeedsPCToOriginMap should call Code::forcePreservationOfB3Origins
+        https://bugs.webkit.org/show_bug.cgi?id=234093
+
+        Reviewed by Yusuke Suzuki.
+
+        We need to do this to ensure the sampling profiler works in FTL.
+        The reason this was sometimes working was Air::Code's constructor
+        was looking at Procedure's m_needsPCToOriginMap before it was initialized,
+        in its constructor. This is because Procedure was constructing Code
+        before all its fields were initialized. This patch fixes that bug to
+        construct Code after Procedure has all its fields initialized.
+
+        * b3/B3Procedure.cpp:
+        (JSC::B3::Procedure::Procedure):
+        (JSC::B3::Procedure::setNeedsPCToOriginMap):
+        * b3/B3Procedure.h:
+        (JSC::B3::Procedure::setNeedsPCToOriginMap): Deleted.
+
+2021-12-09  Saam Barati  <[email protected]>
+
         Add an option to dump the B3 IR for an allowlist of Wasm function indices
         https://bugs.webkit.org/show_bug.cgi?id=234028
 

Modified: trunk/Source/_javascript_Core/b3/B3Procedure.cpp (286801 => 286802)


--- trunk/Source/_javascript_Core/b3/B3Procedure.cpp	2021-12-09 21:28:22 UTC (rev 286801)
+++ trunk/Source/_javascript_Core/b3/B3Procedure.cpp	2021-12-09 21:49:45 UTC (rev 286802)
@@ -48,8 +48,10 @@
     : m_cfg(new CFG(*this))
     , m_lastPhaseName("initial")
     , m_byproducts(makeUnique<OpaqueByproducts>())
-    , m_code(new Air::Code(*this))
 {
+    // Initialize all our fields before constructing Air::Code since
+    // it looks into our fields.
+    m_code = std::unique_ptr<Air::Code>(new Air::Code(*this));
     m_code->setNumEntrypoints(m_numEntrypoints);
 }
 
@@ -486,6 +488,12 @@
     m_code->forcePreservationOfB3Origins();
 }
 
+void Procedure::setNeedsPCToOriginMap()
+{ 
+    m_needsPCToOriginMap = true;
+    m_code->forcePreservationOfB3Origins();
+}
+
 } } // namespace JSC::B3
 
 #endif // ENABLE(B3_JIT)

Modified: trunk/Source/_javascript_Core/b3/B3Procedure.h (286801 => 286802)


--- trunk/Source/_javascript_Core/b3/B3Procedure.h	2021-12-09 21:28:22 UTC (rev 286801)
+++ trunk/Source/_javascript_Core/b3/B3Procedure.h	2021-12-09 21:49:45 UTC (rev 286802)
@@ -275,7 +275,7 @@
     JS_EXPORT_PRIVATE RegisterSet mutableGPRs();
     JS_EXPORT_PRIVATE RegisterSet mutableFPRs();
 
-    void setNeedsPCToOriginMap() { m_needsPCToOriginMap = true; }
+    void setNeedsPCToOriginMap();
     bool needsPCToOriginMap() { return m_needsPCToOriginMap; }
 
     JS_EXPORT_PRIVATE void freeUnneededB3ValuesAfterLowering();

Modified: trunk/Source/_javascript_Core/b3/air/AirCode.cpp (286801 => 286802)


--- trunk/Source/_javascript_Core/b3/air/AirCode.cpp	2021-12-09 21:28:22 UTC (rev 286801)
+++ trunk/Source/_javascript_Core/b3/air/AirCode.cpp	2021-12-09 21:49:45 UTC (rev 286802)
@@ -56,7 +56,7 @@
 Code::Code(Procedure& proc)
     : m_proc(proc)
     , m_cfg(new CFG(*this))
-    , m_preserveB3Origins(proc.needsPCToOriginMap() || Options::dumpAirGraphAtEachPhase() || Options::dumpFTLDisassembly())
+    , m_preserveB3Origins(Options::dumpAirGraphAtEachPhase() || Options::dumpFTLDisassembly())
     , m_lastPhaseName("initial")
     , m_defaultPrologueGenerator(createSharedTask<PrologueGeneratorFunction>(&defaultPrologueGenerator))
 {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to