NewRegexp should not prevent inlining
https://bugs.webkit.org/show_bug.cgi?id=154808
Patch by Caio Lima <ticaiolima@gmail.com> on 2016-08-25
Reviewed by Geoffrey Garen.
JSTests:
Added test where functions with NewRegExp can be inlined right now.
* stress/new-regex-inline.js: Added.
(assert):
(testRegexpInline):
(toInlineGlobal):
(withRegexp):
(inlineRegexpNotGlobal):
(toInlineRecursive):
(regexpContainsRecursive):
Source/JavaScriptCore:
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):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@204958 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp b/Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp
index 2b2ea9e..5002b79 100644
--- a/Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp
+++ b/Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp
@@ -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");