Diff
Modified: branches/safari-612-branch/JSTests/ChangeLog (285459 => 285460)
--- branches/safari-612-branch/JSTests/ChangeLog 2021-11-09 01:08:57 UTC (rev 285459)
+++ branches/safari-612-branch/JSTests/ChangeLog 2021-11-09 01:09:00 UTC (rev 285460)
@@ -1,5 +1,48 @@
2021-11-08 Kocsen Chung <[email protected]>
+ Cherry-pick r283567. rdar://problem/85173529
+
+ CodeBlock should not add/remove LoopHintExecutionCounters.
+ https://bugs.webkit.org/show_bug.cgi?id=231209
+ rdar://83571235
+
+ Reviewed by Saam Barati.
+
+ JSTests:
+
+ * stress/codeBlock-should-not-add-remove-loop-hint-execution-counters-due-to-cached-unlinked-baseline-code.js: Added.
+
+ Source/_javascript_Core:
+
+ This is because cached unlinked baseline JIT code would retain a pointer to those
+ counters. Hence, the UnlinkedCodeBlock should do the add /remove of the counters
+ instead.
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::finishCreation):
+ (JSC::CodeBlock::~CodeBlock):
+ * bytecode/UnlinkedCodeBlock.cpp:
+ (JSC::UnlinkedCodeBlock::initializeLoopHintExecutionCounter):
+ (JSC::UnlinkedCodeBlock::~UnlinkedCodeBlock):
+ * bytecode/UnlinkedCodeBlock.h:
+ * bytecode/UnlinkedCodeBlockGenerator.cpp:
+ (JSC::UnlinkedCodeBlockGenerator::finalize):
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283567 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-10-05 Mark Lam <[email protected]>
+
+ CodeBlock should not add/remove LoopHintExecutionCounters.
+ https://bugs.webkit.org/show_bug.cgi?id=231209
+ rdar://83571235
+
+ Reviewed by Saam Barati.
+
+ * stress/codeBlock-should-not-add-remove-loop-hint-execution-counters-due-to-cached-unlinked-baseline-code.js: Added.
+
+2021-11-08 Kocsen Chung <[email protected]>
+
Cherry-pick r283332. rdar://problem/85173157
The DFG/FTL need to be aware that Proxy's can produce "function" for typeof and might be callable
Added: branches/safari-612-branch/JSTests/stress/codeBlock-should-not-add-remove-loop-hint-execution-counters-due-to-cached-unlinked-baseline-code.js (0 => 285460)
--- branches/safari-612-branch/JSTests/stress/codeBlock-should-not-add-remove-loop-hint-execution-counters-due-to-cached-unlinked-baseline-code.js (rev 0)
+++ branches/safari-612-branch/JSTests/stress/codeBlock-should-not-add-remove-loop-hint-execution-counters-due-to-cached-unlinked-baseline-code.js 2021-11-09 01:09:00 UTC (rev 285460)
@@ -0,0 +1,10 @@
+//@ runDefault("--returnEarlyFromInfiniteLoopsForFuzzing=true", "--forceCodeBlockToJettisonDueToOldAge=true", "--collectContinuously=true")
+
+async function foo() {
+ for (let i = 0; i < 1000; i++);
+}
+
+for (let i = 0; i < 1000; i++) {
+ foo();
+ edenGC();
+}
Modified: branches/safari-612-branch/Source/_javascript_Core/ChangeLog (285459 => 285460)
--- branches/safari-612-branch/Source/_javascript_Core/ChangeLog 2021-11-09 01:08:57 UTC (rev 285459)
+++ branches/safari-612-branch/Source/_javascript_Core/ChangeLog 2021-11-09 01:09:00 UTC (rev 285460)
@@ -1,5 +1,60 @@
2021-11-08 Kocsen Chung <[email protected]>
+ Cherry-pick r283567. rdar://problem/85173529
+
+ CodeBlock should not add/remove LoopHintExecutionCounters.
+ https://bugs.webkit.org/show_bug.cgi?id=231209
+ rdar://83571235
+
+ Reviewed by Saam Barati.
+
+ JSTests:
+
+ * stress/codeBlock-should-not-add-remove-loop-hint-execution-counters-due-to-cached-unlinked-baseline-code.js: Added.
+
+ Source/_javascript_Core:
+
+ This is because cached unlinked baseline JIT code would retain a pointer to those
+ counters. Hence, the UnlinkedCodeBlock should do the add /remove of the counters
+ instead.
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::finishCreation):
+ (JSC::CodeBlock::~CodeBlock):
+ * bytecode/UnlinkedCodeBlock.cpp:
+ (JSC::UnlinkedCodeBlock::initializeLoopHintExecutionCounter):
+ (JSC::UnlinkedCodeBlock::~UnlinkedCodeBlock):
+ * bytecode/UnlinkedCodeBlock.h:
+ * bytecode/UnlinkedCodeBlockGenerator.cpp:
+ (JSC::UnlinkedCodeBlockGenerator::finalize):
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283567 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-10-05 Mark Lam <[email protected]>
+
+ CodeBlock should not add/remove LoopHintExecutionCounters.
+ https://bugs.webkit.org/show_bug.cgi?id=231209
+ rdar://83571235
+
+ Reviewed by Saam Barati.
+
+ This is because cached unlinked baseline JIT code would retain a pointer to those
+ counters. Hence, the UnlinkedCodeBlock should do the add /remove of the counters
+ instead.
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::finishCreation):
+ (JSC::CodeBlock::~CodeBlock):
+ * bytecode/UnlinkedCodeBlock.cpp:
+ (JSC::UnlinkedCodeBlock::initializeLoopHintExecutionCounter):
+ (JSC::UnlinkedCodeBlock::~UnlinkedCodeBlock):
+ * bytecode/UnlinkedCodeBlock.h:
+ * bytecode/UnlinkedCodeBlockGenerator.cpp:
+ (JSC::UnlinkedCodeBlockGenerator::finalize):
+
+2021-11-08 Kocsen Chung <[email protected]>
+
Cherry-pick r283332. rdar://problem/85173157
The DFG/FTL need to be aware that Proxy's can produce "function" for typeof and might be callable
Modified: branches/safari-612-branch/Source/_javascript_Core/bytecode/CodeBlock.cpp (285459 => 285460)
--- branches/safari-612-branch/Source/_javascript_Core/bytecode/CodeBlock.cpp 2021-11-09 01:08:57 UTC (rev 285459)
+++ branches/safari-612-branch/Source/_javascript_Core/bytecode/CodeBlock.cpp 2021-11-09 01:09:00 UTC (rev 285460)
@@ -745,12 +745,6 @@
break;
}
- case op_loop_hint: {
- if (UNLIKELY(Options::returnEarlyFromInfiniteLoopsForFuzzing()))
- vm.addLoopHintExecutionCounter(instruction.ptr());
- break;
- }
-
default:
break;
}
@@ -799,13 +793,6 @@
// So, we can access member UnlinkedCodeBlock safely here. We bypass the assertion by using unvalidatedGet.
UnlinkedCodeBlock* unlinkedCodeBlock = m_unlinkedCode.unvalidatedGet();
- if (UNLIKELY(Options::returnEarlyFromInfiniteLoopsForFuzzing() && JITCode::isBaselineCode(jitType()))) {
- for (const auto& instruction : unlinkedCodeBlock->instructions()) {
- if (instruction->is<OpLoopHint>())
- vm.removeLoopHintExecutionCounter(instruction.ptr());
- }
- }
-
if (JITCode::isBaselineCode(jitType())) {
if (m_metadata) {
m_metadata->forEach<OpCatch>([&](auto& metadata) {
Modified: branches/safari-612-branch/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp (285459 => 285460)
--- branches/safari-612-branch/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp 2021-11-09 01:08:57 UTC (rev 285459)
+++ branches/safari-612-branch/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp 2021-11-09 01:09:00 UTC (rev 285460)
@@ -80,6 +80,16 @@
}
}
+void UnlinkedCodeBlock::initializeLoopHintExecutionCounter()
+{
+ ASSERT(Options::returnEarlyFromInfiniteLoopsForFuzzing());
+ VM& vm = this->vm();
+ for (const auto& instruction : instructions()) {
+ if (instruction->is<OpLoopHint>())
+ vm.addLoopHintExecutionCounter(instruction.ptr());
+ }
+}
+
template<typename Visitor>
void UnlinkedCodeBlock::visitChildrenImpl(JSCell* cell, Visitor& visitor)
{
@@ -270,6 +280,13 @@
UnlinkedCodeBlock::~UnlinkedCodeBlock()
{
+ if (UNLIKELY(Options::returnEarlyFromInfiniteLoopsForFuzzing())) {
+ VM& vm = this->vm();
+ for (const auto& instruction : instructions()) {
+ if (instruction->is<OpLoopHint>())
+ vm.removeLoopHintExecutionCounter(instruction.ptr());
+ }
+ }
}
const InstructionStream& UnlinkedCodeBlock::instructions() const
Modified: branches/safari-612-branch/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h (285459 => 285460)
--- branches/safari-612-branch/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h 2021-11-09 01:08:57 UTC (rev 285459)
+++ branches/safari-612-branch/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h 2021-11-09 01:09:00 UTC (rev 285460)
@@ -138,6 +138,8 @@
enum { CallFunction, ApplyFunction };
+ void initializeLoopHintExecutionCounter();
+
bool isConstructor() const { return m_isConstructor; }
bool usesCallEval() const { return m_usesCallEval; }
void setUsesCallEval() { m_usesCallEval = true; }
Modified: branches/safari-612-branch/Source/_javascript_Core/bytecode/UnlinkedCodeBlockGenerator.cpp (285459 => 285460)
--- branches/safari-612-branch/Source/_javascript_Core/bytecode/UnlinkedCodeBlockGenerator.cpp 2021-11-09 01:08:57 UTC (rev 285459)
+++ branches/safari-612-branch/Source/_javascript_Core/bytecode/UnlinkedCodeBlockGenerator.cpp 2021-11-09 01:09:00 UTC (rev 285460)
@@ -152,6 +152,9 @@
m_codeBlock->m_rareData->m_bitVectors = WTFMove(m_bitVectors);
m_codeBlock->m_rareData->m_constantIdentifierSets = WTFMove(m_constantIdentifierSets);
}
+
+ if (UNLIKELY(Options::returnEarlyFromInfiniteLoopsForFuzzing()))
+ m_codeBlock->initializeLoopHintExecutionCounter();
}
m_vm.heap.writeBarrier(m_codeBlock.get());
m_vm.heap.reportExtraMemoryAllocated(m_codeBlock->m_instructions->sizeInBytes() + m_codeBlock->m_metadata->sizeInBytes());