Diff
Modified: trunk/JSTests/ChangeLog (204957 => 204958)
--- trunk/JSTests/ChangeLog 2016-08-25 06:51:04 UTC (rev 204957)
+++ trunk/JSTests/ChangeLog 2016-08-25 07:04:00 UTC (rev 204958)
@@ -1,3 +1,21 @@
+2016-08-25 Caio Lima <[email protected]>
+
+ NewRegexp should not prevent inlining
+ https://bugs.webkit.org/show_bug.cgi?id=154808
+
+ Reviewed by Geoffrey Garen.
+
+ Added test where functions with NewRegExp can be inlined right now.
+
+ * stress/new-regex-inline.js: Added.
+ (assert):
+ (testRegexpInline):
+ (toInlineGlobal):
+ (withRegexp):
+ (inlineRegexpNotGlobal):
+ (toInlineRecursive):
+ (regexpContainsRecursive):
+
2016-08-24 Benjamin Poulain <[email protected]>
[JSC] Make FRound work with any type
Added: trunk/JSTests/stress/new-regex-inline.js (0 => 204958)
--- trunk/JSTests/stress/new-regex-inline.js (rev 0)
+++ trunk/JSTests/stress/new-regex-inline.js 2016-08-25 07:04:00 UTC (rev 204958)
@@ -0,0 +1,82 @@
+function assert(a) {
+ if (!a)
+ throw Error("bad assertion");
+}
+
+function testRegexpInline(functor) {
+ for (let i = 0; i < 100000; i++) {
+ functor();
+ }
+
+ gc();
+
+ // Create objects to force collected objects be reused
+ for (let i = 0; i < 10000000; i++) {
+ let a = {value: i};
+ }
+
+ // Checking if RegExp were collected
+ for (let i = 0; i < 100; i++) {
+ functor();
+ }
+}
+
+function toInlineGlobal() {
+ var re = /cc+/;
+
+ assert(re.test("ccc"));
+ assert(!re.test("abc"));
+ return 0;
+}
+
+function withRegexp() {
+ toInlineGlobal();
+ var re = /(ab)+/;
+ assert(re.test("ab"));
+ assert(!re.test("ba"));
+ return 0;
+}
+
+noInline(withRegexp);
+
+testRegexpInline(withRegexp);
+
+function inlineRegexpNotGlobal() {
+ let toInline = () => {
+ let re = /a+/;
+
+ assert(re.test("aaaaaa"));
+ assert(!re.test("bc"));
+ }
+
+ toInline();
+}
+
+noInline(inlineRegexpNotGlobal);
+
+testRegexpInline(inlineRegexpNotGlobal);
+
+function toInlineRecursive(depth) {
+ if (depth == 5) {
+ return;
+ }
+
+ var re = /(ef)+/;
+
+ assert(re.test("efef"));
+ assert(!re.test("abc"));
+
+ toInlineRecursive(depth + 1);
+}
+
+function regexpContainsRecursive() {
+ var re = /r+/;
+ toInlineRecursive(0);
+
+ assert(re.test("r"));
+ assert(!re.test("ab"));
+}
+noInline(regexpContainsRecursive);
+
+testRegexpInline(regexpContainsRecursive);
+
Modified: trunk/Source/_javascript_Core/ChangeLog (204957 => 204958)
--- trunk/Source/_javascript_Core/ChangeLog 2016-08-25 06:51:04 UTC (rev 204957)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-08-25 07:04:00 UTC (rev 204958)
@@ -1,3 +1,35 @@
+2016-08-25 Caio Lima <[email protected]>
+
+ NewRegexp should not prevent inlining
+ https://bugs.webkit.org/show_bug.cgi?id=154808
+
+ Reviewed by Geoffrey Garen.
+
+ In this patch we are changing the current mechanism used to represent
+ RegExp in NewRegexp nodes. We are changing the use of a index
+ pointing to RegExp in
+ CodeBlock->m_unlinkedCodeBlock->m_rareData->m_regexps as the operand of
+ NewRegexp node to RegExp address as the operand. To make sure that RegExp* is
+ pointing to a valid object, we are using m_graph.freezeStrong
+ mechanism.
+
+ * dfg/DFGByteCodeParser.cpp:
+ (JSC::DFG::ByteCodeParser::parseBlock):
+ * dfg/DFGCapabilities.cpp:
+ (JSC::DFG::capabilityLevel):
+ * dfg/DFGNode.h:
+ (JSC::DFG::Node::hasCellOperand):
+ (JSC::DFG::Node::hasRegexpIndex): Deleted.
+ (JSC::DFG::Node::regexpIndex): Deleted.
+ * dfg/DFGSpeculativeJIT32_64.cpp:
+ (JSC::DFG::SpeculativeJIT::compile):
+ * dfg/DFGSpeculativeJIT64.cpp:
+ (JSC::DFG::SpeculativeJIT::compile):
+ * dfg/DFGStrengthReductionPhase.cpp:
+ (JSC::DFG::StrengthReductionPhase::handleNode):
+ * ftl/FTLLowerDFGToB3.cpp:
+ (JSC::FTL::DFG::LowerDFGToB3::compileNewRegexp):
+
2016-08-24 Benjamin Poulain <[email protected]>
[JSC] Make FRound work with any type
Modified: trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp (204957 => 204958)
--- trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp 2016-08-25 06:51:04 UTC (rev 204957)
+++ trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp 2016-08-25 07:04:00 UTC (rev 204958)
@@ -3698,10 +3698,9 @@
}
case op_new_regexp: {
- // FIXME: We really should be able to inline code that uses NewRegexp. That means
- // using something other than the index into the CodeBlock here.
- // https://bugs.webkit.org/show_bug.cgi?id=154808
- set(VirtualRegister(currentInstruction[1].u.operand), addToGraph(NewRegexp, OpInfo(currentInstruction[2].u.operand)));
+ RegExp* regexp = m_inlineStackTop->m_codeBlock->regexp(currentInstruction[2].u.operand);
+ FrozenValue* frozen = m_graph.freezeStrong(regexp);
+ set(VirtualRegister(currentInstruction[1].u.operand), addToGraph(NewRegexp, OpInfo(frozen)));
NEXT_OPCODE(op_new_regexp);
}
Modified: trunk/Source/_javascript_Core/dfg/DFGCapabilities.cpp (204957 => 204958)
--- trunk/Source/_javascript_Core/dfg/DFGCapabilities.cpp 2016-08-25 06:51:04 UTC (rev 204957)
+++ trunk/Source/_javascript_Core/dfg/DFGCapabilities.cpp 2016-08-25 07:04:00 UTC (rev 204958)
@@ -245,9 +245,9 @@
case op_log_shadow_chicken_tail:
case op_put_to_scope:
case op_resolve_scope:
+ case op_new_regexp:
return CanCompileAndInline;
- case op_new_regexp:
case op_switch_string: // Don't inline because we don't want to copy string tables in the concurrent JIT.
case op_call_eval:
return CanCompile;
Modified: trunk/Source/_javascript_Core/dfg/DFGNode.h (204957 => 204958)
--- trunk/Source/_javascript_Core/dfg/DFGNode.h 2016-08-25 06:51:04 UTC (rev 204957)
+++ trunk/Source/_javascript_Core/dfg/DFGNode.h 2016-08-25 07:04:00 UTC (rev 204958)
@@ -1100,20 +1100,6 @@
m_opInfo = indexingType;
}
- // FIXME: We really should be able to inline code that uses NewRegexp. That means
- // using something other than the index into the CodeBlock here.
- // https://bugs.webkit.org/show_bug.cgi?id=154808
- bool hasRegexpIndex()
- {
- return op() == NewRegexp;
- }
-
- unsigned regexpIndex()
- {
- ASSERT(hasRegexpIndex());
- return m_opInfo;
- }
-
bool hasScopeOffset()
{
return op() == GetClosureVar || op() == PutClosureVar;
@@ -1468,6 +1454,7 @@
case NewGeneratorFunction:
case CreateActivation:
case MaterializeCreateActivation:
+ case NewRegexp:
case CompareEqPtr:
return true;
default:
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp (204957 => 204958)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp 2016-08-25 06:51:04 UTC (rev 204957)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp 2016-08-25 07:04:00 UTC (rev 204958)
@@ -3984,7 +3984,8 @@
GPRFlushedCallResult resultPayload(this);
GPRFlushedCallResult2 resultTag(this);
- callOperation(operationNewRegexp, JSValueRegs(resultTag.gpr(), resultPayload.gpr()), m_jit.codeBlock()->regexp(node->regexpIndex()));
+ RegExp* regexp = node->castOperand<RegExp*>();
+ callOperation(operationNewRegexp, JSValueRegs(resultTag.gpr(), resultPayload.gpr()), regexp);
m_jit.exceptionCheck();
// FIXME: make the callOperation above explicitly return a cell result, or jitAssert the tag is a cell tag.
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp (204957 => 204958)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp 2016-08-25 06:51:04 UTC (rev 204957)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp 2016-08-25 07:04:00 UTC (rev 204958)
@@ -3933,10 +3933,8 @@
flushRegisters();
GPRFlushedCallResult result(this);
- // FIXME: We really should be able to inline code that uses NewRegexp. That means not
- // reaching into the CodeBlock here.
- // https://bugs.webkit.org/show_bug.cgi?id=154808
- callOperation(operationNewRegexp, result.gpr(), m_jit.codeBlock()->regexp(node->regexpIndex()));
+ RegExp* regexp = node->castOperand<RegExp*>();
+ callOperation(operationNewRegexp, result.gpr(), regexp);
m_jit.exceptionCheck();
cellResult(result.gpr(), node);
Modified: trunk/Source/_javascript_Core/dfg/DFGStrengthReductionPhase.cpp (204957 => 204958)
--- trunk/Source/_javascript_Core/dfg/DFGStrengthReductionPhase.cpp 2016-08-25 06:51:04 UTC (rev 204957)
+++ trunk/Source/_javascript_Core/dfg/DFGStrengthReductionPhase.cpp 2016-08-25 07:04:00 UTC (rev 204958)
@@ -391,7 +391,7 @@
if (RegExpObject* regExpObject = regExpObjectNode->dynamicCastConstant<RegExpObject*>())
regExp = regExpObject->regExp();
else if (regExpObjectNode->op() == NewRegexp)
- regExp = codeBlock()->regexp(regExpObjectNode->regexpIndex());
+ regExp = regExpObjectNode->castOperand<RegExp*>();
else {
if (verbose)
dataLog("Giving up because the regexp is unknown.\n");
@@ -631,7 +631,7 @@
if (RegExpObject* regExpObject = regExpObjectNode->dynamicCastConstant<RegExpObject*>())
regExp = regExpObject->regExp();
else if (regExpObjectNode->op() == NewRegexp)
- regExp = codeBlock()->regexp(regExpObjectNode->regexpIndex());
+ regExp = regExpObjectNode->castOperand<RegExp*>();
else {
if (verbose)
dataLog("Giving up because the regexp is unknown.\n");
Modified: trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp (204957 => 204958)
--- trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp 2016-08-25 06:51:04 UTC (rev 204957)
+++ trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp 2016-08-25 07:04:00 UTC (rev 204958)
@@ -7339,14 +7339,11 @@
void compileNewRegexp()
{
- // FIXME: We really should be able to inline code that uses NewRegexp. That means not
- // reaching into the CodeBlock here.
- // https://bugs.webkit.org/show_bug.cgi?id=154808
-
+ RegExp* regexp = m_node->castOperand<RegExp*>();
LValue result = vmCall(
pointerType(),
m_out.operation(operationNewRegexp), m_callFrame,
- m_out.constIntPtr(codeBlock()->regexp(m_node->regexpIndex())));
+ m_out.constIntPtr(regexp));
setJSValue(result);
}