Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Unified Diff: test/cctest/test-regexp.cc

Issue 18096: Experimental: merge from bleeding_edge. Merge up to and including... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-debug.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-regexp.cc
===================================================================
--- test/cctest/test-regexp.cc (revision 1085)
+++ test/cctest/test-regexp.cc (working copy)
@@ -291,8 +291,8 @@
CHECK_MIN_MAX("(?:ab)|cde", 2, 3);
CHECK_MIN_MAX("(ab)", 2, 2);
CHECK_MIN_MAX("(ab|cde)", 2, 3);
- CHECK_MIN_MAX("(ab)\\1", 4, 4);
- CHECK_MIN_MAX("(ab|cde)\\1", 4, 6);
+ CHECK_MIN_MAX("(ab)\\1", 2, 4);
+ CHECK_MIN_MAX("(ab|cde)\\1", 2, 6);
CHECK_MIN_MAX("(?:ab)?", 0, 2);
CHECK_MIN_MAX("(?:ab)*", 0, RegExpTree::kInfinity);
CHECK_MIN_MAX("(?:ab)+", 2, RegExpTree::kInfinity);
@@ -598,7 +598,7 @@
foo_chars[2] = 'o';
Vector<const uc16> foo(foo_chars, 3);
m.SetRegister(4, 42);
- m.PushRegister(4);
+ m.PushRegister(4, RegExpMacroAssembler::kNoStackLimitCheck);
m.AdvanceRegister(4, 42);
m.GoTo(&start);
m.Fail();
@@ -666,7 +666,41 @@
v8::internal::StackGuard stack_guard_;
};
+// Helper functions for calling the Execute method.
+template <typename T>
+static RegExpMacroAssemblerIA32::Result ExecuteIA32(Code* code,
+ const T** input,
+ int start_offset,
+ int end_offset,
+ int* captures,
+ bool at_start) {
+ return RegExpMacroAssemblerIA32::Execute(
+ code,
+ reinterpret_cast<Address*>(
+ reinterpret_cast<void*>(const_cast<T**>(input))),
+ start_offset,
+ end_offset,
+ captures,
+ at_start);
+}
+template <typename T>
+static RegExpMacroAssemblerIA32::Result ExecuteIA32(Code* code,
+ T** input,
+ int start_offset,
+ int end_offset,
+ int* captures,
+ bool at_start) {
+ return RegExpMacroAssemblerIA32::Execute(
+ code,
+ reinterpret_cast<Address*>(reinterpret_cast<void*>(input)),
+ start_offset,
+ end_offset,
+ captures,
+ at_start);
+}
+
+
TEST(MacroAssemblerIA32Success) {
v8::V8::Initialize();
ContextInitializer initializer;
@@ -687,12 +721,12 @@
int end_offset = start_offset + seq_input->length();
RegExpMacroAssemblerIA32::Result result =
- RegExpMacroAssemblerIA32::Execute(*code,
- seq_input.location(),
- start_offset,
- end_offset,
- captures,
- true);
+ ExecuteIA32(*code,
+ seq_input.location(),
+ start_offset,
+ end_offset,
+ captures,
+ true);
CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
CHECK_EQ(-1, captures[0]);
@@ -732,12 +766,12 @@
int end_offset = start_offset + seq_input->length();
RegExpMacroAssemblerIA32::Result result =
- RegExpMacroAssemblerIA32::Execute(*code,
- seq_input.location(),
- start_offset,
- end_offset,
- captures,
- true);
+ ExecuteIA32(*code,
+ seq_input.location(),
+ start_offset,
+ end_offset,
+ captures,
+ true);
CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
CHECK_EQ(0, captures[0]);
@@ -751,12 +785,12 @@
start_offset = start_adr - reinterpret_cast<Address>(*seq_input);
end_offset = start_offset + seq_input->length();
- result = RegExpMacroAssemblerIA32::Execute(*code,
- seq_input.location(),
- start_offset,
- end_offset,
- captures,
- true);
+ result = ExecuteIA32(*code,
+ seq_input.location(),
+ start_offset,
+ end_offset,
+ captures,
+ true);
CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result);
}
@@ -794,12 +828,12 @@
int end_offset = start_offset + seq_input->length() * sizeof(uc16);
RegExpMacroAssemblerIA32::Result result =
- RegExpMacroAssemblerIA32::Execute(*code,
- seq_input.location(),
- start_offset,
- end_offset,
- captures,
- true);
+ ExecuteIA32(*code,
+ seq_input.location(),
+ start_offset,
+ end_offset,
+ captures,
+ true);
CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
CHECK_EQ(0, captures[0]);
@@ -814,12 +848,12 @@
start_offset = start_adr - reinterpret_cast<Address>(*seq_input);
end_offset = start_offset + seq_input->length() * sizeof(uc16);
- result = RegExpMacroAssemblerIA32::Execute(*code,
- seq_input.location(),
- start_offset,
- end_offset,
- captures,
- true);
+ result = ExecuteIA32(*code,
+ seq_input.location(),
+ start_offset,
+ end_offset,
+ captures,
+ true);
CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result);
}
@@ -853,12 +887,12 @@
int end_offset = start_offset + seq_input->length();
RegExpMacroAssemblerIA32::Result result =
- RegExpMacroAssemblerIA32::Execute(*code,
- seq_input.location(),
- start_offset,
- end_offset,
- NULL,
- true);
+ ExecuteIA32(*code,
+ seq_input.location(),
+ start_offset,
+ end_offset,
+ NULL,
+ true);
CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result);
}
@@ -897,12 +931,12 @@
int output[3];
RegExpMacroAssemblerIA32::Result result =
- RegExpMacroAssemblerIA32::Execute(*code,
- seq_input.location(),
- start_offset,
- end_offset,
- output,
- true);
+ ExecuteIA32(*code,
+ seq_input.location(),
+ start_offset,
+ end_offset,
+ output,
+ true);
CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
CHECK_EQ(0, output[0]);
@@ -947,12 +981,12 @@
int output[3];
RegExpMacroAssemblerIA32::Result result =
- RegExpMacroAssemblerIA32::Execute(*code,
- seq_input.location(),
- start_offset,
- end_offset,
- output,
- true);
+ ExecuteIA32(*code,
+ seq_input.location(),
+ start_offset,
+ end_offset,
+ output,
+ true);
CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
CHECK_EQ(0, output[0]);
@@ -1000,29 +1034,27 @@
int end_offset = start_offset + seq_input->length();
RegExpMacroAssemblerIA32::Result result =
- RegExpMacroAssemblerIA32::Execute(*code,
- seq_input.location(),
- start_offset,
- end_offset,
- NULL,
- true);
+ ExecuteIA32(*code,
+ seq_input.location(),
+ start_offset,
+ end_offset,
+ NULL,
+ true);
CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
start_offset += 3;
- result = RegExpMacroAssemblerIA32::Execute(*code,
- seq_input.location(),
- start_offset,
- end_offset,
- NULL,
- false);
+ result = ExecuteIA32(*code,
+ seq_input.location(),
+ start_offset,
+ end_offset,
+ NULL,
+ false);
CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
}
-
-
TEST(MacroAssemblerIA32BackRefNoCase) {
v8::V8::Initialize();
ContextInitializer initializer;
@@ -1065,12 +1097,12 @@
int output[4];
RegExpMacroAssemblerIA32::Result result =
- RegExpMacroAssemblerIA32::Execute(*code,
- seq_input.location(),
- start_offset,
- end_offset,
- output,
- true);
+ ExecuteIA32(*code,
+ seq_input.location(),
+ start_offset,
+ end_offset,
+ output,
+ true);
CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
CHECK_EQ(0, output[0]);
@@ -1094,13 +1126,13 @@
Label fail;
Label backtrack;
m.WriteCurrentPositionToRegister(out1, 0); // Output: [0]
- m.PushRegister(out1);
+ m.PushRegister(out1, RegExpMacroAssembler::kNoStackLimitCheck);
m.PushBacktrack(&backtrack);
m.WriteStackPointerToRegister(sp);
// Fill stack and registers
m.AdvanceCurrentPosition(2);
m.WriteCurrentPositionToRegister(out1, 0);
- m.PushRegister(out1);
+ m.PushRegister(out1, RegExpMacroAssembler::kNoStackLimitCheck);
m.PushBacktrack(&fail);
// Drop backtrack stack frames.
m.ReadStackPointerFromRegister(sp);
@@ -1135,8 +1167,8 @@
Label loop3;
Label exit_loop3;
- m.PushRegister(out4);
- m.PushRegister(out4);
+ m.PushRegister(out4, RegExpMacroAssembler::kNoStackLimitCheck);
+ m.PushRegister(out4, RegExpMacroAssembler::kNoStackLimitCheck);
m.ReadCurrentPositionFromRegister(out3);
m.Bind(&loop3);
m.AdvanceCurrentPosition(1);
@@ -1166,12 +1198,12 @@
int output[5];
RegExpMacroAssemblerIA32::Result result =
- RegExpMacroAssemblerIA32::Execute(*code,
- seq_input.location(),
- start_offset,
- end_offset,
- output,
- true);
+ ExecuteIA32(*code,
+ seq_input.location(),
+ start_offset,
+ end_offset,
+ output,
+ true);
CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
CHECK_EQ(0, output[0]);
@@ -1207,12 +1239,12 @@
int end_offset = start_offset + seq_input->length();
RegExpMacroAssemblerIA32::Result result =
- RegExpMacroAssemblerIA32::Execute(*code,
- seq_input.location(),
- start_offset,
- end_offset,
- NULL,
- true);
+ ExecuteIA32(*code,
+ seq_input.location(),
+ start_offset,
+ end_offset,
+ NULL,
+ true);
CHECK_EQ(RegExpMacroAssemblerIA32::EXCEPTION, result);
CHECK(Top::has_pending_exception());
@@ -1220,6 +1252,56 @@
}
+TEST(MacroAssemblerIA32LotsOfRegisters) {
+ v8::V8::Initialize();
+ ContextInitializer initializer;
+
+ RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 2);
+
+ // At least 2048, to ensure the allocated space for registers
+ // span one full page.
+ const int large_number = 8000;
+ m.WriteCurrentPositionToRegister(large_number, 42);
+ m.WriteCurrentPositionToRegister(0, 0);
+ m.WriteCurrentPositionToRegister(1, 1);
+ Label done;
+ m.CheckNotBackReference(0, &done); // Performs a system-stack push.
+ m.Bind(&done);
+ m.PushRegister(large_number, RegExpMacroAssembler::kNoStackLimitCheck);
+ m.PopRegister(1);
+ m.Succeed();
+
+ Handle<String> source =
+ Factory::NewStringFromAscii(CStrVector("<huge register space test>"));
+ Handle<Object> code_object = m.GetCode(source);
+ Handle<Code> code = Handle<Code>::cast(code_object);
+
+ // String long enough for test (content doesn't matter).
+ Handle<String> input =
+ Factory::NewStringFromAscii(CStrVector("sample text"));
+ Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input);
+ Address start_adr = seq_input->GetCharsAddress();
+ int start_offset = start_adr - reinterpret_cast<Address>(*seq_input);
+ int end_offset = start_offset + seq_input->length();
+
+ int captures[2];
+ RegExpMacroAssemblerIA32::Result result =
+ ExecuteIA32(*code,
+ seq_input.location(),
+ start_offset,
+ end_offset,
+ captures,
+ true);
+
+ CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
+ CHECK_EQ(0, captures[0]);
+ CHECK_EQ(42, captures[1]);
+
+ Top::clear_pending_exception();
+}
+
+
+
#endif // !defined ARM
TEST(AddInverseToTable) {
@@ -1466,5 +1548,5 @@
TEST(Graph) {
V8::Initialize(NULL);
- Execute("\\b\\w+\\b", false, true, true);
+ Execute("(?:(?:x(.))?\1)+$", false, true, true);
}
« no previous file with comments | « test/cctest/test-debug.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698