diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-05-30 12:48:17 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-05-30 12:48:17 +0200 |
commit | 881da28418d380042aa95a97f0cbd42560a64f7c (patch) | |
tree | a794dff3274695e99c651902dde93d934ea7a5af /Source/JavaScriptCore/runtime/RegExpCachedResult.h | |
parent | 7e104c57a70fdf551bb3d22a5d637cdcbc69dbea (diff) | |
parent | 0fcedcd17cc00d3dd44c718b3cb36c1033319671 (diff) | |
download | qtwebkit-881da28418d380042aa95a97f0cbd42560a64f7c.tar.gz |
Merge 'wip/next' into dev
Change-Id: Iff9ee5e23bb326c4371ec8ed81d56f2f05d680e9
Diffstat (limited to 'Source/JavaScriptCore/runtime/RegExpCachedResult.h')
-rw-r--r-- | Source/JavaScriptCore/runtime/RegExpCachedResult.h | 91 |
1 files changed, 49 insertions, 42 deletions
diff --git a/Source/JavaScriptCore/runtime/RegExpCachedResult.h b/Source/JavaScriptCore/runtime/RegExpCachedResult.h index d2763bc77..bf6c0b864 100644 --- a/Source/JavaScriptCore/runtime/RegExpCachedResult.h +++ b/Source/JavaScriptCore/runtime/RegExpCachedResult.h @@ -30,54 +30,61 @@ namespace JSC { - class JSString; - class RegExpMatchesArray; +class JSArray; +class JSString; - // RegExpCachedResult is used to track the cached results of the last - // match, stores on the RegExp constructor (e.g. $&, $_, $1, $2 ...). - // These values will be lazily generated on demand, so the cached result - // may be in a lazy or reified state. A lazy state is indicated by a - // value of m_result indicating a successful match, and a reified state - // is indicated by setting m_result to MatchResult::failed(). - // Following a successful match, m_result, m_lastInput and m_lastRegExp - // can be used to reify the results from the match, following reification - // m_reifiedResult and m_reifiedInput hold the cached results. - class RegExpCachedResult { - public: - RegExpCachedResult(VM& vm, JSObject* owner, RegExp* emptyRegExp) - : m_result(0, 0) - { - m_lastInput.set(vm, owner, jsEmptyString(&vm)); - m_lastRegExp.set(vm, owner, emptyRegExp); - } +// RegExpCachedResult is used to track the cached results of the last +// match, stores on the RegExp constructor (e.g. $&, $_, $1, $2 ...). +// These values will be lazily generated on demand, so the cached result +// may be in a lazy or reified state. A lazy state is indicated by a +// value of m_result indicating a successful match, and a reified state +// is indicated by setting m_result to MatchResult::failed(). +// Following a successful match, m_result, m_lastInput and m_lastRegExp +// can be used to reify the results from the match, following reification +// m_reifiedResult and m_reifiedInput hold the cached results. +class RegExpCachedResult { +public: + RegExpCachedResult(VM& vm, JSObject* owner, RegExp* emptyRegExp) + : m_result(0, 0) + , m_reified(false) + { + m_lastInput.set(vm, owner, jsEmptyString(&vm)); + m_lastRegExp.set(vm, owner, emptyRegExp); + } - ALWAYS_INLINE void record(VM& vm, JSObject* owner, RegExp* regExp, JSString* input, MatchResult result) - { - m_lastRegExp.set(vm, owner, regExp); - m_lastInput.set(vm, owner, input); - m_result = result; - } + ALWAYS_INLINE void record(VM& vm, JSObject* owner, RegExp* regExp, JSString* input, MatchResult result) + { + m_lastRegExp.set(vm, owner, regExp); + m_lastInput.set(vm, owner, input); + m_reifiedLeftContext.clear(); + m_reifiedRightContext.clear(); + m_result = result; + m_reified = false; + } - RegExpMatchesArray* lastResult(ExecState*, JSObject* owner); - void setInput(ExecState*, JSObject* owner, JSString*); + JSArray* lastResult(ExecState*, JSObject* owner); + void setInput(ExecState*, JSObject* owner, JSString*); - JSString* input() - { - // If m_result showas a match then we're in a lazy state, so m_lastInput - // is the most recent value of the input property. If not then we have - // reified, in which case m_reifiedInput will contain the correct value. - return m_result ? m_lastInput.get() : m_reifiedInput.get(); - } + JSString* leftContext(ExecState*, JSObject* owner); + JSString* rightContext(ExecState*, JSObject* owner); - void visitChildren(SlotVisitor&); + JSString* input() + { + return m_reified ? m_reifiedInput.get() : m_lastInput.get(); + } - private: - MatchResult m_result; - WriteBarrier<JSString> m_lastInput; - WriteBarrier<RegExp> m_lastRegExp; - WriteBarrier<RegExpMatchesArray> m_reifiedResult; - WriteBarrier<JSString> m_reifiedInput; - }; + void visitChildren(SlotVisitor&); + +private: + MatchResult m_result; + bool m_reified; + WriteBarrier<JSString> m_lastInput; + WriteBarrier<RegExp> m_lastRegExp; + WriteBarrier<JSArray> m_reifiedResult; + WriteBarrier<JSString> m_reifiedInput; + WriteBarrier<JSString> m_reifiedLeftContext; + WriteBarrier<JSString> m_reifiedRightContext; +}; } // namespace JSC |