DFGDesiredWatchpoints.cpp [plain text]
#include "config.h"
#include "DFGDesiredWatchpoints.h"
#if ENABLE(DFG_JIT)
#include "CodeBlock.h"
#include "DFGGraph.h"
#include "JSCInlines.h"
namespace JSC { namespace DFG {
void ArrayBufferViewWatchpointAdaptor::add(
CodeBlock* codeBlock, JSArrayBufferView* view, CommonData& common)
{
CodeBlockJettisoningWatchpoint* watchpoint = nullptr;
{
ConcurrentJSLocker locker(codeBlock->m_lock);
watchpoint = common.watchpoints.add(codeBlock);
}
ArrayBuffer* arrayBuffer = view->possiblySharedBuffer();
if (!arrayBuffer) {
watchpoint->fire(codeBlock->vm(), StringFireDetail("ArrayBuffer could not be allocated, probably because of OOM."));
return;
}
arrayBuffer->detachingWatchpointSet().add(WTFMove(watchpoint));
}
void SymbolTableAdaptor::add(
CodeBlock* codeBlock, SymbolTable* symbolTable, CommonData& common)
{
codeBlock->addConstant(ConcurrentJSLocker(codeBlock->m_lock), symbolTable); CodeBlockJettisoningWatchpoint* watchpoint = nullptr;
{
ConcurrentJSLocker locker(codeBlock->m_lock);
watchpoint = common.watchpoints.add(codeBlock);
}
symbolTable->singleton().add(WTFMove(watchpoint));
}
void FunctionExecutableAdaptor::add(
CodeBlock* codeBlock, FunctionExecutable* executable, CommonData& common)
{
codeBlock->addConstant(ConcurrentJSLocker(codeBlock->m_lock), executable); CodeBlockJettisoningWatchpoint* watchpoint = nullptr;
{
ConcurrentJSLocker locker(codeBlock->m_lock);
watchpoint = common.watchpoints.add(codeBlock);
}
executable->singleton().add(WTFMove(watchpoint));
}
void AdaptiveStructureWatchpointAdaptor::add(
CodeBlock* codeBlock, const ObjectPropertyCondition& key, CommonData& common)
{
VM& vm = codeBlock->vm();
switch (key.kind()) {
case PropertyCondition::Equivalence: {
AdaptiveInferredPropertyValueWatchpoint* watchpoint = nullptr;
{
ConcurrentJSLocker locker(codeBlock->m_lock);
watchpoint = common.adaptiveInferredPropertyValueWatchpoints.add(key, codeBlock);
}
watchpoint->install(vm);
break;
}
default: {
AdaptiveStructureWatchpoint* watchpoint = nullptr;
{
ConcurrentJSLocker locker(codeBlock->m_lock);
watchpoint = common.adaptiveStructureWatchpoints.add(key, codeBlock);
}
watchpoint->install(vm);
break;
}
}
}
DesiredWatchpoints::DesiredWatchpoints() { }
DesiredWatchpoints::~DesiredWatchpoints() { }
void DesiredWatchpoints::addLazily(WatchpointSet* set)
{
m_sets.addLazily(set);
}
void DesiredWatchpoints::addLazily(InlineWatchpointSet& set)
{
m_inlineSets.addLazily(&set);
}
void DesiredWatchpoints::addLazily(SymbolTable* symbolTable)
{
m_symbolTables.addLazily(symbolTable);
}
void DesiredWatchpoints::addLazily(FunctionExecutable* executable)
{
m_functionExecutables.addLazily(executable);
}
void DesiredWatchpoints::addLazily(JSArrayBufferView* view)
{
m_bufferViews.addLazily(view);
}
void DesiredWatchpoints::addLazily(const ObjectPropertyCondition& key)
{
m_adaptiveStructureSets.addLazily(key);
}
bool DesiredWatchpoints::consider(Structure* structure)
{
if (!structure->dfgShouldWatch())
return false;
addLazily(structure->transitionWatchpointSet());
return true;
}
void DesiredWatchpoints::reallyAdd(CodeBlock* codeBlock, CommonData& commonData)
{
m_sets.reallyAdd(codeBlock, commonData);
m_inlineSets.reallyAdd(codeBlock, commonData);
m_symbolTables.reallyAdd(codeBlock, commonData);
m_functionExecutables.reallyAdd(codeBlock, commonData);
m_bufferViews.reallyAdd(codeBlock, commonData);
m_adaptiveStructureSets.reallyAdd(codeBlock, commonData);
}
bool DesiredWatchpoints::areStillValid() const
{
return m_sets.areStillValid()
&& m_inlineSets.areStillValid()
&& m_symbolTables.areStillValid()
&& m_functionExecutables.areStillValid()
&& m_bufferViews.areStillValid()
&& m_adaptiveStructureSets.areStillValid();
}
void DesiredWatchpoints::dumpInContext(PrintStream& out, DumpContext* context) const
{
Prefix noPrefix(Prefix::NoHeader);
Prefix& prefix = context && context->graph ? context->graph->prefix() : noPrefix;
out.print(prefix, "Desired watchpoints:\n");
out.print(prefix, " Watchpoint sets: ", inContext(m_sets, context), "\n");
out.print(prefix, " Inline watchpoint sets: ", inContext(m_inlineSets, context), "\n");
out.print(prefix, " SymbolTables: ", inContext(m_symbolTables, context), "\n");
out.print(prefix, " FunctionExecutables: ", inContext(m_functionExecutables, context), "\n");
out.print(prefix, " Buffer views: ", inContext(m_bufferViews, context), "\n");
out.print(prefix, " Object property conditions: ", inContext(m_adaptiveStructureSets, context), "\n");
}
} }
#endif // ENABLE(DFG_JIT)