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

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

Issue 142813003: A64: Synchronize with r15358. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-profile-generator.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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(v8::Isolate::GetCurrent());
80 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 80 Zone zone(Isolate::Current());
81 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 81 FlatStringReader reader(Isolate::Current(), CStrVector(input));
82 RegExpCompileData result; 82 RegExpCompileData result;
83 return v8::internal::RegExpParser::ParseRegExp( 83 return v8::internal::RegExpParser::ParseRegExp(
84 &reader, false, &result, Isolate::Current()->runtime_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(v8::Isolate::GetCurrent());
91 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 91 Zone zone(Isolate::Current());
92 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 92 FlatStringReader reader(Isolate::Current(), CStrVector(input));
93 RegExpCompileData result; 93 RegExpCompileData result;
94 CHECK(v8::internal::RegExpParser::ParseRegExp( 94 CHECK(v8::internal::RegExpParser::ParseRegExp(
95 &reader, false, &result, Isolate::Current()->runtime_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 = 98 SmartArrayPointer<const char> output = result.tree->ToString(&zone);
99 result.tree->ToString(Isolate::Current()->runtime_zone());
100 return output; 99 return output;
101 } 100 }
102 101
103 static bool CheckSimple(const char* input) { 102 static bool CheckSimple(const char* input) {
104 V8::Initialize(NULL); 103 V8::Initialize(NULL);
105 v8::HandleScope scope(v8::Isolate::GetCurrent()); 104 v8::HandleScope scope(v8::Isolate::GetCurrent());
106 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 105 Zone zone(Isolate::Current());
107 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 106 FlatStringReader reader(Isolate::Current(), CStrVector(input));
108 RegExpCompileData result; 107 RegExpCompileData result;
109 CHECK(v8::internal::RegExpParser::ParseRegExp( 108 CHECK(v8::internal::RegExpParser::ParseRegExp(
110 &reader, false, &result, Isolate::Current()->runtime_zone())); 109 &reader, false, &result, &zone));
111 CHECK(result.tree != NULL); 110 CHECK(result.tree != NULL);
112 CHECK(result.error.is_null()); 111 CHECK(result.error.is_null());
113 return result.simple; 112 return result.simple;
114 } 113 }
115 114
116 struct MinMaxPair { 115 struct MinMaxPair {
117 int min_match; 116 int min_match;
118 int max_match; 117 int max_match;
119 }; 118 };
120 119
121 static MinMaxPair CheckMinMaxMatch(const char* input) { 120 static MinMaxPair CheckMinMaxMatch(const char* input) {
122 V8::Initialize(NULL); 121 V8::Initialize(NULL);
123 v8::HandleScope scope(v8::Isolate::GetCurrent()); 122 v8::HandleScope scope(v8::Isolate::GetCurrent());
124 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 123 Zone zone(Isolate::Current());
125 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 124 FlatStringReader reader(Isolate::Current(), CStrVector(input));
126 RegExpCompileData result; 125 RegExpCompileData result;
127 CHECK(v8::internal::RegExpParser::ParseRegExp( 126 CHECK(v8::internal::RegExpParser::ParseRegExp(
128 &reader, false, &result, Isolate::Current()->runtime_zone())); 127 &reader, false, &result, &zone));
129 CHECK(result.tree != NULL); 128 CHECK(result.tree != NULL);
130 CHECK(result.error.is_null()); 129 CHECK(result.error.is_null());
131 int min_match = result.tree->min_match(); 130 int min_match = result.tree->min_match();
132 int max_match = result.tree->max_match(); 131 int max_match = result.tree->max_match();
133 MinMaxPair pair = { min_match, max_match }; 132 MinMaxPair pair = { min_match, max_match };
134 return pair; 133 return pair;
135 } 134 }
136 135
137 136
138 #define CHECK_PARSE_ERROR(input) CHECK(!CheckParse(input)) 137 #define CHECK_PARSE_ERROR(input) CHECK(!CheckParse(input))
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 CHECK_PARSE_EQ("[A-Z$-][x]", "(! [A-Z $ -] [x])"); 386 CHECK_PARSE_EQ("[A-Z$-][x]", "(! [A-Z $ -] [x])");
388 CHECK_PARSE_EQ("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')"); 387 CHECK_PARSE_EQ("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')");
389 CHECK_PARSE_EQ("{", "'{'"); 388 CHECK_PARSE_EQ("{", "'{'");
390 CHECK_PARSE_EQ("a|", "(| 'a' %)"); 389 CHECK_PARSE_EQ("a|", "(| 'a' %)");
391 } 390 }
392 391
393 static void ExpectError(const char* input, 392 static void ExpectError(const char* input,
394 const char* expected) { 393 const char* expected) {
395 V8::Initialize(NULL); 394 V8::Initialize(NULL);
396 v8::HandleScope scope(v8::Isolate::GetCurrent()); 395 v8::HandleScope scope(v8::Isolate::GetCurrent());
397 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 396 Zone zone(Isolate::Current());
398 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 397 FlatStringReader reader(Isolate::Current(), CStrVector(input));
399 RegExpCompileData result; 398 RegExpCompileData result;
400 CHECK(!v8::internal::RegExpParser::ParseRegExp( 399 CHECK(!v8::internal::RegExpParser::ParseRegExp(
401 &reader, false, &result, Isolate::Current()->runtime_zone())); 400 &reader, false, &result, &zone));
402 CHECK(result.tree == NULL); 401 CHECK(result.tree == NULL);
403 CHECK(!result.error.is_null()); 402 CHECK(!result.error.is_null());
404 SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS); 403 SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS);
405 CHECK_EQ(expected, *str); 404 CHECK_EQ(expected, *str);
406 } 405 }
407 406
408 407
409 TEST(Errors) { 408 TEST(Errors) {
410 V8::Initialize(NULL); 409 V8::Initialize(NULL);
411 const char* kEndBackslash = "\\ at end of pattern"; 410 const char* kEndBackslash = "\\ at end of pattern";
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 return !IsWhiteSpace(c); 470 return !IsWhiteSpace(c);
472 } 471 }
473 472
474 473
475 static bool NotWord(uc16 c) { 474 static bool NotWord(uc16 c) {
476 return !IsRegExpWord(c); 475 return !IsRegExpWord(c);
477 } 476 }
478 477
479 478
480 static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) { 479 static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) {
481 ZoneScope scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 480 Zone zone(Isolate::Current());
482 Zone* zone = Isolate::Current()->runtime_zone();
483 ZoneList<CharacterRange>* ranges = 481 ZoneList<CharacterRange>* ranges =
484 new(zone) ZoneList<CharacterRange>(2, zone); 482 new(&zone) ZoneList<CharacterRange>(2, &zone);
485 CharacterRange::AddClassEscape(c, ranges, zone); 483 CharacterRange::AddClassEscape(c, ranges, &zone);
486 for (unsigned i = 0; i < (1 << 16); i++) { 484 for (unsigned i = 0; i < (1 << 16); i++) {
487 bool in_class = false; 485 bool in_class = false;
488 for (int j = 0; !in_class && j < ranges->length(); j++) { 486 for (int j = 0; !in_class && j < ranges->length(); j++) {
489 CharacterRange& range = ranges->at(j); 487 CharacterRange& range = ranges->at(j);
490 in_class = (range.from() <= i && i <= range.to()); 488 in_class = (range.from() <= i && i <= range.to());
491 } 489 }
492 CHECK_EQ(pred(i), in_class); 490 CHECK_EQ(pred(i), in_class);
493 } 491 }
494 } 492 }
495 493
496 494
497 TEST(CharacterClassEscapes) { 495 TEST(CharacterClassEscapes) {
498 v8::internal::V8::Initialize(NULL); 496 v8::internal::V8::Initialize(NULL);
499 TestCharacterClassEscapes('.', IsRegExpNewline); 497 TestCharacterClassEscapes('.', IsRegExpNewline);
500 TestCharacterClassEscapes('d', IsDigit); 498 TestCharacterClassEscapes('d', IsDigit);
501 TestCharacterClassEscapes('D', NotDigit); 499 TestCharacterClassEscapes('D', NotDigit);
502 TestCharacterClassEscapes('s', IsWhiteSpace); 500 TestCharacterClassEscapes('s', IsWhiteSpace);
503 TestCharacterClassEscapes('S', NotWhiteSpace); 501 TestCharacterClassEscapes('S', NotWhiteSpace);
504 TestCharacterClassEscapes('w', IsRegExpWord); 502 TestCharacterClassEscapes('w', IsRegExpWord);
505 TestCharacterClassEscapes('W', NotWord); 503 TestCharacterClassEscapes('W', NotWord);
506 } 504 }
507 505
508 506
509 static RegExpNode* Compile(const char* input, bool multiline, bool is_ascii) { 507 static RegExpNode* Compile(const char* input,
508 bool multiline,
509 bool is_ascii,
510 Zone* zone) {
510 V8::Initialize(NULL); 511 V8::Initialize(NULL);
511 Isolate* isolate = Isolate::Current(); 512 Isolate* isolate = Isolate::Current();
512 FlatStringReader reader(isolate, CStrVector(input)); 513 FlatStringReader reader(isolate, CStrVector(input));
513 RegExpCompileData compile_data; 514 RegExpCompileData compile_data;
514 if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline, 515 if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline,
515 &compile_data, 516 &compile_data, zone))
516 isolate->runtime_zone()))
517 return NULL; 517 return NULL;
518 Handle<String> pattern = isolate->factory()-> 518 Handle<String> pattern = isolate->factory()->
519 NewStringFromUtf8(CStrVector(input)); 519 NewStringFromUtf8(CStrVector(input));
520 Handle<String> sample_subject = 520 Handle<String> sample_subject =
521 isolate->factory()->NewStringFromUtf8(CStrVector("")); 521 isolate->factory()->NewStringFromUtf8(CStrVector(""));
522 RegExpEngine::Compile(&compile_data, 522 RegExpEngine::Compile(&compile_data,
523 false, 523 false,
524 false, 524 false,
525 multiline, 525 multiline,
526 pattern, 526 pattern,
527 sample_subject, 527 sample_subject,
528 is_ascii, 528 is_ascii,
529 isolate->runtime_zone()); 529 zone);
530 return compile_data.node; 530 return compile_data.node;
531 } 531 }
532 532
533 533
534 static void Execute(const char* input, 534 static void Execute(const char* input,
535 bool multiline, 535 bool multiline,
536 bool is_ascii, 536 bool is_ascii,
537 bool dot_output = false) { 537 bool dot_output = false) {
538 v8::HandleScope scope(v8::Isolate::GetCurrent()); 538 v8::HandleScope scope(v8::Isolate::GetCurrent());
539 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 539 Zone zone(Isolate::Current());
540 RegExpNode* node = Compile(input, multiline, is_ascii); 540 RegExpNode* node = Compile(input, multiline, is_ascii, &zone);
541 USE(node); 541 USE(node);
542 #ifdef DEBUG 542 #ifdef DEBUG
543 if (dot_output) { 543 if (dot_output) {
544 RegExpEngine::DotPrint(input, node, false); 544 RegExpEngine::DotPrint(input, node, false);
545 exit(0); 545 exit(0);
546 } 546 }
547 #endif // DEBUG 547 #endif // DEBUG
548 } 548 }
549 549
550 550
(...skipping 18 matching lines...) Expand all
569 569
570 570
571 static unsigned PseudoRandom(int i, int j) { 571 static unsigned PseudoRandom(int i, int j) {
572 return ~(~((i * 781) ^ (j * 329))); 572 return ~(~((i * 781) ^ (j * 329)));
573 } 573 }
574 574
575 575
576 TEST(SplayTreeSimple) { 576 TEST(SplayTreeSimple) {
577 v8::internal::V8::Initialize(NULL); 577 v8::internal::V8::Initialize(NULL);
578 static const unsigned kLimit = 1000; 578 static const unsigned kLimit = 1000;
579 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 579 Zone zone(Isolate::Current());
580 ZoneSplayTree<TestConfig> tree(Isolate::Current()->runtime_zone()); 580 ZoneSplayTree<TestConfig> tree(&zone);
581 bool seen[kLimit]; 581 bool seen[kLimit];
582 for (unsigned i = 0; i < kLimit; i++) seen[i] = false; 582 for (unsigned i = 0; i < kLimit; i++) seen[i] = false;
583 #define CHECK_MAPS_EQUAL() do { \ 583 #define CHECK_MAPS_EQUAL() do { \
584 for (unsigned k = 0; k < kLimit; k++) \ 584 for (unsigned k = 0; k < kLimit; k++) \
585 CHECK_EQ(seen[k], tree.Find(k, &loc)); \ 585 CHECK_EQ(seen[k], tree.Find(k, &loc)); \
586 } while (false) 586 } while (false)
587 for (int i = 0; i < 50; i++) { 587 for (int i = 0; i < 50; i++) {
588 for (int j = 0; j < 50; j++) { 588 for (int j = 0; j < 50; j++) {
589 unsigned next = PseudoRandom(i, j) % kLimit; 589 unsigned next = PseudoRandom(i, j) % kLimit;
590 if (seen[next]) { 590 if (seen[next]) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 Vector<uc16> range(ranges[i], 2 * kRangeSize); 637 Vector<uc16> range(ranges[i], 2 * kRangeSize);
638 for (int j = 0; j < 2 * kRangeSize; j++) { 638 for (int j = 0; j < 2 * kRangeSize; j++) {
639 range[j] = PseudoRandom(i + 25, j + 87) % kLimit; 639 range[j] = PseudoRandom(i + 25, j + 87) % kLimit;
640 } 640 }
641 range.Sort(); 641 range.Sort();
642 for (int j = 1; j < 2 * kRangeSize; j++) { 642 for (int j = 1; j < 2 * kRangeSize; j++) {
643 CHECK(range[j-1] <= range[j]); 643 CHECK(range[j-1] <= range[j]);
644 } 644 }
645 } 645 }
646 // Enter test data into dispatch table. 646 // Enter test data into dispatch table.
647 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 647 Zone zone(Isolate::Current());
648 DispatchTable table(Isolate::Current()->runtime_zone()); 648 DispatchTable table(&zone);
649 for (int i = 0; i < kRangeCount; i++) { 649 for (int i = 0; i < kRangeCount; i++) {
650 uc16* range = ranges[i]; 650 uc16* range = ranges[i];
651 for (int j = 0; j < 2 * kRangeSize; j += 2) 651 for (int j = 0; j < 2 * kRangeSize; j += 2)
652 table.AddRange(CharacterRange(range[j], range[j + 1]), i, 652 table.AddRange(CharacterRange(range[j], range[j + 1]), i, &zone);
653 Isolate::Current()->runtime_zone());
654 } 653 }
655 // Check that the table looks as we would expect 654 // Check that the table looks as we would expect
656 for (int p = 0; p < kLimit; p++) { 655 for (int p = 0; p < kLimit; p++) {
657 OutSet* outs = table.Get(p); 656 OutSet* outs = table.Get(p);
658 for (int j = 0; j < kRangeCount; j++) { 657 for (int j = 0; j < kRangeCount; j++) {
659 uc16* range = ranges[j]; 658 uc16* range = ranges[j];
660 bool is_on = false; 659 bool is_on = false;
661 for (int k = 0; !is_on && (k < 2 * kRangeSize); k += 2) 660 for (int k = 0; !is_on && (k < 2 * kRangeSize); k += 2)
662 is_on = (range[k] <= p && p <= range[k + 1]); 661 is_on = (range[k] <= p && p <= range[k + 1]);
663 CHECK_EQ(is_on, outs->Get(j)); 662 CHECK_EQ(is_on, outs->Get(j));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 #elif V8_TARGET_ARCH_A64 707 #elif V8_TARGET_ARCH_A64
709 typedef RegExpMacroAssemblerA64 ArchRegExpMacroAssembler; 708 typedef RegExpMacroAssemblerA64 ArchRegExpMacroAssembler;
710 #elif V8_TARGET_ARCH_MIPS 709 #elif V8_TARGET_ARCH_MIPS
711 typedef RegExpMacroAssemblerMIPS ArchRegExpMacroAssembler; 710 typedef RegExpMacroAssemblerMIPS ArchRegExpMacroAssembler;
712 #endif 711 #endif
713 712
714 class ContextInitializer { 713 class ContextInitializer {
715 public: 714 public:
716 ContextInitializer() 715 ContextInitializer()
717 : scope_(v8::Isolate::GetCurrent()), 716 : scope_(v8::Isolate::GetCurrent()),
718 env_(v8::Context::New(v8::Isolate::GetCurrent())), 717 env_(v8::Context::New(v8::Isolate::GetCurrent())) {
719 zone_(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT) {
720 env_->Enter(); 718 env_->Enter();
721 } 719 }
722 ~ContextInitializer() { 720 ~ContextInitializer() {
723 env_->Exit(); 721 env_->Exit();
724 } 722 }
725 private: 723 private:
726 v8::HandleScope scope_; 724 v8::HandleScope scope_;
727 v8::Handle<v8::Context> env_; 725 v8::Handle<v8::Context> env_;
728 v8::internal::ZoneScope zone_;
729 }; 726 };
730 727
731 728
732 static ArchRegExpMacroAssembler::Result Execute(Code* code, 729 static ArchRegExpMacroAssembler::Result Execute(Code* code,
733 String* input, 730 String* input,
734 int start_offset, 731 int start_offset,
735 const byte* input_start, 732 const byte* input_start,
736 const byte* input_end, 733 const byte* input_end,
737 int* captures) { 734 int* captures) {
738 return NativeRegExpMacroAssembler::Execute( 735 return NativeRegExpMacroAssembler::Execute(
739 code, 736 code,
740 input, 737 input,
741 start_offset, 738 start_offset,
742 input_start, 739 input_start,
743 input_end, 740 input_end,
744 captures, 741 captures,
745 0, 742 0,
746 Isolate::Current()); 743 Isolate::Current());
747 } 744 }
748 745
749 746
750 TEST(MacroAssemblerNativeSuccess) { 747 TEST(MacroAssemblerNativeSuccess) {
751 v8::V8::Initialize(); 748 v8::V8::Initialize();
752 ContextInitializer initializer; 749 ContextInitializer initializer;
753 Factory* factory = Isolate::Current()->factory(); 750 Isolate* isolate = Isolate::Current();
751 Factory* factory = isolate->factory();
752 Zone zone(isolate);
754 753
755 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, 754 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
756 Isolate::Current()->runtime_zone());
757 755
758 m.Succeed(); 756 m.Succeed();
759 757
760 Handle<String> source = factory->NewStringFromAscii(CStrVector("")); 758 Handle<String> source = factory->NewStringFromAscii(CStrVector(""));
761 Handle<Object> code_object = m.GetCode(source); 759 Handle<Object> code_object = m.GetCode(source);
762 Handle<Code> code = Handle<Code>::cast(code_object); 760 Handle<Code> code = Handle<Code>::cast(code_object);
763 761
764 int captures[4] = {42, 37, 87, 117}; 762 int captures[4] = {42, 37, 87, 117};
765 Handle<String> input = factory->NewStringFromAscii(CStrVector("foofoo")); 763 Handle<String> input = factory->NewStringFromAscii(CStrVector("foofoo"));
766 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); 764 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
(...skipping 12 matching lines...) Expand all
779 CHECK_EQ(-1, captures[0]); 777 CHECK_EQ(-1, captures[0]);
780 CHECK_EQ(-1, captures[1]); 778 CHECK_EQ(-1, captures[1]);
781 CHECK_EQ(-1, captures[2]); 779 CHECK_EQ(-1, captures[2]);
782 CHECK_EQ(-1, captures[3]); 780 CHECK_EQ(-1, captures[3]);
783 } 781 }
784 782
785 783
786 TEST(MacroAssemblerNativeSimple) { 784 TEST(MacroAssemblerNativeSimple) {
787 v8::V8::Initialize(); 785 v8::V8::Initialize();
788 ContextInitializer initializer; 786 ContextInitializer initializer;
789 Factory* factory = Isolate::Current()->factory(); 787 Isolate* isolate = Isolate::Current();
788 Factory* factory = isolate->factory();
789 Zone zone(isolate);
790 790
791 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, 791 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
792 Isolate::Current()->runtime_zone());
793 792
794 Label fail, backtrack; 793 Label fail, backtrack;
795 m.PushBacktrack(&fail); 794 m.PushBacktrack(&fail);
796 m.CheckNotAtStart(NULL); 795 m.CheckNotAtStart(NULL);
797 m.LoadCurrentCharacter(2, NULL); 796 m.LoadCurrentCharacter(2, NULL);
798 m.CheckNotCharacter('o', NULL); 797 m.CheckNotCharacter('o', NULL);
799 m.LoadCurrentCharacter(1, NULL, false); 798 m.LoadCurrentCharacter(1, NULL, false);
800 m.CheckNotCharacter('o', NULL); 799 m.CheckNotCharacter('o', NULL);
801 m.LoadCurrentCharacter(0, NULL, false); 800 m.LoadCurrentCharacter(0, NULL, false);
802 m.CheckNotCharacter('f', NULL); 801 m.CheckNotCharacter('f', NULL);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 start_adr + input->length(), 843 start_adr + input->length(),
845 captures); 844 captures);
846 845
847 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); 846 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result);
848 } 847 }
849 848
850 849
851 TEST(MacroAssemblerNativeSimpleUC16) { 850 TEST(MacroAssemblerNativeSimpleUC16) {
852 v8::V8::Initialize(); 851 v8::V8::Initialize();
853 ContextInitializer initializer; 852 ContextInitializer initializer;
854 Factory* factory = Isolate::Current()->factory(); 853 Isolate* isolate = Isolate::Current();
854 Factory* factory = isolate->factory();
855 Zone zone(isolate);
855 856
856 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4, 857 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4, &zone);
857 Isolate::Current()->runtime_zone());
858 858
859 Label fail, backtrack; 859 Label fail, backtrack;
860 m.PushBacktrack(&fail); 860 m.PushBacktrack(&fail);
861 m.CheckNotAtStart(NULL); 861 m.CheckNotAtStart(NULL);
862 m.LoadCurrentCharacter(2, NULL); 862 m.LoadCurrentCharacter(2, NULL);
863 m.CheckNotCharacter('o', NULL); 863 m.CheckNotCharacter('o', NULL);
864 m.LoadCurrentCharacter(1, NULL, false); 864 m.LoadCurrentCharacter(1, NULL, false);
865 m.CheckNotCharacter('o', NULL); 865 m.CheckNotCharacter('o', NULL);
866 m.LoadCurrentCharacter(0, NULL, false); 866 m.LoadCurrentCharacter(0, NULL, false);
867 m.CheckNotCharacter('f', NULL); 867 m.CheckNotCharacter('f', NULL);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 start_adr + input->length() * 2, 914 start_adr + input->length() * 2,
915 captures); 915 captures);
916 916
917 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); 917 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result);
918 } 918 }
919 919
920 920
921 TEST(MacroAssemblerNativeBacktrack) { 921 TEST(MacroAssemblerNativeBacktrack) {
922 v8::V8::Initialize(); 922 v8::V8::Initialize();
923 ContextInitializer initializer; 923 ContextInitializer initializer;
924 Factory* factory = Isolate::Current()->factory(); 924 Isolate* isolate = Isolate::Current();
925 Factory* factory = isolate->factory();
926 Zone zone(isolate);
925 927
926 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, 928 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone);
927 Isolate::Current()->runtime_zone());
928 929
929 Label fail; 930 Label fail;
930 Label backtrack; 931 Label backtrack;
931 m.LoadCurrentCharacter(10, &fail); 932 m.LoadCurrentCharacter(10, &fail);
932 m.Succeed(); 933 m.Succeed();
933 m.Bind(&fail); 934 m.Bind(&fail);
934 m.PushBacktrack(&backtrack); 935 m.PushBacktrack(&backtrack);
935 m.LoadCurrentCharacter(10, NULL); 936 m.LoadCurrentCharacter(10, NULL);
936 m.Succeed(); 937 m.Succeed();
937 m.Bind(&backtrack); 938 m.Bind(&backtrack);
(...skipping 15 matching lines...) Expand all
953 start_adr + input->length(), 954 start_adr + input->length(),
954 NULL); 955 NULL);
955 956
956 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); 957 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result);
957 } 958 }
958 959
959 960
960 TEST(MacroAssemblerNativeBackReferenceASCII) { 961 TEST(MacroAssemblerNativeBackReferenceASCII) {
961 v8::V8::Initialize(); 962 v8::V8::Initialize();
962 ContextInitializer initializer; 963 ContextInitializer initializer;
963 Factory* factory = Isolate::Current()->factory(); 964 Isolate* isolate = Isolate::Current();
965 Factory* factory = isolate->factory();
966 Zone zone(isolate);
964 967
965 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, 968 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
966 Isolate::Current()->runtime_zone());
967 969
968 m.WriteCurrentPositionToRegister(0, 0); 970 m.WriteCurrentPositionToRegister(0, 0);
969 m.AdvanceCurrentPosition(2); 971 m.AdvanceCurrentPosition(2);
970 m.WriteCurrentPositionToRegister(1, 0); 972 m.WriteCurrentPositionToRegister(1, 0);
971 Label nomatch; 973 Label nomatch;
972 m.CheckNotBackReference(0, &nomatch); 974 m.CheckNotBackReference(0, &nomatch);
973 m.Fail(); 975 m.Fail();
974 m.Bind(&nomatch); 976 m.Bind(&nomatch);
975 m.AdvanceCurrentPosition(2); 977 m.AdvanceCurrentPosition(2);
976 Label missing_match; 978 Label missing_match;
(...skipping 24 matching lines...) Expand all
1001 CHECK_EQ(0, output[0]); 1003 CHECK_EQ(0, output[0]);
1002 CHECK_EQ(2, output[1]); 1004 CHECK_EQ(2, output[1]);
1003 CHECK_EQ(6, output[2]); 1005 CHECK_EQ(6, output[2]);
1004 CHECK_EQ(-1, output[3]); 1006 CHECK_EQ(-1, output[3]);
1005 } 1007 }
1006 1008
1007 1009
1008 TEST(MacroAssemblerNativeBackReferenceUC16) { 1010 TEST(MacroAssemblerNativeBackReferenceUC16) {
1009 v8::V8::Initialize(); 1011 v8::V8::Initialize();
1010 ContextInitializer initializer; 1012 ContextInitializer initializer;
1011 Factory* factory = Isolate::Current()->factory(); 1013 Isolate* isolate = Isolate::Current();
1014 Factory* factory = isolate->factory();
1015 Zone zone(isolate);
1012 1016
1013 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4, 1017 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4, &zone);
1014 Isolate::Current()->runtime_zone());
1015 1018
1016 m.WriteCurrentPositionToRegister(0, 0); 1019 m.WriteCurrentPositionToRegister(0, 0);
1017 m.AdvanceCurrentPosition(2); 1020 m.AdvanceCurrentPosition(2);
1018 m.WriteCurrentPositionToRegister(1, 0); 1021 m.WriteCurrentPositionToRegister(1, 0);
1019 Label nomatch; 1022 Label nomatch;
1020 m.CheckNotBackReference(0, &nomatch); 1023 m.CheckNotBackReference(0, &nomatch);
1021 m.Fail(); 1024 m.Fail();
1022 m.Bind(&nomatch); 1025 m.Bind(&nomatch);
1023 m.AdvanceCurrentPosition(2); 1026 m.AdvanceCurrentPosition(2);
1024 Label missing_match; 1027 Label missing_match;
(...skipping 27 matching lines...) Expand all
1052 CHECK_EQ(2, output[1]); 1055 CHECK_EQ(2, output[1]);
1053 CHECK_EQ(6, output[2]); 1056 CHECK_EQ(6, output[2]);
1054 CHECK_EQ(-1, output[3]); 1057 CHECK_EQ(-1, output[3]);
1055 } 1058 }
1056 1059
1057 1060
1058 1061
1059 TEST(MacroAssemblernativeAtStart) { 1062 TEST(MacroAssemblernativeAtStart) {
1060 v8::V8::Initialize(); 1063 v8::V8::Initialize();
1061 ContextInitializer initializer; 1064 ContextInitializer initializer;
1062 Factory* factory = Isolate::Current()->factory(); 1065 Isolate* isolate = Isolate::Current();
1066 Factory* factory = isolate->factory();
1067 Zone zone(isolate);
1063 1068
1064 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, 1069 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone);
1065 Isolate::Current()->runtime_zone());
1066 1070
1067 Label not_at_start, newline, fail; 1071 Label not_at_start, newline, fail;
1068 m.CheckNotAtStart(&not_at_start); 1072 m.CheckNotAtStart(&not_at_start);
1069 // Check that prevchar = '\n' and current = 'f'. 1073 // Check that prevchar = '\n' and current = 'f'.
1070 m.CheckCharacter('\n', &newline); 1074 m.CheckCharacter('\n', &newline);
1071 m.Bind(&fail); 1075 m.Bind(&fail);
1072 m.Fail(); 1076 m.Fail();
1073 m.Bind(&newline); 1077 m.Bind(&newline);
1074 m.LoadCurrentCharacter(0, &fail); 1078 m.LoadCurrentCharacter(0, &fail);
1075 m.CheckNotCharacter('f', &fail); 1079 m.CheckNotCharacter('f', &fail);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 start_adr + input->length(), 1114 start_adr + input->length(),
1111 NULL); 1115 NULL);
1112 1116
1113 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); 1117 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result);
1114 } 1118 }
1115 1119
1116 1120
1117 TEST(MacroAssemblerNativeBackRefNoCase) { 1121 TEST(MacroAssemblerNativeBackRefNoCase) {
1118 v8::V8::Initialize(); 1122 v8::V8::Initialize();
1119 ContextInitializer initializer; 1123 ContextInitializer initializer;
1120 Factory* factory = Isolate::Current()->factory(); 1124 Isolate* isolate = Isolate::Current();
1125 Factory* factory = isolate->factory();
1126 Zone zone(isolate);
1121 1127
1122 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, 1128 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
1123 Isolate::Current()->runtime_zone());
1124 1129
1125 Label fail, succ; 1130 Label fail, succ;
1126 1131
1127 m.WriteCurrentPositionToRegister(0, 0); 1132 m.WriteCurrentPositionToRegister(0, 0);
1128 m.WriteCurrentPositionToRegister(2, 0); 1133 m.WriteCurrentPositionToRegister(2, 0);
1129 m.AdvanceCurrentPosition(3); 1134 m.AdvanceCurrentPosition(3);
1130 m.WriteCurrentPositionToRegister(3, 0); 1135 m.WriteCurrentPositionToRegister(3, 0);
1131 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "AbC". 1136 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "AbC".
1132 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "ABC". 1137 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "ABC".
1133 Label expected_fail; 1138 Label expected_fail;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 CHECK_EQ(12, output[1]); 1173 CHECK_EQ(12, output[1]);
1169 CHECK_EQ(0, output[2]); 1174 CHECK_EQ(0, output[2]);
1170 CHECK_EQ(3, output[3]); 1175 CHECK_EQ(3, output[3]);
1171 } 1176 }
1172 1177
1173 1178
1174 1179
1175 TEST(MacroAssemblerNativeRegisters) { 1180 TEST(MacroAssemblerNativeRegisters) {
1176 v8::V8::Initialize(); 1181 v8::V8::Initialize();
1177 ContextInitializer initializer; 1182 ContextInitializer initializer;
1178 Factory* factory = Isolate::Current()->factory(); 1183 Isolate* isolate = Isolate::Current();
1184 Factory* factory = isolate->factory();
1185 Zone zone(isolate);
1179 1186
1180 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 6, 1187 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 6, &zone);
1181 Isolate::Current()->runtime_zone());
1182 1188
1183 uc16 foo_chars[3] = {'f', 'o', 'o'}; 1189 uc16 foo_chars[3] = {'f', 'o', 'o'};
1184 Vector<const uc16> foo(foo_chars, 3); 1190 Vector<const uc16> foo(foo_chars, 3);
1185 1191
1186 enum registers { out1, out2, out3, out4, out5, out6, sp, loop_cnt }; 1192 enum registers { out1, out2, out3, out4, out5, out6, sp, loop_cnt };
1187 Label fail; 1193 Label fail;
1188 Label backtrack; 1194 Label backtrack;
1189 m.WriteCurrentPositionToRegister(out1, 0); // Output: [0] 1195 m.WriteCurrentPositionToRegister(out1, 0); // Output: [0]
1190 m.PushRegister(out1, RegExpMacroAssembler::kNoStackLimitCheck); 1196 m.PushRegister(out1, RegExpMacroAssembler::kNoStackLimitCheck);
1191 m.PushBacktrack(&backtrack); 1197 m.PushBacktrack(&backtrack);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 CHECK_EQ(9, output[4]); 1278 CHECK_EQ(9, output[4]);
1273 CHECK_EQ(-1, output[5]); 1279 CHECK_EQ(-1, output[5]);
1274 } 1280 }
1275 1281
1276 1282
1277 TEST(MacroAssemblerStackOverflow) { 1283 TEST(MacroAssemblerStackOverflow) {
1278 v8::V8::Initialize(); 1284 v8::V8::Initialize();
1279 ContextInitializer initializer; 1285 ContextInitializer initializer;
1280 Isolate* isolate = Isolate::Current(); 1286 Isolate* isolate = Isolate::Current();
1281 Factory* factory = isolate->factory(); 1287 Factory* factory = isolate->factory();
1288 Zone zone(isolate);
1282 1289
1283 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, 1290 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone);
1284 Isolate::Current()->runtime_zone());
1285 1291
1286 Label loop; 1292 Label loop;
1287 m.Bind(&loop); 1293 m.Bind(&loop);
1288 m.PushBacktrack(&loop); 1294 m.PushBacktrack(&loop);
1289 m.GoTo(&loop); 1295 m.GoTo(&loop);
1290 1296
1291 Handle<String> source = 1297 Handle<String> source =
1292 factory->NewStringFromAscii(CStrVector("<stack overflow test>")); 1298 factory->NewStringFromAscii(CStrVector("<stack overflow test>"));
1293 Handle<Object> code_object = m.GetCode(source); 1299 Handle<Object> code_object = m.GetCode(source);
1294 Handle<Code> code = Handle<Code>::cast(code_object); 1300 Handle<Code> code = Handle<Code>::cast(code_object);
(...skipping 16 matching lines...) Expand all
1311 CHECK(isolate->has_pending_exception()); 1317 CHECK(isolate->has_pending_exception());
1312 isolate->clear_pending_exception(); 1318 isolate->clear_pending_exception();
1313 } 1319 }
1314 1320
1315 1321
1316 TEST(MacroAssemblerNativeLotsOfRegisters) { 1322 TEST(MacroAssemblerNativeLotsOfRegisters) {
1317 v8::V8::Initialize(); 1323 v8::V8::Initialize();
1318 ContextInitializer initializer; 1324 ContextInitializer initializer;
1319 Isolate* isolate = Isolate::Current(); 1325 Isolate* isolate = Isolate::Current();
1320 Factory* factory = isolate->factory(); 1326 Factory* factory = isolate->factory();
1327 Zone zone(isolate);
1321 1328
1322 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 2, 1329 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 2, &zone);
1323 Isolate::Current()->runtime_zone());
1324 1330
1325 // At least 2048, to ensure the allocated space for registers 1331 // At least 2048, to ensure the allocated space for registers
1326 // span one full page. 1332 // span one full page.
1327 const int large_number = 8000; 1333 const int large_number = 8000;
1328 m.WriteCurrentPositionToRegister(large_number, 42); 1334 m.WriteCurrentPositionToRegister(large_number, 42);
1329 m.WriteCurrentPositionToRegister(0, 0); 1335 m.WriteCurrentPositionToRegister(0, 0);
1330 m.WriteCurrentPositionToRegister(1, 1); 1336 m.WriteCurrentPositionToRegister(1, 1);
1331 Label done; 1337 Label done;
1332 m.CheckNotBackReference(0, &done); // Performs a system-stack push. 1338 m.CheckNotBackReference(0, &done); // Performs a system-stack push.
1333 m.Bind(&done); 1339 m.Bind(&done);
(...skipping 26 matching lines...) Expand all
1360 CHECK_EQ(42, captures[1]); 1366 CHECK_EQ(42, captures[1]);
1361 1367
1362 isolate->clear_pending_exception(); 1368 isolate->clear_pending_exception();
1363 } 1369 }
1364 1370
1365 #else // V8_INTERPRETED_REGEXP 1371 #else // V8_INTERPRETED_REGEXP
1366 1372
1367 TEST(MacroAssembler) { 1373 TEST(MacroAssembler) {
1368 V8::Initialize(NULL); 1374 V8::Initialize(NULL);
1369 byte codes[1024]; 1375 byte codes[1024];
1370 RegExpMacroAssemblerIrregexp m(Vector<byte>(codes, 1024), 1376 Zone zone(Isolate::Current());
1371 Isolate::Current()->runtime_zone()); 1377 RegExpMacroAssemblerIrregexp m(Vector<byte>(codes, 1024), &zone);
1372 // ^f(o)o. 1378 // ^f(o)o.
1373 Label start, fail, backtrack; 1379 Label start, fail, backtrack;
1374 1380
1375 m.SetRegister(4, 42); 1381 m.SetRegister(4, 42);
1376 m.PushRegister(4, RegExpMacroAssembler::kNoStackLimitCheck); 1382 m.PushRegister(4, RegExpMacroAssembler::kNoStackLimitCheck);
1377 m.AdvanceRegister(4, 42); 1383 m.AdvanceRegister(4, 42);
1378 m.GoTo(&start); 1384 m.GoTo(&start);
1379 m.Fail(); 1385 m.Fail();
1380 m.Bind(&start); 1386 m.Bind(&start);
1381 m.PushBacktrack(&fail); 1387 m.PushBacktrack(&fail);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 } 1434 }
1429 1435
1430 #endif // V8_INTERPRETED_REGEXP 1436 #endif // V8_INTERPRETED_REGEXP
1431 1437
1432 1438
1433 TEST(AddInverseToTable) { 1439 TEST(AddInverseToTable) {
1434 v8::internal::V8::Initialize(NULL); 1440 v8::internal::V8::Initialize(NULL);
1435 static const int kLimit = 1000; 1441 static const int kLimit = 1000;
1436 static const int kRangeCount = 16; 1442 static const int kRangeCount = 16;
1437 for (int t = 0; t < 10; t++) { 1443 for (int t = 0; t < 10; t++) {
1438 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 1444 Zone zone(Isolate::Current());
1439 Zone* zone = Isolate::Current()->runtime_zone();
1440 ZoneList<CharacterRange>* ranges = 1445 ZoneList<CharacterRange>* ranges =
1441 new(zone) 1446 new(&zone) ZoneList<CharacterRange>(kRangeCount, &zone);
1442 ZoneList<CharacterRange>(kRangeCount, zone);
1443 for (int i = 0; i < kRangeCount; i++) { 1447 for (int i = 0; i < kRangeCount; i++) {
1444 int from = PseudoRandom(t + 87, i + 25) % kLimit; 1448 int from = PseudoRandom(t + 87, i + 25) % kLimit;
1445 int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20)); 1449 int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20));
1446 if (to > kLimit) to = kLimit; 1450 if (to > kLimit) to = kLimit;
1447 ranges->Add(CharacterRange(from, to), zone); 1451 ranges->Add(CharacterRange(from, to), &zone);
1448 } 1452 }
1449 DispatchTable table(zone); 1453 DispatchTable table(&zone);
1450 DispatchTableConstructor cons(&table, false, 1454 DispatchTableConstructor cons(&table, false, &zone);
1451 Isolate::Current()->runtime_zone());
1452 cons.set_choice_index(0); 1455 cons.set_choice_index(0);
1453 cons.AddInverse(ranges); 1456 cons.AddInverse(ranges);
1454 for (int i = 0; i < kLimit; i++) { 1457 for (int i = 0; i < kLimit; i++) {
1455 bool is_on = false; 1458 bool is_on = false;
1456 for (int j = 0; !is_on && j < kRangeCount; j++) 1459 for (int j = 0; !is_on && j < kRangeCount; j++)
1457 is_on = ranges->at(j).Contains(i); 1460 is_on = ranges->at(j).Contains(i);
1458 OutSet* set = table.Get(i); 1461 OutSet* set = table.Get(i);
1459 CHECK_EQ(is_on, set->Get(0) == false); 1462 CHECK_EQ(is_on, set->Get(0) == false);
1460 } 1463 }
1461 } 1464 }
1462 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 1465 Zone zone(Isolate::Current());
1463 Zone* zone = Isolate::Current()->runtime_zone();
1464 ZoneList<CharacterRange>* ranges = 1466 ZoneList<CharacterRange>* ranges =
1465 new(zone) ZoneList<CharacterRange>(1, zone); 1467 new(&zone) ZoneList<CharacterRange>(1, &zone);
1466 ranges->Add(CharacterRange(0xFFF0, 0xFFFE), zone); 1468 ranges->Add(CharacterRange(0xFFF0, 0xFFFE), &zone);
1467 DispatchTable table(zone); 1469 DispatchTable table(&zone);
1468 DispatchTableConstructor cons(&table, false, 1470 DispatchTableConstructor cons(&table, false, &zone);
1469 Isolate::Current()->runtime_zone());
1470 cons.set_choice_index(0); 1471 cons.set_choice_index(0);
1471 cons.AddInverse(ranges); 1472 cons.AddInverse(ranges);
1472 CHECK(!table.Get(0xFFFE)->Get(0)); 1473 CHECK(!table.Get(0xFFFE)->Get(0));
1473 CHECK(table.Get(0xFFFF)->Get(0)); 1474 CHECK(table.Get(0xFFFF)->Get(0));
1474 } 1475 }
1475 1476
1476 1477
1477 static uc32 canonicalize(uc32 c) { 1478 static uc32 canonicalize(uc32 c) {
1478 unibrow::uchar canon[unibrow::Ecma262Canonicalize::kMaxWidth]; 1479 unibrow::uchar canon[unibrow::Ecma262Canonicalize::kMaxWidth];
1479 int count = unibrow::Ecma262Canonicalize::Convert(c, '\0', canon, NULL); 1480 int count = unibrow::Ecma262Canonicalize::Convert(c, '\0', canon, NULL);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 CHECK_EQ(length, length2); 1568 CHECK_EQ(length, length2);
1568 for (int k = 0; k < length; k++) 1569 for (int k = 0; k < length; k++)
1569 CHECK_EQ(static_cast<int>(chars[k]), static_cast<int>(chars2[k])); 1570 CHECK_EQ(static_cast<int>(chars[k]), static_cast<int>(chars2[k]));
1570 } 1571 }
1571 } 1572 }
1572 } 1573 }
1573 1574
1574 1575
1575 static void TestRangeCaseIndependence(CharacterRange input, 1576 static void TestRangeCaseIndependence(CharacterRange input,
1576 Vector<CharacterRange> expected) { 1577 Vector<CharacterRange> expected) {
1577 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 1578 Zone zone(Isolate::Current());
1578 Zone* zone = Isolate::Current()->runtime_zone();
1579 int count = expected.length(); 1579 int count = expected.length();
1580 ZoneList<CharacterRange>* list = 1580 ZoneList<CharacterRange>* list =
1581 new(zone) ZoneList<CharacterRange>(count, zone); 1581 new(&zone) ZoneList<CharacterRange>(count, &zone);
1582 input.AddCaseEquivalents(list, false, zone); 1582 input.AddCaseEquivalents(list, false, &zone);
1583 CHECK_EQ(count, list->length()); 1583 CHECK_EQ(count, list->length());
1584 for (int i = 0; i < list->length(); i++) { 1584 for (int i = 0; i < list->length(); i++) {
1585 CHECK_EQ(expected[i].from(), list->at(i).from()); 1585 CHECK_EQ(expected[i].from(), list->at(i).from());
1586 CHECK_EQ(expected[i].to(), list->at(i).to()); 1586 CHECK_EQ(expected[i].to(), list->at(i).to());
1587 } 1587 }
1588 } 1588 }
1589 1589
1590 1590
1591 static void TestSimpleRangeCaseIndependence(CharacterRange input, 1591 static void TestSimpleRangeCaseIndependence(CharacterRange input,
1592 CharacterRange expected) { 1592 CharacterRange expected) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 CharacterRange range = ranges->at(i); 1633 CharacterRange range = ranges->at(i);
1634 if (range.from() <= c && c <= range.to()) 1634 if (range.from() <= c && c <= range.to())
1635 return true; 1635 return true;
1636 } 1636 }
1637 return false; 1637 return false;
1638 } 1638 }
1639 1639
1640 1640
1641 TEST(CharClassDifference) { 1641 TEST(CharClassDifference) {
1642 v8::internal::V8::Initialize(NULL); 1642 v8::internal::V8::Initialize(NULL);
1643 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 1643 Zone zone(Isolate::Current());
1644 Zone* zone = Isolate::Current()->runtime_zone();
1645 ZoneList<CharacterRange>* base = 1644 ZoneList<CharacterRange>* base =
1646 new(zone) ZoneList<CharacterRange>(1, zone); 1645 new(&zone) ZoneList<CharacterRange>(1, &zone);
1647 base->Add(CharacterRange::Everything(), zone); 1646 base->Add(CharacterRange::Everything(), &zone);
1648 Vector<const int> overlay = CharacterRange::GetWordBounds(); 1647 Vector<const int> overlay = CharacterRange::GetWordBounds();
1649 ZoneList<CharacterRange>* included = NULL; 1648 ZoneList<CharacterRange>* included = NULL;
1650 ZoneList<CharacterRange>* excluded = NULL; 1649 ZoneList<CharacterRange>* excluded = NULL;
1651 CharacterRange::Split(base, overlay, &included, &excluded, 1650 CharacterRange::Split(base, overlay, &included, &excluded, &zone);
1652 Isolate::Current()->runtime_zone());
1653 for (int i = 0; i < (1 << 16); i++) { 1651 for (int i = 0; i < (1 << 16); i++) {
1654 bool in_base = InClass(i, base); 1652 bool in_base = InClass(i, base);
1655 if (in_base) { 1653 if (in_base) {
1656 bool in_overlay = false; 1654 bool in_overlay = false;
1657 for (int j = 0; !in_overlay && j < overlay.length(); j += 2) { 1655 for (int j = 0; !in_overlay && j < overlay.length(); j += 2) {
1658 if (overlay[j] <= i && i < overlay[j+1]) 1656 if (overlay[j] <= i && i < overlay[j+1])
1659 in_overlay = true; 1657 in_overlay = true;
1660 } 1658 }
1661 CHECK_EQ(in_overlay, InClass(i, included)); 1659 CHECK_EQ(in_overlay, InClass(i, included));
1662 CHECK_EQ(!in_overlay, InClass(i, excluded)); 1660 CHECK_EQ(!in_overlay, InClass(i, excluded));
1663 } else { 1661 } else {
1664 CHECK(!InClass(i, included)); 1662 CHECK(!InClass(i, included));
1665 CHECK(!InClass(i, excluded)); 1663 CHECK(!InClass(i, excluded));
1666 } 1664 }
1667 } 1665 }
1668 } 1666 }
1669 1667
1670 1668
1671 TEST(CanonicalizeCharacterSets) { 1669 TEST(CanonicalizeCharacterSets) {
1672 v8::internal::V8::Initialize(NULL); 1670 v8::internal::V8::Initialize(NULL);
1673 ZoneScope scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 1671 Zone zone(Isolate::Current());
1674 Zone* zone = Isolate::Current()->runtime_zone();
1675 ZoneList<CharacterRange>* list = 1672 ZoneList<CharacterRange>* list =
1676 new(zone) ZoneList<CharacterRange>(4, zone); 1673 new(&zone) ZoneList<CharacterRange>(4, &zone);
1677 CharacterSet set(list); 1674 CharacterSet set(list);
1678 1675
1679 list->Add(CharacterRange(10, 20), zone); 1676 list->Add(CharacterRange(10, 20), &zone);
1680 list->Add(CharacterRange(30, 40), zone); 1677 list->Add(CharacterRange(30, 40), &zone);
1681 list->Add(CharacterRange(50, 60), zone); 1678 list->Add(CharacterRange(50, 60), &zone);
1682 set.Canonicalize(); 1679 set.Canonicalize();
1683 ASSERT_EQ(3, list->length()); 1680 ASSERT_EQ(3, list->length());
1684 ASSERT_EQ(10, list->at(0).from()); 1681 ASSERT_EQ(10, list->at(0).from());
1685 ASSERT_EQ(20, list->at(0).to()); 1682 ASSERT_EQ(20, list->at(0).to());
1686 ASSERT_EQ(30, list->at(1).from()); 1683 ASSERT_EQ(30, list->at(1).from());
1687 ASSERT_EQ(40, list->at(1).to()); 1684 ASSERT_EQ(40, list->at(1).to());
1688 ASSERT_EQ(50, list->at(2).from()); 1685 ASSERT_EQ(50, list->at(2).from());
1689 ASSERT_EQ(60, list->at(2).to()); 1686 ASSERT_EQ(60, list->at(2).to());
1690 1687
1691 list->Rewind(0); 1688 list->Rewind(0);
1692 list->Add(CharacterRange(10, 20), zone); 1689 list->Add(CharacterRange(10, 20), &zone);
1693 list->Add(CharacterRange(50, 60), zone); 1690 list->Add(CharacterRange(50, 60), &zone);
1694 list->Add(CharacterRange(30, 40), zone); 1691 list->Add(CharacterRange(30, 40), &zone);
1695 set.Canonicalize(); 1692 set.Canonicalize();
1696 ASSERT_EQ(3, list->length()); 1693 ASSERT_EQ(3, list->length());
1697 ASSERT_EQ(10, list->at(0).from()); 1694 ASSERT_EQ(10, list->at(0).from());
1698 ASSERT_EQ(20, list->at(0).to()); 1695 ASSERT_EQ(20, list->at(0).to());
1699 ASSERT_EQ(30, list->at(1).from()); 1696 ASSERT_EQ(30, list->at(1).from());
1700 ASSERT_EQ(40, list->at(1).to()); 1697 ASSERT_EQ(40, list->at(1).to());
1701 ASSERT_EQ(50, list->at(2).from()); 1698 ASSERT_EQ(50, list->at(2).from());
1702 ASSERT_EQ(60, list->at(2).to()); 1699 ASSERT_EQ(60, list->at(2).to());
1703 1700
1704 list->Rewind(0); 1701 list->Rewind(0);
1705 list->Add(CharacterRange(30, 40), zone); 1702 list->Add(CharacterRange(30, 40), &zone);
1706 list->Add(CharacterRange(10, 20), zone); 1703 list->Add(CharacterRange(10, 20), &zone);
1707 list->Add(CharacterRange(25, 25), zone); 1704 list->Add(CharacterRange(25, 25), &zone);
1708 list->Add(CharacterRange(100, 100), zone); 1705 list->Add(CharacterRange(100, 100), &zone);
1709 list->Add(CharacterRange(1, 1), zone); 1706 list->Add(CharacterRange(1, 1), &zone);
1710 set.Canonicalize(); 1707 set.Canonicalize();
1711 ASSERT_EQ(5, list->length()); 1708 ASSERT_EQ(5, list->length());
1712 ASSERT_EQ(1, list->at(0).from()); 1709 ASSERT_EQ(1, list->at(0).from());
1713 ASSERT_EQ(1, list->at(0).to()); 1710 ASSERT_EQ(1, list->at(0).to());
1714 ASSERT_EQ(10, list->at(1).from()); 1711 ASSERT_EQ(10, list->at(1).from());
1715 ASSERT_EQ(20, list->at(1).to()); 1712 ASSERT_EQ(20, list->at(1).to());
1716 ASSERT_EQ(25, list->at(2).from()); 1713 ASSERT_EQ(25, list->at(2).from());
1717 ASSERT_EQ(25, list->at(2).to()); 1714 ASSERT_EQ(25, list->at(2).to());
1718 ASSERT_EQ(30, list->at(3).from()); 1715 ASSERT_EQ(30, list->at(3).from());
1719 ASSERT_EQ(40, list->at(3).to()); 1716 ASSERT_EQ(40, list->at(3).to());
1720 ASSERT_EQ(100, list->at(4).from()); 1717 ASSERT_EQ(100, list->at(4).from());
1721 ASSERT_EQ(100, list->at(4).to()); 1718 ASSERT_EQ(100, list->at(4).to());
1722 1719
1723 list->Rewind(0); 1720 list->Rewind(0);
1724 list->Add(CharacterRange(10, 19), zone); 1721 list->Add(CharacterRange(10, 19), &zone);
1725 list->Add(CharacterRange(21, 30), zone); 1722 list->Add(CharacterRange(21, 30), &zone);
1726 list->Add(CharacterRange(20, 20), zone); 1723 list->Add(CharacterRange(20, 20), &zone);
1727 set.Canonicalize(); 1724 set.Canonicalize();
1728 ASSERT_EQ(1, list->length()); 1725 ASSERT_EQ(1, list->length());
1729 ASSERT_EQ(10, list->at(0).from()); 1726 ASSERT_EQ(10, list->at(0).from());
1730 ASSERT_EQ(30, list->at(0).to()); 1727 ASSERT_EQ(30, list->at(0).to());
1731 } 1728 }
1732 1729
1733 1730
1734 TEST(CharacterRangeMerge) { 1731 TEST(CharacterRangeMerge) {
1735 v8::internal::V8::Initialize(NULL); 1732 v8::internal::V8::Initialize(NULL);
1736 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 1733 Zone zone(Isolate::Current());
1737 ZoneList<CharacterRange> l1(4, Isolate::Current()->runtime_zone()); 1734 ZoneList<CharacterRange> l1(4, &zone);
1738 ZoneList<CharacterRange> l2(4, Isolate::Current()->runtime_zone()); 1735 ZoneList<CharacterRange> l2(4, &zone);
1739 Zone* zone = Isolate::Current()->runtime_zone();
1740 // Create all combinations of intersections of ranges, both singletons and 1736 // Create all combinations of intersections of ranges, both singletons and
1741 // longer. 1737 // longer.
1742 1738
1743 int offset = 0; 1739 int offset = 0;
1744 1740
1745 // The five kinds of singleton intersections: 1741 // The five kinds of singleton intersections:
1746 // X 1742 // X
1747 // Y - outside before 1743 // Y - outside before
1748 // Y - outside touching start 1744 // Y - outside touching start
1749 // Y - overlap 1745 // Y - overlap
1750 // Y - outside touching end 1746 // Y - outside touching end
1751 // Y - outside after 1747 // Y - outside after
1752 1748
1753 for (int i = 0; i < 5; i++) { 1749 for (int i = 0; i < 5; i++) {
1754 l1.Add(CharacterRange::Singleton(offset + 2), zone); 1750 l1.Add(CharacterRange::Singleton(offset + 2), &zone);
1755 l2.Add(CharacterRange::Singleton(offset + i), zone); 1751 l2.Add(CharacterRange::Singleton(offset + i), &zone);
1756 offset += 6; 1752 offset += 6;
1757 } 1753 }
1758 1754
1759 // The seven kinds of singleton/non-singleton intersections: 1755 // The seven kinds of singleton/non-singleton intersections:
1760 // XXX 1756 // XXX
1761 // Y - outside before 1757 // Y - outside before
1762 // Y - outside touching start 1758 // Y - outside touching start
1763 // Y - inside touching start 1759 // Y - inside touching start
1764 // Y - entirely inside 1760 // Y - entirely inside
1765 // Y - inside touching end 1761 // Y - inside touching end
1766 // Y - outside touching end 1762 // Y - outside touching end
1767 // Y - disjoint after 1763 // Y - disjoint after
1768 1764
1769 for (int i = 0; i < 7; i++) { 1765 for (int i = 0; i < 7; i++) {
1770 l1.Add(CharacterRange::Range(offset + 2, offset + 4), zone); 1766 l1.Add(CharacterRange::Range(offset + 2, offset + 4), &zone);
1771 l2.Add(CharacterRange::Singleton(offset + i), zone); 1767 l2.Add(CharacterRange::Singleton(offset + i), &zone);
1772 offset += 8; 1768 offset += 8;
1773 } 1769 }
1774 1770
1775 // The eleven kinds of non-singleton intersections: 1771 // The eleven kinds of non-singleton intersections:
1776 // 1772 //
1777 // XXXXXXXX 1773 // XXXXXXXX
1778 // YYYY - outside before. 1774 // YYYY - outside before.
1779 // YYYY - outside touching start. 1775 // YYYY - outside touching start.
1780 // YYYY - overlapping start 1776 // YYYY - overlapping start
1781 // YYYY - inside touching start 1777 // YYYY - inside touching start
1782 // YYYY - entirely inside 1778 // YYYY - entirely inside
1783 // YYYY - inside touching end 1779 // YYYY - inside touching end
1784 // YYYY - overlapping end 1780 // YYYY - overlapping end
1785 // YYYY - outside touching end 1781 // YYYY - outside touching end
1786 // YYYY - outside after 1782 // YYYY - outside after
1787 // YYYYYYYY - identical 1783 // YYYYYYYY - identical
1788 // YYYYYYYYYYYY - containing entirely. 1784 // YYYYYYYYYYYY - containing entirely.
1789 1785
1790 for (int i = 0; i < 9; i++) { 1786 for (int i = 0; i < 9; i++) {
1791 l1.Add(CharacterRange::Range(offset + 6, offset + 15), zone); // Length 8. 1787 l1.Add(CharacterRange::Range(offset + 6, offset + 15), &zone); // Length 8.
1792 l2.Add(CharacterRange::Range(offset + 2 * i, offset + 2 * i + 3), zone); 1788 l2.Add(CharacterRange::Range(offset + 2 * i, offset + 2 * i + 3), &zone);
1793 offset += 22; 1789 offset += 22;
1794 } 1790 }
1795 l1.Add(CharacterRange::Range(offset + 6, offset + 15), zone); 1791 l1.Add(CharacterRange::Range(offset + 6, offset + 15), &zone);
1796 l2.Add(CharacterRange::Range(offset + 6, offset + 15), zone); 1792 l2.Add(CharacterRange::Range(offset + 6, offset + 15), &zone);
1797 offset += 22; 1793 offset += 22;
1798 l1.Add(CharacterRange::Range(offset + 6, offset + 15), zone); 1794 l1.Add(CharacterRange::Range(offset + 6, offset + 15), &zone);
1799 l2.Add(CharacterRange::Range(offset + 4, offset + 17), zone); 1795 l2.Add(CharacterRange::Range(offset + 4, offset + 17), &zone);
1800 offset += 22; 1796 offset += 22;
1801 1797
1802 // Different kinds of multi-range overlap: 1798 // Different kinds of multi-range overlap:
1803 // XXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXX 1799 // XXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXX
1804 // YYYY Y YYYY Y YYYY Y YYYY Y YYYY Y YYYY Y 1800 // YYYY Y YYYY Y YYYY Y YYYY Y YYYY Y YYYY Y
1805 1801
1806 l1.Add(CharacterRange::Range(offset, offset + 21), zone); 1802 l1.Add(CharacterRange::Range(offset, offset + 21), &zone);
1807 l1.Add(CharacterRange::Range(offset + 31, offset + 52), zone); 1803 l1.Add(CharacterRange::Range(offset + 31, offset + 52), &zone);
1808 for (int i = 0; i < 6; i++) { 1804 for (int i = 0; i < 6; i++) {
1809 l2.Add(CharacterRange::Range(offset + 2, offset + 5), zone); 1805 l2.Add(CharacterRange::Range(offset + 2, offset + 5), &zone);
1810 l2.Add(CharacterRange::Singleton(offset + 8), zone); 1806 l2.Add(CharacterRange::Singleton(offset + 8), &zone);
1811 offset += 9; 1807 offset += 9;
1812 } 1808 }
1813 1809
1814 ASSERT(CharacterRange::IsCanonical(&l1)); 1810 ASSERT(CharacterRange::IsCanonical(&l1));
1815 ASSERT(CharacterRange::IsCanonical(&l2)); 1811 ASSERT(CharacterRange::IsCanonical(&l2));
1816 1812
1817 ZoneList<CharacterRange> first_only(4, Isolate::Current()->runtime_zone()); 1813 ZoneList<CharacterRange> first_only(4, &zone);
1818 ZoneList<CharacterRange> second_only(4, Isolate::Current()->runtime_zone()); 1814 ZoneList<CharacterRange> second_only(4, &zone);
1819 ZoneList<CharacterRange> both(4, Isolate::Current()->runtime_zone()); 1815 ZoneList<CharacterRange> both(4, &zone);
1820 } 1816 }
1821 1817
1822 1818
1823 TEST(Graph) { 1819 TEST(Graph) {
1824 V8::Initialize(NULL); 1820 V8::Initialize(NULL);
1825 Execute("\\b\\w+\\b", false, true, true); 1821 Execute("\\b\\w+\\b", false, true, true);
1826 } 1822 }
OLDNEW
« no previous file with comments | « test/cctest/test-profile-generator.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698