summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.h')
-rw-r--r--Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.h233
1 files changed, 103 insertions, 130 deletions
diff --git a/Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.h b/Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.h
index 64e88c764..e94bfe0d7 100644
--- a/Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.h
+++ b/Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,69 +23,90 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef DFGDesiredWatchpoints_h
-#define DFGDesiredWatchpoints_h
-
-#include <wtf/Platform.h>
+#pragma once
#if ENABLE(DFG_JIT)
#include "CodeOrigin.h"
#include "DFGCommonData.h"
+#include "DFGDesiredInferredType.h"
+#include "InferredValue.h"
#include "JSArrayBufferView.h"
+#include "ObjectPropertyCondition.h"
#include "Watchpoint.h"
-#include <wtf/HashMap.h>
+#include <wtf/CommaPrinter.h>
#include <wtf/HashSet.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/Vector.h>
namespace JSC { namespace DFG {
-template<typename WatchpointSetType>
-struct WatchpointForGenericWatchpointSet {
- WatchpointForGenericWatchpointSet()
- : m_exitKind(ExitKindUnset)
- , m_set(0)
+class Graph;
+
+template<typename T>
+struct SetPointerAdaptor {
+ static void add(CodeBlock* codeBlock, T set, CommonData& common)
{
+ return set->add(common.watchpoints.add(codeBlock));
}
-
- WatchpointForGenericWatchpointSet(
- CodeOrigin codeOrigin, ExitKind exitKind, WatchpointSetType* set)
- : m_codeOrigin(codeOrigin)
- , m_exitKind(exitKind)
- , m_set(set)
+ static bool hasBeenInvalidated(T set) { return set->hasBeenInvalidated(); }
+ static void dumpInContext(PrintStream& out, T set, DumpContext*)
{
+ out.print(RawPointer(set));
}
-
- CodeOrigin m_codeOrigin;
- ExitKind m_exitKind;
- WatchpointSetType* m_set;
};
-template<typename T>
-struct GenericSetAdaptor {
- static void add(CodeBlock*, T* set, Watchpoint* watchpoint)
+struct InferredValueAdaptor {
+ static void add(CodeBlock*, InferredValue*, CommonData&);
+ static bool hasBeenInvalidated(InferredValue* inferredValue)
+ {
+ return inferredValue->hasBeenInvalidated();
+ }
+ static void dumpInContext(PrintStream& out, InferredValue* inferredValue, DumpContext*)
{
- return set->add(watchpoint);
+ out.print(RawPointer(inferredValue));
}
- static bool hasBeenInvalidated(T* set) { return set->hasBeenInvalidated(); }
};
struct ArrayBufferViewWatchpointAdaptor {
- static void add(CodeBlock*, JSArrayBufferView*, Watchpoint*);
+ static void add(CodeBlock*, JSArrayBufferView*, CommonData&);
static bool hasBeenInvalidated(JSArrayBufferView* view)
{
- bool result = !view->length();
- WTF::loadLoadFence();
- return result;
+ return !view->length();
+ }
+ static void dumpInContext(PrintStream& out, JSArrayBufferView* view, DumpContext* context)
+ {
+ out.print(inContext(JSValue(view), context));
+ }
+};
+
+struct AdaptiveStructureWatchpointAdaptor {
+ static void add(CodeBlock*, const ObjectPropertyCondition&, CommonData&);
+ static bool hasBeenInvalidated(const ObjectPropertyCondition& key)
+ {
+ return !key.isWatchable();
+ }
+ static void dumpInContext(
+ PrintStream& out, const ObjectPropertyCondition& key, DumpContext* context)
+ {
+ out.print(inContext(key, context));
+ }
+};
+
+struct InferredTypeAdaptor {
+ static void add(CodeBlock*, const DesiredInferredType&, CommonData&);
+ static bool hasBeenInvalidated(const DesiredInferredType& key)
+ {
+ return !key.isStillValid();
+ }
+ static void dumpInContext(PrintStream& out, const DesiredInferredType& key, DumpContext* context)
+ {
+ out.print(inContext(key, context));
}
};
-template<typename WatchpointSetType, typename Adaptor = GenericSetAdaptor<WatchpointSetType>>
+template<typename WatchpointSetType, typename Adaptor = SetPointerAdaptor<WatchpointSetType>>
class GenericDesiredWatchpoints {
- WTF_MAKE_NONCOPYABLE(GenericDesiredWatchpoints);
#if !ASSERT_DISABLED
- typedef HashMap<WatchpointSetType*, bool> StateMap;
+ typedef HashMap<WatchpointSetType, bool> StateMap;
#endif
public:
GenericDesiredWatchpoints()
@@ -93,95 +114,47 @@ public:
{
}
- void addLazily(WatchpointSetType* set)
+ void addLazily(const WatchpointSetType& set)
{
m_sets.add(set);
}
- void addLazily(CodeOrigin codeOrigin, ExitKind exitKind, WatchpointSetType* set)
- {
- m_profiledWatchpoints.append(
- WatchpointForGenericWatchpointSet<WatchpointSetType>(codeOrigin, exitKind, set));
- }
-
void reallyAdd(CodeBlock* codeBlock, CommonData& common)
{
RELEASE_ASSERT(!m_reallyAdded);
- typename HashSet<WatchpointSetType*>::iterator iter = m_sets.begin();
- typename HashSet<WatchpointSetType*>::iterator end = m_sets.end();
- for (; iter != end; ++iter) {
- common.watchpoints.append(CodeBlockJettisoningWatchpoint(codeBlock));
- Adaptor::add(codeBlock, *iter, &common.watchpoints.last());
- }
-
- for (unsigned i = m_profiledWatchpoints.size(); i--;) {
- WatchpointForGenericWatchpointSet<WatchpointSetType> watchpoint =
- m_profiledWatchpoints[i];
- common.profiledWatchpoints.append(
- ProfiledCodeBlockJettisoningWatchpoint(watchpoint.m_codeOrigin, watchpoint.m_exitKind, codeBlock));
- Adaptor::add(codeBlock, watchpoint.m_set, &common.profiledWatchpoints.last());
- }
+ for (auto& set : m_sets)
+ Adaptor::add(codeBlock, set, common);
m_reallyAdded = true;
}
bool areStillValid() const
{
- typename HashSet<WatchpointSetType*>::iterator iter = m_sets.begin();
- typename HashSet<WatchpointSetType*>::iterator end = m_sets.end();
- for (; iter != end; ++iter) {
- if (Adaptor::hasBeenInvalidated(*iter))
- return false;
- }
-
- for (unsigned i = m_profiledWatchpoints.size(); i--;) {
- if (Adaptor::hasBeenInvalidated(m_profiledWatchpoints[i].m_set))
+ for (auto& set : m_sets) {
+ if (Adaptor::hasBeenInvalidated(set))
return false;
}
return true;
}
-#if ASSERT_DISABLED
- bool isStillValid(WatchpointSetType* set)
- {
- return !Adaptor::hasBeenInvalidated(set);
- }
-
- bool shouldAssumeMixedState(WatchpointSetType*)
+ bool isWatched(const WatchpointSetType& set) const
{
- return true;
- }
-#else
- bool isStillValid(WatchpointSetType* set)
- {
- bool result = !Adaptor::hasBeenInvalidated(set);
- m_firstKnownState.add(set, result);
- return result;
+ return m_sets.contains(set);
}
-
- bool shouldAssumeMixedState(WatchpointSetType* set)
- {
- typename StateMap::iterator iter = m_firstKnownState.find(set);
- if (iter == m_firstKnownState.end())
- return false;
-
- return iter->value != !Adaptor::hasBeenInvalidated(set);
- }
-#endif
-
- bool isValidOrMixed(WatchpointSetType* set)
+
+ void dumpInContext(PrintStream& out, DumpContext* context) const
{
- return isStillValid(set) || shouldAssumeMixedState(set);
+ CommaPrinter comma;
+ for (const WatchpointSetType& entry : m_sets) {
+ out.print(comma);
+ Adaptor::dumpInContext(out, entry, context);
+ }
}
private:
- Vector<WatchpointForGenericWatchpointSet<WatchpointSetType>> m_profiledWatchpoints;
- HashSet<WatchpointSetType*> m_sets;
-#if !ASSERT_DISABLED
- StateMap m_firstKnownState;
-#endif
+ HashSet<WatchpointSetType> m_sets;
bool m_reallyAdded;
};
@@ -192,60 +165,60 @@ public:
void addLazily(WatchpointSet*);
void addLazily(InlineWatchpointSet&);
+ void addLazily(InferredValue*);
void addLazily(JSArrayBufferView*);
- void addLazily(CodeOrigin, ExitKind, WatchpointSet*);
- void addLazily(CodeOrigin, ExitKind, InlineWatchpointSet&);
+
+ // It's recommended that you don't call this directly. Use Graph::watchCondition(), which does
+ // the required GC magic as well as some other bookkeeping.
+ void addLazily(const ObjectPropertyCondition&);
+
+ // It's recommended that you don't call this directly. Use Graph::inferredTypeFor(), which does
+ // the required GC magic.
+ void addLazily(const DesiredInferredType&);
+
+ bool consider(Structure*);
void reallyAdd(CodeBlock*, CommonData&);
bool areStillValid() const;
- bool isStillValid(WatchpointSet* set)
- {
- return m_sets.isStillValid(set);
- }
- bool isStillValid(InlineWatchpointSet& set)
+ bool isWatched(WatchpointSet* set)
{
- return m_inlineSets.isStillValid(&set);
+ return m_sets.isWatched(set);
}
- bool isStillValid(JSArrayBufferView* view)
+ bool isWatched(InlineWatchpointSet& set)
{
- return m_bufferViews.isStillValid(view);
+ return m_inlineSets.isWatched(&set);
}
- bool shouldAssumeMixedState(WatchpointSet* set)
+ bool isWatched(InferredValue* inferredValue)
{
- return m_sets.shouldAssumeMixedState(set);
+ return m_inferredValues.isWatched(inferredValue);
}
- bool shouldAssumeMixedState(InlineWatchpointSet& set)
+ bool isWatched(JSArrayBufferView* view)
{
- return m_inlineSets.shouldAssumeMixedState(&set);
+ return m_bufferViews.isWatched(view);
}
- bool shouldAssumeMixedState(JSArrayBufferView* view)
+ bool isWatched(const ObjectPropertyCondition& key)
{
- return m_bufferViews.shouldAssumeMixedState(view);
+ return m_adaptiveStructureSets.isWatched(key);
}
- bool isValidOrMixed(WatchpointSet* set)
+ bool isWatched(const DesiredInferredType& key)
{
- return m_sets.isValidOrMixed(set);
- }
- bool isValidOrMixed(InlineWatchpointSet& set)
- {
- return m_inlineSets.isValidOrMixed(&set);
- }
- bool isValidOrMixed(JSArrayBufferView* view)
- {
- return m_bufferViews.isValidOrMixed(view);
+ return m_inferredTypes.isWatched(key);
}
+
+ void dumpInContext(PrintStream&, DumpContext*) const;
+ void dump(PrintStream&) const;
private:
- GenericDesiredWatchpoints<WatchpointSet> m_sets;
- GenericDesiredWatchpoints<InlineWatchpointSet> m_inlineSets;
- GenericDesiredWatchpoints<JSArrayBufferView, ArrayBufferViewWatchpointAdaptor> m_bufferViews;
+ GenericDesiredWatchpoints<WatchpointSet*> m_sets;
+ GenericDesiredWatchpoints<InlineWatchpointSet*> m_inlineSets;
+ GenericDesiredWatchpoints<InferredValue*, InferredValueAdaptor> m_inferredValues;
+ GenericDesiredWatchpoints<JSArrayBufferView*, ArrayBufferViewWatchpointAdaptor> m_bufferViews;
+ GenericDesiredWatchpoints<ObjectPropertyCondition, AdaptiveStructureWatchpointAdaptor> m_adaptiveStructureSets;
+ GenericDesiredWatchpoints<DesiredInferredType, InferredTypeAdaptor> m_inferredTypes;
};
} } // namespace JSC::DFG
#endif // ENABLE(DFG_JIT)
-
-#endif // DFGDesiredWatchpoints_h
-