X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/2d39b0e377c0896910ee49ae70082ba665faf986..refs/heads/master:/dfg/DFGDesiredWatchpoints.h diff --git a/dfg/DFGDesiredWatchpoints.h b/dfg/DFGDesiredWatchpoints.h index 3e07f9b..ce89a04 100644 --- a/dfg/DFGDesiredWatchpoints.h +++ b/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 @@ -30,6 +30,7 @@ #include "CodeOrigin.h" #include "DFGCommonData.h" +#include "InferredValue.h" #include "JSArrayBufferView.h" #include "Watchpoint.h" #include @@ -39,26 +40,7 @@ namespace JSC { namespace DFG { -template -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 struct GenericSetAdaptor { @@ -69,6 +51,14 @@ 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) @@ -95,12 +85,6 @@ public: m_sets.add(set); } - void addLazily(CodeOrigin codeOrigin, ExitKind exitKind, WatchpointSetType* set) - { - m_profiledWatchpoints.append( - WatchpointForGenericWatchpointSet(codeOrigin, exitKind, set)); - } - void reallyAdd(CodeBlock* codeBlock, CommonData& common) { RELEASE_ASSERT(!m_reallyAdded); @@ -112,14 +96,6 @@ public: Adaptor::add(codeBlock, *iter, &common.watchpoints.last()); } - for (unsigned i = m_profiledWatchpoints.size(); i--;) { - WatchpointForGenericWatchpointSet 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; } @@ -132,53 +108,16 @@ public: 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> m_profiledWatchpoints; HashSet m_sets; -#if !ASSERT_DISABLED - StateMap m_firstKnownState; -#endif bool m_reallyAdded; }; @@ -189,54 +128,36 @@ public: 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 m_sets; GenericDesiredWatchpoints m_inlineSets; + GenericDesiredWatchpoints m_inferredValues; GenericDesiredWatchpoints m_bufferViews; };