#593: M1608256 (and clean up code)
This commit is contained in:
parent
6dc231866c
commit
38794a041f
|
@ -1875,82 +1875,6 @@ jit::ApplyTypeInformation(MIRGenerator* mir, MIRGraph& graph)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
jit::MakeMRegExpHoistable(MIRGenerator* mir, MIRGraph& graph)
|
||||
{
|
||||
MOZ_CRASH("thou may not hoist this regex");
|
||||
return false;
|
||||
#if(0)
|
||||
// If we are compiling try blocks, regular expressions may be observable
|
||||
// from catch blocks (which Ion does not compile). For now just disable the
|
||||
// pass in this case.
|
||||
if (graph.hasTryBlock())
|
||||
return true;
|
||||
|
||||
for (ReversePostorderIterator block(graph.rpoBegin()); block != graph.rpoEnd(); block++) {
|
||||
if (mir->shouldCancel("MakeMRegExpHoistable outer loop"))
|
||||
return false;
|
||||
|
||||
for (MDefinitionIterator iter(*block); iter; iter++) {
|
||||
if (mir->shouldCancel("MakeMRegExpHoistable inner loop"))
|
||||
return false;
|
||||
|
||||
if (!iter->isRegExp())
|
||||
continue;
|
||||
|
||||
MRegExp* regexp = iter->toRegExp();
|
||||
|
||||
// Test if MRegExp is hoistable by looking at all uses.
|
||||
bool hoistable = true;
|
||||
for (MUseIterator i = regexp->usesBegin(); i != regexp->usesEnd(); i++) {
|
||||
if (mir->shouldCancel("IsRegExpHoistable inner loop"))
|
||||
return false;
|
||||
|
||||
// Ignore resume points. At this point all uses are listed.
|
||||
// No DCE or GVN or something has happened.
|
||||
if (i->consumer()->isResumePoint())
|
||||
continue;
|
||||
|
||||
MOZ_ASSERT(i->consumer()->isDefinition());
|
||||
|
||||
// All MRegExp* MIR's don't adjust the regexp.
|
||||
MDefinition* use = i->consumer()->toDefinition();
|
||||
if (use->isRegExpReplace())
|
||||
continue;
|
||||
if (use->isRegExpExec())
|
||||
continue;
|
||||
if (use->isRegExpTest())
|
||||
continue;
|
||||
|
||||
hoistable = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!hoistable)
|
||||
continue;
|
||||
|
||||
// Make MRegExp hoistable
|
||||
regexp->setMovable();
|
||||
|
||||
// That would be incorrect for global/sticky, because lastIndex could be wrong.
|
||||
// Therefore setting the lastIndex to 0. That is faster than a not movable regexp.
|
||||
RegExpObject* source = regexp->source();
|
||||
if (source->sticky() || source->global()) {
|
||||
MOZ_ASSERT(regexp->mustClone());
|
||||
MConstant* zero = MConstant::New(graph.alloc(), Int32Value(0));
|
||||
regexp->block()->insertAfter(regexp, zero);
|
||||
|
||||
MStoreFixedSlot* lastIndex =
|
||||
MStoreFixedSlot::New(graph.alloc(), regexp, RegExpObject::lastIndexSlot(), zero);
|
||||
regexp->block()->insertAfter(zero, lastIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
jit::RenumberBlocks(MIRGraph& graph)
|
||||
{
|
||||
|
|
|
@ -53,9 +53,6 @@ EliminateDeadCode(MIRGenerator* mir, MIRGraph& graph);
|
|||
bool
|
||||
ApplyTypeInformation(MIRGenerator* mir, MIRGraph& graph);
|
||||
|
||||
bool
|
||||
MakeMRegExpHoistable(MIRGenerator* mir, MIRGraph& graph);
|
||||
|
||||
bool
|
||||
RenumberBlocks(MIRGraph& graph);
|
||||
|
||||
|
|
|
@ -12810,7 +12810,6 @@ IonBuilder::jsop_regexp(RegExpObject* reobj)
|
|||
// then check if this regex object only flows into known natives and can
|
||||
// avoid cloning in this case.
|
||||
|
||||
bool mustClone = true;
|
||||
TypeSet::ObjectKey* globalKey = TypeSet::ObjectKey::get(&script()->global());
|
||||
if (!globalKey->hasFlags(constraints(), OBJECT_FLAG_REGEXP_FLAGS_SET)) {
|
||||
#ifdef DEBUG
|
||||
|
@ -12824,12 +12823,9 @@ IonBuilder::jsop_regexp(RegExpObject* reobj)
|
|||
MOZ_ASSERT((origFlags & staticsFlags) == staticsFlags);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!reobj->global() && !reobj->sticky())
|
||||
mustClone = false;
|
||||
}
|
||||
|
||||
MRegExp* regexp = MRegExp::New(alloc(), constraints(), reobj, mustClone);
|
||||
MRegExp* regexp = MRegExp::New(alloc(), constraints(), reobj);
|
||||
current->add(regexp);
|
||||
current->push(regexp);
|
||||
|
||||
|
|
|
@ -2034,68 +2034,6 @@ LIRGenerator::visitToObjectOrNull(MToObjectOrNull* ins)
|
|||
assignSafepoint(lir, ins);
|
||||
}
|
||||
|
||||
static bool
|
||||
MustCloneRegExpForCall(MCall* call, uint32_t useIndex)
|
||||
{
|
||||
// We have a regex literal flowing into a call. Return |false| iff
|
||||
// this is a native call that does not let the regex escape.
|
||||
|
||||
JSFunction* target = call->getSingleTarget();
|
||||
if (!target || !target->isNative())
|
||||
return true;
|
||||
|
||||
if (useIndex == MCall::IndexOfThis() &&
|
||||
(target->native() == regexp_exec || target->native() == regexp_test))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (useIndex == MCall::IndexOfArgument(0) &&
|
||||
(target->native() == str_split ||
|
||||
target->native() == str_replace ||
|
||||
target->native() == str_match ||
|
||||
target->native() == str_search))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
MustCloneRegExp(MRegExp* regexp)
|
||||
{
|
||||
if (regexp->mustClone())
|
||||
return true;
|
||||
|
||||
// If this regex literal only flows into known natives that don't let
|
||||
// it escape, we don't have to clone it.
|
||||
|
||||
for (MUseIterator iter(regexp->usesBegin()); iter != regexp->usesEnd(); iter++) {
|
||||
MNode* node = iter->consumer();
|
||||
if (!node->isDefinition())
|
||||
return true;
|
||||
|
||||
MDefinition* def = node->toDefinition();
|
||||
if (def->isRegExpTest()) {
|
||||
MRegExpTest* test = def->toRegExpTest();
|
||||
if (test->indexOf(*iter) == 1) {
|
||||
// Optimized RegExp.prototype.test.
|
||||
MOZ_ASSERT(test->regexp() == regexp);
|
||||
continue;
|
||||
}
|
||||
} else if (def->isCall()) {
|
||||
MCall* call = def->toCall();
|
||||
if (!MustCloneRegExpForCall(call, call->indexOf(*iter)))
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
LIRGenerator::visitRegExp(MRegExp* ins)
|
||||
{
|
||||
|
|
|
@ -7453,11 +7453,9 @@ class MDefFun
|
|||
class MRegExp : public MNullaryInstruction
|
||||
{
|
||||
CompilerGCPointer<RegExpObject*> source_;
|
||||
bool mustClone_;
|
||||
|
||||
MRegExp(CompilerConstraintList* constraints, RegExpObject* source, bool mustClone)
|
||||
: source_(source),
|
||||
mustClone_(mustClone)
|
||||
MRegExp(CompilerConstraintList* constraints, RegExpObject* source)
|
||||
: source_(source)
|
||||
{
|
||||
setResultType(MIRType_Object);
|
||||
setResultTypeSet(MakeSingletonTypeSet(constraints, source));
|
||||
|
@ -7467,14 +7465,11 @@ class MRegExp : public MNullaryInstruction
|
|||
INSTRUCTION_HEADER(RegExp)
|
||||
|
||||
static MRegExp* New(TempAllocator& alloc, CompilerConstraintList* constraints,
|
||||
RegExpObject* source, bool mustClone)
|
||||
RegExpObject* source)
|
||||
{
|
||||
return new(alloc) MRegExp(constraints, source, mustClone);
|
||||
return new(alloc) MRegExp(constraints, source);
|
||||
}
|
||||
|
||||
bool mustClone() const {
|
||||
return mustClone_;
|
||||
}
|
||||
RegExpObject* source() const {
|
||||
return source_;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue