Title: [197730] trunk/Source/_javascript_Core
- Revision
- 197730
- Author
- [email protected]
- Date
- 2016-03-07 22:55:33 -0800 (Mon, 07 Mar 2016)
Log Message
Reduce the number of instructions needed to record the last regexp result
https://bugs.webkit.org/show_bug.cgi?id=155161
Reviewed by Sam Weinig.
This tightens up RegExpCachedResult::record(). My profiling shows that we spend just
over 1% of the time in Octane/regexp in this function. This function had two obvious
redundancies:
1) It executed the write barrier on owner twice. It only needs to execute it once. Since
the same RegExpConstructor is likely to be used many times, it makes sense to do the
barrier without looking at the 'to' objects at all. In steady state, this means that
the RegExpConstructor will simply be OldGrey so this one barrier will always skip the
slow path.
2) It cleared some fields that didn't need to be cleared, since we can just use
m_reified to indicate that the fields are not meaningful anymore.
This is meant to be a microscopic regexp speed-up.
* runtime/RegExpCachedResult.cpp:
(JSC::RegExpCachedResult::visitChildren):
(JSC::RegExpCachedResult::lastResult):
* runtime/RegExpCachedResult.h:
(JSC::RegExpCachedResult::record):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (197729 => 197730)
--- trunk/Source/_javascript_Core/ChangeLog 2016-03-08 06:53:32 UTC (rev 197729)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-03-08 06:55:33 UTC (rev 197730)
@@ -1,5 +1,33 @@
2016-03-07 Filip Pizlo <[email protected]>
+ Reduce the number of instructions needed to record the last regexp result
+ https://bugs.webkit.org/show_bug.cgi?id=155161
+
+ Reviewed by Sam Weinig.
+
+ This tightens up RegExpCachedResult::record(). My profiling shows that we spend just
+ over 1% of the time in Octane/regexp in this function. This function had two obvious
+ redundancies:
+
+ 1) It executed the write barrier on owner twice. It only needs to execute it once. Since
+ the same RegExpConstructor is likely to be used many times, it makes sense to do the
+ barrier without looking at the 'to' objects at all. In steady state, this means that
+ the RegExpConstructor will simply be OldGrey so this one barrier will always skip the
+ slow path.
+
+ 2) It cleared some fields that didn't need to be cleared, since we can just use
+ m_reified to indicate that the fields are not meaningful anymore.
+
+ This is meant to be a microscopic regexp speed-up.
+
+ * runtime/RegExpCachedResult.cpp:
+ (JSC::RegExpCachedResult::visitChildren):
+ (JSC::RegExpCachedResult::lastResult):
+ * runtime/RegExpCachedResult.h:
+ (JSC::RegExpCachedResult::record):
+
+2016-03-07 Filip Pizlo <[email protected]>
+
createRegExpMatchesArray should allocate substrings more quickly
https://bugs.webkit.org/show_bug.cgi?id=155160
Modified: trunk/Source/_javascript_Core/runtime/RegExpCachedResult.cpp (197729 => 197730)
--- trunk/Source/_javascript_Core/runtime/RegExpCachedResult.cpp 2016-03-08 06:53:32 UTC (rev 197729)
+++ trunk/Source/_javascript_Core/runtime/RegExpCachedResult.cpp 2016-03-08 06:55:33 UTC (rev 197730)
@@ -35,10 +35,12 @@
{
visitor.append(&m_lastInput);
visitor.append(&m_lastRegExp);
- visitor.append(&m_reifiedInput);
- visitor.append(&m_reifiedResult);
- visitor.append(&m_reifiedLeftContext);
- visitor.append(&m_reifiedRightContext);
+ if (m_reified) {
+ visitor.append(&m_reifiedInput);
+ visitor.append(&m_reifiedResult);
+ visitor.append(&m_reifiedLeftContext);
+ visitor.append(&m_reifiedRightContext);
+ }
}
JSArray* RegExpCachedResult::lastResult(ExecState* exec, JSObject* owner)
@@ -49,6 +51,8 @@
m_reifiedResult.set(exec->vm(), owner, createRegExpMatchesArray(exec, exec->lexicalGlobalObject(), m_lastInput.get(), m_lastRegExp.get(), m_result.start));
else
m_reifiedResult.set(exec->vm(), owner, createEmptyRegExpMatchesArray(exec->lexicalGlobalObject(), m_lastInput.get(), m_lastRegExp.get()));
+ m_reifiedLeftContext.clear();
+ m_reifiedRightContext.clear();
m_reified = true;
}
return m_reifiedResult.get();
Modified: trunk/Source/_javascript_Core/runtime/RegExpCachedResult.h (197729 => 197730)
--- trunk/Source/_javascript_Core/runtime/RegExpCachedResult.h 2016-03-08 06:53:32 UTC (rev 197729)
+++ trunk/Source/_javascript_Core/runtime/RegExpCachedResult.h 2016-03-08 06:55:33 UTC (rev 197730)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -54,10 +54,9 @@
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();
+ vm.heap.writeBarrier(owner);
+ m_lastRegExp.setWithoutWriteBarrier(regExp);
+ m_lastInput.setWithoutWriteBarrier(input);
m_result = result;
m_reified = false;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes