/*
- * 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
#include "CodeOrigin.h"
#include "DFGCommonData.h"
+#include "InferredValue.h"
#include "JSArrayBufferView.h"
#include "Watchpoint.h"
#include <wtf/HashMap.h>
namespace JSC { namespace DFG {
-template<typename WatchpointSetType>
-struct WatchpointForGenericWatchpointSet {
- WatchpointForGenericWatchpointSet()
- : m_exitKind(ExitKindUnset)
- , m_set(0)
- {
- }
-
- WatchpointForGenericWatchpointSet(
- CodeOrigin codeOrigin, ExitKind exitKind, WatchpointSetType* set)
- : m_codeOrigin(codeOrigin)
- , m_exitKind(exitKind)
- , m_set(set)
- {
- }
-
- CodeOrigin m_codeOrigin;
- ExitKind m_exitKind;
- WatchpointSetType* m_set;
-};
+class Graph;
template<typename T>
struct GenericSetAdaptor {
static bool hasBeenInvalidated(T* set) { return set->hasBeenInvalidated(); }
};
+struct InferredValueAdaptor {
+ static void add(CodeBlock*, InferredValue*, Watchpoint*);
+ static bool hasBeenInvalidated(InferredValue* inferredValue)
+ {
+ return inferredValue->hasBeenInvalidated();
+ }
+};
+
struct ArrayBufferViewWatchpointAdaptor {
static void add(CodeBlock*, JSArrayBufferView*, Watchpoint*);
static bool hasBeenInvalidated(JSArrayBufferView* view)
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);
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());
- }
-
m_reallyAdded = true;
}
return false;
}
- for (unsigned i = m_profiledWatchpoints.size(); i--;) {
- if (Adaptor::hasBeenInvalidated(m_profiledWatchpoints[i].m_set))
- return false;
- }
-
return true;
}
-#if ASSERT_DISABLED
- bool isStillValid(WatchpointSetType* set)
- {
- return !Adaptor::hasBeenInvalidated(set);
- }
-
- bool shouldAssumeMixedState(WatchpointSetType*)
+ bool isWatched(WatchpointSetType* set) const
{
- return true;
- }
-#else
- bool isStillValid(WatchpointSetType* set)
- {
- bool result = !Adaptor::hasBeenInvalidated(set);
- m_firstKnownState.add(set, result);
- return result;
- }
-
- 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)
- {
- return isStillValid(set) || shouldAssumeMixedState(set);
+ return m_sets.contains(set);
}
private:
- Vector<WatchpointForGenericWatchpointSet<WatchpointSetType>> m_profiledWatchpoints;
HashSet<WatchpointSetType*> m_sets;
-#if !ASSERT_DISABLED
- StateMap m_firstKnownState;
-#endif
bool m_reallyAdded;
};
void addLazily(WatchpointSet*);
void addLazily(InlineWatchpointSet&);
+ void addLazily(InferredValue*);
void addLazily(JSArrayBufferView*);
- void addLazily(CodeOrigin, ExitKind, WatchpointSet*);
- void addLazily(CodeOrigin, ExitKind, InlineWatchpointSet&);
+
+ bool consider(Structure*);
void reallyAdd(CodeBlock*, CommonData&);
bool areStillValid() const;
- bool isStillValid(WatchpointSet* set)
- {
- return m_sets.isStillValid(set);
- }
- bool isStillValid(InlineWatchpointSet& set)
- {
- return m_inlineSets.isStillValid(&set);
- }
- bool isStillValid(JSArrayBufferView* view)
- {
- return m_bufferViews.isStillValid(view);
- }
- bool shouldAssumeMixedState(WatchpointSet* set)
- {
- return m_sets.shouldAssumeMixedState(set);
- }
- bool shouldAssumeMixedState(InlineWatchpointSet& set)
- {
- return m_inlineSets.shouldAssumeMixedState(&set);
- }
- bool shouldAssumeMixedState(JSArrayBufferView* view)
+ bool isWatched(WatchpointSet* set)
{
- return m_bufferViews.shouldAssumeMixedState(view);
+ return m_sets.isWatched(set);
}
- bool isValidOrMixed(WatchpointSet* set)
+ bool isWatched(InlineWatchpointSet& set)
{
- return m_sets.isValidOrMixed(set);
+ return m_inlineSets.isWatched(&set);
}
- bool isValidOrMixed(InlineWatchpointSet& set)
+ bool isWatched(InferredValue* inferredValue)
{
- return m_inlineSets.isValidOrMixed(&set);
+ return m_inferredValues.isWatched(inferredValue);
}
- bool isValidOrMixed(JSArrayBufferView* view)
+ bool isWatched(JSArrayBufferView* view)
{
- return m_bufferViews.isValidOrMixed(view);
+ return m_bufferViews.isWatched(view);
}
private:
GenericDesiredWatchpoints<WatchpointSet> m_sets;
GenericDesiredWatchpoints<InlineWatchpointSet> m_inlineSets;
+ GenericDesiredWatchpoints<InferredValue, InferredValueAdaptor> m_inferredValues;
GenericDesiredWatchpoints<JSArrayBufferView, ArrayBufferViewWatchpointAdaptor> m_bufferViews;
};