Revision: 11825
Author: [email protected]
Date: Thu Jun 14 10:06:16 2012
Log: Unbreak interpreted regexp.
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/10535164
http://code.google.com/p/v8/source/detail?r=11825
Modified:
/branches/bleeding_edge/src/arm/regexp-macro-assembler-arm.h
/branches/bleeding_edge/src/ia32/regexp-macro-assembler-ia32.h
/branches/bleeding_edge/src/jsregexp.cc
/branches/bleeding_edge/src/jsregexp.h
/branches/bleeding_edge/src/mips/regexp-macro-assembler-mips.h
/branches/bleeding_edge/src/regexp-macro-assembler-irregexp.cc
/branches/bleeding_edge/src/regexp-macro-assembler-irregexp.h
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/test/cctest/test-regexp.cc
=======================================
--- /branches/bleeding_edge/src/arm/regexp-macro-assembler-arm.h Mon Jun 11
05:42:31 2012
+++ /branches/bleeding_edge/src/arm/regexp-macro-assembler-arm.h Thu Jun 14
10:06:16 2012
@@ -35,14 +35,7 @@
namespace internal {
-#ifdef V8_INTERPRETED_REGEXP
-class RegExpMacroAssemblerARM: public RegExpMacroAssembler {
- public:
- RegExpMacroAssemblerARM();
- virtual ~RegExpMacroAssemblerARM();
-};
-
-#else // V8_INTERPRETED_REGEXP
+#ifndef V8_INTERPRETED_REGEXP
class RegExpMacroAssemblerARM: public NativeRegExpMacroAssembler {
public:
RegExpMacroAssemblerARM(Mode mode, int registers_to_save, Zone* zone);
=======================================
--- /branches/bleeding_edge/src/ia32/regexp-macro-assembler-ia32.h Mon Jun
11 05:42:31 2012
+++ /branches/bleeding_edge/src/ia32/regexp-macro-assembler-ia32.h Thu Jun
14 10:06:16 2012
@@ -34,14 +34,7 @@
namespace v8 {
namespace internal {
-#ifdef V8_INTERPRETED_REGEXP
-class RegExpMacroAssemblerIA32: public RegExpMacroAssembler {
- public:
- RegExpMacroAssemblerIA32() { }
- virtual ~RegExpMacroAssemblerIA32() { }
-};
-
-#else // V8_INTERPRETED_REGEXP
+#ifndef V8_INTERPRETED_REGEXP
class RegExpMacroAssemblerIA32: public NativeRegExpMacroAssembler {
public:
RegExpMacroAssemblerIA32(Mode mode, int registers_to_save, Zone* zone);
=======================================
--- /branches/bleeding_edge/src/jsregexp.cc Mon Jun 11 23:43:13 2012
+++ /branches/bleeding_edge/src/jsregexp.cc Thu Jun 14 10:06:16 2012
@@ -231,14 +231,13 @@
Handle<Object> RegExpImpl::Exec(Handle<JSRegExp> regexp,
Handle<String> subject,
int index,
- Handle<JSArray> last_match_info,
- Zone* zone) {
+ Handle<JSArray> last_match_info) {
switch (regexp->TypeTag()) {
case JSRegExp::ATOM:
return AtomExec(regexp, subject, index, last_match_info);
case JSRegExp::IRREGEXP: {
Handle<Object> result =
- IrregexpExec(regexp, subject, index, last_match_info, zone);
+ IrregexpExec(regexp, subject, index, last_match_info);
ASSERT(!result.is_null() ||
regexp->GetIsolate()->has_pending_exception());
return result;
@@ -345,8 +344,7 @@
// If compilation fails, an exception is thrown and this function
// returns false.
bool RegExpImpl::EnsureCompiledIrregexp(
- Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii,
- Zone* zone) {
+ Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii) {
Object* compiled_code = re->DataAt(JSRegExp::code_index(is_ascii));
#ifdef V8_INTERPRETED_REGEXP
if (compiled_code->IsByteArray()) return true;
@@ -362,7 +360,7 @@
ASSERT(compiled_code->IsSmi());
return true;
}
- return CompileIrregexp(re, sample_subject, is_ascii, zone);
+ return CompileIrregexp(re, sample_subject, is_ascii);
}
@@ -384,8 +382,7 @@
bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re,
Handle<String> sample_subject,
- bool is_ascii,
- Zone* zone) {
+ bool is_ascii) {
// Compile the RegExp.
Isolate* isolate = re->GetIsolate();
ZoneScope zone_scope(isolate, DELETE_ON_EXIT);
@@ -437,7 +434,7 @@
pattern,
sample_subject,
is_ascii,
- zone);
+ isolate->zone());
if (result.error_message != NULL) {
// Unable to compile regexp.
Handle<String> error_message =
@@ -502,13 +499,12 @@
int RegExpImpl::IrregexpPrepare(Handle<JSRegExp> regexp,
- Handle<String> subject,
- Zone* zone) {
+ Handle<String> subject) {
if (!subject->IsFlat()) FlattenString(subject);
// Check the asciiness of the underlying storage.
bool is_ascii = subject->IsAsciiRepresentationUnderneath();
- if (!EnsureCompiledIrregexp(regexp, subject, is_ascii, zone)) return -1;
+ if (!EnsureCompiledIrregexp(regexp, subject, is_ascii)) return -1;
#ifdef V8_INTERPRETED_REGEXP
// Byte-code regexp needs space allocated for all its registers.
@@ -541,8 +537,7 @@
Handle<JSRegExp> regexp,
Handle<String> subject,
int index,
- Vector<int> output,
- Zone* zone) {
+ Vector<int> output) {
Isolate* isolate = regexp->GetIsolate();
Handle<FixedArray> irregexp(FixedArray::cast(regexp->data()), isolate);
@@ -556,7 +551,7 @@
#ifndef V8_INTERPRETED_REGEXP
ASSERT(output.length() >= (IrregexpNumberOfCaptures(*irregexp) + 1) * 2);
do {
- EnsureCompiledIrregexp(regexp, subject, is_ascii, zone);
+ EnsureCompiledIrregexp(regexp, subject, is_ascii);
Handle<Code> code(IrregexpNativeCode(*irregexp, is_ascii), isolate);
NativeRegExpMacroAssembler::Result res =
NativeRegExpMacroAssembler::Match(code,
@@ -582,7 +577,7 @@
// the, potentially, different subject (the string can switch between
// being internal and external, and even between being ASCII and UC16,
// but the characters are always the same).
- IrregexpPrepare(regexp, subject, zone);
+ IrregexpPrepare(regexp, subject);
is_ascii = subject->IsAsciiRepresentationUnderneath();
} while (true);
UNREACHABLE();
@@ -617,8 +612,7 @@
Handle<Object> RegExpImpl::IrregexpExec(Handle<JSRegExp> jsregexp,
Handle<String> subject,
int previous_index,
- Handle<JSArray> last_match_info,
- Zone* zone) {
+ Handle<JSArray> last_match_info) {
Isolate* isolate = jsregexp->GetIsolate();
ASSERT_EQ(jsregexp->TypeTag(), JSRegExp::IRREGEXP);
@@ -632,7 +626,7 @@
}
#endif
#endif
- int required_registers = RegExpImpl::IrregexpPrepare(jsregexp, subject,
zone);
+ int required_registers = RegExpImpl::IrregexpPrepare(jsregexp, subject);
if (required_registers < 0) {
// Compiling failed with an exception.
ASSERT(isolate->has_pending_exception());
@@ -643,8 +637,7 @@
int res = RegExpImpl::IrregexpExecRaw(jsregexp, subject, previous_index,
Vector<int>(registers.vector(),
- registers.length()),
- zone);
+ registers.length()));
if (res == RE_SUCCESS) {
int capture_register_count =
(IrregexpNumberOfCaptures(FixedArray::cast(jsregexp->data())) + 1)
* 2;
@@ -5987,7 +5980,7 @@
#else // V8_INTERPRETED_REGEXP
// Interpreted regexp implementation.
EmbeddedVector<byte, 1024> codes;
- RegExpMacroAssemblerIrregexp macro_assembler(codes);
+ RegExpMacroAssemblerIrregexp macro_assembler(codes, zone);
#endif // V8_INTERPRETED_REGEXP
// Inserted here, instead of in Assembler, because it depends on
information
=======================================
--- /branches/bleeding_edge/src/jsregexp.h Mon Jun 11 05:42:31 2012
+++ /branches/bleeding_edge/src/jsregexp.h Thu Jun 14 10:06:16 2012
@@ -78,8 +78,7 @@
static Handle<Object> Exec(Handle<JSRegExp> regexp,
Handle<String> subject,
int index,
- Handle<JSArray> lastMatchInfo,
- Zone* zone);
+ Handle<JSArray> lastMatchInfo);
// Prepares a JSRegExp object with Irregexp-specific data.
static void IrregexpInitialize(Handle<JSRegExp> re,
@@ -108,8 +107,7 @@
// as its "registers" argument. If the regexp cannot be compiled,
// an exception is set as pending, and this function returns negative.
static int IrregexpPrepare(Handle<JSRegExp> regexp,
- Handle<String> subject,
- Zone* zone);
+ Handle<String> subject);
// Calculate the size of offsets vector for the case of global regexp
// and the number of matches this vector is able to store.
@@ -126,8 +124,7 @@
static int IrregexpExecRaw(Handle<JSRegExp> regexp,
Handle<String> subject,
int index,
- Vector<int> registers,
- Zone* zone);
+ Vector<int> registers);
// Execute an Irregexp bytecode pattern.
// On a successful match, the result is a JSArray containing
@@ -136,8 +133,7 @@
static Handle<Object> IrregexpExec(Handle<JSRegExp> regexp,
Handle<String> subject,
int index,
- Handle<JSArray> lastMatchInfo,
- Zone* zone);
+ Handle<JSArray> lastMatchInfo);
// Array index in the lastMatchInfo array.
static const int kLastCaptureCount = 0;
@@ -202,11 +198,9 @@
static String* two_byte_cached_string_;
static bool CompileIrregexp(
- Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii,
- Zone* zone);
+ Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii);
static inline bool EnsureCompiledIrregexp(
- Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii,
- Zone* zone);
+ Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii);
// Set the subject cache. The previous string buffer is not deleted, so
the
=======================================
--- /branches/bleeding_edge/src/mips/regexp-macro-assembler-mips.h Mon Jun
11 23:43:13 2012
+++ /branches/bleeding_edge/src/mips/regexp-macro-assembler-mips.h Thu Jun
14 10:06:16 2012
@@ -38,13 +38,7 @@
namespace v8 {
namespace internal {
-#ifdef V8_INTERPRETED_REGEXP
-class RegExpMacroAssemblerMIPS: public RegExpMacroAssembler {
- public:
- RegExpMacroAssemblerMIPS();
- virtual ~RegExpMacroAssemblerMIPS();
-};
-#else // V8_INTERPRETED_REGEXP
+#ifndef V8_INTERPRETED_REGEXP
class RegExpMacroAssemblerMIPS: public NativeRegExpMacroAssembler {
public:
RegExpMacroAssemblerMIPS(Mode mode, int registers_to_save, Zone* zone);
=======================================
--- /branches/bleeding_edge/src/regexp-macro-assembler-irregexp.cc Wed Jun
6 00:50:22 2012
+++ /branches/bleeding_edge/src/regexp-macro-assembler-irregexp.cc Thu Jun
14 10:06:16 2012
@@ -38,8 +38,10 @@
#ifdef V8_INTERPRETED_REGEXP
-RegExpMacroAssemblerIrregexp::RegExpMacroAssemblerIrregexp(Vector<byte>
buffer)
- : buffer_(buffer),
+RegExpMacroAssemblerIrregexp::RegExpMacroAssemblerIrregexp(Vector<byte>
buffer,
+ Zone* zone)
+ : RegExpMacroAssembler(zone),
+ buffer_(buffer),
pc_(0),
own_buffer_(false),
advance_current_end_(kInvalidPC) {
=======================================
--- /branches/bleeding_edge/src/regexp-macro-assembler-irregexp.h Wed Jun
6 00:50:22 2012
+++ /branches/bleeding_edge/src/regexp-macro-assembler-irregexp.h Thu Jun
14 10:06:16 2012
@@ -48,7 +48,7 @@
// for code generation and assumes its size to be buffer_size. If the
buffer
// is too small, a fatal error occurs. No deallocation of the buffer is
done
// upon destruction of the assembler.
- explicit RegExpMacroAssemblerIrregexp(Vector<byte>);
+ RegExpMacroAssemblerIrregexp(Vector<byte>, Zone* zone);
virtual ~RegExpMacroAssemblerIrregexp();
// The byte-code interpreter checks on each push anyway.
virtual int stack_limit_slack() { return 1; }
=======================================
--- /branches/bleeding_edge/src/runtime.cc Thu Jun 14 07:37:10 2012
+++ /branches/bleeding_edge/src/runtime.cc Thu Jun 14 10:06:16 2012
@@ -1754,8 +1754,7 @@
Handle<Object> result = RegExpImpl::Exec(regexp,
subject,
index,
- last_match_info,
- isolate->zone());
+ last_match_info);
if (result.is_null()) return Failure::Exception();
return *result;
}
@@ -3089,8 +3088,7 @@
Handle<Object> match = RegExpImpl::Exec(regexp_handle,
subject_handle,
0,
- last_match_info_handle,
- isolate->zone());
+ last_match_info_handle);
if (match.is_null()) {
return Failure::Exception();
}
@@ -3191,8 +3189,7 @@
match = RegExpImpl::Exec(regexp_handle,
subject_handle,
next,
- last_match_info_handle,
- isolate->zone());
+ last_match_info_handle);
if (match.is_null()) {
return Failure::Exception();
}
@@ -3248,8 +3245,7 @@
Handle<Object> match = RegExpImpl::Exec(regexp_handle,
subject_handle,
0,
- last_match_info_handle,
- isolate->zone());
+ last_match_info_handle);
if (match.is_null()) return Failure::Exception();
if (match->IsNull()) return *subject_handle;
@@ -3323,8 +3319,7 @@
match = RegExpImpl::Exec(regexp_handle,
subject_handle,
next,
- last_match_info_handle,
- isolate->zone());
+ last_match_info_handle);
if (match.is_null()) return Failure::Exception();
if (match->IsNull()) break;
@@ -3739,8 +3734,7 @@
CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2);
HandleScope handles;
- Handle<Object> match = RegExpImpl::Exec(regexp, subject, 0, regexp_info,
- isolate->zone());
+ Handle<Object> match = RegExpImpl::Exec(regexp, subject, 0, regexp_info);
if (match.is_null()) {
return Failure::Exception();
@@ -3765,8 +3759,7 @@
offsets.Add(start, zone);
offsets.Add(end, zone);
if (start == end) if (++end > length) break;
- match = RegExpImpl::Exec(regexp, subject, end, regexp_info,
- isolate->zone());
+ match = RegExpImpl::Exec(regexp, subject, end, regexp_info);
if (match.is_null()) {
return Failure::Exception();
}
@@ -3864,8 +3857,7 @@
int match_start = -1;
int match_end = 0;
int pos = 0;
- int registers_per_match = RegExpImpl::IrregexpPrepare(regexp, subject,
- isolate->zone());
+ int registers_per_match = RegExpImpl::IrregexpPrepare(regexp, subject);
if (registers_per_match < 0) return RegExpImpl::RE_EXCEPTION;
int max_matches;
@@ -3880,8 +3872,7 @@
int num_matches = RegExpImpl::IrregexpExecRaw(regexp,
subject,
pos,
- register_vector,
- isolate->zone());
+ register_vector);
if (num_matches > 0) {
for (int match_index = 0; match_index < num_matches; match_index++) {
int32_t* current_match = ®ister_vector[match_index * 2];
@@ -3951,8 +3942,7 @@
FixedArrayBuilder* builder) {
ASSERT(subject->IsFlat());
- int registers_per_match = RegExpImpl::IrregexpPrepare(regexp, subject,
- isolate->zone());
+ int registers_per_match = RegExpImpl::IrregexpPrepare(regexp, subject);
if (registers_per_match < 0) return RegExpImpl::RE_EXCEPTION;
int max_matches;
@@ -3965,8 +3955,7 @@
int num_matches = RegExpImpl::IrregexpExecRaw(regexp,
subject,
0,
- register_vector,
- isolate->zone());
+ register_vector);
int capture_count = regexp->CaptureCount();
int subject_length = subject->length();
@@ -4052,8 +4041,7 @@
num_matches = RegExpImpl::IrregexpExecRaw(regexp,
subject,
pos,
- register_vector,
- isolate->zone());
+ register_vector);
} while (num_matches > 0);
if (num_matches != RegExpImpl::RE_EXCEPTION) {
=======================================
--- /branches/bleeding_edge/test/cctest/test-regexp.cc Mon Jun 11 05:42:31
2012
+++ /branches/bleeding_edge/test/cctest/test-regexp.cc Thu Jun 14 10:06:16
2012
@@ -1341,7 +1341,8 @@
TEST(MacroAssembler) {
V8::Initialize(NULL);
byte codes[1024];
- RegExpMacroAssemblerIrregexp m(Vector<byte>(codes, 1024));
+ RegExpMacroAssemblerIrregexp m(Vector<byte>(codes, 1024),
+ Isolate::Current()->zone());
// ^f(o)o.
Label fail, fail2, start;
uc16 foo_chars[3];
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev