| Index: test/cctest/test-regexp.cc
|
| diff --git a/test/cctest/test-regexp.cc b/test/cctest/test-regexp.cc
|
| index 89ea9abb4ef7f14d2a79789b0522cedd08b09686..f3141883b3eb5337c9d31a2f715344d39e3f6c06 100644
|
| --- a/test/cctest/test-regexp.cc
|
| +++ b/test/cctest/test-regexp.cc
|
| @@ -598,15 +598,15 @@ TEST(MacroAssembler) {
|
| 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();
|
| m.Bind(&start);
|
| - m.PushBacktrack(&fail2);
|
| + m.PushBacktrack(&fail2, RegExpMacroAssembler::kCheckStackLimit);
|
| m.CheckCharacters(foo, 0, &fail, true);
|
| m.WriteCurrentPositionToRegister(0, 0);
|
| - m.PushCurrentPosition();
|
| + m.PushCurrentPosition(RegExpMacroAssembler::kCheckStackLimit);
|
| m.AdvanceCurrentPosition(3);
|
| m.WriteCurrentPositionToRegister(1, 0);
|
| m.PopCurrentPosition();
|
| @@ -666,6 +666,40 @@ class ContextInitializer {
|
| 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();
|
| @@ -687,12 +721,12 @@ TEST(MacroAssemblerIA32Success) {
|
| 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 @@ TEST(MacroAssemblerIA32Simple) {
|
| 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 @@ TEST(MacroAssemblerIA32Simple) {
|
| 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 @@ TEST(MacroAssemblerIA32SimpleUC16) {
|
| 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 @@ TEST(MacroAssemblerIA32SimpleUC16) {
|
| 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);
|
| }
|
| @@ -836,7 +870,7 @@ TEST(MacroAssemblerIA32Backtrack) {
|
| m.LoadCurrentCharacter(10, &fail);
|
| m.Succeed();
|
| m.Bind(&fail);
|
| - m.PushBacktrack(&backtrack);
|
| + m.PushBacktrack(&backtrack, RegExpMacroAssembler::kNoStackLimitCheck);
|
| m.LoadCurrentCharacter(10, NULL);
|
| m.Succeed();
|
| m.Bind(&backtrack);
|
| @@ -853,12 +887,12 @@ TEST(MacroAssemblerIA32Backtrack) {
|
| 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 @@ TEST(MacroAssemblerIA32BackReferenceASCII) {
|
|
|
| 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 @@ TEST(MacroAssemblerIA32BackReferenceUC16) {
|
|
|
| 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,22 +1034,22 @@ TEST(MacroAssemblerIA32AtStart) {
|
| 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);
|
| }
|
| @@ -1065,12 +1099,12 @@ TEST(MacroAssemblerIA32BackRefNoCase) {
|
|
|
| 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,20 +1128,20 @@ TEST(MacroAssemblerIA32Registers) {
|
| Label fail;
|
| Label backtrack;
|
| m.WriteCurrentPositionToRegister(out1, 0); // Output: [0]
|
| - m.PushRegister(out1);
|
| - m.PushBacktrack(&backtrack);
|
| + m.PushRegister(out1, RegExpMacroAssembler::kNoStackLimitCheck);
|
| + m.PushBacktrack(&backtrack, RegExpMacroAssembler::kCheckStackLimit);
|
| m.WriteStackPointerToRegister(sp);
|
| // Fill stack and registers
|
| m.AdvanceCurrentPosition(2);
|
| m.WriteCurrentPositionToRegister(out1, 0);
|
| - m.PushRegister(out1);
|
| - m.PushBacktrack(&fail);
|
| + m.PushRegister(out1, RegExpMacroAssembler::kNoStackLimitCheck);
|
| + m.PushBacktrack(&fail, RegExpMacroAssembler::kCheckStackLimit);
|
| // Drop backtrack stack frames.
|
| m.ReadStackPointerFromRegister(sp);
|
| // And take the first backtrack (to &backtrack)
|
| m.Backtrack();
|
|
|
| - m.PushCurrentPosition();
|
| + m.PushCurrentPosition(RegExpMacroAssembler::kNoStackLimitCheck);
|
| m.AdvanceCurrentPosition(2);
|
| m.PopCurrentPosition();
|
|
|
| @@ -1135,8 +1169,8 @@ TEST(MacroAssemblerIA32Registers) {
|
|
|
| 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 +1200,12 @@ TEST(MacroAssemblerIA32Registers) {
|
|
|
| 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]);
|
| @@ -1190,7 +1224,7 @@ TEST(MacroAssemblerIA32StackOverflow) {
|
|
|
| Label loop;
|
| m.Bind(&loop);
|
| - m.PushBacktrack(&loop);
|
| + m.PushBacktrack(&loop, RegExpMacroAssembler::kCheckStackLimit);
|
| m.GoTo(&loop);
|
|
|
| Handle<String> source =
|
| @@ -1207,12 +1241,12 @@ TEST(MacroAssemblerIA32StackOverflow) {
|
| 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());
|
|
|