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

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

Issue 17827005: Get rid of ZoneScope completely. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Suggestions from danno Created 7 years, 5 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-liveedit.cc ('k') | test/cctest/test-strings.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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #include "ia32/regexp-macro-assembler-ia32.h" 65 #include "ia32/regexp-macro-assembler-ia32.h"
66 #endif 66 #endif
67 #endif // V8_INTERPRETED_REGEXP 67 #endif // V8_INTERPRETED_REGEXP
68 68
69 using namespace v8::internal; 69 using namespace v8::internal;
70 70
71 71
72 static bool CheckParse(const char* input) { 72 static bool CheckParse(const char* input) {
73 V8::Initialize(NULL); 73 V8::Initialize(NULL);
74 v8::HandleScope scope(v8::Isolate::GetCurrent()); 74 v8::HandleScope scope(v8::Isolate::GetCurrent());
75 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 75 Zone zone(Isolate::Current());
76 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 76 FlatStringReader reader(Isolate::Current(), CStrVector(input));
77 RegExpCompileData result; 77 RegExpCompileData result;
78 return v8::internal::RegExpParser::ParseRegExp( 78 return v8::internal::RegExpParser::ParseRegExp(
79 &reader, false, &result, Isolate::Current()->runtime_zone()); 79 &reader, false, &result, &zone);
80 } 80 }
81 81
82 82
83 static SmartArrayPointer<const char> Parse(const char* input) { 83 static SmartArrayPointer<const char> Parse(const char* input) {
84 V8::Initialize(NULL); 84 V8::Initialize(NULL);
85 v8::HandleScope scope(v8::Isolate::GetCurrent()); 85 v8::HandleScope scope(v8::Isolate::GetCurrent());
86 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 86 Zone zone(Isolate::Current());
87 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 87 FlatStringReader reader(Isolate::Current(), CStrVector(input));
88 RegExpCompileData result; 88 RegExpCompileData result;
89 CHECK(v8::internal::RegExpParser::ParseRegExp( 89 CHECK(v8::internal::RegExpParser::ParseRegExp(
90 &reader, false, &result, Isolate::Current()->runtime_zone())); 90 &reader, false, &result, &zone));
91 CHECK(result.tree != NULL); 91 CHECK(result.tree != NULL);
92 CHECK(result.error.is_null()); 92 CHECK(result.error.is_null());
93 SmartArrayPointer<const char> output = 93 SmartArrayPointer<const char> output = result.tree->ToString(&zone);
94 result.tree->ToString(Isolate::Current()->runtime_zone());
95 return output; 94 return output;
96 } 95 }
97 96
98 static bool CheckSimple(const char* input) { 97 static bool CheckSimple(const char* input) {
99 V8::Initialize(NULL); 98 V8::Initialize(NULL);
100 v8::HandleScope scope(v8::Isolate::GetCurrent()); 99 v8::HandleScope scope(v8::Isolate::GetCurrent());
101 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 100 Zone zone(Isolate::Current());
102 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 101 FlatStringReader reader(Isolate::Current(), CStrVector(input));
103 RegExpCompileData result; 102 RegExpCompileData result;
104 CHECK(v8::internal::RegExpParser::ParseRegExp( 103 CHECK(v8::internal::RegExpParser::ParseRegExp(
105 &reader, false, &result, Isolate::Current()->runtime_zone())); 104 &reader, false, &result, &zone));
106 CHECK(result.tree != NULL); 105 CHECK(result.tree != NULL);
107 CHECK(result.error.is_null()); 106 CHECK(result.error.is_null());
108 return result.simple; 107 return result.simple;
109 } 108 }
110 109
111 struct MinMaxPair { 110 struct MinMaxPair {
112 int min_match; 111 int min_match;
113 int max_match; 112 int max_match;
114 }; 113 };
115 114
116 static MinMaxPair CheckMinMaxMatch(const char* input) { 115 static MinMaxPair CheckMinMaxMatch(const char* input) {
117 V8::Initialize(NULL); 116 V8::Initialize(NULL);
118 v8::HandleScope scope(v8::Isolate::GetCurrent()); 117 v8::HandleScope scope(v8::Isolate::GetCurrent());
119 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 118 Zone zone(Isolate::Current());
120 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 119 FlatStringReader reader(Isolate::Current(), CStrVector(input));
121 RegExpCompileData result; 120 RegExpCompileData result;
122 CHECK(v8::internal::RegExpParser::ParseRegExp( 121 CHECK(v8::internal::RegExpParser::ParseRegExp(
123 &reader, false, &result, Isolate::Current()->runtime_zone())); 122 &reader, false, &result, &zone));
124 CHECK(result.tree != NULL); 123 CHECK(result.tree != NULL);
125 CHECK(result.error.is_null()); 124 CHECK(result.error.is_null());
126 int min_match = result.tree->min_match(); 125 int min_match = result.tree->min_match();
127 int max_match = result.tree->max_match(); 126 int max_match = result.tree->max_match();
128 MinMaxPair pair = { min_match, max_match }; 127 MinMaxPair pair = { min_match, max_match };
129 return pair; 128 return pair;
130 } 129 }
131 130
132 131
133 #define CHECK_PARSE_ERROR(input) CHECK(!CheckParse(input)) 132 #define CHECK_PARSE_ERROR(input) CHECK(!CheckParse(input))
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 CHECK_PARSE_EQ("[A-Z$-][x]", "(! [A-Z $ -] [x])"); 381 CHECK_PARSE_EQ("[A-Z$-][x]", "(! [A-Z $ -] [x])");
383 CHECK_PARSE_EQ("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')"); 382 CHECK_PARSE_EQ("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')");
384 CHECK_PARSE_EQ("{", "'{'"); 383 CHECK_PARSE_EQ("{", "'{'");
385 CHECK_PARSE_EQ("a|", "(| 'a' %)"); 384 CHECK_PARSE_EQ("a|", "(| 'a' %)");
386 } 385 }
387 386
388 static void ExpectError(const char* input, 387 static void ExpectError(const char* input,
389 const char* expected) { 388 const char* expected) {
390 V8::Initialize(NULL); 389 V8::Initialize(NULL);
391 v8::HandleScope scope(v8::Isolate::GetCurrent()); 390 v8::HandleScope scope(v8::Isolate::GetCurrent());
392 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 391 Zone zone(Isolate::Current());
393 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 392 FlatStringReader reader(Isolate::Current(), CStrVector(input));
394 RegExpCompileData result; 393 RegExpCompileData result;
395 CHECK(!v8::internal::RegExpParser::ParseRegExp( 394 CHECK(!v8::internal::RegExpParser::ParseRegExp(
396 &reader, false, &result, Isolate::Current()->runtime_zone())); 395 &reader, false, &result, &zone));
397 CHECK(result.tree == NULL); 396 CHECK(result.tree == NULL);
398 CHECK(!result.error.is_null()); 397 CHECK(!result.error.is_null());
399 SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS); 398 SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS);
400 CHECK_EQ(expected, *str); 399 CHECK_EQ(expected, *str);
401 } 400 }
402 401
403 402
404 TEST(Errors) { 403 TEST(Errors) {
405 V8::Initialize(NULL); 404 V8::Initialize(NULL);
406 const char* kEndBackslash = "\\ at end of pattern"; 405 const char* kEndBackslash = "\\ at end of pattern";
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 return !IsWhiteSpace(c); 465 return !IsWhiteSpace(c);
467 } 466 }
468 467
469 468
470 static bool NotWord(uc16 c) { 469 static bool NotWord(uc16 c) {
471 return !IsRegExpWord(c); 470 return !IsRegExpWord(c);
472 } 471 }
473 472
474 473
475 static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) { 474 static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) {
476 ZoneScope scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 475 Zone zone(Isolate::Current());
477 Zone* zone = Isolate::Current()->runtime_zone();
478 ZoneList<CharacterRange>* ranges = 476 ZoneList<CharacterRange>* ranges =
479 new(zone) ZoneList<CharacterRange>(2, zone); 477 new(&zone) ZoneList<CharacterRange>(2, &zone);
480 CharacterRange::AddClassEscape(c, ranges, zone); 478 CharacterRange::AddClassEscape(c, ranges, &zone);
481 for (unsigned i = 0; i < (1 << 16); i++) { 479 for (unsigned i = 0; i < (1 << 16); i++) {
482 bool in_class = false; 480 bool in_class = false;
483 for (int j = 0; !in_class && j < ranges->length(); j++) { 481 for (int j = 0; !in_class && j < ranges->length(); j++) {
484 CharacterRange& range = ranges->at(j); 482 CharacterRange& range = ranges->at(j);
485 in_class = (range.from() <= i && i <= range.to()); 483 in_class = (range.from() <= i && i <= range.to());
486 } 484 }
487 CHECK_EQ(pred(i), in_class); 485 CHECK_EQ(pred(i), in_class);
488 } 486 }
489 } 487 }
490 488
491 489
492 TEST(CharacterClassEscapes) { 490 TEST(CharacterClassEscapes) {
493 v8::internal::V8::Initialize(NULL); 491 v8::internal::V8::Initialize(NULL);
494 TestCharacterClassEscapes('.', IsRegExpNewline); 492 TestCharacterClassEscapes('.', IsRegExpNewline);
495 TestCharacterClassEscapes('d', IsDigit); 493 TestCharacterClassEscapes('d', IsDigit);
496 TestCharacterClassEscapes('D', NotDigit); 494 TestCharacterClassEscapes('D', NotDigit);
497 TestCharacterClassEscapes('s', IsWhiteSpace); 495 TestCharacterClassEscapes('s', IsWhiteSpace);
498 TestCharacterClassEscapes('S', NotWhiteSpace); 496 TestCharacterClassEscapes('S', NotWhiteSpace);
499 TestCharacterClassEscapes('w', IsRegExpWord); 497 TestCharacterClassEscapes('w', IsRegExpWord);
500 TestCharacterClassEscapes('W', NotWord); 498 TestCharacterClassEscapes('W', NotWord);
501 } 499 }
502 500
503 501
504 static RegExpNode* Compile(const char* input, bool multiline, bool is_ascii) { 502 static RegExpNode* Compile(const char* input,
503 bool multiline,
504 bool is_ascii,
505 Zone* zone) {
505 V8::Initialize(NULL); 506 V8::Initialize(NULL);
506 Isolate* isolate = Isolate::Current(); 507 Isolate* isolate = Isolate::Current();
507 FlatStringReader reader(isolate, CStrVector(input)); 508 FlatStringReader reader(isolate, CStrVector(input));
508 RegExpCompileData compile_data; 509 RegExpCompileData compile_data;
509 if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline, 510 if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline,
510 &compile_data, 511 &compile_data, zone))
511 isolate->runtime_zone()))
512 return NULL; 512 return NULL;
513 Handle<String> pattern = isolate->factory()-> 513 Handle<String> pattern = isolate->factory()->
514 NewStringFromUtf8(CStrVector(input)); 514 NewStringFromUtf8(CStrVector(input));
515 Handle<String> sample_subject = 515 Handle<String> sample_subject =
516 isolate->factory()->NewStringFromUtf8(CStrVector("")); 516 isolate->factory()->NewStringFromUtf8(CStrVector(""));
517 RegExpEngine::Compile(&compile_data, 517 RegExpEngine::Compile(&compile_data,
518 false, 518 false,
519 false, 519 false,
520 multiline, 520 multiline,
521 pattern, 521 pattern,
522 sample_subject, 522 sample_subject,
523 is_ascii, 523 is_ascii,
524 isolate->runtime_zone()); 524 zone);
525 return compile_data.node; 525 return compile_data.node;
526 } 526 }
527 527
528 528
529 static void Execute(const char* input, 529 static void Execute(const char* input,
530 bool multiline, 530 bool multiline,
531 bool is_ascii, 531 bool is_ascii,
532 bool dot_output = false) { 532 bool dot_output = false) {
533 v8::HandleScope scope(v8::Isolate::GetCurrent()); 533 v8::HandleScope scope(v8::Isolate::GetCurrent());
534 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 534 Zone zone(Isolate::Current());
535 RegExpNode* node = Compile(input, multiline, is_ascii); 535 RegExpNode* node = Compile(input, multiline, is_ascii, &zone);
536 USE(node); 536 USE(node);
537 #ifdef DEBUG 537 #ifdef DEBUG
538 if (dot_output) { 538 if (dot_output) {
539 RegExpEngine::DotPrint(input, node, false); 539 RegExpEngine::DotPrint(input, node, false);
540 exit(0); 540 exit(0);
541 } 541 }
542 #endif // DEBUG 542 #endif // DEBUG
543 } 543 }
544 544
545 545
(...skipping 18 matching lines...) Expand all
564 564
565 565
566 static unsigned PseudoRandom(int i, int j) { 566 static unsigned PseudoRandom(int i, int j) {
567 return ~(~((i * 781) ^ (j * 329))); 567 return ~(~((i * 781) ^ (j * 329)));
568 } 568 }
569 569
570 570
571 TEST(SplayTreeSimple) { 571 TEST(SplayTreeSimple) {
572 v8::internal::V8::Initialize(NULL); 572 v8::internal::V8::Initialize(NULL);
573 static const unsigned kLimit = 1000; 573 static const unsigned kLimit = 1000;
574 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 574 Zone zone(Isolate::Current());
575 ZoneSplayTree<TestConfig> tree(Isolate::Current()->runtime_zone()); 575 ZoneSplayTree<TestConfig> tree(&zone);
576 bool seen[kLimit]; 576 bool seen[kLimit];
577 for (unsigned i = 0; i < kLimit; i++) seen[i] = false; 577 for (unsigned i = 0; i < kLimit; i++) seen[i] = false;
578 #define CHECK_MAPS_EQUAL() do { \ 578 #define CHECK_MAPS_EQUAL() do { \
579 for (unsigned k = 0; k < kLimit; k++) \ 579 for (unsigned k = 0; k < kLimit; k++) \
580 CHECK_EQ(seen[k], tree.Find(k, &loc)); \ 580 CHECK_EQ(seen[k], tree.Find(k, &loc)); \
581 } while (false) 581 } while (false)
582 for (int i = 0; i < 50; i++) { 582 for (int i = 0; i < 50; i++) {
583 for (int j = 0; j < 50; j++) { 583 for (int j = 0; j < 50; j++) {
584 unsigned next = PseudoRandom(i, j) % kLimit; 584 unsigned next = PseudoRandom(i, j) % kLimit;
585 if (seen[next]) { 585 if (seen[next]) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 Vector<uc16> range(ranges[i], 2 * kRangeSize); 632 Vector<uc16> range(ranges[i], 2 * kRangeSize);
633 for (int j = 0; j < 2 * kRangeSize; j++) { 633 for (int j = 0; j < 2 * kRangeSize; j++) {
634 range[j] = PseudoRandom(i + 25, j + 87) % kLimit; 634 range[j] = PseudoRandom(i + 25, j + 87) % kLimit;
635 } 635 }
636 range.Sort(); 636 range.Sort();
637 for (int j = 1; j < 2 * kRangeSize; j++) { 637 for (int j = 1; j < 2 * kRangeSize; j++) {
638 CHECK(range[j-1] <= range[j]); 638 CHECK(range[j-1] <= range[j]);
639 } 639 }
640 } 640 }
641 // Enter test data into dispatch table. 641 // Enter test data into dispatch table.
642 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 642 Zone zone(Isolate::Current());
643 DispatchTable table(Isolate::Current()->runtime_zone()); 643 DispatchTable table(&zone);
644 for (int i = 0; i < kRangeCount; i++) { 644 for (int i = 0; i < kRangeCount; i++) {
645 uc16* range = ranges[i]; 645 uc16* range = ranges[i];
646 for (int j = 0; j < 2 * kRangeSize; j += 2) 646 for (int j = 0; j < 2 * kRangeSize; j += 2)
647 table.AddRange(CharacterRange(range[j], range[j + 1]), i, 647 table.AddRange(CharacterRange(range[j], range[j + 1]), i, &zone);
648 Isolate::Current()->runtime_zone());
649 } 648 }
650 // Check that the table looks as we would expect 649 // Check that the table looks as we would expect
651 for (int p = 0; p < kLimit; p++) { 650 for (int p = 0; p < kLimit; p++) {
652 OutSet* outs = table.Get(p); 651 OutSet* outs = table.Get(p);
653 for (int j = 0; j < kRangeCount; j++) { 652 for (int j = 0; j < kRangeCount; j++) {
654 uc16* range = ranges[j]; 653 uc16* range = ranges[j];
655 bool is_on = false; 654 bool is_on = false;
656 for (int k = 0; !is_on && (k < 2 * kRangeSize); k += 2) 655 for (int k = 0; !is_on && (k < 2 * kRangeSize); k += 2)
657 is_on = (range[k] <= p && p <= range[k + 1]); 656 is_on = (range[k] <= p && p <= range[k + 1]);
658 CHECK_EQ(is_on, outs->Get(j)); 657 CHECK_EQ(is_on, outs->Get(j));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 #elif V8_TARGET_ARCH_ARM 700 #elif V8_TARGET_ARCH_ARM
702 typedef RegExpMacroAssemblerARM ArchRegExpMacroAssembler; 701 typedef RegExpMacroAssemblerARM ArchRegExpMacroAssembler;
703 #elif V8_TARGET_ARCH_MIPS 702 #elif V8_TARGET_ARCH_MIPS
704 typedef RegExpMacroAssemblerMIPS ArchRegExpMacroAssembler; 703 typedef RegExpMacroAssemblerMIPS ArchRegExpMacroAssembler;
705 #endif 704 #endif
706 705
707 class ContextInitializer { 706 class ContextInitializer {
708 public: 707 public:
709 ContextInitializer() 708 ContextInitializer()
710 : scope_(v8::Isolate::GetCurrent()), 709 : scope_(v8::Isolate::GetCurrent()),
711 env_(v8::Context::New(v8::Isolate::GetCurrent())), 710 env_(v8::Context::New(v8::Isolate::GetCurrent())) {
712 zone_(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT) {
713 env_->Enter(); 711 env_->Enter();
714 } 712 }
715 ~ContextInitializer() { 713 ~ContextInitializer() {
716 env_->Exit(); 714 env_->Exit();
717 } 715 }
718 private: 716 private:
719 v8::HandleScope scope_; 717 v8::HandleScope scope_;
720 v8::Handle<v8::Context> env_; 718 v8::Handle<v8::Context> env_;
721 v8::internal::ZoneScope zone_;
722 }; 719 };
723 720
724 721
725 static ArchRegExpMacroAssembler::Result Execute(Code* code, 722 static ArchRegExpMacroAssembler::Result Execute(Code* code,
726 String* input, 723 String* input,
727 int start_offset, 724 int start_offset,
728 const byte* input_start, 725 const byte* input_start,
729 const byte* input_end, 726 const byte* input_end,
730 int* captures) { 727 int* captures) {
731 return NativeRegExpMacroAssembler::Execute( 728 return NativeRegExpMacroAssembler::Execute(
732 code, 729 code,
733 input, 730 input,
734 start_offset, 731 start_offset,
735 input_start, 732 input_start,
736 input_end, 733 input_end,
737 captures, 734 captures,
738 0, 735 0,
739 Isolate::Current()); 736 Isolate::Current());
740 } 737 }
741 738
742 739
743 TEST(MacroAssemblerNativeSuccess) { 740 TEST(MacroAssemblerNativeSuccess) {
744 v8::V8::Initialize(); 741 v8::V8::Initialize();
745 ContextInitializer initializer; 742 ContextInitializer initializer;
746 Factory* factory = Isolate::Current()->factory(); 743 Isolate* isolate = Isolate::Current();
744 Factory* factory = isolate->factory();
745 Zone zone(isolate);
747 746
748 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, 747 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
749 Isolate::Current()->runtime_zone());
750 748
751 m.Succeed(); 749 m.Succeed();
752 750
753 Handle<String> source = factory->NewStringFromAscii(CStrVector("")); 751 Handle<String> source = factory->NewStringFromAscii(CStrVector(""));
754 Handle<Object> code_object = m.GetCode(source); 752 Handle<Object> code_object = m.GetCode(source);
755 Handle<Code> code = Handle<Code>::cast(code_object); 753 Handle<Code> code = Handle<Code>::cast(code_object);
756 754
757 int captures[4] = {42, 37, 87, 117}; 755 int captures[4] = {42, 37, 87, 117};
758 Handle<String> input = factory->NewStringFromAscii(CStrVector("foofoo")); 756 Handle<String> input = factory->NewStringFromAscii(CStrVector("foofoo"));
759 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); 757 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
(...skipping 12 matching lines...) Expand all
772 CHECK_EQ(-1, captures[0]); 770 CHECK_EQ(-1, captures[0]);
773 CHECK_EQ(-1, captures[1]); 771 CHECK_EQ(-1, captures[1]);
774 CHECK_EQ(-1, captures[2]); 772 CHECK_EQ(-1, captures[2]);
775 CHECK_EQ(-1, captures[3]); 773 CHECK_EQ(-1, captures[3]);
776 } 774 }
777 775
778 776
779 TEST(MacroAssemblerNativeSimple) { 777 TEST(MacroAssemblerNativeSimple) {
780 v8::V8::Initialize(); 778 v8::V8::Initialize();
781 ContextInitializer initializer; 779 ContextInitializer initializer;
782 Factory* factory = Isolate::Current()->factory(); 780 Isolate* isolate = Isolate::Current();
781 Factory* factory = isolate->factory();
782 Zone zone(isolate);
783 783
784 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, 784 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
785 Isolate::Current()->runtime_zone());
786 785
787 Label fail, backtrack; 786 Label fail, backtrack;
788 m.PushBacktrack(&fail); 787 m.PushBacktrack(&fail);
789 m.CheckNotAtStart(NULL); 788 m.CheckNotAtStart(NULL);
790 m.LoadCurrentCharacter(2, NULL); 789 m.LoadCurrentCharacter(2, NULL);
791 m.CheckNotCharacter('o', NULL); 790 m.CheckNotCharacter('o', NULL);
792 m.LoadCurrentCharacter(1, NULL, false); 791 m.LoadCurrentCharacter(1, NULL, false);
793 m.CheckNotCharacter('o', NULL); 792 m.CheckNotCharacter('o', NULL);
794 m.LoadCurrentCharacter(0, NULL, false); 793 m.LoadCurrentCharacter(0, NULL, false);
795 m.CheckNotCharacter('f', NULL); 794 m.CheckNotCharacter('f', NULL);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 start_adr + input->length(), 836 start_adr + input->length(),
838 captures); 837 captures);
839 838
840 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); 839 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result);
841 } 840 }
842 841
843 842
844 TEST(MacroAssemblerNativeSimpleUC16) { 843 TEST(MacroAssemblerNativeSimpleUC16) {
845 v8::V8::Initialize(); 844 v8::V8::Initialize();
846 ContextInitializer initializer; 845 ContextInitializer initializer;
847 Factory* factory = Isolate::Current()->factory(); 846 Isolate* isolate = Isolate::Current();
847 Factory* factory = isolate->factory();
848 Zone zone(isolate);
848 849
849 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4, 850 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4, &zone);
850 Isolate::Current()->runtime_zone());
851 851
852 Label fail, backtrack; 852 Label fail, backtrack;
853 m.PushBacktrack(&fail); 853 m.PushBacktrack(&fail);
854 m.CheckNotAtStart(NULL); 854 m.CheckNotAtStart(NULL);
855 m.LoadCurrentCharacter(2, NULL); 855 m.LoadCurrentCharacter(2, NULL);
856 m.CheckNotCharacter('o', NULL); 856 m.CheckNotCharacter('o', NULL);
857 m.LoadCurrentCharacter(1, NULL, false); 857 m.LoadCurrentCharacter(1, NULL, false);
858 m.CheckNotCharacter('o', NULL); 858 m.CheckNotCharacter('o', NULL);
859 m.LoadCurrentCharacter(0, NULL, false); 859 m.LoadCurrentCharacter(0, NULL, false);
860 m.CheckNotCharacter('f', NULL); 860 m.CheckNotCharacter('f', NULL);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 start_adr + input->length() * 2, 907 start_adr + input->length() * 2,
908 captures); 908 captures);
909 909
910 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); 910 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result);
911 } 911 }
912 912
913 913
914 TEST(MacroAssemblerNativeBacktrack) { 914 TEST(MacroAssemblerNativeBacktrack) {
915 v8::V8::Initialize(); 915 v8::V8::Initialize();
916 ContextInitializer initializer; 916 ContextInitializer initializer;
917 Factory* factory = Isolate::Current()->factory(); 917 Isolate* isolate = Isolate::Current();
918 Factory* factory = isolate->factory();
919 Zone zone(isolate);
918 920
919 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, 921 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone);
920 Isolate::Current()->runtime_zone());
921 922
922 Label fail; 923 Label fail;
923 Label backtrack; 924 Label backtrack;
924 m.LoadCurrentCharacter(10, &fail); 925 m.LoadCurrentCharacter(10, &fail);
925 m.Succeed(); 926 m.Succeed();
926 m.Bind(&fail); 927 m.Bind(&fail);
927 m.PushBacktrack(&backtrack); 928 m.PushBacktrack(&backtrack);
928 m.LoadCurrentCharacter(10, NULL); 929 m.LoadCurrentCharacter(10, NULL);
929 m.Succeed(); 930 m.Succeed();
930 m.Bind(&backtrack); 931 m.Bind(&backtrack);
(...skipping 15 matching lines...) Expand all
946 start_adr + input->length(), 947 start_adr + input->length(),
947 NULL); 948 NULL);
948 949
949 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); 950 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result);
950 } 951 }
951 952
952 953
953 TEST(MacroAssemblerNativeBackReferenceASCII) { 954 TEST(MacroAssemblerNativeBackReferenceASCII) {
954 v8::V8::Initialize(); 955 v8::V8::Initialize();
955 ContextInitializer initializer; 956 ContextInitializer initializer;
956 Factory* factory = Isolate::Current()->factory(); 957 Isolate* isolate = Isolate::Current();
958 Factory* factory = isolate->factory();
959 Zone zone(isolate);
957 960
958 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, 961 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
959 Isolate::Current()->runtime_zone());
960 962
961 m.WriteCurrentPositionToRegister(0, 0); 963 m.WriteCurrentPositionToRegister(0, 0);
962 m.AdvanceCurrentPosition(2); 964 m.AdvanceCurrentPosition(2);
963 m.WriteCurrentPositionToRegister(1, 0); 965 m.WriteCurrentPositionToRegister(1, 0);
964 Label nomatch; 966 Label nomatch;
965 m.CheckNotBackReference(0, &nomatch); 967 m.CheckNotBackReference(0, &nomatch);
966 m.Fail(); 968 m.Fail();
967 m.Bind(&nomatch); 969 m.Bind(&nomatch);
968 m.AdvanceCurrentPosition(2); 970 m.AdvanceCurrentPosition(2);
969 Label missing_match; 971 Label missing_match;
(...skipping 24 matching lines...) Expand all
994 CHECK_EQ(0, output[0]); 996 CHECK_EQ(0, output[0]);
995 CHECK_EQ(2, output[1]); 997 CHECK_EQ(2, output[1]);
996 CHECK_EQ(6, output[2]); 998 CHECK_EQ(6, output[2]);
997 CHECK_EQ(-1, output[3]); 999 CHECK_EQ(-1, output[3]);
998 } 1000 }
999 1001
1000 1002
1001 TEST(MacroAssemblerNativeBackReferenceUC16) { 1003 TEST(MacroAssemblerNativeBackReferenceUC16) {
1002 v8::V8::Initialize(); 1004 v8::V8::Initialize();
1003 ContextInitializer initializer; 1005 ContextInitializer initializer;
1004 Factory* factory = Isolate::Current()->factory(); 1006 Isolate* isolate = Isolate::Current();
1007 Factory* factory = isolate->factory();
1008 Zone zone(isolate);
1005 1009
1006 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4, 1010 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4, &zone);
1007 Isolate::Current()->runtime_zone());
1008 1011
1009 m.WriteCurrentPositionToRegister(0, 0); 1012 m.WriteCurrentPositionToRegister(0, 0);
1010 m.AdvanceCurrentPosition(2); 1013 m.AdvanceCurrentPosition(2);
1011 m.WriteCurrentPositionToRegister(1, 0); 1014 m.WriteCurrentPositionToRegister(1, 0);
1012 Label nomatch; 1015 Label nomatch;
1013 m.CheckNotBackReference(0, &nomatch); 1016 m.CheckNotBackReference(0, &nomatch);
1014 m.Fail(); 1017 m.Fail();
1015 m.Bind(&nomatch); 1018 m.Bind(&nomatch);
1016 m.AdvanceCurrentPosition(2); 1019 m.AdvanceCurrentPosition(2);
1017 Label missing_match; 1020 Label missing_match;
(...skipping 27 matching lines...) Expand all
1045 CHECK_EQ(2, output[1]); 1048 CHECK_EQ(2, output[1]);
1046 CHECK_EQ(6, output[2]); 1049 CHECK_EQ(6, output[2]);
1047 CHECK_EQ(-1, output[3]); 1050 CHECK_EQ(-1, output[3]);
1048 } 1051 }
1049 1052
1050 1053
1051 1054
1052 TEST(MacroAssemblernativeAtStart) { 1055 TEST(MacroAssemblernativeAtStart) {
1053 v8::V8::Initialize(); 1056 v8::V8::Initialize();
1054 ContextInitializer initializer; 1057 ContextInitializer initializer;
1055 Factory* factory = Isolate::Current()->factory(); 1058 Isolate* isolate = Isolate::Current();
1059 Factory* factory = isolate->factory();
1060 Zone zone(isolate);
1056 1061
1057 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, 1062 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone);
1058 Isolate::Current()->runtime_zone());
1059 1063
1060 Label not_at_start, newline, fail; 1064 Label not_at_start, newline, fail;
1061 m.CheckNotAtStart(&not_at_start); 1065 m.CheckNotAtStart(&not_at_start);
1062 // Check that prevchar = '\n' and current = 'f'. 1066 // Check that prevchar = '\n' and current = 'f'.
1063 m.CheckCharacter('\n', &newline); 1067 m.CheckCharacter('\n', &newline);
1064 m.Bind(&fail); 1068 m.Bind(&fail);
1065 m.Fail(); 1069 m.Fail();
1066 m.Bind(&newline); 1070 m.Bind(&newline);
1067 m.LoadCurrentCharacter(0, &fail); 1071 m.LoadCurrentCharacter(0, &fail);
1068 m.CheckNotCharacter('f', &fail); 1072 m.CheckNotCharacter('f', &fail);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 start_adr + input->length(), 1107 start_adr + input->length(),
1104 NULL); 1108 NULL);
1105 1109
1106 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); 1110 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result);
1107 } 1111 }
1108 1112
1109 1113
1110 TEST(MacroAssemblerNativeBackRefNoCase) { 1114 TEST(MacroAssemblerNativeBackRefNoCase) {
1111 v8::V8::Initialize(); 1115 v8::V8::Initialize();
1112 ContextInitializer initializer; 1116 ContextInitializer initializer;
1113 Factory* factory = Isolate::Current()->factory(); 1117 Isolate* isolate = Isolate::Current();
1118 Factory* factory = isolate->factory();
1119 Zone zone(isolate);
1114 1120
1115 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, 1121 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
1116 Isolate::Current()->runtime_zone());
1117 1122
1118 Label fail, succ; 1123 Label fail, succ;
1119 1124
1120 m.WriteCurrentPositionToRegister(0, 0); 1125 m.WriteCurrentPositionToRegister(0, 0);
1121 m.WriteCurrentPositionToRegister(2, 0); 1126 m.WriteCurrentPositionToRegister(2, 0);
1122 m.AdvanceCurrentPosition(3); 1127 m.AdvanceCurrentPosition(3);
1123 m.WriteCurrentPositionToRegister(3, 0); 1128 m.WriteCurrentPositionToRegister(3, 0);
1124 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "AbC". 1129 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "AbC".
1125 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "ABC". 1130 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "ABC".
1126 Label expected_fail; 1131 Label expected_fail;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 CHECK_EQ(12, output[1]); 1166 CHECK_EQ(12, output[1]);
1162 CHECK_EQ(0, output[2]); 1167 CHECK_EQ(0, output[2]);
1163 CHECK_EQ(3, output[3]); 1168 CHECK_EQ(3, output[3]);
1164 } 1169 }
1165 1170
1166 1171
1167 1172
1168 TEST(MacroAssemblerNativeRegisters) { 1173 TEST(MacroAssemblerNativeRegisters) {
1169 v8::V8::Initialize(); 1174 v8::V8::Initialize();
1170 ContextInitializer initializer; 1175 ContextInitializer initializer;
1171 Factory* factory = Isolate::Current()->factory(); 1176 Isolate* isolate = Isolate::Current();
1177 Factory* factory = isolate->factory();
1178 Zone zone(isolate);
1172 1179
1173 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 6, 1180 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 6, &zone);
1174 Isolate::Current()->runtime_zone());
1175 1181
1176 uc16 foo_chars[3] = {'f', 'o', 'o'}; 1182 uc16 foo_chars[3] = {'f', 'o', 'o'};
1177 Vector<const uc16> foo(foo_chars, 3); 1183 Vector<const uc16> foo(foo_chars, 3);
1178 1184
1179 enum registers { out1, out2, out3, out4, out5, out6, sp, loop_cnt }; 1185 enum registers { out1, out2, out3, out4, out5, out6, sp, loop_cnt };
1180 Label fail; 1186 Label fail;
1181 Label backtrack; 1187 Label backtrack;
1182 m.WriteCurrentPositionToRegister(out1, 0); // Output: [0] 1188 m.WriteCurrentPositionToRegister(out1, 0); // Output: [0]
1183 m.PushRegister(out1, RegExpMacroAssembler::kNoStackLimitCheck); 1189 m.PushRegister(out1, RegExpMacroAssembler::kNoStackLimitCheck);
1184 m.PushBacktrack(&backtrack); 1190 m.PushBacktrack(&backtrack);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 CHECK_EQ(9, output[4]); 1271 CHECK_EQ(9, output[4]);
1266 CHECK_EQ(-1, output[5]); 1272 CHECK_EQ(-1, output[5]);
1267 } 1273 }
1268 1274
1269 1275
1270 TEST(MacroAssemblerStackOverflow) { 1276 TEST(MacroAssemblerStackOverflow) {
1271 v8::V8::Initialize(); 1277 v8::V8::Initialize();
1272 ContextInitializer initializer; 1278 ContextInitializer initializer;
1273 Isolate* isolate = Isolate::Current(); 1279 Isolate* isolate = Isolate::Current();
1274 Factory* factory = isolate->factory(); 1280 Factory* factory = isolate->factory();
1281 Zone zone(isolate);
1275 1282
1276 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, 1283 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone);
1277 Isolate::Current()->runtime_zone());
1278 1284
1279 Label loop; 1285 Label loop;
1280 m.Bind(&loop); 1286 m.Bind(&loop);
1281 m.PushBacktrack(&loop); 1287 m.PushBacktrack(&loop);
1282 m.GoTo(&loop); 1288 m.GoTo(&loop);
1283 1289
1284 Handle<String> source = 1290 Handle<String> source =
1285 factory->NewStringFromAscii(CStrVector("<stack overflow test>")); 1291 factory->NewStringFromAscii(CStrVector("<stack overflow test>"));
1286 Handle<Object> code_object = m.GetCode(source); 1292 Handle<Object> code_object = m.GetCode(source);
1287 Handle<Code> code = Handle<Code>::cast(code_object); 1293 Handle<Code> code = Handle<Code>::cast(code_object);
(...skipping 16 matching lines...) Expand all
1304 CHECK(isolate->has_pending_exception()); 1310 CHECK(isolate->has_pending_exception());
1305 isolate->clear_pending_exception(); 1311 isolate->clear_pending_exception();
1306 } 1312 }
1307 1313
1308 1314
1309 TEST(MacroAssemblerNativeLotsOfRegisters) { 1315 TEST(MacroAssemblerNativeLotsOfRegisters) {
1310 v8::V8::Initialize(); 1316 v8::V8::Initialize();
1311 ContextInitializer initializer; 1317 ContextInitializer initializer;
1312 Isolate* isolate = Isolate::Current(); 1318 Isolate* isolate = Isolate::Current();
1313 Factory* factory = isolate->factory(); 1319 Factory* factory = isolate->factory();
1320 Zone zone(isolate);
1314 1321
1315 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 2, 1322 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 2, &zone);
1316 Isolate::Current()->runtime_zone());
1317 1323
1318 // At least 2048, to ensure the allocated space for registers 1324 // At least 2048, to ensure the allocated space for registers
1319 // span one full page. 1325 // span one full page.
1320 const int large_number = 8000; 1326 const int large_number = 8000;
1321 m.WriteCurrentPositionToRegister(large_number, 42); 1327 m.WriteCurrentPositionToRegister(large_number, 42);
1322 m.WriteCurrentPositionToRegister(0, 0); 1328 m.WriteCurrentPositionToRegister(0, 0);
1323 m.WriteCurrentPositionToRegister(1, 1); 1329 m.WriteCurrentPositionToRegister(1, 1);
1324 Label done; 1330 Label done;
1325 m.CheckNotBackReference(0, &done); // Performs a system-stack push. 1331 m.CheckNotBackReference(0, &done); // Performs a system-stack push.
1326 m.Bind(&done); 1332 m.Bind(&done);
(...skipping 26 matching lines...) Expand all
1353 CHECK_EQ(42, captures[1]); 1359 CHECK_EQ(42, captures[1]);
1354 1360
1355 isolate->clear_pending_exception(); 1361 isolate->clear_pending_exception();
1356 } 1362 }
1357 1363
1358 #else // V8_INTERPRETED_REGEXP 1364 #else // V8_INTERPRETED_REGEXP
1359 1365
1360 TEST(MacroAssembler) { 1366 TEST(MacroAssembler) {
1361 V8::Initialize(NULL); 1367 V8::Initialize(NULL);
1362 byte codes[1024]; 1368 byte codes[1024];
1363 RegExpMacroAssemblerIrregexp m(Vector<byte>(codes, 1024), 1369 Zone zone(Isolate::Current());
1364 Isolate::Current()->runtime_zone()); 1370 RegExpMacroAssemblerIrregexp m(Vector<byte>(codes, 1024), &zone);
1365 // ^f(o)o. 1371 // ^f(o)o.
1366 Label start, fail, backtrack; 1372 Label start, fail, backtrack;
1367 1373
1368 m.SetRegister(4, 42); 1374 m.SetRegister(4, 42);
1369 m.PushRegister(4, RegExpMacroAssembler::kNoStackLimitCheck); 1375 m.PushRegister(4, RegExpMacroAssembler::kNoStackLimitCheck);
1370 m.AdvanceRegister(4, 42); 1376 m.AdvanceRegister(4, 42);
1371 m.GoTo(&start); 1377 m.GoTo(&start);
1372 m.Fail(); 1378 m.Fail();
1373 m.Bind(&start); 1379 m.Bind(&start);
1374 m.PushBacktrack(&fail); 1380 m.PushBacktrack(&fail);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 } 1427 }
1422 1428
1423 #endif // V8_INTERPRETED_REGEXP 1429 #endif // V8_INTERPRETED_REGEXP
1424 1430
1425 1431
1426 TEST(AddInverseToTable) { 1432 TEST(AddInverseToTable) {
1427 v8::internal::V8::Initialize(NULL); 1433 v8::internal::V8::Initialize(NULL);
1428 static const int kLimit = 1000; 1434 static const int kLimit = 1000;
1429 static const int kRangeCount = 16; 1435 static const int kRangeCount = 16;
1430 for (int t = 0; t < 10; t++) { 1436 for (int t = 0; t < 10; t++) {
1431 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 1437 Zone zone(Isolate::Current());
1432 Zone* zone = Isolate::Current()->runtime_zone();
1433 ZoneList<CharacterRange>* ranges = 1438 ZoneList<CharacterRange>* ranges =
1434 new(zone) 1439 new(&zone) ZoneList<CharacterRange>(kRangeCount, &zone);
1435 ZoneList<CharacterRange>(kRangeCount, zone);
1436 for (int i = 0; i < kRangeCount; i++) { 1440 for (int i = 0; i < kRangeCount; i++) {
1437 int from = PseudoRandom(t + 87, i + 25) % kLimit; 1441 int from = PseudoRandom(t + 87, i + 25) % kLimit;
1438 int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20)); 1442 int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20));
1439 if (to > kLimit) to = kLimit; 1443 if (to > kLimit) to = kLimit;
1440 ranges->Add(CharacterRange(from, to), zone); 1444 ranges->Add(CharacterRange(from, to), &zone);
1441 } 1445 }
1442 DispatchTable table(zone); 1446 DispatchTable table(&zone);
1443 DispatchTableConstructor cons(&table, false, 1447 DispatchTableConstructor cons(&table, false, &zone);
1444 Isolate::Current()->runtime_zone());
1445 cons.set_choice_index(0); 1448 cons.set_choice_index(0);
1446 cons.AddInverse(ranges); 1449 cons.AddInverse(ranges);
1447 for (int i = 0; i < kLimit; i++) { 1450 for (int i = 0; i < kLimit; i++) {
1448 bool is_on = false; 1451 bool is_on = false;
1449 for (int j = 0; !is_on && j < kRangeCount; j++) 1452 for (int j = 0; !is_on && j < kRangeCount; j++)
1450 is_on = ranges->at(j).Contains(i); 1453 is_on = ranges->at(j).Contains(i);
1451 OutSet* set = table.Get(i); 1454 OutSet* set = table.Get(i);
1452 CHECK_EQ(is_on, set->Get(0) == false); 1455 CHECK_EQ(is_on, set->Get(0) == false);
1453 } 1456 }
1454 } 1457 }
1455 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 1458 Zone zone(Isolate::Current());
1456 Zone* zone = Isolate::Current()->runtime_zone();
1457 ZoneList<CharacterRange>* ranges = 1459 ZoneList<CharacterRange>* ranges =
1458 new(zone) ZoneList<CharacterRange>(1, zone); 1460 new(&zone) ZoneList<CharacterRange>(1, &zone);
1459 ranges->Add(CharacterRange(0xFFF0, 0xFFFE), zone); 1461 ranges->Add(CharacterRange(0xFFF0, 0xFFFE), &zone);
1460 DispatchTable table(zone); 1462 DispatchTable table(&zone);
1461 DispatchTableConstructor cons(&table, false, 1463 DispatchTableConstructor cons(&table, false, &zone);
1462 Isolate::Current()->runtime_zone());
1463 cons.set_choice_index(0); 1464 cons.set_choice_index(0);
1464 cons.AddInverse(ranges); 1465 cons.AddInverse(ranges);
1465 CHECK(!table.Get(0xFFFE)->Get(0)); 1466 CHECK(!table.Get(0xFFFE)->Get(0));
1466 CHECK(table.Get(0xFFFF)->Get(0)); 1467 CHECK(table.Get(0xFFFF)->Get(0));
1467 } 1468 }
1468 1469
1469 1470
1470 static uc32 canonicalize(uc32 c) { 1471 static uc32 canonicalize(uc32 c) {
1471 unibrow::uchar canon[unibrow::Ecma262Canonicalize::kMaxWidth]; 1472 unibrow::uchar canon[unibrow::Ecma262Canonicalize::kMaxWidth];
1472 int count = unibrow::Ecma262Canonicalize::Convert(c, '\0', canon, NULL); 1473 int count = unibrow::Ecma262Canonicalize::Convert(c, '\0', canon, NULL);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 CHECK_EQ(length, length2); 1561 CHECK_EQ(length, length2);
1561 for (int k = 0; k < length; k++) 1562 for (int k = 0; k < length; k++)
1562 CHECK_EQ(static_cast<int>(chars[k]), static_cast<int>(chars2[k])); 1563 CHECK_EQ(static_cast<int>(chars[k]), static_cast<int>(chars2[k]));
1563 } 1564 }
1564 } 1565 }
1565 } 1566 }
1566 1567
1567 1568
1568 static void TestRangeCaseIndependence(CharacterRange input, 1569 static void TestRangeCaseIndependence(CharacterRange input,
1569 Vector<CharacterRange> expected) { 1570 Vector<CharacterRange> expected) {
1570 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 1571 Zone zone(Isolate::Current());
1571 Zone* zone = Isolate::Current()->runtime_zone();
1572 int count = expected.length(); 1572 int count = expected.length();
1573 ZoneList<CharacterRange>* list = 1573 ZoneList<CharacterRange>* list =
1574 new(zone) ZoneList<CharacterRange>(count, zone); 1574 new(&zone) ZoneList<CharacterRange>(count, &zone);
1575 input.AddCaseEquivalents(list, false, zone); 1575 input.AddCaseEquivalents(list, false, &zone);
1576 CHECK_EQ(count, list->length()); 1576 CHECK_EQ(count, list->length());
1577 for (int i = 0; i < list->length(); i++) { 1577 for (int i = 0; i < list->length(); i++) {
1578 CHECK_EQ(expected[i].from(), list->at(i).from()); 1578 CHECK_EQ(expected[i].from(), list->at(i).from());
1579 CHECK_EQ(expected[i].to(), list->at(i).to()); 1579 CHECK_EQ(expected[i].to(), list->at(i).to());
1580 } 1580 }
1581 } 1581 }
1582 1582
1583 1583
1584 static void TestSimpleRangeCaseIndependence(CharacterRange input, 1584 static void TestSimpleRangeCaseIndependence(CharacterRange input,
1585 CharacterRange expected) { 1585 CharacterRange expected) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 CharacterRange range = ranges->at(i); 1626 CharacterRange range = ranges->at(i);
1627 if (range.from() <= c && c <= range.to()) 1627 if (range.from() <= c && c <= range.to())
1628 return true; 1628 return true;
1629 } 1629 }
1630 return false; 1630 return false;
1631 } 1631 }
1632 1632
1633 1633
1634 TEST(CharClassDifference) { 1634 TEST(CharClassDifference) {
1635 v8::internal::V8::Initialize(NULL); 1635 v8::internal::V8::Initialize(NULL);
1636 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 1636 Zone zone(Isolate::Current());
1637 Zone* zone = Isolate::Current()->runtime_zone();
1638 ZoneList<CharacterRange>* base = 1637 ZoneList<CharacterRange>* base =
1639 new(zone) ZoneList<CharacterRange>(1, zone); 1638 new(&zone) ZoneList<CharacterRange>(1, &zone);
1640 base->Add(CharacterRange::Everything(), zone); 1639 base->Add(CharacterRange::Everything(), &zone);
1641 Vector<const int> overlay = CharacterRange::GetWordBounds(); 1640 Vector<const int> overlay = CharacterRange::GetWordBounds();
1642 ZoneList<CharacterRange>* included = NULL; 1641 ZoneList<CharacterRange>* included = NULL;
1643 ZoneList<CharacterRange>* excluded = NULL; 1642 ZoneList<CharacterRange>* excluded = NULL;
1644 CharacterRange::Split(base, overlay, &included, &excluded, 1643 CharacterRange::Split(base, overlay, &included, &excluded, &zone);
1645 Isolate::Current()->runtime_zone());
1646 for (int i = 0; i < (1 << 16); i++) { 1644 for (int i = 0; i < (1 << 16); i++) {
1647 bool in_base = InClass(i, base); 1645 bool in_base = InClass(i, base);
1648 if (in_base) { 1646 if (in_base) {
1649 bool in_overlay = false; 1647 bool in_overlay = false;
1650 for (int j = 0; !in_overlay && j < overlay.length(); j += 2) { 1648 for (int j = 0; !in_overlay && j < overlay.length(); j += 2) {
1651 if (overlay[j] <= i && i < overlay[j+1]) 1649 if (overlay[j] <= i && i < overlay[j+1])
1652 in_overlay = true; 1650 in_overlay = true;
1653 } 1651 }
1654 CHECK_EQ(in_overlay, InClass(i, included)); 1652 CHECK_EQ(in_overlay, InClass(i, included));
1655 CHECK_EQ(!in_overlay, InClass(i, excluded)); 1653 CHECK_EQ(!in_overlay, InClass(i, excluded));
1656 } else { 1654 } else {
1657 CHECK(!InClass(i, included)); 1655 CHECK(!InClass(i, included));
1658 CHECK(!InClass(i, excluded)); 1656 CHECK(!InClass(i, excluded));
1659 } 1657 }
1660 } 1658 }
1661 } 1659 }
1662 1660
1663 1661
1664 TEST(CanonicalizeCharacterSets) { 1662 TEST(CanonicalizeCharacterSets) {
1665 v8::internal::V8::Initialize(NULL); 1663 v8::internal::V8::Initialize(NULL);
1666 ZoneScope scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 1664 Zone zone(Isolate::Current());
1667 Zone* zone = Isolate::Current()->runtime_zone();
1668 ZoneList<CharacterRange>* list = 1665 ZoneList<CharacterRange>* list =
1669 new(zone) ZoneList<CharacterRange>(4, zone); 1666 new(&zone) ZoneList<CharacterRange>(4, &zone);
1670 CharacterSet set(list); 1667 CharacterSet set(list);
1671 1668
1672 list->Add(CharacterRange(10, 20), zone); 1669 list->Add(CharacterRange(10, 20), &zone);
1673 list->Add(CharacterRange(30, 40), zone); 1670 list->Add(CharacterRange(30, 40), &zone);
1674 list->Add(CharacterRange(50, 60), zone); 1671 list->Add(CharacterRange(50, 60), &zone);
1675 set.Canonicalize(); 1672 set.Canonicalize();
1676 ASSERT_EQ(3, list->length()); 1673 ASSERT_EQ(3, list->length());
1677 ASSERT_EQ(10, list->at(0).from()); 1674 ASSERT_EQ(10, list->at(0).from());
1678 ASSERT_EQ(20, list->at(0).to()); 1675 ASSERT_EQ(20, list->at(0).to());
1679 ASSERT_EQ(30, list->at(1).from()); 1676 ASSERT_EQ(30, list->at(1).from());
1680 ASSERT_EQ(40, list->at(1).to()); 1677 ASSERT_EQ(40, list->at(1).to());
1681 ASSERT_EQ(50, list->at(2).from()); 1678 ASSERT_EQ(50, list->at(2).from());
1682 ASSERT_EQ(60, list->at(2).to()); 1679 ASSERT_EQ(60, list->at(2).to());
1683 1680
1684 list->Rewind(0); 1681 list->Rewind(0);
1685 list->Add(CharacterRange(10, 20), zone); 1682 list->Add(CharacterRange(10, 20), &zone);
1686 list->Add(CharacterRange(50, 60), zone); 1683 list->Add(CharacterRange(50, 60), &zone);
1687 list->Add(CharacterRange(30, 40), zone); 1684 list->Add(CharacterRange(30, 40), &zone);
1688 set.Canonicalize(); 1685 set.Canonicalize();
1689 ASSERT_EQ(3, list->length()); 1686 ASSERT_EQ(3, list->length());
1690 ASSERT_EQ(10, list->at(0).from()); 1687 ASSERT_EQ(10, list->at(0).from());
1691 ASSERT_EQ(20, list->at(0).to()); 1688 ASSERT_EQ(20, list->at(0).to());
1692 ASSERT_EQ(30, list->at(1).from()); 1689 ASSERT_EQ(30, list->at(1).from());
1693 ASSERT_EQ(40, list->at(1).to()); 1690 ASSERT_EQ(40, list->at(1).to());
1694 ASSERT_EQ(50, list->at(2).from()); 1691 ASSERT_EQ(50, list->at(2).from());
1695 ASSERT_EQ(60, list->at(2).to()); 1692 ASSERT_EQ(60, list->at(2).to());
1696 1693
1697 list->Rewind(0); 1694 list->Rewind(0);
1698 list->Add(CharacterRange(30, 40), zone); 1695 list->Add(CharacterRange(30, 40), &zone);
1699 list->Add(CharacterRange(10, 20), zone); 1696 list->Add(CharacterRange(10, 20), &zone);
1700 list->Add(CharacterRange(25, 25), zone); 1697 list->Add(CharacterRange(25, 25), &zone);
1701 list->Add(CharacterRange(100, 100), zone); 1698 list->Add(CharacterRange(100, 100), &zone);
1702 list->Add(CharacterRange(1, 1), zone); 1699 list->Add(CharacterRange(1, 1), &zone);
1703 set.Canonicalize(); 1700 set.Canonicalize();
1704 ASSERT_EQ(5, list->length()); 1701 ASSERT_EQ(5, list->length());
1705 ASSERT_EQ(1, list->at(0).from()); 1702 ASSERT_EQ(1, list->at(0).from());
1706 ASSERT_EQ(1, list->at(0).to()); 1703 ASSERT_EQ(1, list->at(0).to());
1707 ASSERT_EQ(10, list->at(1).from()); 1704 ASSERT_EQ(10, list->at(1).from());
1708 ASSERT_EQ(20, list->at(1).to()); 1705 ASSERT_EQ(20, list->at(1).to());
1709 ASSERT_EQ(25, list->at(2).from()); 1706 ASSERT_EQ(25, list->at(2).from());
1710 ASSERT_EQ(25, list->at(2).to()); 1707 ASSERT_EQ(25, list->at(2).to());
1711 ASSERT_EQ(30, list->at(3).from()); 1708 ASSERT_EQ(30, list->at(3).from());
1712 ASSERT_EQ(40, list->at(3).to()); 1709 ASSERT_EQ(40, list->at(3).to());
1713 ASSERT_EQ(100, list->at(4).from()); 1710 ASSERT_EQ(100, list->at(4).from());
1714 ASSERT_EQ(100, list->at(4).to()); 1711 ASSERT_EQ(100, list->at(4).to());
1715 1712
1716 list->Rewind(0); 1713 list->Rewind(0);
1717 list->Add(CharacterRange(10, 19), zone); 1714 list->Add(CharacterRange(10, 19), &zone);
1718 list->Add(CharacterRange(21, 30), zone); 1715 list->Add(CharacterRange(21, 30), &zone);
1719 list->Add(CharacterRange(20, 20), zone); 1716 list->Add(CharacterRange(20, 20), &zone);
1720 set.Canonicalize(); 1717 set.Canonicalize();
1721 ASSERT_EQ(1, list->length()); 1718 ASSERT_EQ(1, list->length());
1722 ASSERT_EQ(10, list->at(0).from()); 1719 ASSERT_EQ(10, list->at(0).from());
1723 ASSERT_EQ(30, list->at(0).to()); 1720 ASSERT_EQ(30, list->at(0).to());
1724 } 1721 }
1725 1722
1726 1723
1727 TEST(CharacterRangeMerge) { 1724 TEST(CharacterRangeMerge) {
1728 v8::internal::V8::Initialize(NULL); 1725 v8::internal::V8::Initialize(NULL);
1729 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); 1726 Zone zone(Isolate::Current());
1730 ZoneList<CharacterRange> l1(4, Isolate::Current()->runtime_zone()); 1727 ZoneList<CharacterRange> l1(4, &zone);
1731 ZoneList<CharacterRange> l2(4, Isolate::Current()->runtime_zone()); 1728 ZoneList<CharacterRange> l2(4, &zone);
1732 Zone* zone = Isolate::Current()->runtime_zone();
1733 // Create all combinations of intersections of ranges, both singletons and 1729 // Create all combinations of intersections of ranges, both singletons and
1734 // longer. 1730 // longer.
1735 1731
1736 int offset = 0; 1732 int offset = 0;
1737 1733
1738 // The five kinds of singleton intersections: 1734 // The five kinds of singleton intersections:
1739 // X 1735 // X
1740 // Y - outside before 1736 // Y - outside before
1741 // Y - outside touching start 1737 // Y - outside touching start
1742 // Y - overlap 1738 // Y - overlap
1743 // Y - outside touching end 1739 // Y - outside touching end
1744 // Y - outside after 1740 // Y - outside after
1745 1741
1746 for (int i = 0; i < 5; i++) { 1742 for (int i = 0; i < 5; i++) {
1747 l1.Add(CharacterRange::Singleton(offset + 2), zone); 1743 l1.Add(CharacterRange::Singleton(offset + 2), &zone);
1748 l2.Add(CharacterRange::Singleton(offset + i), zone); 1744 l2.Add(CharacterRange::Singleton(offset + i), &zone);
1749 offset += 6; 1745 offset += 6;
1750 } 1746 }
1751 1747
1752 // The seven kinds of singleton/non-singleton intersections: 1748 // The seven kinds of singleton/non-singleton intersections:
1753 // XXX 1749 // XXX
1754 // Y - outside before 1750 // Y - outside before
1755 // Y - outside touching start 1751 // Y - outside touching start
1756 // Y - inside touching start 1752 // Y - inside touching start
1757 // Y - entirely inside 1753 // Y - entirely inside
1758 // Y - inside touching end 1754 // Y - inside touching end
1759 // Y - outside touching end 1755 // Y - outside touching end
1760 // Y - disjoint after 1756 // Y - disjoint after
1761 1757
1762 for (int i = 0; i < 7; i++) { 1758 for (int i = 0; i < 7; i++) {
1763 l1.Add(CharacterRange::Range(offset + 2, offset + 4), zone); 1759 l1.Add(CharacterRange::Range(offset + 2, offset + 4), &zone);
1764 l2.Add(CharacterRange::Singleton(offset + i), zone); 1760 l2.Add(CharacterRange::Singleton(offset + i), &zone);
1765 offset += 8; 1761 offset += 8;
1766 } 1762 }
1767 1763
1768 // The eleven kinds of non-singleton intersections: 1764 // The eleven kinds of non-singleton intersections:
1769 // 1765 //
1770 // XXXXXXXX 1766 // XXXXXXXX
1771 // YYYY - outside before. 1767 // YYYY - outside before.
1772 // YYYY - outside touching start. 1768 // YYYY - outside touching start.
1773 // YYYY - overlapping start 1769 // YYYY - overlapping start
1774 // YYYY - inside touching start 1770 // YYYY - inside touching start
1775 // YYYY - entirely inside 1771 // YYYY - entirely inside
1776 // YYYY - inside touching end 1772 // YYYY - inside touching end
1777 // YYYY - overlapping end 1773 // YYYY - overlapping end
1778 // YYYY - outside touching end 1774 // YYYY - outside touching end
1779 // YYYY - outside after 1775 // YYYY - outside after
1780 // YYYYYYYY - identical 1776 // YYYYYYYY - identical
1781 // YYYYYYYYYYYY - containing entirely. 1777 // YYYYYYYYYYYY - containing entirely.
1782 1778
1783 for (int i = 0; i < 9; i++) { 1779 for (int i = 0; i < 9; i++) {
1784 l1.Add(CharacterRange::Range(offset + 6, offset + 15), zone); // Length 8. 1780 l1.Add(CharacterRange::Range(offset + 6, offset + 15), &zone); // Length 8.
1785 l2.Add(CharacterRange::Range(offset + 2 * i, offset + 2 * i + 3), zone); 1781 l2.Add(CharacterRange::Range(offset + 2 * i, offset + 2 * i + 3), &zone);
1786 offset += 22; 1782 offset += 22;
1787 } 1783 }
1788 l1.Add(CharacterRange::Range(offset + 6, offset + 15), zone); 1784 l1.Add(CharacterRange::Range(offset + 6, offset + 15), &zone);
1789 l2.Add(CharacterRange::Range(offset + 6, offset + 15), zone); 1785 l2.Add(CharacterRange::Range(offset + 6, offset + 15), &zone);
1790 offset += 22; 1786 offset += 22;
1791 l1.Add(CharacterRange::Range(offset + 6, offset + 15), zone); 1787 l1.Add(CharacterRange::Range(offset + 6, offset + 15), &zone);
1792 l2.Add(CharacterRange::Range(offset + 4, offset + 17), zone); 1788 l2.Add(CharacterRange::Range(offset + 4, offset + 17), &zone);
1793 offset += 22; 1789 offset += 22;
1794 1790
1795 // Different kinds of multi-range overlap: 1791 // Different kinds of multi-range overlap:
1796 // XXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXX 1792 // XXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXX
1797 // YYYY Y YYYY Y YYYY Y YYYY Y YYYY Y YYYY Y 1793 // YYYY Y YYYY Y YYYY Y YYYY Y YYYY Y YYYY Y
1798 1794
1799 l1.Add(CharacterRange::Range(offset, offset + 21), zone); 1795 l1.Add(CharacterRange::Range(offset, offset + 21), &zone);
1800 l1.Add(CharacterRange::Range(offset + 31, offset + 52), zone); 1796 l1.Add(CharacterRange::Range(offset + 31, offset + 52), &zone);
1801 for (int i = 0; i < 6; i++) { 1797 for (int i = 0; i < 6; i++) {
1802 l2.Add(CharacterRange::Range(offset + 2, offset + 5), zone); 1798 l2.Add(CharacterRange::Range(offset + 2, offset + 5), &zone);
1803 l2.Add(CharacterRange::Singleton(offset + 8), zone); 1799 l2.Add(CharacterRange::Singleton(offset + 8), &zone);
1804 offset += 9; 1800 offset += 9;
1805 } 1801 }
1806 1802
1807 ASSERT(CharacterRange::IsCanonical(&l1)); 1803 ASSERT(CharacterRange::IsCanonical(&l1));
1808 ASSERT(CharacterRange::IsCanonical(&l2)); 1804 ASSERT(CharacterRange::IsCanonical(&l2));
1809 1805
1810 ZoneList<CharacterRange> first_only(4, Isolate::Current()->runtime_zone()); 1806 ZoneList<CharacterRange> first_only(4, &zone);
1811 ZoneList<CharacterRange> second_only(4, Isolate::Current()->runtime_zone()); 1807 ZoneList<CharacterRange> second_only(4, &zone);
1812 ZoneList<CharacterRange> both(4, Isolate::Current()->runtime_zone()); 1808 ZoneList<CharacterRange> both(4, &zone);
1813 } 1809 }
1814 1810
1815 1811
1816 TEST(Graph) { 1812 TEST(Graph) {
1817 V8::Initialize(NULL); 1813 V8::Initialize(NULL);
1818 Execute("\\b\\w+\\b", false, true, true); 1814 Execute("\\b\\w+\\b", false, true, true);
1819 } 1815 }
OLDNEW
« no previous file with comments | « test/cctest/test-liveedit.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698