summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/RegExpCachedResult.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2015-05-20 09:56:07 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2015-05-20 09:56:07 +0000
commit41386e9cb918eed93b3f13648cbef387e371e451 (patch)
treea97f9d7bd1d9d091833286085f72da9d83fd0606 /Source/JavaScriptCore/runtime/RegExpCachedResult.h
parente15dd966d523731101f70ccf768bba12435a0208 (diff)
downloadWebKitGtk-tarball-41386e9cb918eed93b3f13648cbef387e371e451.tar.gz
webkitgtk-2.4.9webkitgtk-2.4.9
Diffstat (limited to 'Source/JavaScriptCore/runtime/RegExpCachedResult.h')
-rw-r--r--Source/JavaScriptCore/runtime/RegExpCachedResult.h91
1 files changed, 42 insertions, 49 deletions
diff --git a/Source/JavaScriptCore/runtime/RegExpCachedResult.h b/Source/JavaScriptCore/runtime/RegExpCachedResult.h
index bf6c0b864..d2763bc77 100644
--- a/Source/JavaScriptCore/runtime/RegExpCachedResult.h
+++ b/Source/JavaScriptCore/runtime/RegExpCachedResult.h
@@ -30,61 +30,54 @@
namespace JSC {
-class JSArray;
-class JSString;
+ class JSString;
+ class RegExpMatchesArray;
-// 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);
- }
+ // 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);
+ }
- 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;
- }
+ 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;
+ }
- JSArray* lastResult(ExecState*, JSObject* owner);
- void setInput(ExecState*, JSObject* owner, JSString*);
+ RegExpMatchesArray* lastResult(ExecState*, JSObject* owner);
+ void setInput(ExecState*, JSObject* owner, JSString*);
- JSString* leftContext(ExecState*, JSObject* owner);
- JSString* rightContext(ExecState*, JSObject* owner);
+ 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* input()
- {
- return m_reified ? m_reifiedInput.get() : m_lastInput.get();
- }
+ void visitChildren(SlotVisitor&);
- 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;
-};
+ private:
+ MatchResult m_result;
+ WriteBarrier<JSString> m_lastInput;
+ WriteBarrier<RegExp> m_lastRegExp;
+ WriteBarrier<RegExpMatchesArray> m_reifiedResult;
+ WriteBarrier<JSString> m_reifiedInput;
+ };
} // namespace JSC