| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 #include "src/x87/macro-assembler-x87.h" | 91 #include "src/x87/macro-assembler-x87.h" |
| 92 #endif | 92 #endif |
| 93 #endif // V8_INTERPRETED_REGEXP | 93 #endif // V8_INTERPRETED_REGEXP |
| 94 #include "test/cctest/cctest.h" | 94 #include "test/cctest/cctest.h" |
| 95 | 95 |
| 96 using namespace v8::internal; | 96 using namespace v8::internal; |
| 97 | 97 |
| 98 | 98 |
| 99 static bool CheckParse(const char* input) { | 99 static bool CheckParse(const char* input) { |
| 100 v8::HandleScope scope(CcTest::isolate()); | 100 v8::HandleScope scope(CcTest::isolate()); |
| 101 Zone zone(CcTest::i_isolate()->allocator()); | 101 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 102 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); | 102 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); |
| 103 RegExpCompileData result; | 103 RegExpCompileData result; |
| 104 return v8::internal::RegExpParser::ParseRegExp( | 104 return v8::internal::RegExpParser::ParseRegExp( |
| 105 CcTest::i_isolate(), &zone, &reader, JSRegExp::kNone, &result); | 105 CcTest::i_isolate(), &zone, &reader, JSRegExp::kNone, &result); |
| 106 } | 106 } |
| 107 | 107 |
| 108 | 108 |
| 109 static void CheckParseEq(const char* input, const char* expected, | 109 static void CheckParseEq(const char* input, const char* expected, |
| 110 bool unicode = false) { | 110 bool unicode = false) { |
| 111 v8::HandleScope scope(CcTest::isolate()); | 111 v8::HandleScope scope(CcTest::isolate()); |
| 112 Zone zone(CcTest::i_isolate()->allocator()); | 112 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 113 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); | 113 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); |
| 114 RegExpCompileData result; | 114 RegExpCompileData result; |
| 115 JSRegExp::Flags flags = JSRegExp::kNone; | 115 JSRegExp::Flags flags = JSRegExp::kNone; |
| 116 if (unicode) flags |= JSRegExp::kUnicode; | 116 if (unicode) flags |= JSRegExp::kUnicode; |
| 117 CHECK(v8::internal::RegExpParser::ParseRegExp(CcTest::i_isolate(), &zone, | 117 CHECK(v8::internal::RegExpParser::ParseRegExp(CcTest::i_isolate(), &zone, |
| 118 &reader, flags, &result)); | 118 &reader, flags, &result)); |
| 119 CHECK(result.tree != NULL); | 119 CHECK(result.tree != NULL); |
| 120 CHECK(result.error.is_null()); | 120 CHECK(result.error.is_null()); |
| 121 std::ostringstream os; | 121 std::ostringstream os; |
| 122 result.tree->Print(os, &zone); | 122 result.tree->Print(os, &zone); |
| 123 if (strcmp(expected, os.str().c_str()) != 0) { | 123 if (strcmp(expected, os.str().c_str()) != 0) { |
| 124 printf("%s | %s\n", expected, os.str().c_str()); | 124 printf("%s | %s\n", expected, os.str().c_str()); |
| 125 } | 125 } |
| 126 CHECK_EQ(0, strcmp(expected, os.str().c_str())); | 126 CHECK_EQ(0, strcmp(expected, os.str().c_str())); |
| 127 } | 127 } |
| 128 | 128 |
| 129 | 129 |
| 130 static bool CheckSimple(const char* input) { | 130 static bool CheckSimple(const char* input) { |
| 131 v8::HandleScope scope(CcTest::isolate()); | 131 v8::HandleScope scope(CcTest::isolate()); |
| 132 Zone zone(CcTest::i_isolate()->allocator()); | 132 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 133 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); | 133 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); |
| 134 RegExpCompileData result; | 134 RegExpCompileData result; |
| 135 CHECK(v8::internal::RegExpParser::ParseRegExp( | 135 CHECK(v8::internal::RegExpParser::ParseRegExp( |
| 136 CcTest::i_isolate(), &zone, &reader, JSRegExp::kNone, &result)); | 136 CcTest::i_isolate(), &zone, &reader, JSRegExp::kNone, &result)); |
| 137 CHECK(result.tree != NULL); | 137 CHECK(result.tree != NULL); |
| 138 CHECK(result.error.is_null()); | 138 CHECK(result.error.is_null()); |
| 139 return result.simple; | 139 return result.simple; |
| 140 } | 140 } |
| 141 | 141 |
| 142 struct MinMaxPair { | 142 struct MinMaxPair { |
| 143 int min_match; | 143 int min_match; |
| 144 int max_match; | 144 int max_match; |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 | 147 |
| 148 static MinMaxPair CheckMinMaxMatch(const char* input) { | 148 static MinMaxPair CheckMinMaxMatch(const char* input) { |
| 149 v8::HandleScope scope(CcTest::isolate()); | 149 v8::HandleScope scope(CcTest::isolate()); |
| 150 Zone zone(CcTest::i_isolate()->allocator()); | 150 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 151 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); | 151 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); |
| 152 RegExpCompileData result; | 152 RegExpCompileData result; |
| 153 CHECK(v8::internal::RegExpParser::ParseRegExp( | 153 CHECK(v8::internal::RegExpParser::ParseRegExp( |
| 154 CcTest::i_isolate(), &zone, &reader, JSRegExp::kNone, &result)); | 154 CcTest::i_isolate(), &zone, &reader, JSRegExp::kNone, &result)); |
| 155 CHECK(result.tree != NULL); | 155 CHECK(result.tree != NULL); |
| 156 CHECK(result.error.is_null()); | 156 CHECK(result.error.is_null()); |
| 157 int min_match = result.tree->min_match(); | 157 int min_match = result.tree->min_match(); |
| 158 int max_match = result.tree->max_match(); | 158 int max_match = result.tree->max_match(); |
| 159 MinMaxPair pair = { min_match, max_match }; | 159 MinMaxPair pair = { min_match, max_match }; |
| 160 return pair; | 160 return pair; |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 TEST(ParserRegression) { | 470 TEST(ParserRegression) { |
| 471 CheckParseEq("[A-Z$-][x]", "(! [A-Z $ -] [x])"); | 471 CheckParseEq("[A-Z$-][x]", "(! [A-Z $ -] [x])"); |
| 472 CheckParseEq("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')"); | 472 CheckParseEq("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')"); |
| 473 CheckParseEq("{", "'{'"); | 473 CheckParseEq("{", "'{'"); |
| 474 CheckParseEq("a|", "(| 'a' %)"); | 474 CheckParseEq("a|", "(| 'a' %)"); |
| 475 } | 475 } |
| 476 | 476 |
| 477 static void ExpectError(const char* input, const char* expected, | 477 static void ExpectError(const char* input, const char* expected, |
| 478 bool unicode = false) { | 478 bool unicode = false) { |
| 479 v8::HandleScope scope(CcTest::isolate()); | 479 v8::HandleScope scope(CcTest::isolate()); |
| 480 Zone zone(CcTest::i_isolate()->allocator()); | 480 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 481 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); | 481 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); |
| 482 RegExpCompileData result; | 482 RegExpCompileData result; |
| 483 JSRegExp::Flags flags = JSRegExp::kNone; | 483 JSRegExp::Flags flags = JSRegExp::kNone; |
| 484 if (unicode) flags |= JSRegExp::kUnicode; | 484 if (unicode) flags |= JSRegExp::kUnicode; |
| 485 CHECK(!v8::internal::RegExpParser::ParseRegExp(CcTest::i_isolate(), &zone, | 485 CHECK(!v8::internal::RegExpParser::ParseRegExp(CcTest::i_isolate(), &zone, |
| 486 &reader, flags, &result)); | 486 &reader, flags, &result)); |
| 487 CHECK(result.tree == NULL); | 487 CHECK(result.tree == NULL); |
| 488 CHECK(!result.error.is_null()); | 488 CHECK(!result.error.is_null()); |
| 489 std::unique_ptr<char[]> str = result.error->ToCString(ALLOW_NULLS); | 489 std::unique_ptr<char[]> str = result.error->ToCString(ALLOW_NULLS); |
| 490 CHECK_EQ(0, strcmp(expected, str.get())); | 490 CHECK_EQ(0, strcmp(expected, str.get())); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 return !IsWhiteSpaceOrLineTerminator(c); | 558 return !IsWhiteSpaceOrLineTerminator(c); |
| 559 } | 559 } |
| 560 | 560 |
| 561 | 561 |
| 562 static bool NotWord(uc16 c) { | 562 static bool NotWord(uc16 c) { |
| 563 return !IsRegExpWord(c); | 563 return !IsRegExpWord(c); |
| 564 } | 564 } |
| 565 | 565 |
| 566 | 566 |
| 567 static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) { | 567 static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) { |
| 568 Zone zone(CcTest::i_isolate()->allocator()); | 568 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 569 ZoneList<CharacterRange>* ranges = | 569 ZoneList<CharacterRange>* ranges = |
| 570 new(&zone) ZoneList<CharacterRange>(2, &zone); | 570 new(&zone) ZoneList<CharacterRange>(2, &zone); |
| 571 CharacterRange::AddClassEscape(c, ranges, &zone); | 571 CharacterRange::AddClassEscape(c, ranges, &zone); |
| 572 for (uc32 i = 0; i < (1 << 16); i++) { | 572 for (uc32 i = 0; i < (1 << 16); i++) { |
| 573 bool in_class = false; | 573 bool in_class = false; |
| 574 for (int j = 0; !in_class && j < ranges->length(); j++) { | 574 for (int j = 0; !in_class && j < ranges->length(); j++) { |
| 575 CharacterRange& range = ranges->at(j); | 575 CharacterRange& range = ranges->at(j); |
| 576 in_class = (range.from() <= i && i <= range.to()); | 576 in_class = (range.from() <= i && i <= range.to()); |
| 577 } | 577 } |
| 578 CHECK_EQ(pred(i), in_class); | 578 CHECK_EQ(pred(i), in_class); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 609 isolate->factory()->NewStringFromUtf8(CStrVector("")).ToHandleChecked(); | 609 isolate->factory()->NewStringFromUtf8(CStrVector("")).ToHandleChecked(); |
| 610 RegExpEngine::Compile(isolate, zone, &compile_data, flags, pattern, | 610 RegExpEngine::Compile(isolate, zone, &compile_data, flags, pattern, |
| 611 sample_subject, is_one_byte); | 611 sample_subject, is_one_byte); |
| 612 return compile_data.node; | 612 return compile_data.node; |
| 613 } | 613 } |
| 614 | 614 |
| 615 | 615 |
| 616 static void Execute(const char* input, bool multiline, bool unicode, | 616 static void Execute(const char* input, bool multiline, bool unicode, |
| 617 bool is_one_byte, bool dot_output = false) { | 617 bool is_one_byte, bool dot_output = false) { |
| 618 v8::HandleScope scope(CcTest::isolate()); | 618 v8::HandleScope scope(CcTest::isolate()); |
| 619 Zone zone(CcTest::i_isolate()->allocator()); | 619 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 620 RegExpNode* node = Compile(input, multiline, unicode, is_one_byte, &zone); | 620 RegExpNode* node = Compile(input, multiline, unicode, is_one_byte, &zone); |
| 621 USE(node); | 621 USE(node); |
| 622 #ifdef DEBUG | 622 #ifdef DEBUG |
| 623 if (dot_output) { | 623 if (dot_output) { |
| 624 RegExpEngine::DotPrint(input, node, false); | 624 RegExpEngine::DotPrint(input, node, false); |
| 625 } | 625 } |
| 626 #endif // DEBUG | 626 #endif // DEBUG |
| 627 } | 627 } |
| 628 | 628 |
| 629 | 629 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 647 const int TestConfig::kNoKey = 0; | 647 const int TestConfig::kNoKey = 0; |
| 648 | 648 |
| 649 | 649 |
| 650 static unsigned PseudoRandom(int i, int j) { | 650 static unsigned PseudoRandom(int i, int j) { |
| 651 return ~(~((i * 781) ^ (j * 329))); | 651 return ~(~((i * 781) ^ (j * 329))); |
| 652 } | 652 } |
| 653 | 653 |
| 654 | 654 |
| 655 TEST(SplayTreeSimple) { | 655 TEST(SplayTreeSimple) { |
| 656 static const unsigned kLimit = 1000; | 656 static const unsigned kLimit = 1000; |
| 657 Zone zone(CcTest::i_isolate()->allocator()); | 657 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 658 ZoneSplayTree<TestConfig> tree(&zone); | 658 ZoneSplayTree<TestConfig> tree(&zone); |
| 659 bool seen[kLimit]; | 659 bool seen[kLimit]; |
| 660 for (unsigned i = 0; i < kLimit; i++) seen[i] = false; | 660 for (unsigned i = 0; i < kLimit; i++) seen[i] = false; |
| 661 #define CHECK_MAPS_EQUAL() do { \ | 661 #define CHECK_MAPS_EQUAL() do { \ |
| 662 for (unsigned k = 0; k < kLimit; k++) \ | 662 for (unsigned k = 0; k < kLimit; k++) \ |
| 663 CHECK_EQ(seen[k], tree.Find(k, &loc)); \ | 663 CHECK_EQ(seen[k], tree.Find(k, &loc)); \ |
| 664 } while (false) | 664 } while (false) |
| 665 for (int i = 0; i < 50; i++) { | 665 for (int i = 0; i < 50; i++) { |
| 666 for (int j = 0; j < 50; j++) { | 666 for (int j = 0; j < 50; j++) { |
| 667 int next = PseudoRandom(i, j) % kLimit; | 667 int next = PseudoRandom(i, j) % kLimit; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 Vector<uc16> range(ranges[i], 2 * kRangeSize); | 714 Vector<uc16> range(ranges[i], 2 * kRangeSize); |
| 715 for (int j = 0; j < 2 * kRangeSize; j++) { | 715 for (int j = 0; j < 2 * kRangeSize; j++) { |
| 716 range[j] = PseudoRandom(i + 25, j + 87) % kLimit; | 716 range[j] = PseudoRandom(i + 25, j + 87) % kLimit; |
| 717 } | 717 } |
| 718 range.Sort(); | 718 range.Sort(); |
| 719 for (int j = 1; j < 2 * kRangeSize; j++) { | 719 for (int j = 1; j < 2 * kRangeSize; j++) { |
| 720 CHECK(range[j-1] <= range[j]); | 720 CHECK(range[j-1] <= range[j]); |
| 721 } | 721 } |
| 722 } | 722 } |
| 723 // Enter test data into dispatch table. | 723 // Enter test data into dispatch table. |
| 724 Zone zone(CcTest::i_isolate()->allocator()); | 724 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 725 DispatchTable table(&zone); | 725 DispatchTable table(&zone); |
| 726 for (int i = 0; i < kRangeCount; i++) { | 726 for (int i = 0; i < kRangeCount; i++) { |
| 727 uc16* range = ranges[i]; | 727 uc16* range = ranges[i]; |
| 728 for (int j = 0; j < 2 * kRangeSize; j += 2) | 728 for (int j = 0; j < 2 * kRangeSize; j += 2) |
| 729 table.AddRange(CharacterRange::Range(range[j], range[j + 1]), i, &zone); | 729 table.AddRange(CharacterRange::Range(range[j], range[j + 1]), i, &zone); |
| 730 } | 730 } |
| 731 // Check that the table looks as we would expect | 731 // Check that the table looks as we would expect |
| 732 for (int p = 0; p < kLimit; p++) { | 732 for (int p = 0; p < kLimit; p++) { |
| 733 OutSet* outs = table.Get(p); | 733 OutSet* outs = table.Get(p); |
| 734 for (int j = 0; j < kRangeCount; j++) { | 734 for (int j = 0; j < kRangeCount; j++) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 0, | 828 0, |
| 829 CcTest::i_isolate()); | 829 CcTest::i_isolate()); |
| 830 } | 830 } |
| 831 | 831 |
| 832 | 832 |
| 833 TEST(MacroAssemblerNativeSuccess) { | 833 TEST(MacroAssemblerNativeSuccess) { |
| 834 v8::V8::Initialize(); | 834 v8::V8::Initialize(); |
| 835 ContextInitializer initializer; | 835 ContextInitializer initializer; |
| 836 Isolate* isolate = CcTest::i_isolate(); | 836 Isolate* isolate = CcTest::i_isolate(); |
| 837 Factory* factory = isolate->factory(); | 837 Factory* factory = isolate->factory(); |
| 838 Zone zone(CcTest::i_isolate()->allocator()); | 838 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 839 | 839 |
| 840 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 840 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
| 841 4); | 841 4); |
| 842 | 842 |
| 843 m.Succeed(); | 843 m.Succeed(); |
| 844 | 844 |
| 845 Handle<String> source = factory->NewStringFromStaticChars(""); | 845 Handle<String> source = factory->NewStringFromStaticChars(""); |
| 846 Handle<Object> code_object = m.GetCode(source); | 846 Handle<Object> code_object = m.GetCode(source); |
| 847 Handle<Code> code = Handle<Code>::cast(code_object); | 847 Handle<Code> code = Handle<Code>::cast(code_object); |
| 848 | 848 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 866 CHECK_EQ(-1, captures[2]); | 866 CHECK_EQ(-1, captures[2]); |
| 867 CHECK_EQ(-1, captures[3]); | 867 CHECK_EQ(-1, captures[3]); |
| 868 } | 868 } |
| 869 | 869 |
| 870 | 870 |
| 871 TEST(MacroAssemblerNativeSimple) { | 871 TEST(MacroAssemblerNativeSimple) { |
| 872 v8::V8::Initialize(); | 872 v8::V8::Initialize(); |
| 873 ContextInitializer initializer; | 873 ContextInitializer initializer; |
| 874 Isolate* isolate = CcTest::i_isolate(); | 874 Isolate* isolate = CcTest::i_isolate(); |
| 875 Factory* factory = isolate->factory(); | 875 Factory* factory = isolate->factory(); |
| 876 Zone zone(CcTest::i_isolate()->allocator()); | 876 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 877 | 877 |
| 878 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 878 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
| 879 4); | 879 4); |
| 880 | 880 |
| 881 Label fail, backtrack; | 881 Label fail, backtrack; |
| 882 m.PushBacktrack(&fail); | 882 m.PushBacktrack(&fail); |
| 883 m.CheckNotAtStart(0, NULL); | 883 m.CheckNotAtStart(0, NULL); |
| 884 m.LoadCurrentCharacter(2, NULL); | 884 m.LoadCurrentCharacter(2, NULL); |
| 885 m.CheckNotCharacter('o', NULL); | 885 m.CheckNotCharacter('o', NULL); |
| 886 m.LoadCurrentCharacter(1, NULL, false); | 886 m.LoadCurrentCharacter(1, NULL, false); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 | 933 |
| 934 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); | 934 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); |
| 935 } | 935 } |
| 936 | 936 |
| 937 | 937 |
| 938 TEST(MacroAssemblerNativeSimpleUC16) { | 938 TEST(MacroAssemblerNativeSimpleUC16) { |
| 939 v8::V8::Initialize(); | 939 v8::V8::Initialize(); |
| 940 ContextInitializer initializer; | 940 ContextInitializer initializer; |
| 941 Isolate* isolate = CcTest::i_isolate(); | 941 Isolate* isolate = CcTest::i_isolate(); |
| 942 Factory* factory = isolate->factory(); | 942 Factory* factory = isolate->factory(); |
| 943 Zone zone(CcTest::i_isolate()->allocator()); | 943 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 944 | 944 |
| 945 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::UC16, | 945 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::UC16, |
| 946 4); | 946 4); |
| 947 | 947 |
| 948 Label fail, backtrack; | 948 Label fail, backtrack; |
| 949 m.PushBacktrack(&fail); | 949 m.PushBacktrack(&fail); |
| 950 m.CheckNotAtStart(0, NULL); | 950 m.CheckNotAtStart(0, NULL); |
| 951 m.LoadCurrentCharacter(2, NULL); | 951 m.LoadCurrentCharacter(2, NULL); |
| 952 m.CheckNotCharacter('o', NULL); | 952 m.CheckNotCharacter('o', NULL); |
| 953 m.LoadCurrentCharacter(1, NULL, false); | 953 m.LoadCurrentCharacter(1, NULL, false); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 | 1006 |
| 1007 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); | 1007 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); |
| 1008 } | 1008 } |
| 1009 | 1009 |
| 1010 | 1010 |
| 1011 TEST(MacroAssemblerNativeBacktrack) { | 1011 TEST(MacroAssemblerNativeBacktrack) { |
| 1012 v8::V8::Initialize(); | 1012 v8::V8::Initialize(); |
| 1013 ContextInitializer initializer; | 1013 ContextInitializer initializer; |
| 1014 Isolate* isolate = CcTest::i_isolate(); | 1014 Isolate* isolate = CcTest::i_isolate(); |
| 1015 Factory* factory = isolate->factory(); | 1015 Factory* factory = isolate->factory(); |
| 1016 Zone zone(CcTest::i_isolate()->allocator()); | 1016 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 1017 | 1017 |
| 1018 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 1018 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
| 1019 0); | 1019 0); |
| 1020 | 1020 |
| 1021 Label fail; | 1021 Label fail; |
| 1022 Label backtrack; | 1022 Label backtrack; |
| 1023 m.LoadCurrentCharacter(10, &fail); | 1023 m.LoadCurrentCharacter(10, &fail); |
| 1024 m.Succeed(); | 1024 m.Succeed(); |
| 1025 m.Bind(&fail); | 1025 m.Bind(&fail); |
| 1026 m.PushBacktrack(&backtrack); | 1026 m.PushBacktrack(&backtrack); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1047 | 1047 |
| 1048 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); | 1048 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); |
| 1049 } | 1049 } |
| 1050 | 1050 |
| 1051 | 1051 |
| 1052 TEST(MacroAssemblerNativeBackReferenceLATIN1) { | 1052 TEST(MacroAssemblerNativeBackReferenceLATIN1) { |
| 1053 v8::V8::Initialize(); | 1053 v8::V8::Initialize(); |
| 1054 ContextInitializer initializer; | 1054 ContextInitializer initializer; |
| 1055 Isolate* isolate = CcTest::i_isolate(); | 1055 Isolate* isolate = CcTest::i_isolate(); |
| 1056 Factory* factory = isolate->factory(); | 1056 Factory* factory = isolate->factory(); |
| 1057 Zone zone(CcTest::i_isolate()->allocator()); | 1057 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 1058 | 1058 |
| 1059 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 1059 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
| 1060 4); | 1060 4); |
| 1061 | 1061 |
| 1062 m.WriteCurrentPositionToRegister(0, 0); | 1062 m.WriteCurrentPositionToRegister(0, 0); |
| 1063 m.AdvanceCurrentPosition(2); | 1063 m.AdvanceCurrentPosition(2); |
| 1064 m.WriteCurrentPositionToRegister(1, 0); | 1064 m.WriteCurrentPositionToRegister(1, 0); |
| 1065 Label nomatch; | 1065 Label nomatch; |
| 1066 m.CheckNotBackReference(0, false, &nomatch); | 1066 m.CheckNotBackReference(0, false, &nomatch); |
| 1067 m.Fail(); | 1067 m.Fail(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1097 CHECK_EQ(6, output[2]); | 1097 CHECK_EQ(6, output[2]); |
| 1098 CHECK_EQ(-1, output[3]); | 1098 CHECK_EQ(-1, output[3]); |
| 1099 } | 1099 } |
| 1100 | 1100 |
| 1101 | 1101 |
| 1102 TEST(MacroAssemblerNativeBackReferenceUC16) { | 1102 TEST(MacroAssemblerNativeBackReferenceUC16) { |
| 1103 v8::V8::Initialize(); | 1103 v8::V8::Initialize(); |
| 1104 ContextInitializer initializer; | 1104 ContextInitializer initializer; |
| 1105 Isolate* isolate = CcTest::i_isolate(); | 1105 Isolate* isolate = CcTest::i_isolate(); |
| 1106 Factory* factory = isolate->factory(); | 1106 Factory* factory = isolate->factory(); |
| 1107 Zone zone(CcTest::i_isolate()->allocator()); | 1107 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 1108 | 1108 |
| 1109 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::UC16, | 1109 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::UC16, |
| 1110 4); | 1110 4); |
| 1111 | 1111 |
| 1112 m.WriteCurrentPositionToRegister(0, 0); | 1112 m.WriteCurrentPositionToRegister(0, 0); |
| 1113 m.AdvanceCurrentPosition(2); | 1113 m.AdvanceCurrentPosition(2); |
| 1114 m.WriteCurrentPositionToRegister(1, 0); | 1114 m.WriteCurrentPositionToRegister(1, 0); |
| 1115 Label nomatch; | 1115 Label nomatch; |
| 1116 m.CheckNotBackReference(0, false, &nomatch); | 1116 m.CheckNotBackReference(0, false, &nomatch); |
| 1117 m.Fail(); | 1117 m.Fail(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 CHECK_EQ(-1, output[3]); | 1150 CHECK_EQ(-1, output[3]); |
| 1151 } | 1151 } |
| 1152 | 1152 |
| 1153 | 1153 |
| 1154 | 1154 |
| 1155 TEST(MacroAssemblernativeAtStart) { | 1155 TEST(MacroAssemblernativeAtStart) { |
| 1156 v8::V8::Initialize(); | 1156 v8::V8::Initialize(); |
| 1157 ContextInitializer initializer; | 1157 ContextInitializer initializer; |
| 1158 Isolate* isolate = CcTest::i_isolate(); | 1158 Isolate* isolate = CcTest::i_isolate(); |
| 1159 Factory* factory = isolate->factory(); | 1159 Factory* factory = isolate->factory(); |
| 1160 Zone zone(CcTest::i_isolate()->allocator()); | 1160 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 1161 | 1161 |
| 1162 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 1162 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
| 1163 0); | 1163 0); |
| 1164 | 1164 |
| 1165 Label not_at_start, newline, fail; | 1165 Label not_at_start, newline, fail; |
| 1166 m.CheckNotAtStart(0, ¬_at_start); | 1166 m.CheckNotAtStart(0, ¬_at_start); |
| 1167 // Check that prevchar = '\n' and current = 'f'. | 1167 // Check that prevchar = '\n' and current = 'f'. |
| 1168 m.CheckCharacter('\n', &newline); | 1168 m.CheckCharacter('\n', &newline); |
| 1169 m.Bind(&fail); | 1169 m.Bind(&fail); |
| 1170 m.Fail(); | 1170 m.Fail(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 | 1210 |
| 1211 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); | 1211 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
| 1212 } | 1212 } |
| 1213 | 1213 |
| 1214 | 1214 |
| 1215 TEST(MacroAssemblerNativeBackRefNoCase) { | 1215 TEST(MacroAssemblerNativeBackRefNoCase) { |
| 1216 v8::V8::Initialize(); | 1216 v8::V8::Initialize(); |
| 1217 ContextInitializer initializer; | 1217 ContextInitializer initializer; |
| 1218 Isolate* isolate = CcTest::i_isolate(); | 1218 Isolate* isolate = CcTest::i_isolate(); |
| 1219 Factory* factory = isolate->factory(); | 1219 Factory* factory = isolate->factory(); |
| 1220 Zone zone(CcTest::i_isolate()->allocator()); | 1220 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 1221 | 1221 |
| 1222 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 1222 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
| 1223 4); | 1223 4); |
| 1224 | 1224 |
| 1225 Label fail, succ; | 1225 Label fail, succ; |
| 1226 | 1226 |
| 1227 m.WriteCurrentPositionToRegister(0, 0); | 1227 m.WriteCurrentPositionToRegister(0, 0); |
| 1228 m.WriteCurrentPositionToRegister(2, 0); | 1228 m.WriteCurrentPositionToRegister(2, 0); |
| 1229 m.AdvanceCurrentPosition(3); | 1229 m.AdvanceCurrentPosition(3); |
| 1230 m.WriteCurrentPositionToRegister(3, 0); | 1230 m.WriteCurrentPositionToRegister(3, 0); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1269 CHECK_EQ(3, output[3]); | 1269 CHECK_EQ(3, output[3]); |
| 1270 } | 1270 } |
| 1271 | 1271 |
| 1272 | 1272 |
| 1273 | 1273 |
| 1274 TEST(MacroAssemblerNativeRegisters) { | 1274 TEST(MacroAssemblerNativeRegisters) { |
| 1275 v8::V8::Initialize(); | 1275 v8::V8::Initialize(); |
| 1276 ContextInitializer initializer; | 1276 ContextInitializer initializer; |
| 1277 Isolate* isolate = CcTest::i_isolate(); | 1277 Isolate* isolate = CcTest::i_isolate(); |
| 1278 Factory* factory = isolate->factory(); | 1278 Factory* factory = isolate->factory(); |
| 1279 Zone zone(CcTest::i_isolate()->allocator()); | 1279 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 1280 | 1280 |
| 1281 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 1281 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
| 1282 6); | 1282 6); |
| 1283 | 1283 |
| 1284 uc16 foo_chars[3] = {'f', 'o', 'o'}; | 1284 uc16 foo_chars[3] = {'f', 'o', 'o'}; |
| 1285 Vector<const uc16> foo(foo_chars, 3); | 1285 Vector<const uc16> foo(foo_chars, 3); |
| 1286 | 1286 |
| 1287 enum registers { out1, out2, out3, out4, out5, out6, sp, loop_cnt }; | 1287 enum registers { out1, out2, out3, out4, out5, out6, sp, loop_cnt }; |
| 1288 Label fail; | 1288 Label fail; |
| 1289 Label backtrack; | 1289 Label backtrack; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1371 CHECK_EQ(9, output[4]); | 1371 CHECK_EQ(9, output[4]); |
| 1372 CHECK_EQ(-1, output[5]); | 1372 CHECK_EQ(-1, output[5]); |
| 1373 } | 1373 } |
| 1374 | 1374 |
| 1375 | 1375 |
| 1376 TEST(MacroAssemblerStackOverflow) { | 1376 TEST(MacroAssemblerStackOverflow) { |
| 1377 v8::V8::Initialize(); | 1377 v8::V8::Initialize(); |
| 1378 ContextInitializer initializer; | 1378 ContextInitializer initializer; |
| 1379 Isolate* isolate = CcTest::i_isolate(); | 1379 Isolate* isolate = CcTest::i_isolate(); |
| 1380 Factory* factory = isolate->factory(); | 1380 Factory* factory = isolate->factory(); |
| 1381 Zone zone(CcTest::i_isolate()->allocator()); | 1381 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 1382 | 1382 |
| 1383 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 1383 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
| 1384 0); | 1384 0); |
| 1385 | 1385 |
| 1386 Label loop; | 1386 Label loop; |
| 1387 m.Bind(&loop); | 1387 m.Bind(&loop); |
| 1388 m.PushBacktrack(&loop); | 1388 m.PushBacktrack(&loop); |
| 1389 m.GoTo(&loop); | 1389 m.GoTo(&loop); |
| 1390 | 1390 |
| 1391 Handle<String> source = | 1391 Handle<String> source = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1410 CHECK(isolate->has_pending_exception()); | 1410 CHECK(isolate->has_pending_exception()); |
| 1411 isolate->clear_pending_exception(); | 1411 isolate->clear_pending_exception(); |
| 1412 } | 1412 } |
| 1413 | 1413 |
| 1414 | 1414 |
| 1415 TEST(MacroAssemblerNativeLotsOfRegisters) { | 1415 TEST(MacroAssemblerNativeLotsOfRegisters) { |
| 1416 v8::V8::Initialize(); | 1416 v8::V8::Initialize(); |
| 1417 ContextInitializer initializer; | 1417 ContextInitializer initializer; |
| 1418 Isolate* isolate = CcTest::i_isolate(); | 1418 Isolate* isolate = CcTest::i_isolate(); |
| 1419 Factory* factory = isolate->factory(); | 1419 Factory* factory = isolate->factory(); |
| 1420 Zone zone(CcTest::i_isolate()->allocator()); | 1420 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 1421 | 1421 |
| 1422 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 1422 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
| 1423 2); | 1423 2); |
| 1424 | 1424 |
| 1425 // At least 2048, to ensure the allocated space for registers | 1425 // At least 2048, to ensure the allocated space for registers |
| 1426 // span one full page. | 1426 // span one full page. |
| 1427 const int large_number = 8000; | 1427 const int large_number = 8000; |
| 1428 m.WriteCurrentPositionToRegister(large_number, 42); | 1428 m.WriteCurrentPositionToRegister(large_number, 42); |
| 1429 m.WriteCurrentPositionToRegister(0, 0); | 1429 m.WriteCurrentPositionToRegister(0, 0); |
| 1430 m.WriteCurrentPositionToRegister(1, 1); | 1430 m.WriteCurrentPositionToRegister(1, 1); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1458 CHECK_EQ(0, captures[0]); | 1458 CHECK_EQ(0, captures[0]); |
| 1459 CHECK_EQ(42, captures[1]); | 1459 CHECK_EQ(42, captures[1]); |
| 1460 | 1460 |
| 1461 isolate->clear_pending_exception(); | 1461 isolate->clear_pending_exception(); |
| 1462 } | 1462 } |
| 1463 | 1463 |
| 1464 #else // V8_INTERPRETED_REGEXP | 1464 #else // V8_INTERPRETED_REGEXP |
| 1465 | 1465 |
| 1466 TEST(MacroAssembler) { | 1466 TEST(MacroAssembler) { |
| 1467 byte codes[1024]; | 1467 byte codes[1024]; |
| 1468 Zone zone(CcTest::i_isolate()->allocator()); | 1468 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 1469 RegExpMacroAssemblerIrregexp m(CcTest::i_isolate(), Vector<byte>(codes, 1024), | 1469 RegExpMacroAssemblerIrregexp m(CcTest::i_isolate(), Vector<byte>(codes, 1024), |
| 1470 &zone); | 1470 &zone); |
| 1471 // ^f(o)o. | 1471 // ^f(o)o. |
| 1472 Label start, fail, backtrack; | 1472 Label start, fail, backtrack; |
| 1473 | 1473 |
| 1474 m.SetRegister(4, 42); | 1474 m.SetRegister(4, 42); |
| 1475 m.PushRegister(4, RegExpMacroAssembler::kNoStackLimitCheck); | 1475 m.PushRegister(4, RegExpMacroAssembler::kNoStackLimitCheck); |
| 1476 m.AdvanceRegister(4, 42); | 1476 m.AdvanceRegister(4, 42); |
| 1477 m.GoTo(&start); | 1477 m.GoTo(&start); |
| 1478 m.Fail(); | 1478 m.Fail(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 CHECK_EQ(42, captures[0]); | 1526 CHECK_EQ(42, captures[0]); |
| 1527 } | 1527 } |
| 1528 | 1528 |
| 1529 #endif // V8_INTERPRETED_REGEXP | 1529 #endif // V8_INTERPRETED_REGEXP |
| 1530 | 1530 |
| 1531 | 1531 |
| 1532 TEST(AddInverseToTable) { | 1532 TEST(AddInverseToTable) { |
| 1533 static const int kLimit = 1000; | 1533 static const int kLimit = 1000; |
| 1534 static const int kRangeCount = 16; | 1534 static const int kRangeCount = 16; |
| 1535 for (int t = 0; t < 10; t++) { | 1535 for (int t = 0; t < 10; t++) { |
| 1536 Zone zone(CcTest::i_isolate()->allocator()); | 1536 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 1537 ZoneList<CharacterRange>* ranges = | 1537 ZoneList<CharacterRange>* ranges = |
| 1538 new(&zone) ZoneList<CharacterRange>(kRangeCount, &zone); | 1538 new(&zone) ZoneList<CharacterRange>(kRangeCount, &zone); |
| 1539 for (int i = 0; i < kRangeCount; i++) { | 1539 for (int i = 0; i < kRangeCount; i++) { |
| 1540 int from = PseudoRandom(t + 87, i + 25) % kLimit; | 1540 int from = PseudoRandom(t + 87, i + 25) % kLimit; |
| 1541 int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20)); | 1541 int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20)); |
| 1542 if (to > kLimit) to = kLimit; | 1542 if (to > kLimit) to = kLimit; |
| 1543 ranges->Add(CharacterRange::Range(from, to), &zone); | 1543 ranges->Add(CharacterRange::Range(from, to), &zone); |
| 1544 } | 1544 } |
| 1545 DispatchTable table(&zone); | 1545 DispatchTable table(&zone); |
| 1546 DispatchTableConstructor cons(&table, false, &zone); | 1546 DispatchTableConstructor cons(&table, false, &zone); |
| 1547 cons.set_choice_index(0); | 1547 cons.set_choice_index(0); |
| 1548 cons.AddInverse(ranges); | 1548 cons.AddInverse(ranges); |
| 1549 for (int i = 0; i < kLimit; i++) { | 1549 for (int i = 0; i < kLimit; i++) { |
| 1550 bool is_on = false; | 1550 bool is_on = false; |
| 1551 for (int j = 0; !is_on && j < kRangeCount; j++) | 1551 for (int j = 0; !is_on && j < kRangeCount; j++) |
| 1552 is_on = ranges->at(j).Contains(i); | 1552 is_on = ranges->at(j).Contains(i); |
| 1553 OutSet* set = table.Get(i); | 1553 OutSet* set = table.Get(i); |
| 1554 CHECK_EQ(is_on, set->Get(0) == false); | 1554 CHECK_EQ(is_on, set->Get(0) == false); |
| 1555 } | 1555 } |
| 1556 } | 1556 } |
| 1557 Zone zone(CcTest::i_isolate()->allocator()); | 1557 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 1558 ZoneList<CharacterRange>* ranges = | 1558 ZoneList<CharacterRange>* ranges = |
| 1559 new(&zone) ZoneList<CharacterRange>(1, &zone); | 1559 new(&zone) ZoneList<CharacterRange>(1, &zone); |
| 1560 ranges->Add(CharacterRange::Range(0xFFF0, 0xFFFE), &zone); | 1560 ranges->Add(CharacterRange::Range(0xFFF0, 0xFFFE), &zone); |
| 1561 DispatchTable table(&zone); | 1561 DispatchTable table(&zone); |
| 1562 DispatchTableConstructor cons(&table, false, &zone); | 1562 DispatchTableConstructor cons(&table, false, &zone); |
| 1563 cons.set_choice_index(0); | 1563 cons.set_choice_index(0); |
| 1564 cons.AddInverse(ranges); | 1564 cons.AddInverse(ranges); |
| 1565 CHECK(!table.Get(0xFFFE)->Get(0)); | 1565 CHECK(!table.Get(0xFFFE)->Get(0)); |
| 1566 CHECK(table.Get(0xFFFF)->Get(0)); | 1566 CHECK(table.Get(0xFFFF)->Get(0)); |
| 1567 } | 1567 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1660 CHECK_EQ(length, length2); | 1660 CHECK_EQ(length, length2); |
| 1661 for (int k = 0; k < length; k++) | 1661 for (int k = 0; k < length; k++) |
| 1662 CHECK_EQ(static_cast<int>(chars[k]), static_cast<int>(chars2[k])); | 1662 CHECK_EQ(static_cast<int>(chars[k]), static_cast<int>(chars2[k])); |
| 1663 } | 1663 } |
| 1664 } | 1664 } |
| 1665 } | 1665 } |
| 1666 | 1666 |
| 1667 | 1667 |
| 1668 static void TestRangeCaseIndependence(Isolate* isolate, CharacterRange input, | 1668 static void TestRangeCaseIndependence(Isolate* isolate, CharacterRange input, |
| 1669 Vector<CharacterRange> expected) { | 1669 Vector<CharacterRange> expected) { |
| 1670 Zone zone(CcTest::i_isolate()->allocator()); | 1670 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 1671 int count = expected.length(); | 1671 int count = expected.length(); |
| 1672 ZoneList<CharacterRange>* list = | 1672 ZoneList<CharacterRange>* list = |
| 1673 new(&zone) ZoneList<CharacterRange>(count, &zone); | 1673 new(&zone) ZoneList<CharacterRange>(count, &zone); |
| 1674 list->Add(input, &zone); | 1674 list->Add(input, &zone); |
| 1675 CharacterRange::AddCaseEquivalents(isolate, &zone, list, false); | 1675 CharacterRange::AddCaseEquivalents(isolate, &zone, list, false); |
| 1676 list->Remove(0); // Remove the input before checking results. | 1676 list->Remove(0); // Remove the input before checking results. |
| 1677 CHECK_EQ(count, list->length()); | 1677 CHECK_EQ(count, list->length()); |
| 1678 for (int i = 0; i < list->length(); i++) { | 1678 for (int i = 0; i < list->length(); i++) { |
| 1679 CHECK_EQ(expected[i].from(), list->at(i).from()); | 1679 CHECK_EQ(expected[i].from(), list->at(i).from()); |
| 1680 CHECK_EQ(expected[i].to(), list->at(i).to()); | 1680 CHECK_EQ(expected[i].to(), list->at(i).to()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1729 for (int i = 0; i < ranges->length(); i++) { | 1729 for (int i = 0; i < ranges->length(); i++) { |
| 1730 CharacterRange range = ranges->at(i); | 1730 CharacterRange range = ranges->at(i); |
| 1731 if (range.from() <= c && c <= range.to()) | 1731 if (range.from() <= c && c <= range.to()) |
| 1732 return true; | 1732 return true; |
| 1733 } | 1733 } |
| 1734 return false; | 1734 return false; |
| 1735 } | 1735 } |
| 1736 | 1736 |
| 1737 | 1737 |
| 1738 TEST(UnicodeRangeSplitter) { | 1738 TEST(UnicodeRangeSplitter) { |
| 1739 Zone zone(CcTest::i_isolate()->allocator()); | 1739 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 1740 ZoneList<CharacterRange>* base = | 1740 ZoneList<CharacterRange>* base = |
| 1741 new(&zone) ZoneList<CharacterRange>(1, &zone); | 1741 new(&zone) ZoneList<CharacterRange>(1, &zone); |
| 1742 base->Add(CharacterRange::Everything(), &zone); | 1742 base->Add(CharacterRange::Everything(), &zone); |
| 1743 UnicodeRangeSplitter splitter(&zone, base); | 1743 UnicodeRangeSplitter splitter(&zone, base); |
| 1744 // BMP | 1744 // BMP |
| 1745 for (uc32 c = 0; c < 0xd800; c++) { | 1745 for (uc32 c = 0; c < 0xd800; c++) { |
| 1746 CHECK(InClass(c, splitter.bmp())); | 1746 CHECK(InClass(c, splitter.bmp())); |
| 1747 CHECK(!InClass(c, splitter.lead_surrogates())); | 1747 CHECK(!InClass(c, splitter.lead_surrogates())); |
| 1748 CHECK(!InClass(c, splitter.trail_surrogates())); | 1748 CHECK(!InClass(c, splitter.trail_surrogates())); |
| 1749 CHECK(!InClass(c, splitter.non_bmp())); | 1749 CHECK(!InClass(c, splitter.non_bmp())); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1773 for (uc32 c = 0x10000; c < 0x10ffff; c++) { | 1773 for (uc32 c = 0x10000; c < 0x10ffff; c++) { |
| 1774 CHECK(!InClass(c, splitter.bmp())); | 1774 CHECK(!InClass(c, splitter.bmp())); |
| 1775 CHECK(!InClass(c, splitter.lead_surrogates())); | 1775 CHECK(!InClass(c, splitter.lead_surrogates())); |
| 1776 CHECK(!InClass(c, splitter.trail_surrogates())); | 1776 CHECK(!InClass(c, splitter.trail_surrogates())); |
| 1777 CHECK(InClass(c, splitter.non_bmp())); | 1777 CHECK(InClass(c, splitter.non_bmp())); |
| 1778 } | 1778 } |
| 1779 } | 1779 } |
| 1780 | 1780 |
| 1781 | 1781 |
| 1782 TEST(CanonicalizeCharacterSets) { | 1782 TEST(CanonicalizeCharacterSets) { |
| 1783 Zone zone(CcTest::i_isolate()->allocator()); | 1783 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 1784 ZoneList<CharacterRange>* list = | 1784 ZoneList<CharacterRange>* list = |
| 1785 new(&zone) ZoneList<CharacterRange>(4, &zone); | 1785 new(&zone) ZoneList<CharacterRange>(4, &zone); |
| 1786 CharacterSet set(list); | 1786 CharacterSet set(list); |
| 1787 | 1787 |
| 1788 list->Add(CharacterRange::Range(10, 20), &zone); | 1788 list->Add(CharacterRange::Range(10, 20), &zone); |
| 1789 list->Add(CharacterRange::Range(30, 40), &zone); | 1789 list->Add(CharacterRange::Range(30, 40), &zone); |
| 1790 list->Add(CharacterRange::Range(50, 60), &zone); | 1790 list->Add(CharacterRange::Range(50, 60), &zone); |
| 1791 set.Canonicalize(); | 1791 set.Canonicalize(); |
| 1792 CHECK_EQ(3, list->length()); | 1792 CHECK_EQ(3, list->length()); |
| 1793 CHECK_EQ(10, list->at(0).from()); | 1793 CHECK_EQ(10, list->at(0).from()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1834 list->Add(CharacterRange::Range(21, 30), &zone); | 1834 list->Add(CharacterRange::Range(21, 30), &zone); |
| 1835 list->Add(CharacterRange::Range(20, 20), &zone); | 1835 list->Add(CharacterRange::Range(20, 20), &zone); |
| 1836 set.Canonicalize(); | 1836 set.Canonicalize(); |
| 1837 CHECK_EQ(1, list->length()); | 1837 CHECK_EQ(1, list->length()); |
| 1838 CHECK_EQ(10, list->at(0).from()); | 1838 CHECK_EQ(10, list->at(0).from()); |
| 1839 CHECK_EQ(30, list->at(0).to()); | 1839 CHECK_EQ(30, list->at(0).to()); |
| 1840 } | 1840 } |
| 1841 | 1841 |
| 1842 | 1842 |
| 1843 TEST(CharacterRangeMerge) { | 1843 TEST(CharacterRangeMerge) { |
| 1844 Zone zone(CcTest::i_isolate()->allocator()); | 1844 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); |
| 1845 ZoneList<CharacterRange> l1(4, &zone); | 1845 ZoneList<CharacterRange> l1(4, &zone); |
| 1846 ZoneList<CharacterRange> l2(4, &zone); | 1846 ZoneList<CharacterRange> l2(4, &zone); |
| 1847 // Create all combinations of intersections of ranges, both singletons and | 1847 // Create all combinations of intersections of ranges, both singletons and |
| 1848 // longer. | 1848 // longer. |
| 1849 | 1849 |
| 1850 int offset = 0; | 1850 int offset = 0; |
| 1851 | 1851 |
| 1852 // The five kinds of singleton intersections: | 1852 // The five kinds of singleton intersections: |
| 1853 // X | 1853 // X |
| 1854 // Y - outside before | 1854 // Y - outside before |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2024 v8::Local<v8::String> external = | 2024 v8::Local<v8::String> external = |
| 2025 v8::String::NewExternalOneByte(isolate, new UncachedExternalString()) | 2025 v8::String::NewExternalOneByte(isolate, new UncachedExternalString()) |
| 2026 .ToLocalChecked(); | 2026 .ToLocalChecked(); |
| 2027 CHECK(v8::Utils::OpenHandle(*external)->map() == | 2027 CHECK(v8::Utils::OpenHandle(*external)->map() == |
| 2028 CcTest::i_isolate()->heap()->short_external_one_byte_string_map()); | 2028 CcTest::i_isolate()->heap()->short_external_one_byte_string_map()); |
| 2029 v8::Local<v8::Object> global = env->Global(); | 2029 v8::Local<v8::Object> global = env->Global(); |
| 2030 global->Set(env.local(), v8_str("external"), external).FromJust(); | 2030 global->Set(env.local(), v8_str("external"), external).FromJust(); |
| 2031 CompileRun("var re = /y(.)/; re.test('ab');"); | 2031 CompileRun("var re = /y(.)/; re.test('ab');"); |
| 2032 ExpectString("external.substring(1).match(re)[1]", "z"); | 2032 ExpectString("external.substring(1).match(re)[1]", "z"); |
| 2033 } | 2033 } |
| OLD | NEW |