Skip to content

Commit

Permalink
[JSC] Threading Concurrency::MainThread in isWatchableAssumingImpureP…
Browse files Browse the repository at this point in the history
…ropertyWatchpoint

https://bugs.webkit.org/show_bug.cgi?id=273540
rdar://127348006

Reviewed by Justin Michaud.

We should thread Concurrency::MainThread when calling isWatchableAssumingImpurePropertyWatchpoint from main thread code.

* Source/JavaScriptCore/bytecode/AccessCase.cpp:
(JSC::AccessCase::couldStillSucceed const):
* Source/JavaScriptCore/bytecode/InlineCacheCompiler.cpp:
(JSC::InlineCacheCompiler::generateImpl):
* Source/JavaScriptCore/bytecode/ObjectPropertyCondition.cpp:
(JSC::ObjectPropertyCondition::isWatchableAssumingImpurePropertyWatchpoint const):
* Source/JavaScriptCore/bytecode/ObjectPropertyCondition.h:
* Source/JavaScriptCore/bytecode/PropertyCondition.cpp:
(JSC::PropertyCondition::isWatchableAssumingImpurePropertyWatchpoint const):
* Source/JavaScriptCore/bytecode/PropertyCondition.h:

Canonical link: https://commits.webkit.org/278213@main
  • Loading branch information
Constellation committed May 1, 2024
1 parent 53e67f6 commit 14cbb53
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/bytecode/AccessCase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ bool AccessCase::couldStillSucceed() const
{
for (const ObjectPropertyCondition& condition : m_conditionSet) {
if (condition.condition().kind() == PropertyCondition::Equivalence) {
if (!condition.isWatchableAssumingImpurePropertyWatchpoint(PropertyCondition::WatchabilityEffort::EnsureWatchability))
if (!condition.isWatchableAssumingImpurePropertyWatchpoint(PropertyCondition::WatchabilityEffort::EnsureWatchability, Concurrency::MainThread))
return false;
} else {
if (!condition.structureEnsuresValidityAssumingImpurePropertyWatchpoint(Concurrency::MainThread))
Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/bytecode/InlineCacheCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2741,7 +2741,7 @@ void InlineCacheCompiler::generateImpl(AccessCase& accessCase)
for (const ObjectPropertyCondition& condition : accessCase.m_conditionSet) {
RELEASE_ASSERT(!accessCase.polyProtoAccessChain());

if (condition.isWatchableAssumingImpurePropertyWatchpoint(PropertyCondition::WatchabilityEffort::EnsureWatchability)) {
if (condition.isWatchableAssumingImpurePropertyWatchpoint(PropertyCondition::WatchabilityEffort::EnsureWatchability, Concurrency::MainThread)) {
m_conditions.append(condition);
continue;
}
Expand Down
19 changes: 15 additions & 4 deletions Source/JavaScriptCore/bytecode/ObjectPropertyCondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,25 @@ bool ObjectPropertyCondition::structureEnsuresValidity(Concurrency concurrency)
return structureEnsuresValidity(concurrency, m_object->structure());
}

bool ObjectPropertyCondition::isWatchableAssumingImpurePropertyWatchpoint(
Structure* structure, PropertyCondition::WatchabilityEffort effort) const
bool ObjectPropertyCondition::isWatchableAssumingImpurePropertyWatchpoint(Structure* structure, PropertyCondition::WatchabilityEffort effort, Concurrency concurrency) const
{
return m_condition.isWatchableAssumingImpurePropertyWatchpoint(structure, m_object, effort, concurrency);
}

bool ObjectPropertyCondition::isWatchableAssumingImpurePropertyWatchpoint(Structure* structure, PropertyCondition::WatchabilityEffort effort) const
{
return m_condition.isWatchableAssumingImpurePropertyWatchpoint(structure, m_object, effort);
}

bool ObjectPropertyCondition::isWatchableAssumingImpurePropertyWatchpoint(
PropertyCondition::WatchabilityEffort effort) const
bool ObjectPropertyCondition::isWatchableAssumingImpurePropertyWatchpoint(PropertyCondition::WatchabilityEffort effort, Concurrency concurrency) const
{
if (!*this)
return false;

return isWatchableAssumingImpurePropertyWatchpoint(m_object->structure(), effort, concurrency);
}

bool ObjectPropertyCondition::isWatchableAssumingImpurePropertyWatchpoint(PropertyCondition::WatchabilityEffort effort) const
{
if (!*this)
return false;
Expand Down
9 changes: 4 additions & 5 deletions Source/JavaScriptCore/bytecode/ObjectPropertyCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,10 @@ class ObjectPropertyCondition {

// This means that it's still valid and we could enforce validity by setting a transition
// watchpoint on the structure and possibly an impure property watchpoint.
bool isWatchableAssumingImpurePropertyWatchpoint(
Structure*,
PropertyCondition::WatchabilityEffort) const;
bool isWatchableAssumingImpurePropertyWatchpoint(
PropertyCondition::WatchabilityEffort) const;
bool isWatchableAssumingImpurePropertyWatchpoint(Structure*, PropertyCondition::WatchabilityEffort, Concurrency) const;
bool isWatchableAssumingImpurePropertyWatchpoint(PropertyCondition::WatchabilityEffort, Concurrency) const;
bool isWatchableAssumingImpurePropertyWatchpoint(Structure*, PropertyCondition::WatchabilityEffort) const;
bool isWatchableAssumingImpurePropertyWatchpoint(PropertyCondition::WatchabilityEffort) const;

// This means that it's still valid and we could enforce validity by setting a transition
// watchpoint on the structure, and a value change watchpoint if we're Equivalence.
Expand Down
11 changes: 7 additions & 4 deletions Source/JavaScriptCore/bytecode/PropertyCondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,14 @@ bool PropertyCondition::isWatchableWhenValid(Structure* structure, WatchabilityE
return true;
}

bool PropertyCondition::isWatchableAssumingImpurePropertyWatchpoint(
Structure* structure, JSObject* base, WatchabilityEffort effort) const
bool PropertyCondition::isWatchableAssumingImpurePropertyWatchpoint(Structure* structure, JSObject* base, WatchabilityEffort effort, Concurrency concurrency) const
{
return isStillValidAssumingImpurePropertyWatchpoint(watchabilityToConcurrency(effort), structure, base)
&& isWatchableWhenValid(structure, effort, watchabilityToConcurrency(effort));
return isStillValidAssumingImpurePropertyWatchpoint(concurrency, structure, base) && isWatchableWhenValid(structure, effort, concurrency);
}

bool PropertyCondition::isWatchableAssumingImpurePropertyWatchpoint(Structure* structure, JSObject* base, WatchabilityEffort effort) const
{
return isWatchableAssumingImpurePropertyWatchpoint(structure, base, effort, watchabilityToConcurrency(effort));
}

bool PropertyCondition::isWatchable(Structure* structure, JSObject* base, WatchabilityEffort effort) const
Expand Down
4 changes: 2 additions & 2 deletions Source/JavaScriptCore/bytecode/PropertyCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ class PropertyCondition {

// This means that it's still valid and we could enforce validity by setting a transition
// watchpoint on the structure and possibly an impure property watchpoint.
bool isWatchableAssumingImpurePropertyWatchpoint(
Structure*, JSObject* base, WatchabilityEffort) const;
bool isWatchableAssumingImpurePropertyWatchpoint(Structure*, JSObject*, WatchabilityEffort) const;
bool isWatchableAssumingImpurePropertyWatchpoint(Structure*, JSObject*, WatchabilityEffort, Concurrency) const;

// This means that it's still valid and we could enforce validity by setting a transition
// watchpoint on the structure.
Expand Down

0 comments on commit 14cbb53

Please sign in to comment.