Bug 1038593 - IonMonkey: Implement RRegExpExec. r=nbp

This commit is contained in:
Lawrence Abadier 2014-08-19 18:16:31 +02:00
parent 64d7f2ea45
commit b897782665
4 changed files with 161 additions and 0 deletions

View File

@ -565,6 +565,113 @@ function rstr_split(i) {
return i;
}
var uceFault_regexp_exec = eval(uneval(uceFault).replace('uceFault', 'uceFault_regexp_exec'))
function rregexp_exec(i) {
var re = new RegExp("(str)\\d+" + i + "\\d+rts");
var res = re.exec("str01234567899876543210rts");
if (uceFault_regexp_exec(i) || uceFault_regexp_exec(i)) {
assertEq(res[1], "str");
}
return i;
}
var uceFault_regexp_y_exec = eval(uneval(uceFault).replace('uceFault', 'uceFault_regexp_y_exec'))
function rregexp_y_exec(i) {
var re = new RegExp("(str)\\d+" + (i % 10), "y");
var res = re.exec("str00123456789");
if (uceFault_regexp_y_exec(i) || uceFault_regexp_y_exec(i)) {
assertEq(res[1], "str");
}
assertEq(re.lastIndex == 0, false);
return i;
}
var uceFault_regexp_y_literal_exec = eval(uneval(uceFault).replace('uceFault', 'uceFault_regexp_y_literal_exec'))
function rregexp_y_literal_exec(i) {
var re = /(str)\d*0/y;
var res = re.exec("str00123456789");
if (uceFault_regexp_y_literal_exec(i) || uceFault_regexp_y_literal_exec(i)) {
assertEq(res[1], "str");
}
assertEq(re.lastIndex == 0, false);
return i;
}
var uceFault_regexp_g_exec = eval(uneval(uceFault).replace('uceFault', 'uceFault_regexp_g_exec'))
function rregexp_g_exec(i) {
var re = new RegExp("(str)\\d+" + (i % 10), "g");
var res = re.exec("str00123456789str00123456789");
if (uceFault_regexp_g_exec(i) || uceFault_regexp_g_exec(i)) {
assertEq(res[1], "str");
}
assertEq(re.lastIndex == 0, false);
return i;
}
var uceFault_regexp_g_literal_exec = eval(uneval(uceFault).replace('uceFault', 'uceFault_regexp_g_literal_exec'))
function rregexp_g_literal_exec(i) {
var re = /(str)\d*0/g;
var res = re.exec("str00123456789str00123456789");
if (uceFault_regexp_g_literal_exec(i) || uceFault_regexp_g_literal_exec(i)) {
assertEq(res[1], "str");
}
assertEq(re.lastIndex == 0, false);
return i;
}
var uceFault_regexp_i_exec = eval(uneval(uceFault).replace('uceFault', 'uceFault_regexp_i_exec'))
function rregexp_i_exec(i) {
var re = new RegExp("(str)\\d+" + (i % 10), "i");
var res = re.exec("STR00123456789");
if (uceFault_regexp_i_exec(i) || uceFault_regexp_i_exec(i)) {
assertEq(res[1], "STR");
}
assertEq(re.lastIndex == 0, true);
return i;
}
var uceFault_regexp_i_literal_exec = eval(uneval(uceFault).replace('uceFault', 'uceFault_regexp_i_literal_exec'))
function rregexp_i_literal_exec(i) {
var re = /(str)\d*0/i;
var res = re.exec("STR00123456789");
if (uceFault_regexp_i_literal_exec(i) || uceFault_regexp_i_literal_exec(i)) {
assertEq(res[1], "STR");
}
assertEq(re.lastIndex == 0, true);
return i;
}
var uceFault_regexp_m_exec = eval(uneval(uceFault).replace('uceFault', 'uceFault_regexp_m_exec'))
function rregexp_m_exec(i) {
var re = new RegExp("^(str)\\d+" + (i % 10), "m");
var res = re.exec("abc\nstr00123456789");
if (uceFault_regexp_m_exec(i) || uceFault_regexp_m_exec(i)) {
assertEq(res[1], "str");
}
assertEq(re.lastIndex == 0, true);
return i;
}
var uceFault_regexp_m_literal_exec = eval(uneval(uceFault).replace('uceFault', 'uceFault_regexp_m_literal_exec'))
function rregexp_m_literal_exec(i) {
var re = /^(str)\d*0/m;
var res = re.exec("abc\nstr00123456789");
if (uceFault_regexp_m_literal_exec(i) || uceFault_regexp_m_literal_exec(i)) {
assertEq(res[1], "str");
}
assertEq(re.lastIndex == 0, true);
return i;
}
var uceFault_regexp_test = eval(uneval(uceFault).replace('uceFault', 'uceFault_regexp_test'))
function rregexp_test(i) {
var re = new RegExp("str\\d+" + i + "\\d+rts");
@ -732,6 +839,15 @@ for (i = 0; i < 100; i++) {
ratan2_number(i);
ratan2_object(i);
rstr_split(i);
rregexp_exec(i);
rregexp_y_exec(i);
rregexp_y_literal_exec(i);
rregexp_g_exec(i);
rregexp_g_literal_exec(i);
rregexp_i_exec(i);
rregexp_i_literal_exec(i);
rregexp_m_exec(i);
rregexp_m_literal_exec(i);
rregexp_test(i);
rregexp_y_test(i);
rregexp_y_literal_test(i);

View File

@ -5986,6 +5986,14 @@ class MRegExpExec
return this;
}
bool writeRecoverData(CompactBufferWriter &writer) const;
bool canRecoverOnBailout() const {
if (regexp()->isRegExp())
return !regexp()->toRegExp()->source()->needUpdateLastIndex();
return false;
}
bool possiblyCalls() const {
return true;
}

View File

@ -11,6 +11,7 @@
#include "jsobj.h"
#include "jsstr.h"
#include "builtin/RegExp.h"
#include "builtin/TypedObject.h"
#include "jit/IonSpewer.h"
@ -885,6 +886,29 @@ RStringSplit::recover(JSContext *cx, SnapshotIterator &iter) const
return true;
}
bool MRegExpExec::writeRecoverData(CompactBufferWriter &writer) const
{
MOZ_ASSERT(canRecoverOnBailout());
writer.writeUnsigned(uint32_t(RInstruction::Recover_RegExpExec));
return true;
}
RRegExpExec::RRegExpExec(CompactBufferReader &reader)
{}
bool RRegExpExec::recover(JSContext *cx, SnapshotIterator &iter) const{
RootedObject regexp(cx, &iter.read().toObject());
RootedString input(cx, iter.read().toString());
RootedValue result(cx);
if(!regexp_exec_raw(cx, regexp, input, &result))
return false;
iter.storeInstructionResult(result);
return true;
}
bool
MRegExpTest::writeRecoverData(CompactBufferWriter &writer) const
{

View File

@ -45,6 +45,7 @@ namespace jit {
_(Sqrt) \
_(Atan2) \
_(StringSplit) \
_(RegExpExec) \
_(RegExpTest) \
_(NewObject) \
_(NewArray) \
@ -461,6 +462,18 @@ class RStringSplit MOZ_FINAL : public RInstruction
bool recover(JSContext *cx, SnapshotIterator &iter) const;
};
class RRegExpExec MOZ_FINAL : public RInstruction
{
public:
RINSTRUCTION_HEADER_(RegExpExec)
virtual uint32_t numOperands() const {
return 2;
}
bool recover(JSContext *cx, SnapshotIterator &iter) const;
};
class RRegExpTest MOZ_FINAL : public RInstruction
{
public: