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

Side by Side Diff: test/cctest/test-regexp.cc

Issue 146213004: A64: Synchronize with r16849. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-random.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #include "ia32/macro-assembler-ia32.h" 69 #include "ia32/macro-assembler-ia32.h"
70 #include "ia32/regexp-macro-assembler-ia32.h" 70 #include "ia32/regexp-macro-assembler-ia32.h"
71 #endif 71 #endif
72 #endif // V8_INTERPRETED_REGEXP 72 #endif // V8_INTERPRETED_REGEXP
73 73
74 using namespace v8::internal; 74 using namespace v8::internal;
75 75
76 76
77 static bool CheckParse(const char* input) { 77 static bool CheckParse(const char* input) {
78 V8::Initialize(NULL); 78 V8::Initialize(NULL);
79 v8::HandleScope scope(v8::Isolate::GetCurrent()); 79 v8::HandleScope scope(CcTest::isolate());
80 Zone zone(Isolate::Current()); 80 Zone zone(CcTest::i_isolate());
81 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 81 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input));
82 RegExpCompileData result; 82 RegExpCompileData result;
83 return v8::internal::RegExpParser::ParseRegExp( 83 return v8::internal::RegExpParser::ParseRegExp(
84 &reader, false, &result, &zone); 84 &reader, false, &result, &zone);
85 } 85 }
86 86
87 87
88 static SmartArrayPointer<const char> Parse(const char* input) { 88 static SmartArrayPointer<const char> Parse(const char* input) {
89 V8::Initialize(NULL); 89 V8::Initialize(NULL);
90 v8::HandleScope scope(v8::Isolate::GetCurrent()); 90 v8::HandleScope scope(CcTest::isolate());
91 Zone zone(Isolate::Current()); 91 Zone zone(CcTest::i_isolate());
92 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 92 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input));
93 RegExpCompileData result; 93 RegExpCompileData result;
94 CHECK(v8::internal::RegExpParser::ParseRegExp( 94 CHECK(v8::internal::RegExpParser::ParseRegExp(
95 &reader, false, &result, &zone)); 95 &reader, false, &result, &zone));
96 CHECK(result.tree != NULL); 96 CHECK(result.tree != NULL);
97 CHECK(result.error.is_null()); 97 CHECK(result.error.is_null());
98 SmartArrayPointer<const char> output = result.tree->ToString(&zone); 98 SmartArrayPointer<const char> output = result.tree->ToString(&zone);
99 return output; 99 return output;
100 } 100 }
101 101
102 102
103 static bool CheckSimple(const char* input) { 103 static bool CheckSimple(const char* input) {
104 V8::Initialize(NULL); 104 V8::Initialize(NULL);
105 v8::HandleScope scope(v8::Isolate::GetCurrent()); 105 v8::HandleScope scope(CcTest::isolate());
106 Zone zone(Isolate::Current()); 106 Zone zone(CcTest::i_isolate());
107 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 107 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input));
108 RegExpCompileData result; 108 RegExpCompileData result;
109 CHECK(v8::internal::RegExpParser::ParseRegExp( 109 CHECK(v8::internal::RegExpParser::ParseRegExp(
110 &reader, false, &result, &zone)); 110 &reader, false, &result, &zone));
111 CHECK(result.tree != NULL); 111 CHECK(result.tree != NULL);
112 CHECK(result.error.is_null()); 112 CHECK(result.error.is_null());
113 return result.simple; 113 return result.simple;
114 } 114 }
115 115
116 struct MinMaxPair { 116 struct MinMaxPair {
117 int min_match; 117 int min_match;
118 int max_match; 118 int max_match;
119 }; 119 };
120 120
121 121
122 static MinMaxPair CheckMinMaxMatch(const char* input) { 122 static MinMaxPair CheckMinMaxMatch(const char* input) {
123 V8::Initialize(NULL); 123 V8::Initialize(NULL);
124 v8::HandleScope scope(v8::Isolate::GetCurrent()); 124 v8::HandleScope scope(CcTest::isolate());
125 Zone zone(Isolate::Current()); 125 Zone zone(CcTest::i_isolate());
126 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 126 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input));
127 RegExpCompileData result; 127 RegExpCompileData result;
128 CHECK(v8::internal::RegExpParser::ParseRegExp( 128 CHECK(v8::internal::RegExpParser::ParseRegExp(
129 &reader, false, &result, &zone)); 129 &reader, false, &result, &zone));
130 CHECK(result.tree != NULL); 130 CHECK(result.tree != NULL);
131 CHECK(result.error.is_null()); 131 CHECK(result.error.is_null());
132 int min_match = result.tree->min_match(); 132 int min_match = result.tree->min_match();
133 int max_match = result.tree->max_match(); 133 int max_match = result.tree->max_match();
134 MinMaxPair pair = { min_match, max_match }; 134 MinMaxPair pair = { min_match, max_match };
135 return pair; 135 return pair;
136 } 136 }
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 TEST(ParserRegression) { 388 TEST(ParserRegression) {
389 CHECK_PARSE_EQ("[A-Z$-][x]", "(! [A-Z $ -] [x])"); 389 CHECK_PARSE_EQ("[A-Z$-][x]", "(! [A-Z $ -] [x])");
390 CHECK_PARSE_EQ("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')"); 390 CHECK_PARSE_EQ("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')");
391 CHECK_PARSE_EQ("{", "'{'"); 391 CHECK_PARSE_EQ("{", "'{'");
392 CHECK_PARSE_EQ("a|", "(| 'a' %)"); 392 CHECK_PARSE_EQ("a|", "(| 'a' %)");
393 } 393 }
394 394
395 static void ExpectError(const char* input, 395 static void ExpectError(const char* input,
396 const char* expected) { 396 const char* expected) {
397 V8::Initialize(NULL); 397 V8::Initialize(NULL);
398 v8::HandleScope scope(v8::Isolate::GetCurrent()); 398 v8::HandleScope scope(CcTest::isolate());
399 Zone zone(Isolate::Current()); 399 Zone zone(CcTest::i_isolate());
400 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 400 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input));
401 RegExpCompileData result; 401 RegExpCompileData result;
402 CHECK(!v8::internal::RegExpParser::ParseRegExp( 402 CHECK(!v8::internal::RegExpParser::ParseRegExp(
403 &reader, false, &result, &zone)); 403 &reader, false, &result, &zone));
404 CHECK(result.tree == NULL); 404 CHECK(result.tree == NULL);
405 CHECK(!result.error.is_null()); 405 CHECK(!result.error.is_null());
406 SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS); 406 SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS);
407 CHECK_EQ(expected, *str); 407 CHECK_EQ(expected, *str);
408 } 408 }
409 409
410 410
411 TEST(Errors) { 411 UNINITIALIZED_TEST(Errors) {
412 V8::Initialize(NULL); 412 V8::Initialize(NULL);
413 const char* kEndBackslash = "\\ at end of pattern"; 413 const char* kEndBackslash = "\\ at end of pattern";
414 ExpectError("\\", kEndBackslash); 414 ExpectError("\\", kEndBackslash);
415 const char* kUnterminatedGroup = "Unterminated group"; 415 const char* kUnterminatedGroup = "Unterminated group";
416 ExpectError("(foo", kUnterminatedGroup); 416 ExpectError("(foo", kUnterminatedGroup);
417 const char* kInvalidGroup = "Invalid group"; 417 const char* kInvalidGroup = "Invalid group";
418 ExpectError("(?", kInvalidGroup); 418 ExpectError("(?", kInvalidGroup);
419 const char* kUnterminatedCharacterClass = "Unterminated character class"; 419 const char* kUnterminatedCharacterClass = "Unterminated character class";
420 ExpectError("[", kUnterminatedCharacterClass); 420 ExpectError("[", kUnterminatedCharacterClass);
421 ExpectError("[a-", kUnterminatedCharacterClass); 421 ExpectError("[a-", kUnterminatedCharacterClass);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 return !IsWhiteSpace(c); 473 return !IsWhiteSpace(c);
474 } 474 }
475 475
476 476
477 static bool NotWord(uc16 c) { 477 static bool NotWord(uc16 c) {
478 return !IsRegExpWord(c); 478 return !IsRegExpWord(c);
479 } 479 }
480 480
481 481
482 static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) { 482 static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) {
483 Zone zone(Isolate::Current()); 483 Zone zone(CcTest::i_isolate());
484 ZoneList<CharacterRange>* ranges = 484 ZoneList<CharacterRange>* ranges =
485 new(&zone) ZoneList<CharacterRange>(2, &zone); 485 new(&zone) ZoneList<CharacterRange>(2, &zone);
486 CharacterRange::AddClassEscape(c, ranges, &zone); 486 CharacterRange::AddClassEscape(c, ranges, &zone);
487 for (unsigned i = 0; i < (1 << 16); i++) { 487 for (unsigned i = 0; i < (1 << 16); i++) {
488 bool in_class = false; 488 bool in_class = false;
489 for (int j = 0; !in_class && j < ranges->length(); j++) { 489 for (int j = 0; !in_class && j < ranges->length(); j++) {
490 CharacterRange& range = ranges->at(j); 490 CharacterRange& range = ranges->at(j);
491 in_class = (range.from() <= i && i <= range.to()); 491 in_class = (range.from() <= i && i <= range.to());
492 } 492 }
493 CHECK_EQ(pred(i), in_class); 493 CHECK_EQ(pred(i), in_class);
(...skipping 11 matching lines...) Expand all
505 TestCharacterClassEscapes('w', IsRegExpWord); 505 TestCharacterClassEscapes('w', IsRegExpWord);
506 TestCharacterClassEscapes('W', NotWord); 506 TestCharacterClassEscapes('W', NotWord);
507 } 507 }
508 508
509 509
510 static RegExpNode* Compile(const char* input, 510 static RegExpNode* Compile(const char* input,
511 bool multiline, 511 bool multiline,
512 bool is_ascii, 512 bool is_ascii,
513 Zone* zone) { 513 Zone* zone) {
514 V8::Initialize(NULL); 514 V8::Initialize(NULL);
515 Isolate* isolate = Isolate::Current(); 515 Isolate* isolate = CcTest::i_isolate();
516 FlatStringReader reader(isolate, CStrVector(input)); 516 FlatStringReader reader(isolate, CStrVector(input));
517 RegExpCompileData compile_data; 517 RegExpCompileData compile_data;
518 if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline, 518 if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline,
519 &compile_data, zone)) 519 &compile_data, zone))
520 return NULL; 520 return NULL;
521 Handle<String> pattern = isolate->factory()-> 521 Handle<String> pattern = isolate->factory()->
522 NewStringFromUtf8(CStrVector(input)); 522 NewStringFromUtf8(CStrVector(input));
523 Handle<String> sample_subject = 523 Handle<String> sample_subject =
524 isolate->factory()->NewStringFromUtf8(CStrVector("")); 524 isolate->factory()->NewStringFromUtf8(CStrVector(""));
525 RegExpEngine::Compile(&compile_data, 525 RegExpEngine::Compile(&compile_data,
526 false, 526 false,
527 false, 527 false,
528 multiline, 528 multiline,
529 pattern, 529 pattern,
530 sample_subject, 530 sample_subject,
531 is_ascii, 531 is_ascii,
532 zone); 532 zone);
533 return compile_data.node; 533 return compile_data.node;
534 } 534 }
535 535
536 536
537 static void Execute(const char* input, 537 static void Execute(const char* input,
538 bool multiline, 538 bool multiline,
539 bool is_ascii, 539 bool is_ascii,
540 bool dot_output = false) { 540 bool dot_output = false) {
541 v8::HandleScope scope(v8::Isolate::GetCurrent()); 541 v8::HandleScope scope(CcTest::isolate());
542 Zone zone(Isolate::Current()); 542 Zone zone(CcTest::i_isolate());
543 RegExpNode* node = Compile(input, multiline, is_ascii, &zone); 543 RegExpNode* node = Compile(input, multiline, is_ascii, &zone);
544 USE(node); 544 USE(node);
545 #ifdef DEBUG 545 #ifdef DEBUG
546 if (dot_output) { 546 if (dot_output) {
547 RegExpEngine::DotPrint(input, node, false); 547 RegExpEngine::DotPrint(input, node, false);
548 exit(0); 548 exit(0);
549 } 549 }
550 #endif // DEBUG 550 #endif // DEBUG
551 } 551 }
552 552
(...skipping 19 matching lines...) Expand all
572 572
573 573
574 static unsigned PseudoRandom(int i, int j) { 574 static unsigned PseudoRandom(int i, int j) {
575 return ~(~((i * 781) ^ (j * 329))); 575 return ~(~((i * 781) ^ (j * 329)));
576 } 576 }
577 577
578 578
579 TEST(SplayTreeSimple) { 579 TEST(SplayTreeSimple) {
580 v8::internal::V8::Initialize(NULL); 580 v8::internal::V8::Initialize(NULL);
581 static const unsigned kLimit = 1000; 581 static const unsigned kLimit = 1000;
582 Zone zone(Isolate::Current()); 582 Zone zone(CcTest::i_isolate());
583 ZoneSplayTree<TestConfig> tree(&zone); 583 ZoneSplayTree<TestConfig> tree(&zone);
584 bool seen[kLimit]; 584 bool seen[kLimit];
585 for (unsigned i = 0; i < kLimit; i++) seen[i] = false; 585 for (unsigned i = 0; i < kLimit; i++) seen[i] = false;
586 #define CHECK_MAPS_EQUAL() do { \ 586 #define CHECK_MAPS_EQUAL() do { \
587 for (unsigned k = 0; k < kLimit; k++) \ 587 for (unsigned k = 0; k < kLimit; k++) \
588 CHECK_EQ(seen[k], tree.Find(k, &loc)); \ 588 CHECK_EQ(seen[k], tree.Find(k, &loc)); \
589 } while (false) 589 } while (false)
590 for (int i = 0; i < 50; i++) { 590 for (int i = 0; i < 50; i++) {
591 for (int j = 0; j < 50; j++) { 591 for (int j = 0; j < 50; j++) {
592 unsigned next = PseudoRandom(i, j) % kLimit; 592 unsigned next = PseudoRandom(i, j) % kLimit;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 Vector<uc16> range(ranges[i], 2 * kRangeSize); 640 Vector<uc16> range(ranges[i], 2 * kRangeSize);
641 for (int j = 0; j < 2 * kRangeSize; j++) { 641 for (int j = 0; j < 2 * kRangeSize; j++) {
642 range[j] = PseudoRandom(i + 25, j + 87) % kLimit; 642 range[j] = PseudoRandom(i + 25, j + 87) % kLimit;
643 } 643 }
644 range.Sort(); 644 range.Sort();
645 for (int j = 1; j < 2 * kRangeSize; j++) { 645 for (int j = 1; j < 2 * kRangeSize; j++) {
646 CHECK(range[j-1] <= range[j]); 646 CHECK(range[j-1] <= range[j]);
647 } 647 }
648 } 648 }
649 // Enter test data into dispatch table. 649 // Enter test data into dispatch table.
650 Zone zone(Isolate::Current()); 650 Zone zone(CcTest::i_isolate());
651 DispatchTable table(&zone); 651 DispatchTable table(&zone);
652 for (int i = 0; i < kRangeCount; i++) { 652 for (int i = 0; i < kRangeCount; i++) {
653 uc16* range = ranges[i]; 653 uc16* range = ranges[i];
654 for (int j = 0; j < 2 * kRangeSize; j += 2) 654 for (int j = 0; j < 2 * kRangeSize; j += 2)
655 table.AddRange(CharacterRange(range[j], range[j + 1]), i, &zone); 655 table.AddRange(CharacterRange(range[j], range[j + 1]), i, &zone);
656 } 656 }
657 // Check that the table looks as we would expect 657 // Check that the table looks as we would expect
658 for (int p = 0; p < kLimit; p++) { 658 for (int p = 0; p < kLimit; p++) {
659 OutSet* outs = table.Get(p); 659 OutSet* outs = table.Get(p);
660 for (int j = 0; j < kRangeCount; j++) { 660 for (int j = 0; j < kRangeCount; j++) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 typedef RegExpMacroAssemblerARM ArchRegExpMacroAssembler; 710 typedef RegExpMacroAssemblerARM ArchRegExpMacroAssembler;
711 #elif V8_TARGET_ARCH_A64 711 #elif V8_TARGET_ARCH_A64
712 typedef RegExpMacroAssemblerA64 ArchRegExpMacroAssembler; 712 typedef RegExpMacroAssemblerA64 ArchRegExpMacroAssembler;
713 #elif V8_TARGET_ARCH_MIPS 713 #elif V8_TARGET_ARCH_MIPS
714 typedef RegExpMacroAssemblerMIPS ArchRegExpMacroAssembler; 714 typedef RegExpMacroAssemblerMIPS ArchRegExpMacroAssembler;
715 #endif 715 #endif
716 716
717 class ContextInitializer { 717 class ContextInitializer {
718 public: 718 public:
719 ContextInitializer() 719 ContextInitializer()
720 : scope_(v8::Isolate::GetCurrent()), 720 : scope_(CcTest::isolate()),
721 env_(v8::Context::New(v8::Isolate::GetCurrent())) { 721 env_(v8::Context::New(CcTest::isolate())) {
722 env_->Enter(); 722 env_->Enter();
723 } 723 }
724 ~ContextInitializer() { 724 ~ContextInitializer() {
725 env_->Exit(); 725 env_->Exit();
726 } 726 }
727 private: 727 private:
728 v8::HandleScope scope_; 728 v8::HandleScope scope_;
729 v8::Handle<v8::Context> env_; 729 v8::Handle<v8::Context> env_;
730 }; 730 };
731 731
732 732
733 static ArchRegExpMacroAssembler::Result Execute(Code* code, 733 static ArchRegExpMacroAssembler::Result Execute(Code* code,
734 String* input, 734 String* input,
735 int start_offset, 735 int start_offset,
736 const byte* input_start, 736 const byte* input_start,
737 const byte* input_end, 737 const byte* input_end,
738 int* captures) { 738 int* captures) {
739 return NativeRegExpMacroAssembler::Execute( 739 return NativeRegExpMacroAssembler::Execute(
740 code, 740 code,
741 input, 741 input,
742 start_offset, 742 start_offset,
743 input_start, 743 input_start,
744 input_end, 744 input_end,
745 captures, 745 captures,
746 0, 746 0,
747 Isolate::Current()); 747 CcTest::i_isolate());
748 } 748 }
749 749
750 750
751 TEST(MacroAssemblerNativeSuccess) { 751 TEST(MacroAssemblerNativeSuccess) {
752 v8::V8::Initialize(); 752 v8::V8::Initialize();
753 ContextInitializer initializer; 753 ContextInitializer initializer;
754 Isolate* isolate = Isolate::Current(); 754 Isolate* isolate = CcTest::i_isolate();
755 Factory* factory = isolate->factory(); 755 Factory* factory = isolate->factory();
756 Zone zone(isolate); 756 Zone zone(isolate);
757 757
758 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone); 758 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
759 759
760 m.Succeed(); 760 m.Succeed();
761 761
762 Handle<String> source = factory->NewStringFromAscii(CStrVector("")); 762 Handle<String> source = factory->NewStringFromAscii(CStrVector(""));
763 Handle<Object> code_object = m.GetCode(source); 763 Handle<Object> code_object = m.GetCode(source);
764 Handle<Code> code = Handle<Code>::cast(code_object); 764 Handle<Code> code = Handle<Code>::cast(code_object);
(...skipping 16 matching lines...) Expand all
781 CHECK_EQ(-1, captures[0]); 781 CHECK_EQ(-1, captures[0]);
782 CHECK_EQ(-1, captures[1]); 782 CHECK_EQ(-1, captures[1]);
783 CHECK_EQ(-1, captures[2]); 783 CHECK_EQ(-1, captures[2]);
784 CHECK_EQ(-1, captures[3]); 784 CHECK_EQ(-1, captures[3]);
785 } 785 }
786 786
787 787
788 TEST(MacroAssemblerNativeSimple) { 788 TEST(MacroAssemblerNativeSimple) {
789 v8::V8::Initialize(); 789 v8::V8::Initialize();
790 ContextInitializer initializer; 790 ContextInitializer initializer;
791 Isolate* isolate = Isolate::Current(); 791 Isolate* isolate = CcTest::i_isolate();
792 Factory* factory = isolate->factory(); 792 Factory* factory = isolate->factory();
793 Zone zone(isolate); 793 Zone zone(isolate);
794 794
795 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone); 795 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
796 796
797 Label fail, backtrack; 797 Label fail, backtrack;
798 m.PushBacktrack(&fail); 798 m.PushBacktrack(&fail);
799 m.CheckNotAtStart(NULL); 799 m.CheckNotAtStart(NULL);
800 m.LoadCurrentCharacter(2, NULL); 800 m.LoadCurrentCharacter(2, NULL);
801 m.CheckNotCharacter('o', NULL); 801 m.CheckNotCharacter('o', NULL);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 start_adr + input->length(), 847 start_adr + input->length(),
848 captures); 848 captures);
849 849
850 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); 850 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result);
851 } 851 }
852 852
853 853
854 TEST(MacroAssemblerNativeSimpleUC16) { 854 TEST(MacroAssemblerNativeSimpleUC16) {
855 v8::V8::Initialize(); 855 v8::V8::Initialize();
856 ContextInitializer initializer; 856 ContextInitializer initializer;
857 Isolate* isolate = Isolate::Current(); 857 Isolate* isolate = CcTest::i_isolate();
858 Factory* factory = isolate->factory(); 858 Factory* factory = isolate->factory();
859 Zone zone(isolate); 859 Zone zone(isolate);
860 860
861 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4, &zone); 861 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4, &zone);
862 862
863 Label fail, backtrack; 863 Label fail, backtrack;
864 m.PushBacktrack(&fail); 864 m.PushBacktrack(&fail);
865 m.CheckNotAtStart(NULL); 865 m.CheckNotAtStart(NULL);
866 m.LoadCurrentCharacter(2, NULL); 866 m.LoadCurrentCharacter(2, NULL);
867 m.CheckNotCharacter('o', NULL); 867 m.CheckNotCharacter('o', NULL);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 start_adr + input->length() * 2, 918 start_adr + input->length() * 2,
919 captures); 919 captures);
920 920
921 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); 921 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result);
922 } 922 }
923 923
924 924
925 TEST(MacroAssemblerNativeBacktrack) { 925 TEST(MacroAssemblerNativeBacktrack) {
926 v8::V8::Initialize(); 926 v8::V8::Initialize();
927 ContextInitializer initializer; 927 ContextInitializer initializer;
928 Isolate* isolate = Isolate::Current(); 928 Isolate* isolate = CcTest::i_isolate();
929 Factory* factory = isolate->factory(); 929 Factory* factory = isolate->factory();
930 Zone zone(isolate); 930 Zone zone(isolate);
931 931
932 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone); 932 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone);
933 933
934 Label fail; 934 Label fail;
935 Label backtrack; 935 Label backtrack;
936 m.LoadCurrentCharacter(10, &fail); 936 m.LoadCurrentCharacter(10, &fail);
937 m.Succeed(); 937 m.Succeed();
938 m.Bind(&fail); 938 m.Bind(&fail);
(...skipping 19 matching lines...) Expand all
958 start_adr + input->length(), 958 start_adr + input->length(),
959 NULL); 959 NULL);
960 960
961 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); 961 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result);
962 } 962 }
963 963
964 964
965 TEST(MacroAssemblerNativeBackReferenceASCII) { 965 TEST(MacroAssemblerNativeBackReferenceASCII) {
966 v8::V8::Initialize(); 966 v8::V8::Initialize();
967 ContextInitializer initializer; 967 ContextInitializer initializer;
968 Isolate* isolate = Isolate::Current(); 968 Isolate* isolate = CcTest::i_isolate();
969 Factory* factory = isolate->factory(); 969 Factory* factory = isolate->factory();
970 Zone zone(isolate); 970 Zone zone(isolate);
971 971
972 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone); 972 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
973 973
974 m.WriteCurrentPositionToRegister(0, 0); 974 m.WriteCurrentPositionToRegister(0, 0);
975 m.AdvanceCurrentPosition(2); 975 m.AdvanceCurrentPosition(2);
976 m.WriteCurrentPositionToRegister(1, 0); 976 m.WriteCurrentPositionToRegister(1, 0);
977 Label nomatch; 977 Label nomatch;
978 m.CheckNotBackReference(0, &nomatch); 978 m.CheckNotBackReference(0, &nomatch);
(...skipping 28 matching lines...) Expand all
1007 CHECK_EQ(0, output[0]); 1007 CHECK_EQ(0, output[0]);
1008 CHECK_EQ(2, output[1]); 1008 CHECK_EQ(2, output[1]);
1009 CHECK_EQ(6, output[2]); 1009 CHECK_EQ(6, output[2]);
1010 CHECK_EQ(-1, output[3]); 1010 CHECK_EQ(-1, output[3]);
1011 } 1011 }
1012 1012
1013 1013
1014 TEST(MacroAssemblerNativeBackReferenceUC16) { 1014 TEST(MacroAssemblerNativeBackReferenceUC16) {
1015 v8::V8::Initialize(); 1015 v8::V8::Initialize();
1016 ContextInitializer initializer; 1016 ContextInitializer initializer;
1017 Isolate* isolate = Isolate::Current(); 1017 Isolate* isolate = CcTest::i_isolate();
1018 Factory* factory = isolate->factory(); 1018 Factory* factory = isolate->factory();
1019 Zone zone(isolate); 1019 Zone zone(isolate);
1020 1020
1021 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4, &zone); 1021 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4, &zone);
1022 1022
1023 m.WriteCurrentPositionToRegister(0, 0); 1023 m.WriteCurrentPositionToRegister(0, 0);
1024 m.AdvanceCurrentPosition(2); 1024 m.AdvanceCurrentPosition(2);
1025 m.WriteCurrentPositionToRegister(1, 0); 1025 m.WriteCurrentPositionToRegister(1, 0);
1026 Label nomatch; 1026 Label nomatch;
1027 m.CheckNotBackReference(0, &nomatch); 1027 m.CheckNotBackReference(0, &nomatch);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 CHECK_EQ(2, output[1]); 1059 CHECK_EQ(2, output[1]);
1060 CHECK_EQ(6, output[2]); 1060 CHECK_EQ(6, output[2]);
1061 CHECK_EQ(-1, output[3]); 1061 CHECK_EQ(-1, output[3]);
1062 } 1062 }
1063 1063
1064 1064
1065 1065
1066 TEST(MacroAssemblernativeAtStart) { 1066 TEST(MacroAssemblernativeAtStart) {
1067 v8::V8::Initialize(); 1067 v8::V8::Initialize();
1068 ContextInitializer initializer; 1068 ContextInitializer initializer;
1069 Isolate* isolate = Isolate::Current(); 1069 Isolate* isolate = CcTest::i_isolate();
1070 Factory* factory = isolate->factory(); 1070 Factory* factory = isolate->factory();
1071 Zone zone(isolate); 1071 Zone zone(isolate);
1072 1072
1073 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone); 1073 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone);
1074 1074
1075 Label not_at_start, newline, fail; 1075 Label not_at_start, newline, fail;
1076 m.CheckNotAtStart(&not_at_start); 1076 m.CheckNotAtStart(&not_at_start);
1077 // Check that prevchar = '\n' and current = 'f'. 1077 // Check that prevchar = '\n' and current = 'f'.
1078 m.CheckCharacter('\n', &newline); 1078 m.CheckCharacter('\n', &newline);
1079 m.Bind(&fail); 1079 m.Bind(&fail);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 start_adr + input->length(), 1118 start_adr + input->length(),
1119 NULL); 1119 NULL);
1120 1120
1121 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); 1121 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result);
1122 } 1122 }
1123 1123
1124 1124
1125 TEST(MacroAssemblerNativeBackRefNoCase) { 1125 TEST(MacroAssemblerNativeBackRefNoCase) {
1126 v8::V8::Initialize(); 1126 v8::V8::Initialize();
1127 ContextInitializer initializer; 1127 ContextInitializer initializer;
1128 Isolate* isolate = Isolate::Current(); 1128 Isolate* isolate = CcTest::i_isolate();
1129 Factory* factory = isolate->factory(); 1129 Factory* factory = isolate->factory();
1130 Zone zone(isolate); 1130 Zone zone(isolate);
1131 1131
1132 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone); 1132 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
1133 1133
1134 Label fail, succ; 1134 Label fail, succ;
1135 1135
1136 m.WriteCurrentPositionToRegister(0, 0); 1136 m.WriteCurrentPositionToRegister(0, 0);
1137 m.WriteCurrentPositionToRegister(2, 0); 1137 m.WriteCurrentPositionToRegister(2, 0);
1138 m.AdvanceCurrentPosition(3); 1138 m.AdvanceCurrentPosition(3);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 CHECK_EQ(12, output[1]); 1177 CHECK_EQ(12, output[1]);
1178 CHECK_EQ(0, output[2]); 1178 CHECK_EQ(0, output[2]);
1179 CHECK_EQ(3, output[3]); 1179 CHECK_EQ(3, output[3]);
1180 } 1180 }
1181 1181
1182 1182
1183 1183
1184 TEST(MacroAssemblerNativeRegisters) { 1184 TEST(MacroAssemblerNativeRegisters) {
1185 v8::V8::Initialize(); 1185 v8::V8::Initialize();
1186 ContextInitializer initializer; 1186 ContextInitializer initializer;
1187 Isolate* isolate = Isolate::Current(); 1187 Isolate* isolate = CcTest::i_isolate();
1188 Factory* factory = isolate->factory(); 1188 Factory* factory = isolate->factory();
1189 Zone zone(isolate); 1189 Zone zone(isolate);
1190 1190
1191 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 6, &zone); 1191 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 6, &zone);
1192 1192
1193 uc16 foo_chars[3] = {'f', 'o', 'o'}; 1193 uc16 foo_chars[3] = {'f', 'o', 'o'};
1194 Vector<const uc16> foo(foo_chars, 3); 1194 Vector<const uc16> foo(foo_chars, 3);
1195 1195
1196 enum registers { out1, out2, out3, out4, out5, out6, sp, loop_cnt }; 1196 enum registers { out1, out2, out3, out4, out5, out6, sp, loop_cnt };
1197 Label fail; 1197 Label fail;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 CHECK_EQ(6, output[2]); 1280 CHECK_EQ(6, output[2]);
1281 CHECK_EQ(9, output[3]); 1281 CHECK_EQ(9, output[3]);
1282 CHECK_EQ(9, output[4]); 1282 CHECK_EQ(9, output[4]);
1283 CHECK_EQ(-1, output[5]); 1283 CHECK_EQ(-1, output[5]);
1284 } 1284 }
1285 1285
1286 1286
1287 TEST(MacroAssemblerStackOverflow) { 1287 TEST(MacroAssemblerStackOverflow) {
1288 v8::V8::Initialize(); 1288 v8::V8::Initialize();
1289 ContextInitializer initializer; 1289 ContextInitializer initializer;
1290 Isolate* isolate = Isolate::Current(); 1290 Isolate* isolate = CcTest::i_isolate();
1291 Factory* factory = isolate->factory(); 1291 Factory* factory = isolate->factory();
1292 Zone zone(isolate); 1292 Zone zone(isolate);
1293 1293
1294 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone); 1294 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone);
1295 1295
1296 Label loop; 1296 Label loop;
1297 m.Bind(&loop); 1297 m.Bind(&loop);
1298 m.PushBacktrack(&loop); 1298 m.PushBacktrack(&loop);
1299 m.GoTo(&loop); 1299 m.GoTo(&loop);
1300 1300
(...skipping 18 matching lines...) Expand all
1319 1319
1320 CHECK_EQ(NativeRegExpMacroAssembler::EXCEPTION, result); 1320 CHECK_EQ(NativeRegExpMacroAssembler::EXCEPTION, result);
1321 CHECK(isolate->has_pending_exception()); 1321 CHECK(isolate->has_pending_exception());
1322 isolate->clear_pending_exception(); 1322 isolate->clear_pending_exception();
1323 } 1323 }
1324 1324
1325 1325
1326 TEST(MacroAssemblerNativeLotsOfRegisters) { 1326 TEST(MacroAssemblerNativeLotsOfRegisters) {
1327 v8::V8::Initialize(); 1327 v8::V8::Initialize();
1328 ContextInitializer initializer; 1328 ContextInitializer initializer;
1329 Isolate* isolate = Isolate::Current(); 1329 Isolate* isolate = CcTest::i_isolate();
1330 Factory* factory = isolate->factory(); 1330 Factory* factory = isolate->factory();
1331 Zone zone(isolate); 1331 Zone zone(isolate);
1332 1332
1333 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 2, &zone); 1333 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 2, &zone);
1334 1334
1335 // At least 2048, to ensure the allocated space for registers 1335 // At least 2048, to ensure the allocated space for registers
1336 // span one full page. 1336 // span one full page.
1337 const int large_number = 8000; 1337 const int large_number = 8000;
1338 m.WriteCurrentPositionToRegister(large_number, 42); 1338 m.WriteCurrentPositionToRegister(large_number, 42);
1339 m.WriteCurrentPositionToRegister(0, 0); 1339 m.WriteCurrentPositionToRegister(0, 0);
(...skipping 30 matching lines...) Expand all
1370 CHECK_EQ(42, captures[1]); 1370 CHECK_EQ(42, captures[1]);
1371 1371
1372 isolate->clear_pending_exception(); 1372 isolate->clear_pending_exception();
1373 } 1373 }
1374 1374
1375 #else // V8_INTERPRETED_REGEXP 1375 #else // V8_INTERPRETED_REGEXP
1376 1376
1377 TEST(MacroAssembler) { 1377 TEST(MacroAssembler) {
1378 V8::Initialize(NULL); 1378 V8::Initialize(NULL);
1379 byte codes[1024]; 1379 byte codes[1024];
1380 Zone zone(Isolate::Current()); 1380 Zone zone(CcTest::i_isolate());
1381 RegExpMacroAssemblerIrregexp m(Vector<byte>(codes, 1024), &zone); 1381 RegExpMacroAssemblerIrregexp m(Vector<byte>(codes, 1024), &zone);
1382 // ^f(o)o. 1382 // ^f(o)o.
1383 Label start, fail, backtrack; 1383 Label start, fail, backtrack;
1384 1384
1385 m.SetRegister(4, 42); 1385 m.SetRegister(4, 42);
1386 m.PushRegister(4, RegExpMacroAssembler::kNoStackLimitCheck); 1386 m.PushRegister(4, RegExpMacroAssembler::kNoStackLimitCheck);
1387 m.AdvanceRegister(4, 42); 1387 m.AdvanceRegister(4, 42);
1388 m.GoTo(&start); 1388 m.GoTo(&start);
1389 m.Fail(); 1389 m.Fail();
1390 m.Bind(&start); 1390 m.Bind(&start);
(...skipping 12 matching lines...) Expand all
1403 m.AdvanceCurrentPosition(3); 1403 m.AdvanceCurrentPosition(3);
1404 m.PushBacktrack(&backtrack); 1404 m.PushBacktrack(&backtrack);
1405 m.Succeed(); 1405 m.Succeed();
1406 m.Bind(&backtrack); 1406 m.Bind(&backtrack);
1407 m.ClearRegisters(2, 3); 1407 m.ClearRegisters(2, 3);
1408 m.Backtrack(); 1408 m.Backtrack();
1409 m.Bind(&fail); 1409 m.Bind(&fail);
1410 m.PopRegister(0); 1410 m.PopRegister(0);
1411 m.Fail(); 1411 m.Fail();
1412 1412
1413 Isolate* isolate = Isolate::Current(); 1413 Isolate* isolate = CcTest::i_isolate();
1414 Factory* factory = isolate->factory(); 1414 Factory* factory = isolate->factory();
1415 HandleScope scope(isolate); 1415 HandleScope scope(isolate);
1416 1416
1417 Handle<String> source = factory->NewStringFromAscii(CStrVector("^f(o)o")); 1417 Handle<String> source = factory->NewStringFromAscii(CStrVector("^f(o)o"));
1418 Handle<ByteArray> array = Handle<ByteArray>::cast(m.GetCode(source)); 1418 Handle<ByteArray> array = Handle<ByteArray>::cast(m.GetCode(source));
1419 int captures[5]; 1419 int captures[5];
1420 1420
1421 const uc16 str1[] = {'f', 'o', 'o', 'b', 'a', 'r'}; 1421 const uc16 str1[] = {'f', 'o', 'o', 'b', 'a', 'r'};
1422 Handle<String> f1_16 = 1422 Handle<String> f1_16 =
1423 factory->NewStringFromTwoByte(Vector<const uc16>(str1, 6)); 1423 factory->NewStringFromTwoByte(Vector<const uc16>(str1, 6));
(...skipping 14 matching lines...) Expand all
1438 } 1438 }
1439 1439
1440 #endif // V8_INTERPRETED_REGEXP 1440 #endif // V8_INTERPRETED_REGEXP
1441 1441
1442 1442
1443 TEST(AddInverseToTable) { 1443 TEST(AddInverseToTable) {
1444 v8::internal::V8::Initialize(NULL); 1444 v8::internal::V8::Initialize(NULL);
1445 static const int kLimit = 1000; 1445 static const int kLimit = 1000;
1446 static const int kRangeCount = 16; 1446 static const int kRangeCount = 16;
1447 for (int t = 0; t < 10; t++) { 1447 for (int t = 0; t < 10; t++) {
1448 Zone zone(Isolate::Current()); 1448 Zone zone(CcTest::i_isolate());
1449 ZoneList<CharacterRange>* ranges = 1449 ZoneList<CharacterRange>* ranges =
1450 new(&zone) ZoneList<CharacterRange>(kRangeCount, &zone); 1450 new(&zone) ZoneList<CharacterRange>(kRangeCount, &zone);
1451 for (int i = 0; i < kRangeCount; i++) { 1451 for (int i = 0; i < kRangeCount; i++) {
1452 int from = PseudoRandom(t + 87, i + 25) % kLimit; 1452 int from = PseudoRandom(t + 87, i + 25) % kLimit;
1453 int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20)); 1453 int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20));
1454 if (to > kLimit) to = kLimit; 1454 if (to > kLimit) to = kLimit;
1455 ranges->Add(CharacterRange(from, to), &zone); 1455 ranges->Add(CharacterRange(from, to), &zone);
1456 } 1456 }
1457 DispatchTable table(&zone); 1457 DispatchTable table(&zone);
1458 DispatchTableConstructor cons(&table, false, &zone); 1458 DispatchTableConstructor cons(&table, false, &zone);
1459 cons.set_choice_index(0); 1459 cons.set_choice_index(0);
1460 cons.AddInverse(ranges); 1460 cons.AddInverse(ranges);
1461 for (int i = 0; i < kLimit; i++) { 1461 for (int i = 0; i < kLimit; i++) {
1462 bool is_on = false; 1462 bool is_on = false;
1463 for (int j = 0; !is_on && j < kRangeCount; j++) 1463 for (int j = 0; !is_on && j < kRangeCount; j++)
1464 is_on = ranges->at(j).Contains(i); 1464 is_on = ranges->at(j).Contains(i);
1465 OutSet* set = table.Get(i); 1465 OutSet* set = table.Get(i);
1466 CHECK_EQ(is_on, set->Get(0) == false); 1466 CHECK_EQ(is_on, set->Get(0) == false);
1467 } 1467 }
1468 } 1468 }
1469 Zone zone(Isolate::Current()); 1469 Zone zone(CcTest::i_isolate());
1470 ZoneList<CharacterRange>* ranges = 1470 ZoneList<CharacterRange>* ranges =
1471 new(&zone) ZoneList<CharacterRange>(1, &zone); 1471 new(&zone) ZoneList<CharacterRange>(1, &zone);
1472 ranges->Add(CharacterRange(0xFFF0, 0xFFFE), &zone); 1472 ranges->Add(CharacterRange(0xFFF0, 0xFFFE), &zone);
1473 DispatchTable table(&zone); 1473 DispatchTable table(&zone);
1474 DispatchTableConstructor cons(&table, false, &zone); 1474 DispatchTableConstructor cons(&table, false, &zone);
1475 cons.set_choice_index(0); 1475 cons.set_choice_index(0);
1476 cons.AddInverse(ranges); 1476 cons.AddInverse(ranges);
1477 CHECK(!table.Get(0xFFFE)->Get(0)); 1477 CHECK(!table.Get(0xFFFE)->Get(0));
1478 CHECK(table.Get(0xFFFF)->Get(0)); 1478 CHECK(table.Get(0xFFFF)->Get(0));
1479 } 1479 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 CHECK_EQ(length, length2); 1572 CHECK_EQ(length, length2);
1573 for (int k = 0; k < length; k++) 1573 for (int k = 0; k < length; k++)
1574 CHECK_EQ(static_cast<int>(chars[k]), static_cast<int>(chars2[k])); 1574 CHECK_EQ(static_cast<int>(chars[k]), static_cast<int>(chars2[k]));
1575 } 1575 }
1576 } 1576 }
1577 } 1577 }
1578 1578
1579 1579
1580 static void TestRangeCaseIndependence(CharacterRange input, 1580 static void TestRangeCaseIndependence(CharacterRange input,
1581 Vector<CharacterRange> expected) { 1581 Vector<CharacterRange> expected) {
1582 Zone zone(Isolate::Current()); 1582 Zone zone(CcTest::i_isolate());
1583 int count = expected.length(); 1583 int count = expected.length();
1584 ZoneList<CharacterRange>* list = 1584 ZoneList<CharacterRange>* list =
1585 new(&zone) ZoneList<CharacterRange>(count, &zone); 1585 new(&zone) ZoneList<CharacterRange>(count, &zone);
1586 input.AddCaseEquivalents(list, false, &zone); 1586 input.AddCaseEquivalents(list, false, &zone);
1587 CHECK_EQ(count, list->length()); 1587 CHECK_EQ(count, list->length());
1588 for (int i = 0; i < list->length(); i++) { 1588 for (int i = 0; i < list->length(); i++) {
1589 CHECK_EQ(expected[i].from(), list->at(i).from()); 1589 CHECK_EQ(expected[i].from(), list->at(i).from());
1590 CHECK_EQ(expected[i].to(), list->at(i).to()); 1590 CHECK_EQ(expected[i].to(), list->at(i).to());
1591 } 1591 }
1592 } 1592 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 CharacterRange range = ranges->at(i); 1637 CharacterRange range = ranges->at(i);
1638 if (range.from() <= c && c <= range.to()) 1638 if (range.from() <= c && c <= range.to())
1639 return true; 1639 return true;
1640 } 1640 }
1641 return false; 1641 return false;
1642 } 1642 }
1643 1643
1644 1644
1645 TEST(CharClassDifference) { 1645 TEST(CharClassDifference) {
1646 v8::internal::V8::Initialize(NULL); 1646 v8::internal::V8::Initialize(NULL);
1647 Zone zone(Isolate::Current()); 1647 Zone zone(CcTest::i_isolate());
1648 ZoneList<CharacterRange>* base = 1648 ZoneList<CharacterRange>* base =
1649 new(&zone) ZoneList<CharacterRange>(1, &zone); 1649 new(&zone) ZoneList<CharacterRange>(1, &zone);
1650 base->Add(CharacterRange::Everything(), &zone); 1650 base->Add(CharacterRange::Everything(), &zone);
1651 Vector<const int> overlay = CharacterRange::GetWordBounds(); 1651 Vector<const int> overlay = CharacterRange::GetWordBounds();
1652 ZoneList<CharacterRange>* included = NULL; 1652 ZoneList<CharacterRange>* included = NULL;
1653 ZoneList<CharacterRange>* excluded = NULL; 1653 ZoneList<CharacterRange>* excluded = NULL;
1654 CharacterRange::Split(base, overlay, &included, &excluded, &zone); 1654 CharacterRange::Split(base, overlay, &included, &excluded, &zone);
1655 for (int i = 0; i < (1 << 16); i++) { 1655 for (int i = 0; i < (1 << 16); i++) {
1656 bool in_base = InClass(i, base); 1656 bool in_base = InClass(i, base);
1657 if (in_base) { 1657 if (in_base) {
1658 bool in_overlay = false; 1658 bool in_overlay = false;
1659 for (int j = 0; !in_overlay && j < overlay.length(); j += 2) { 1659 for (int j = 0; !in_overlay && j < overlay.length(); j += 2) {
1660 if (overlay[j] <= i && i < overlay[j+1]) 1660 if (overlay[j] <= i && i < overlay[j+1])
1661 in_overlay = true; 1661 in_overlay = true;
1662 } 1662 }
1663 CHECK_EQ(in_overlay, InClass(i, included)); 1663 CHECK_EQ(in_overlay, InClass(i, included));
1664 CHECK_EQ(!in_overlay, InClass(i, excluded)); 1664 CHECK_EQ(!in_overlay, InClass(i, excluded));
1665 } else { 1665 } else {
1666 CHECK(!InClass(i, included)); 1666 CHECK(!InClass(i, included));
1667 CHECK(!InClass(i, excluded)); 1667 CHECK(!InClass(i, excluded));
1668 } 1668 }
1669 } 1669 }
1670 } 1670 }
1671 1671
1672 1672
1673 TEST(CanonicalizeCharacterSets) { 1673 TEST(CanonicalizeCharacterSets) {
1674 v8::internal::V8::Initialize(NULL); 1674 v8::internal::V8::Initialize(NULL);
1675 Zone zone(Isolate::Current()); 1675 Zone zone(CcTest::i_isolate());
1676 ZoneList<CharacterRange>* list = 1676 ZoneList<CharacterRange>* list =
1677 new(&zone) ZoneList<CharacterRange>(4, &zone); 1677 new(&zone) ZoneList<CharacterRange>(4, &zone);
1678 CharacterSet set(list); 1678 CharacterSet set(list);
1679 1679
1680 list->Add(CharacterRange(10, 20), &zone); 1680 list->Add(CharacterRange(10, 20), &zone);
1681 list->Add(CharacterRange(30, 40), &zone); 1681 list->Add(CharacterRange(30, 40), &zone);
1682 list->Add(CharacterRange(50, 60), &zone); 1682 list->Add(CharacterRange(50, 60), &zone);
1683 set.Canonicalize(); 1683 set.Canonicalize();
1684 ASSERT_EQ(3, list->length()); 1684 ASSERT_EQ(3, list->length());
1685 ASSERT_EQ(10, list->at(0).from()); 1685 ASSERT_EQ(10, list->at(0).from());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 list->Add(CharacterRange(20, 20), &zone); 1727 list->Add(CharacterRange(20, 20), &zone);
1728 set.Canonicalize(); 1728 set.Canonicalize();
1729 ASSERT_EQ(1, list->length()); 1729 ASSERT_EQ(1, list->length());
1730 ASSERT_EQ(10, list->at(0).from()); 1730 ASSERT_EQ(10, list->at(0).from());
1731 ASSERT_EQ(30, list->at(0).to()); 1731 ASSERT_EQ(30, list->at(0).to());
1732 } 1732 }
1733 1733
1734 1734
1735 TEST(CharacterRangeMerge) { 1735 TEST(CharacterRangeMerge) {
1736 v8::internal::V8::Initialize(NULL); 1736 v8::internal::V8::Initialize(NULL);
1737 Zone zone(Isolate::Current()); 1737 Zone zone(CcTest::i_isolate());
1738 ZoneList<CharacterRange> l1(4, &zone); 1738 ZoneList<CharacterRange> l1(4, &zone);
1739 ZoneList<CharacterRange> l2(4, &zone); 1739 ZoneList<CharacterRange> l2(4, &zone);
1740 // Create all combinations of intersections of ranges, both singletons and 1740 // Create all combinations of intersections of ranges, both singletons and
1741 // longer. 1741 // longer.
1742 1742
1743 int offset = 0; 1743 int offset = 0;
1744 1744
1745 // The five kinds of singleton intersections: 1745 // The five kinds of singleton intersections:
1746 // X 1746 // X
1747 // Y - outside before 1747 // Y - outside before
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1817 ZoneList<CharacterRange> first_only(4, &zone); 1817 ZoneList<CharacterRange> first_only(4, &zone);
1818 ZoneList<CharacterRange> second_only(4, &zone); 1818 ZoneList<CharacterRange> second_only(4, &zone);
1819 ZoneList<CharacterRange> both(4, &zone); 1819 ZoneList<CharacterRange> both(4, &zone);
1820 } 1820 }
1821 1821
1822 1822
1823 TEST(Graph) { 1823 TEST(Graph) {
1824 V8::Initialize(NULL); 1824 V8::Initialize(NULL);
1825 Execute("\\b\\w+\\b", false, true, true); 1825 Execute("\\b\\w+\\b", false, true, true);
1826 } 1826 }
OLDNEW
« no previous file with comments | « test/cctest/test-random.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698