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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 #include "src/x87/macro-assembler-x87.h" | 90 #include "src/x87/macro-assembler-x87.h" |
91 #endif | 91 #endif |
92 #endif // V8_INTERPRETED_REGEXP | 92 #endif // V8_INTERPRETED_REGEXP |
93 #include "test/cctest/cctest.h" | 93 #include "test/cctest/cctest.h" |
94 | 94 |
95 using namespace v8::internal; | 95 using namespace v8::internal; |
96 | 96 |
97 | 97 |
98 static bool CheckParse(const char* input) { | 98 static bool CheckParse(const char* input) { |
99 v8::HandleScope scope(CcTest::isolate()); | 99 v8::HandleScope scope(CcTest::isolate()); |
100 Zone zone; | 100 Zone zone(CcTest::i_isolate()->allocator()); |
101 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); | 101 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); |
102 RegExpCompileData result; | 102 RegExpCompileData result; |
103 return v8::internal::RegExpParser::ParseRegExp( | 103 return v8::internal::RegExpParser::ParseRegExp( |
104 CcTest::i_isolate(), &zone, &reader, JSRegExp::kNone, &result); | 104 CcTest::i_isolate(), &zone, &reader, JSRegExp::kNone, &result); |
105 } | 105 } |
106 | 106 |
107 | 107 |
108 static void CheckParseEq(const char* input, const char* expected, | 108 static void CheckParseEq(const char* input, const char* expected, |
109 bool unicode = false) { | 109 bool unicode = false) { |
110 v8::HandleScope scope(CcTest::isolate()); | 110 v8::HandleScope scope(CcTest::isolate()); |
111 Zone zone; | 111 Zone zone(CcTest::i_isolate()->allocator()); |
112 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); | 112 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); |
113 RegExpCompileData result; | 113 RegExpCompileData result; |
114 JSRegExp::Flags flags = JSRegExp::kNone; | 114 JSRegExp::Flags flags = JSRegExp::kNone; |
115 if (unicode) flags |= JSRegExp::kUnicode; | 115 if (unicode) flags |= JSRegExp::kUnicode; |
116 CHECK(v8::internal::RegExpParser::ParseRegExp(CcTest::i_isolate(), &zone, | 116 CHECK(v8::internal::RegExpParser::ParseRegExp(CcTest::i_isolate(), &zone, |
117 &reader, flags, &result)); | 117 &reader, flags, &result)); |
118 CHECK(result.tree != NULL); | 118 CHECK(result.tree != NULL); |
119 CHECK(result.error.is_null()); | 119 CHECK(result.error.is_null()); |
120 std::ostringstream os; | 120 std::ostringstream os; |
121 result.tree->Print(os, &zone); | 121 result.tree->Print(os, &zone); |
122 if (strcmp(expected, os.str().c_str()) != 0) { | 122 if (strcmp(expected, os.str().c_str()) != 0) { |
123 printf("%s | %s\n", expected, os.str().c_str()); | 123 printf("%s | %s\n", expected, os.str().c_str()); |
124 } | 124 } |
125 CHECK_EQ(0, strcmp(expected, os.str().c_str())); | 125 CHECK_EQ(0, strcmp(expected, os.str().c_str())); |
126 } | 126 } |
127 | 127 |
128 | 128 |
129 static bool CheckSimple(const char* input) { | 129 static bool CheckSimple(const char* input) { |
130 v8::HandleScope scope(CcTest::isolate()); | 130 v8::HandleScope scope(CcTest::isolate()); |
131 Zone zone; | 131 Zone zone(CcTest::i_isolate()->allocator()); |
132 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); | 132 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); |
133 RegExpCompileData result; | 133 RegExpCompileData result; |
134 CHECK(v8::internal::RegExpParser::ParseRegExp( | 134 CHECK(v8::internal::RegExpParser::ParseRegExp( |
135 CcTest::i_isolate(), &zone, &reader, JSRegExp::kNone, &result)); | 135 CcTest::i_isolate(), &zone, &reader, JSRegExp::kNone, &result)); |
136 CHECK(result.tree != NULL); | 136 CHECK(result.tree != NULL); |
137 CHECK(result.error.is_null()); | 137 CHECK(result.error.is_null()); |
138 return result.simple; | 138 return result.simple; |
139 } | 139 } |
140 | 140 |
141 struct MinMaxPair { | 141 struct MinMaxPair { |
142 int min_match; | 142 int min_match; |
143 int max_match; | 143 int max_match; |
144 }; | 144 }; |
145 | 145 |
146 | 146 |
147 static MinMaxPair CheckMinMaxMatch(const char* input) { | 147 static MinMaxPair CheckMinMaxMatch(const char* input) { |
148 v8::HandleScope scope(CcTest::isolate()); | 148 v8::HandleScope scope(CcTest::isolate()); |
149 Zone zone; | 149 Zone zone(CcTest::i_isolate()->allocator()); |
150 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); | 150 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); |
151 RegExpCompileData result; | 151 RegExpCompileData result; |
152 CHECK(v8::internal::RegExpParser::ParseRegExp( | 152 CHECK(v8::internal::RegExpParser::ParseRegExp( |
153 CcTest::i_isolate(), &zone, &reader, JSRegExp::kNone, &result)); | 153 CcTest::i_isolate(), &zone, &reader, JSRegExp::kNone, &result)); |
154 CHECK(result.tree != NULL); | 154 CHECK(result.tree != NULL); |
155 CHECK(result.error.is_null()); | 155 CHECK(result.error.is_null()); |
156 int min_match = result.tree->min_match(); | 156 int min_match = result.tree->min_match(); |
157 int max_match = result.tree->max_match(); | 157 int max_match = result.tree->max_match(); |
158 MinMaxPair pair = { min_match, max_match }; | 158 MinMaxPair pair = { min_match, max_match }; |
159 return pair; | 159 return pair; |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 TEST(ParserRegression) { | 454 TEST(ParserRegression) { |
455 CheckParseEq("[A-Z$-][x]", "(! [A-Z $ -] [x])"); | 455 CheckParseEq("[A-Z$-][x]", "(! [A-Z $ -] [x])"); |
456 CheckParseEq("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')"); | 456 CheckParseEq("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')"); |
457 CheckParseEq("{", "'{'"); | 457 CheckParseEq("{", "'{'"); |
458 CheckParseEq("a|", "(| 'a' %)"); | 458 CheckParseEq("a|", "(| 'a' %)"); |
459 } | 459 } |
460 | 460 |
461 static void ExpectError(const char* input, | 461 static void ExpectError(const char* input, |
462 const char* expected) { | 462 const char* expected) { |
463 v8::HandleScope scope(CcTest::isolate()); | 463 v8::HandleScope scope(CcTest::isolate()); |
464 Zone zone; | 464 Zone zone(CcTest::i_isolate()->allocator()); |
465 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); | 465 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); |
466 RegExpCompileData result; | 466 RegExpCompileData result; |
467 CHECK(!v8::internal::RegExpParser::ParseRegExp( | 467 CHECK(!v8::internal::RegExpParser::ParseRegExp( |
468 CcTest::i_isolate(), &zone, &reader, JSRegExp::kNone, &result)); | 468 CcTest::i_isolate(), &zone, &reader, JSRegExp::kNone, &result)); |
469 CHECK(result.tree == NULL); | 469 CHECK(result.tree == NULL); |
470 CHECK(!result.error.is_null()); | 470 CHECK(!result.error.is_null()); |
471 v8::base::SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS); | 471 v8::base::SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS); |
472 CHECK_EQ(0, strcmp(expected, str.get())); | 472 CHECK_EQ(0, strcmp(expected, str.get())); |
473 } | 473 } |
474 | 474 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 return !IsWhiteSpaceOrLineTerminator(c); | 523 return !IsWhiteSpaceOrLineTerminator(c); |
524 } | 524 } |
525 | 525 |
526 | 526 |
527 static bool NotWord(uc16 c) { | 527 static bool NotWord(uc16 c) { |
528 return !IsRegExpWord(c); | 528 return !IsRegExpWord(c); |
529 } | 529 } |
530 | 530 |
531 | 531 |
532 static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) { | 532 static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) { |
533 Zone zone; | 533 Zone zone(CcTest::i_isolate()->allocator()); |
534 ZoneList<CharacterRange>* ranges = | 534 ZoneList<CharacterRange>* ranges = |
535 new(&zone) ZoneList<CharacterRange>(2, &zone); | 535 new(&zone) ZoneList<CharacterRange>(2, &zone); |
536 CharacterRange::AddClassEscape(c, ranges, &zone); | 536 CharacterRange::AddClassEscape(c, ranges, &zone); |
537 for (uc32 i = 0; i < (1 << 16); i++) { | 537 for (uc32 i = 0; i < (1 << 16); i++) { |
538 bool in_class = false; | 538 bool in_class = false; |
539 for (int j = 0; !in_class && j < ranges->length(); j++) { | 539 for (int j = 0; !in_class && j < ranges->length(); j++) { |
540 CharacterRange& range = ranges->at(j); | 540 CharacterRange& range = ranges->at(j); |
541 in_class = (range.from() <= i && i <= range.to()); | 541 in_class = (range.from() <= i && i <= range.to()); |
542 } | 542 } |
543 CHECK_EQ(pred(i), in_class); | 543 CHECK_EQ(pred(i), in_class); |
(...skipping 30 matching lines...) Expand all Loading... |
574 isolate->factory()->NewStringFromUtf8(CStrVector("")).ToHandleChecked(); | 574 isolate->factory()->NewStringFromUtf8(CStrVector("")).ToHandleChecked(); |
575 RegExpEngine::Compile(isolate, zone, &compile_data, flags, pattern, | 575 RegExpEngine::Compile(isolate, zone, &compile_data, flags, pattern, |
576 sample_subject, is_one_byte); | 576 sample_subject, is_one_byte); |
577 return compile_data.node; | 577 return compile_data.node; |
578 } | 578 } |
579 | 579 |
580 | 580 |
581 static void Execute(const char* input, bool multiline, bool unicode, | 581 static void Execute(const char* input, bool multiline, bool unicode, |
582 bool is_one_byte, bool dot_output = false) { | 582 bool is_one_byte, bool dot_output = false) { |
583 v8::HandleScope scope(CcTest::isolate()); | 583 v8::HandleScope scope(CcTest::isolate()); |
584 Zone zone; | 584 Zone zone(CcTest::i_isolate()->allocator()); |
585 RegExpNode* node = Compile(input, multiline, unicode, is_one_byte, &zone); | 585 RegExpNode* node = Compile(input, multiline, unicode, is_one_byte, &zone); |
586 USE(node); | 586 USE(node); |
587 #ifdef DEBUG | 587 #ifdef DEBUG |
588 if (dot_output) { | 588 if (dot_output) { |
589 RegExpEngine::DotPrint(input, node, false); | 589 RegExpEngine::DotPrint(input, node, false); |
590 } | 590 } |
591 #endif // DEBUG | 591 #endif // DEBUG |
592 } | 592 } |
593 | 593 |
594 | 594 |
(...skipping 17 matching lines...) Expand all Loading... |
612 const int TestConfig::kNoKey = 0; | 612 const int TestConfig::kNoKey = 0; |
613 | 613 |
614 | 614 |
615 static unsigned PseudoRandom(int i, int j) { | 615 static unsigned PseudoRandom(int i, int j) { |
616 return ~(~((i * 781) ^ (j * 329))); | 616 return ~(~((i * 781) ^ (j * 329))); |
617 } | 617 } |
618 | 618 |
619 | 619 |
620 TEST(SplayTreeSimple) { | 620 TEST(SplayTreeSimple) { |
621 static const unsigned kLimit = 1000; | 621 static const unsigned kLimit = 1000; |
622 Zone zone; | 622 Zone zone(CcTest::i_isolate()->allocator()); |
623 ZoneSplayTree<TestConfig> tree(&zone); | 623 ZoneSplayTree<TestConfig> tree(&zone); |
624 bool seen[kLimit]; | 624 bool seen[kLimit]; |
625 for (unsigned i = 0; i < kLimit; i++) seen[i] = false; | 625 for (unsigned i = 0; i < kLimit; i++) seen[i] = false; |
626 #define CHECK_MAPS_EQUAL() do { \ | 626 #define CHECK_MAPS_EQUAL() do { \ |
627 for (unsigned k = 0; k < kLimit; k++) \ | 627 for (unsigned k = 0; k < kLimit; k++) \ |
628 CHECK_EQ(seen[k], tree.Find(k, &loc)); \ | 628 CHECK_EQ(seen[k], tree.Find(k, &loc)); \ |
629 } while (false) | 629 } while (false) |
630 for (int i = 0; i < 50; i++) { | 630 for (int i = 0; i < 50; i++) { |
631 for (int j = 0; j < 50; j++) { | 631 for (int j = 0; j < 50; j++) { |
632 int next = PseudoRandom(i, j) % kLimit; | 632 int next = PseudoRandom(i, j) % kLimit; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 Vector<uc16> range(ranges[i], 2 * kRangeSize); | 679 Vector<uc16> range(ranges[i], 2 * kRangeSize); |
680 for (int j = 0; j < 2 * kRangeSize; j++) { | 680 for (int j = 0; j < 2 * kRangeSize; j++) { |
681 range[j] = PseudoRandom(i + 25, j + 87) % kLimit; | 681 range[j] = PseudoRandom(i + 25, j + 87) % kLimit; |
682 } | 682 } |
683 range.Sort(); | 683 range.Sort(); |
684 for (int j = 1; j < 2 * kRangeSize; j++) { | 684 for (int j = 1; j < 2 * kRangeSize; j++) { |
685 CHECK(range[j-1] <= range[j]); | 685 CHECK(range[j-1] <= range[j]); |
686 } | 686 } |
687 } | 687 } |
688 // Enter test data into dispatch table. | 688 // Enter test data into dispatch table. |
689 Zone zone; | 689 Zone zone(CcTest::i_isolate()->allocator()); |
690 DispatchTable table(&zone); | 690 DispatchTable table(&zone); |
691 for (int i = 0; i < kRangeCount; i++) { | 691 for (int i = 0; i < kRangeCount; i++) { |
692 uc16* range = ranges[i]; | 692 uc16* range = ranges[i]; |
693 for (int j = 0; j < 2 * kRangeSize; j += 2) | 693 for (int j = 0; j < 2 * kRangeSize; j += 2) |
694 table.AddRange(CharacterRange::Range(range[j], range[j + 1]), i, &zone); | 694 table.AddRange(CharacterRange::Range(range[j], range[j + 1]), i, &zone); |
695 } | 695 } |
696 // Check that the table looks as we would expect | 696 // Check that the table looks as we would expect |
697 for (int p = 0; p < kLimit; p++) { | 697 for (int p = 0; p < kLimit; p++) { |
698 OutSet* outs = table.Get(p); | 698 OutSet* outs = table.Get(p); |
699 for (int j = 0; j < kRangeCount; j++) { | 699 for (int j = 0; j < kRangeCount; j++) { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 0, | 793 0, |
794 CcTest::i_isolate()); | 794 CcTest::i_isolate()); |
795 } | 795 } |
796 | 796 |
797 | 797 |
798 TEST(MacroAssemblerNativeSuccess) { | 798 TEST(MacroAssemblerNativeSuccess) { |
799 v8::V8::Initialize(); | 799 v8::V8::Initialize(); |
800 ContextInitializer initializer; | 800 ContextInitializer initializer; |
801 Isolate* isolate = CcTest::i_isolate(); | 801 Isolate* isolate = CcTest::i_isolate(); |
802 Factory* factory = isolate->factory(); | 802 Factory* factory = isolate->factory(); |
803 Zone zone; | 803 Zone zone(CcTest::i_isolate()->allocator()); |
804 | 804 |
805 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 805 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
806 4); | 806 4); |
807 | 807 |
808 m.Succeed(); | 808 m.Succeed(); |
809 | 809 |
810 Handle<String> source = factory->NewStringFromStaticChars(""); | 810 Handle<String> source = factory->NewStringFromStaticChars(""); |
811 Handle<Object> code_object = m.GetCode(source); | 811 Handle<Object> code_object = m.GetCode(source); |
812 Handle<Code> code = Handle<Code>::cast(code_object); | 812 Handle<Code> code = Handle<Code>::cast(code_object); |
813 | 813 |
(...skipping 17 matching lines...) Expand all Loading... |
831 CHECK_EQ(-1, captures[2]); | 831 CHECK_EQ(-1, captures[2]); |
832 CHECK_EQ(-1, captures[3]); | 832 CHECK_EQ(-1, captures[3]); |
833 } | 833 } |
834 | 834 |
835 | 835 |
836 TEST(MacroAssemblerNativeSimple) { | 836 TEST(MacroAssemblerNativeSimple) { |
837 v8::V8::Initialize(); | 837 v8::V8::Initialize(); |
838 ContextInitializer initializer; | 838 ContextInitializer initializer; |
839 Isolate* isolate = CcTest::i_isolate(); | 839 Isolate* isolate = CcTest::i_isolate(); |
840 Factory* factory = isolate->factory(); | 840 Factory* factory = isolate->factory(); |
841 Zone zone; | 841 Zone zone(CcTest::i_isolate()->allocator()); |
842 | 842 |
843 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 843 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
844 4); | 844 4); |
845 | 845 |
846 Label fail, backtrack; | 846 Label fail, backtrack; |
847 m.PushBacktrack(&fail); | 847 m.PushBacktrack(&fail); |
848 m.CheckNotAtStart(0, NULL); | 848 m.CheckNotAtStart(0, NULL); |
849 m.LoadCurrentCharacter(2, NULL); | 849 m.LoadCurrentCharacter(2, NULL); |
850 m.CheckNotCharacter('o', NULL); | 850 m.CheckNotCharacter('o', NULL); |
851 m.LoadCurrentCharacter(1, NULL, false); | 851 m.LoadCurrentCharacter(1, NULL, false); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 | 898 |
899 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); | 899 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); |
900 } | 900 } |
901 | 901 |
902 | 902 |
903 TEST(MacroAssemblerNativeSimpleUC16) { | 903 TEST(MacroAssemblerNativeSimpleUC16) { |
904 v8::V8::Initialize(); | 904 v8::V8::Initialize(); |
905 ContextInitializer initializer; | 905 ContextInitializer initializer; |
906 Isolate* isolate = CcTest::i_isolate(); | 906 Isolate* isolate = CcTest::i_isolate(); |
907 Factory* factory = isolate->factory(); | 907 Factory* factory = isolate->factory(); |
908 Zone zone; | 908 Zone zone(CcTest::i_isolate()->allocator()); |
909 | 909 |
910 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::UC16, | 910 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::UC16, |
911 4); | 911 4); |
912 | 912 |
913 Label fail, backtrack; | 913 Label fail, backtrack; |
914 m.PushBacktrack(&fail); | 914 m.PushBacktrack(&fail); |
915 m.CheckNotAtStart(0, NULL); | 915 m.CheckNotAtStart(0, NULL); |
916 m.LoadCurrentCharacter(2, NULL); | 916 m.LoadCurrentCharacter(2, NULL); |
917 m.CheckNotCharacter('o', NULL); | 917 m.CheckNotCharacter('o', NULL); |
918 m.LoadCurrentCharacter(1, NULL, false); | 918 m.LoadCurrentCharacter(1, NULL, false); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 | 971 |
972 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); | 972 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); |
973 } | 973 } |
974 | 974 |
975 | 975 |
976 TEST(MacroAssemblerNativeBacktrack) { | 976 TEST(MacroAssemblerNativeBacktrack) { |
977 v8::V8::Initialize(); | 977 v8::V8::Initialize(); |
978 ContextInitializer initializer; | 978 ContextInitializer initializer; |
979 Isolate* isolate = CcTest::i_isolate(); | 979 Isolate* isolate = CcTest::i_isolate(); |
980 Factory* factory = isolate->factory(); | 980 Factory* factory = isolate->factory(); |
981 Zone zone; | 981 Zone zone(CcTest::i_isolate()->allocator()); |
982 | 982 |
983 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 983 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
984 0); | 984 0); |
985 | 985 |
986 Label fail; | 986 Label fail; |
987 Label backtrack; | 987 Label backtrack; |
988 m.LoadCurrentCharacter(10, &fail); | 988 m.LoadCurrentCharacter(10, &fail); |
989 m.Succeed(); | 989 m.Succeed(); |
990 m.Bind(&fail); | 990 m.Bind(&fail); |
991 m.PushBacktrack(&backtrack); | 991 m.PushBacktrack(&backtrack); |
(...skipping 20 matching lines...) Expand all Loading... |
1012 | 1012 |
1013 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); | 1013 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); |
1014 } | 1014 } |
1015 | 1015 |
1016 | 1016 |
1017 TEST(MacroAssemblerNativeBackReferenceLATIN1) { | 1017 TEST(MacroAssemblerNativeBackReferenceLATIN1) { |
1018 v8::V8::Initialize(); | 1018 v8::V8::Initialize(); |
1019 ContextInitializer initializer; | 1019 ContextInitializer initializer; |
1020 Isolate* isolate = CcTest::i_isolate(); | 1020 Isolate* isolate = CcTest::i_isolate(); |
1021 Factory* factory = isolate->factory(); | 1021 Factory* factory = isolate->factory(); |
1022 Zone zone; | 1022 Zone zone(CcTest::i_isolate()->allocator()); |
1023 | 1023 |
1024 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 1024 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
1025 4); | 1025 4); |
1026 | 1026 |
1027 m.WriteCurrentPositionToRegister(0, 0); | 1027 m.WriteCurrentPositionToRegister(0, 0); |
1028 m.AdvanceCurrentPosition(2); | 1028 m.AdvanceCurrentPosition(2); |
1029 m.WriteCurrentPositionToRegister(1, 0); | 1029 m.WriteCurrentPositionToRegister(1, 0); |
1030 Label nomatch; | 1030 Label nomatch; |
1031 m.CheckNotBackReference(0, false, &nomatch); | 1031 m.CheckNotBackReference(0, false, &nomatch); |
1032 m.Fail(); | 1032 m.Fail(); |
(...skipping 29 matching lines...) Expand all Loading... |
1062 CHECK_EQ(6, output[2]); | 1062 CHECK_EQ(6, output[2]); |
1063 CHECK_EQ(-1, output[3]); | 1063 CHECK_EQ(-1, output[3]); |
1064 } | 1064 } |
1065 | 1065 |
1066 | 1066 |
1067 TEST(MacroAssemblerNativeBackReferenceUC16) { | 1067 TEST(MacroAssemblerNativeBackReferenceUC16) { |
1068 v8::V8::Initialize(); | 1068 v8::V8::Initialize(); |
1069 ContextInitializer initializer; | 1069 ContextInitializer initializer; |
1070 Isolate* isolate = CcTest::i_isolate(); | 1070 Isolate* isolate = CcTest::i_isolate(); |
1071 Factory* factory = isolate->factory(); | 1071 Factory* factory = isolate->factory(); |
1072 Zone zone; | 1072 Zone zone(CcTest::i_isolate()->allocator()); |
1073 | 1073 |
1074 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::UC16, | 1074 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::UC16, |
1075 4); | 1075 4); |
1076 | 1076 |
1077 m.WriteCurrentPositionToRegister(0, 0); | 1077 m.WriteCurrentPositionToRegister(0, 0); |
1078 m.AdvanceCurrentPosition(2); | 1078 m.AdvanceCurrentPosition(2); |
1079 m.WriteCurrentPositionToRegister(1, 0); | 1079 m.WriteCurrentPositionToRegister(1, 0); |
1080 Label nomatch; | 1080 Label nomatch; |
1081 m.CheckNotBackReference(0, false, &nomatch); | 1081 m.CheckNotBackReference(0, false, &nomatch); |
1082 m.Fail(); | 1082 m.Fail(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 CHECK_EQ(-1, output[3]); | 1115 CHECK_EQ(-1, output[3]); |
1116 } | 1116 } |
1117 | 1117 |
1118 | 1118 |
1119 | 1119 |
1120 TEST(MacroAssemblernativeAtStart) { | 1120 TEST(MacroAssemblernativeAtStart) { |
1121 v8::V8::Initialize(); | 1121 v8::V8::Initialize(); |
1122 ContextInitializer initializer; | 1122 ContextInitializer initializer; |
1123 Isolate* isolate = CcTest::i_isolate(); | 1123 Isolate* isolate = CcTest::i_isolate(); |
1124 Factory* factory = isolate->factory(); | 1124 Factory* factory = isolate->factory(); |
1125 Zone zone; | 1125 Zone zone(CcTest::i_isolate()->allocator()); |
1126 | 1126 |
1127 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 1127 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
1128 0); | 1128 0); |
1129 | 1129 |
1130 Label not_at_start, newline, fail; | 1130 Label not_at_start, newline, fail; |
1131 m.CheckNotAtStart(0, ¬_at_start); | 1131 m.CheckNotAtStart(0, ¬_at_start); |
1132 // Check that prevchar = '\n' and current = 'f'. | 1132 // Check that prevchar = '\n' and current = 'f'. |
1133 m.CheckCharacter('\n', &newline); | 1133 m.CheckCharacter('\n', &newline); |
1134 m.Bind(&fail); | 1134 m.Bind(&fail); |
1135 m.Fail(); | 1135 m.Fail(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 | 1175 |
1176 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); | 1176 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
1177 } | 1177 } |
1178 | 1178 |
1179 | 1179 |
1180 TEST(MacroAssemblerNativeBackRefNoCase) { | 1180 TEST(MacroAssemblerNativeBackRefNoCase) { |
1181 v8::V8::Initialize(); | 1181 v8::V8::Initialize(); |
1182 ContextInitializer initializer; | 1182 ContextInitializer initializer; |
1183 Isolate* isolate = CcTest::i_isolate(); | 1183 Isolate* isolate = CcTest::i_isolate(); |
1184 Factory* factory = isolate->factory(); | 1184 Factory* factory = isolate->factory(); |
1185 Zone zone; | 1185 Zone zone(CcTest::i_isolate()->allocator()); |
1186 | 1186 |
1187 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 1187 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
1188 4); | 1188 4); |
1189 | 1189 |
1190 Label fail, succ; | 1190 Label fail, succ; |
1191 | 1191 |
1192 m.WriteCurrentPositionToRegister(0, 0); | 1192 m.WriteCurrentPositionToRegister(0, 0); |
1193 m.WriteCurrentPositionToRegister(2, 0); | 1193 m.WriteCurrentPositionToRegister(2, 0); |
1194 m.AdvanceCurrentPosition(3); | 1194 m.AdvanceCurrentPosition(3); |
1195 m.WriteCurrentPositionToRegister(3, 0); | 1195 m.WriteCurrentPositionToRegister(3, 0); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 CHECK_EQ(3, output[3]); | 1234 CHECK_EQ(3, output[3]); |
1235 } | 1235 } |
1236 | 1236 |
1237 | 1237 |
1238 | 1238 |
1239 TEST(MacroAssemblerNativeRegisters) { | 1239 TEST(MacroAssemblerNativeRegisters) { |
1240 v8::V8::Initialize(); | 1240 v8::V8::Initialize(); |
1241 ContextInitializer initializer; | 1241 ContextInitializer initializer; |
1242 Isolate* isolate = CcTest::i_isolate(); | 1242 Isolate* isolate = CcTest::i_isolate(); |
1243 Factory* factory = isolate->factory(); | 1243 Factory* factory = isolate->factory(); |
1244 Zone zone; | 1244 Zone zone(CcTest::i_isolate()->allocator()); |
1245 | 1245 |
1246 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 1246 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
1247 6); | 1247 6); |
1248 | 1248 |
1249 uc16 foo_chars[3] = {'f', 'o', 'o'}; | 1249 uc16 foo_chars[3] = {'f', 'o', 'o'}; |
1250 Vector<const uc16> foo(foo_chars, 3); | 1250 Vector<const uc16> foo(foo_chars, 3); |
1251 | 1251 |
1252 enum registers { out1, out2, out3, out4, out5, out6, sp, loop_cnt }; | 1252 enum registers { out1, out2, out3, out4, out5, out6, sp, loop_cnt }; |
1253 Label fail; | 1253 Label fail; |
1254 Label backtrack; | 1254 Label backtrack; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 CHECK_EQ(9, output[4]); | 1336 CHECK_EQ(9, output[4]); |
1337 CHECK_EQ(-1, output[5]); | 1337 CHECK_EQ(-1, output[5]); |
1338 } | 1338 } |
1339 | 1339 |
1340 | 1340 |
1341 TEST(MacroAssemblerStackOverflow) { | 1341 TEST(MacroAssemblerStackOverflow) { |
1342 v8::V8::Initialize(); | 1342 v8::V8::Initialize(); |
1343 ContextInitializer initializer; | 1343 ContextInitializer initializer; |
1344 Isolate* isolate = CcTest::i_isolate(); | 1344 Isolate* isolate = CcTest::i_isolate(); |
1345 Factory* factory = isolate->factory(); | 1345 Factory* factory = isolate->factory(); |
1346 Zone zone; | 1346 Zone zone(CcTest::i_isolate()->allocator()); |
1347 | 1347 |
1348 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 1348 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
1349 0); | 1349 0); |
1350 | 1350 |
1351 Label loop; | 1351 Label loop; |
1352 m.Bind(&loop); | 1352 m.Bind(&loop); |
1353 m.PushBacktrack(&loop); | 1353 m.PushBacktrack(&loop); |
1354 m.GoTo(&loop); | 1354 m.GoTo(&loop); |
1355 | 1355 |
1356 Handle<String> source = | 1356 Handle<String> source = |
(...skipping 18 matching lines...) Expand all Loading... |
1375 CHECK(isolate->has_pending_exception()); | 1375 CHECK(isolate->has_pending_exception()); |
1376 isolate->clear_pending_exception(); | 1376 isolate->clear_pending_exception(); |
1377 } | 1377 } |
1378 | 1378 |
1379 | 1379 |
1380 TEST(MacroAssemblerNativeLotsOfRegisters) { | 1380 TEST(MacroAssemblerNativeLotsOfRegisters) { |
1381 v8::V8::Initialize(); | 1381 v8::V8::Initialize(); |
1382 ContextInitializer initializer; | 1382 ContextInitializer initializer; |
1383 Isolate* isolate = CcTest::i_isolate(); | 1383 Isolate* isolate = CcTest::i_isolate(); |
1384 Factory* factory = isolate->factory(); | 1384 Factory* factory = isolate->factory(); |
1385 Zone zone; | 1385 Zone zone(CcTest::i_isolate()->allocator()); |
1386 | 1386 |
1387 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 1387 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
1388 2); | 1388 2); |
1389 | 1389 |
1390 // At least 2048, to ensure the allocated space for registers | 1390 // At least 2048, to ensure the allocated space for registers |
1391 // span one full page. | 1391 // span one full page. |
1392 const int large_number = 8000; | 1392 const int large_number = 8000; |
1393 m.WriteCurrentPositionToRegister(large_number, 42); | 1393 m.WriteCurrentPositionToRegister(large_number, 42); |
1394 m.WriteCurrentPositionToRegister(0, 0); | 1394 m.WriteCurrentPositionToRegister(0, 0); |
1395 m.WriteCurrentPositionToRegister(1, 1); | 1395 m.WriteCurrentPositionToRegister(1, 1); |
(...skipping 27 matching lines...) Expand all Loading... |
1423 CHECK_EQ(0, captures[0]); | 1423 CHECK_EQ(0, captures[0]); |
1424 CHECK_EQ(42, captures[1]); | 1424 CHECK_EQ(42, captures[1]); |
1425 | 1425 |
1426 isolate->clear_pending_exception(); | 1426 isolate->clear_pending_exception(); |
1427 } | 1427 } |
1428 | 1428 |
1429 #else // V8_INTERPRETED_REGEXP | 1429 #else // V8_INTERPRETED_REGEXP |
1430 | 1430 |
1431 TEST(MacroAssembler) { | 1431 TEST(MacroAssembler) { |
1432 byte codes[1024]; | 1432 byte codes[1024]; |
1433 Zone zone; | 1433 Zone zone(CcTest::i_isolate()->allocator()); |
1434 RegExpMacroAssemblerIrregexp m(CcTest::i_isolate(), Vector<byte>(codes, 1024), | 1434 RegExpMacroAssemblerIrregexp m(CcTest::i_isolate(), Vector<byte>(codes, 1024), |
1435 &zone); | 1435 &zone); |
1436 // ^f(o)o. | 1436 // ^f(o)o. |
1437 Label start, fail, backtrack; | 1437 Label start, fail, backtrack; |
1438 | 1438 |
1439 m.SetRegister(4, 42); | 1439 m.SetRegister(4, 42); |
1440 m.PushRegister(4, RegExpMacroAssembler::kNoStackLimitCheck); | 1440 m.PushRegister(4, RegExpMacroAssembler::kNoStackLimitCheck); |
1441 m.AdvanceRegister(4, 42); | 1441 m.AdvanceRegister(4, 42); |
1442 m.GoTo(&start); | 1442 m.GoTo(&start); |
1443 m.Fail(); | 1443 m.Fail(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1491 CHECK_EQ(42, captures[0]); | 1491 CHECK_EQ(42, captures[0]); |
1492 } | 1492 } |
1493 | 1493 |
1494 #endif // V8_INTERPRETED_REGEXP | 1494 #endif // V8_INTERPRETED_REGEXP |
1495 | 1495 |
1496 | 1496 |
1497 TEST(AddInverseToTable) { | 1497 TEST(AddInverseToTable) { |
1498 static const int kLimit = 1000; | 1498 static const int kLimit = 1000; |
1499 static const int kRangeCount = 16; | 1499 static const int kRangeCount = 16; |
1500 for (int t = 0; t < 10; t++) { | 1500 for (int t = 0; t < 10; t++) { |
1501 Zone zone; | 1501 Zone zone(CcTest::i_isolate()->allocator()); |
1502 ZoneList<CharacterRange>* ranges = | 1502 ZoneList<CharacterRange>* ranges = |
1503 new(&zone) ZoneList<CharacterRange>(kRangeCount, &zone); | 1503 new(&zone) ZoneList<CharacterRange>(kRangeCount, &zone); |
1504 for (int i = 0; i < kRangeCount; i++) { | 1504 for (int i = 0; i < kRangeCount; i++) { |
1505 int from = PseudoRandom(t + 87, i + 25) % kLimit; | 1505 int from = PseudoRandom(t + 87, i + 25) % kLimit; |
1506 int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20)); | 1506 int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20)); |
1507 if (to > kLimit) to = kLimit; | 1507 if (to > kLimit) to = kLimit; |
1508 ranges->Add(CharacterRange::Range(from, to), &zone); | 1508 ranges->Add(CharacterRange::Range(from, to), &zone); |
1509 } | 1509 } |
1510 DispatchTable table(&zone); | 1510 DispatchTable table(&zone); |
1511 DispatchTableConstructor cons(&table, false, &zone); | 1511 DispatchTableConstructor cons(&table, false, &zone); |
1512 cons.set_choice_index(0); | 1512 cons.set_choice_index(0); |
1513 cons.AddInverse(ranges); | 1513 cons.AddInverse(ranges); |
1514 for (int i = 0; i < kLimit; i++) { | 1514 for (int i = 0; i < kLimit; i++) { |
1515 bool is_on = false; | 1515 bool is_on = false; |
1516 for (int j = 0; !is_on && j < kRangeCount; j++) | 1516 for (int j = 0; !is_on && j < kRangeCount; j++) |
1517 is_on = ranges->at(j).Contains(i); | 1517 is_on = ranges->at(j).Contains(i); |
1518 OutSet* set = table.Get(i); | 1518 OutSet* set = table.Get(i); |
1519 CHECK_EQ(is_on, set->Get(0) == false); | 1519 CHECK_EQ(is_on, set->Get(0) == false); |
1520 } | 1520 } |
1521 } | 1521 } |
1522 Zone zone; | 1522 Zone zone(CcTest::i_isolate()->allocator()); |
1523 ZoneList<CharacterRange>* ranges = | 1523 ZoneList<CharacterRange>* ranges = |
1524 new(&zone) ZoneList<CharacterRange>(1, &zone); | 1524 new(&zone) ZoneList<CharacterRange>(1, &zone); |
1525 ranges->Add(CharacterRange::Range(0xFFF0, 0xFFFE), &zone); | 1525 ranges->Add(CharacterRange::Range(0xFFF0, 0xFFFE), &zone); |
1526 DispatchTable table(&zone); | 1526 DispatchTable table(&zone); |
1527 DispatchTableConstructor cons(&table, false, &zone); | 1527 DispatchTableConstructor cons(&table, false, &zone); |
1528 cons.set_choice_index(0); | 1528 cons.set_choice_index(0); |
1529 cons.AddInverse(ranges); | 1529 cons.AddInverse(ranges); |
1530 CHECK(!table.Get(0xFFFE)->Get(0)); | 1530 CHECK(!table.Get(0xFFFE)->Get(0)); |
1531 CHECK(table.Get(0xFFFF)->Get(0)); | 1531 CHECK(table.Get(0xFFFF)->Get(0)); |
1532 } | 1532 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1625 CHECK_EQ(length, length2); | 1625 CHECK_EQ(length, length2); |
1626 for (int k = 0; k < length; k++) | 1626 for (int k = 0; k < length; k++) |
1627 CHECK_EQ(static_cast<int>(chars[k]), static_cast<int>(chars2[k])); | 1627 CHECK_EQ(static_cast<int>(chars[k]), static_cast<int>(chars2[k])); |
1628 } | 1628 } |
1629 } | 1629 } |
1630 } | 1630 } |
1631 | 1631 |
1632 | 1632 |
1633 static void TestRangeCaseIndependence(Isolate* isolate, CharacterRange input, | 1633 static void TestRangeCaseIndependence(Isolate* isolate, CharacterRange input, |
1634 Vector<CharacterRange> expected) { | 1634 Vector<CharacterRange> expected) { |
1635 Zone zone; | 1635 Zone zone(CcTest::i_isolate()->allocator()); |
1636 int count = expected.length(); | 1636 int count = expected.length(); |
1637 ZoneList<CharacterRange>* list = | 1637 ZoneList<CharacterRange>* list = |
1638 new(&zone) ZoneList<CharacterRange>(count, &zone); | 1638 new(&zone) ZoneList<CharacterRange>(count, &zone); |
1639 list->Add(input, &zone); | 1639 list->Add(input, &zone); |
1640 CharacterRange::AddCaseEquivalents(isolate, &zone, list, false); | 1640 CharacterRange::AddCaseEquivalents(isolate, &zone, list, false); |
1641 list->Remove(0); // Remove the input before checking results. | 1641 list->Remove(0); // Remove the input before checking results. |
1642 CHECK_EQ(count, list->length()); | 1642 CHECK_EQ(count, list->length()); |
1643 for (int i = 0; i < list->length(); i++) { | 1643 for (int i = 0; i < list->length(); i++) { |
1644 CHECK_EQ(expected[i].from(), list->at(i).from()); | 1644 CHECK_EQ(expected[i].from(), list->at(i).from()); |
1645 CHECK_EQ(expected[i].to(), list->at(i).to()); | 1645 CHECK_EQ(expected[i].to(), list->at(i).to()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1694 for (int i = 0; i < ranges->length(); i++) { | 1694 for (int i = 0; i < ranges->length(); i++) { |
1695 CharacterRange range = ranges->at(i); | 1695 CharacterRange range = ranges->at(i); |
1696 if (range.from() <= c && c <= range.to()) | 1696 if (range.from() <= c && c <= range.to()) |
1697 return true; | 1697 return true; |
1698 } | 1698 } |
1699 return false; | 1699 return false; |
1700 } | 1700 } |
1701 | 1701 |
1702 | 1702 |
1703 TEST(UnicodeRangeSplitter) { | 1703 TEST(UnicodeRangeSplitter) { |
1704 Zone zone; | 1704 Zone zone(CcTest::i_isolate()->allocator()); |
1705 ZoneList<CharacterRange>* base = | 1705 ZoneList<CharacterRange>* base = |
1706 new(&zone) ZoneList<CharacterRange>(1, &zone); | 1706 new(&zone) ZoneList<CharacterRange>(1, &zone); |
1707 base->Add(CharacterRange::Everything(), &zone); | 1707 base->Add(CharacterRange::Everything(), &zone); |
1708 UnicodeRangeSplitter splitter(&zone, base); | 1708 UnicodeRangeSplitter splitter(&zone, base); |
1709 // BMP | 1709 // BMP |
1710 for (uc32 c = 0; c < 0xd800; c++) { | 1710 for (uc32 c = 0; c < 0xd800; c++) { |
1711 CHECK(InClass(c, splitter.bmp())); | 1711 CHECK(InClass(c, splitter.bmp())); |
1712 CHECK(!InClass(c, splitter.lead_surrogates())); | 1712 CHECK(!InClass(c, splitter.lead_surrogates())); |
1713 CHECK(!InClass(c, splitter.trail_surrogates())); | 1713 CHECK(!InClass(c, splitter.trail_surrogates())); |
1714 CHECK(!InClass(c, splitter.non_bmp())); | 1714 CHECK(!InClass(c, splitter.non_bmp())); |
(...skipping 23 matching lines...) Expand all Loading... |
1738 for (uc32 c = 0x10000; c < 0x10ffff; c++) { | 1738 for (uc32 c = 0x10000; c < 0x10ffff; c++) { |
1739 CHECK(!InClass(c, splitter.bmp())); | 1739 CHECK(!InClass(c, splitter.bmp())); |
1740 CHECK(!InClass(c, splitter.lead_surrogates())); | 1740 CHECK(!InClass(c, splitter.lead_surrogates())); |
1741 CHECK(!InClass(c, splitter.trail_surrogates())); | 1741 CHECK(!InClass(c, splitter.trail_surrogates())); |
1742 CHECK(InClass(c, splitter.non_bmp())); | 1742 CHECK(InClass(c, splitter.non_bmp())); |
1743 } | 1743 } |
1744 } | 1744 } |
1745 | 1745 |
1746 | 1746 |
1747 TEST(CanonicalizeCharacterSets) { | 1747 TEST(CanonicalizeCharacterSets) { |
1748 Zone zone; | 1748 Zone zone(CcTest::i_isolate()->allocator()); |
1749 ZoneList<CharacterRange>* list = | 1749 ZoneList<CharacterRange>* list = |
1750 new(&zone) ZoneList<CharacterRange>(4, &zone); | 1750 new(&zone) ZoneList<CharacterRange>(4, &zone); |
1751 CharacterSet set(list); | 1751 CharacterSet set(list); |
1752 | 1752 |
1753 list->Add(CharacterRange::Range(10, 20), &zone); | 1753 list->Add(CharacterRange::Range(10, 20), &zone); |
1754 list->Add(CharacterRange::Range(30, 40), &zone); | 1754 list->Add(CharacterRange::Range(30, 40), &zone); |
1755 list->Add(CharacterRange::Range(50, 60), &zone); | 1755 list->Add(CharacterRange::Range(50, 60), &zone); |
1756 set.Canonicalize(); | 1756 set.Canonicalize(); |
1757 CHECK_EQ(3, list->length()); | 1757 CHECK_EQ(3, list->length()); |
1758 CHECK_EQ(10, list->at(0).from()); | 1758 CHECK_EQ(10, list->at(0).from()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1799 list->Add(CharacterRange::Range(21, 30), &zone); | 1799 list->Add(CharacterRange::Range(21, 30), &zone); |
1800 list->Add(CharacterRange::Range(20, 20), &zone); | 1800 list->Add(CharacterRange::Range(20, 20), &zone); |
1801 set.Canonicalize(); | 1801 set.Canonicalize(); |
1802 CHECK_EQ(1, list->length()); | 1802 CHECK_EQ(1, list->length()); |
1803 CHECK_EQ(10, list->at(0).from()); | 1803 CHECK_EQ(10, list->at(0).from()); |
1804 CHECK_EQ(30, list->at(0).to()); | 1804 CHECK_EQ(30, list->at(0).to()); |
1805 } | 1805 } |
1806 | 1806 |
1807 | 1807 |
1808 TEST(CharacterRangeMerge) { | 1808 TEST(CharacterRangeMerge) { |
1809 Zone zone; | 1809 Zone zone(CcTest::i_isolate()->allocator()); |
1810 ZoneList<CharacterRange> l1(4, &zone); | 1810 ZoneList<CharacterRange> l1(4, &zone); |
1811 ZoneList<CharacterRange> l2(4, &zone); | 1811 ZoneList<CharacterRange> l2(4, &zone); |
1812 // Create all combinations of intersections of ranges, both singletons and | 1812 // Create all combinations of intersections of ranges, both singletons and |
1813 // longer. | 1813 // longer. |
1814 | 1814 |
1815 int offset = 0; | 1815 int offset = 0; |
1816 | 1816 |
1817 // The five kinds of singleton intersections: | 1817 // The five kinds of singleton intersections: |
1818 // X | 1818 // X |
1819 // Y - outside before | 1819 // Y - outside before |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1966 // .toString() throws on non-RegExps that aren't RegExp.prototype | 1966 // .toString() throws on non-RegExps that aren't RegExp.prototype |
1967 v8::Local<v8::Value> resultToStringError = CompileRun( | 1967 v8::Local<v8::Value> resultToStringError = CompileRun( |
1968 "var exception;" | 1968 "var exception;" |
1969 "try { RegExp.prototype.toString.call(null) }" | 1969 "try { RegExp.prototype.toString.call(null) }" |
1970 "catch (e) { exception = e; }" | 1970 "catch (e) { exception = e; }" |
1971 "exception"); | 1971 "exception"); |
1972 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); | 1972 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); |
1973 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeToString]); | 1973 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeToString]); |
1974 CHECK(resultToStringError->IsObject()); | 1974 CHECK(resultToStringError->IsObject()); |
1975 } | 1975 } |
OLD | NEW |