| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; | 74 v8::HandleScope scope; |
| 75 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); | 75 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); |
| 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(&reader, false, &result); | 78 return v8::internal::RegExpParser::ParseRegExp( |
| 79 &reader, false, &result, Isolate::Current()->runtime_zone()); |
| 79 } | 80 } |
| 80 | 81 |
| 81 | 82 |
| 82 static SmartArrayPointer<const char> Parse(const char* input) { | 83 static SmartArrayPointer<const char> Parse(const char* input) { |
| 83 V8::Initialize(NULL); | 84 V8::Initialize(NULL); |
| 84 v8::HandleScope scope; | 85 v8::HandleScope scope; |
| 85 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); | 86 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); |
| 86 FlatStringReader reader(Isolate::Current(), CStrVector(input)); | 87 FlatStringReader reader(Isolate::Current(), CStrVector(input)); |
| 87 RegExpCompileData result; | 88 RegExpCompileData result; |
| 88 CHECK(v8::internal::RegExpParser::ParseRegExp(&reader, false, &result)); | 89 CHECK(v8::internal::RegExpParser::ParseRegExp( |
| 90 &reader, false, &result, Isolate::Current()->runtime_zone())); |
| 89 CHECK(result.tree != NULL); | 91 CHECK(result.tree != NULL); |
| 90 CHECK(result.error.is_null()); | 92 CHECK(result.error.is_null()); |
| 91 SmartArrayPointer<const char> output = | 93 SmartArrayPointer<const char> output = |
| 92 result.tree->ToString(Isolate::Current()->zone()); | 94 result.tree->ToString(Isolate::Current()->runtime_zone()); |
| 93 return output; | 95 return output; |
| 94 } | 96 } |
| 95 | 97 |
| 96 static bool CheckSimple(const char* input) { | 98 static bool CheckSimple(const char* input) { |
| 97 V8::Initialize(NULL); | 99 V8::Initialize(NULL); |
| 98 v8::HandleScope scope; | 100 v8::HandleScope scope; |
| 99 unibrow::Utf8InputBuffer<> buffer(input, StrLength(input)); | 101 unibrow::Utf8InputBuffer<> buffer(input, StrLength(input)); |
| 100 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); | 102 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); |
| 101 FlatStringReader reader(Isolate::Current(), CStrVector(input)); | 103 FlatStringReader reader(Isolate::Current(), CStrVector(input)); |
| 102 RegExpCompileData result; | 104 RegExpCompileData result; |
| 103 CHECK(v8::internal::RegExpParser::ParseRegExp(&reader, false, &result)); | 105 CHECK(v8::internal::RegExpParser::ParseRegExp( |
| 106 &reader, false, &result, Isolate::Current()->runtime_zone())); |
| 104 CHECK(result.tree != NULL); | 107 CHECK(result.tree != NULL); |
| 105 CHECK(result.error.is_null()); | 108 CHECK(result.error.is_null()); |
| 106 return result.simple; | 109 return result.simple; |
| 107 } | 110 } |
| 108 | 111 |
| 109 struct MinMaxPair { | 112 struct MinMaxPair { |
| 110 int min_match; | 113 int min_match; |
| 111 int max_match; | 114 int max_match; |
| 112 }; | 115 }; |
| 113 | 116 |
| 114 static MinMaxPair CheckMinMaxMatch(const char* input) { | 117 static MinMaxPair CheckMinMaxMatch(const char* input) { |
| 115 V8::Initialize(NULL); | 118 V8::Initialize(NULL); |
| 116 v8::HandleScope scope; | 119 v8::HandleScope scope; |
| 117 unibrow::Utf8InputBuffer<> buffer(input, StrLength(input)); | 120 unibrow::Utf8InputBuffer<> buffer(input, StrLength(input)); |
| 118 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); | 121 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); |
| 119 FlatStringReader reader(Isolate::Current(), CStrVector(input)); | 122 FlatStringReader reader(Isolate::Current(), CStrVector(input)); |
| 120 RegExpCompileData result; | 123 RegExpCompileData result; |
| 121 CHECK(v8::internal::RegExpParser::ParseRegExp(&reader, false, &result)); | 124 CHECK(v8::internal::RegExpParser::ParseRegExp( |
| 125 &reader, false, &result, Isolate::Current()->runtime_zone())); |
| 122 CHECK(result.tree != NULL); | 126 CHECK(result.tree != NULL); |
| 123 CHECK(result.error.is_null()); | 127 CHECK(result.error.is_null()); |
| 124 int min_match = result.tree->min_match(); | 128 int min_match = result.tree->min_match(); |
| 125 int max_match = result.tree->max_match(); | 129 int max_match = result.tree->max_match(); |
| 126 MinMaxPair pair = { min_match, max_match }; | 130 MinMaxPair pair = { min_match, max_match }; |
| 127 return pair; | 131 return pair; |
| 128 } | 132 } |
| 129 | 133 |
| 130 | 134 |
| 131 #define CHECK_PARSE_ERROR(input) CHECK(!CheckParse(input)) | 135 #define CHECK_PARSE_ERROR(input) CHECK(!CheckParse(input)) |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 CHECK_PARSE_EQ("[A-Z$-][x]", "(! [A-Z $ -] [x])"); | 383 CHECK_PARSE_EQ("[A-Z$-][x]", "(! [A-Z $ -] [x])"); |
| 380 CHECK_PARSE_EQ("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')"); | 384 CHECK_PARSE_EQ("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')"); |
| 381 CHECK_PARSE_EQ("{", "'{'"); | 385 CHECK_PARSE_EQ("{", "'{'"); |
| 382 CHECK_PARSE_EQ("a|", "(| 'a' %)"); | 386 CHECK_PARSE_EQ("a|", "(| 'a' %)"); |
| 383 } | 387 } |
| 384 | 388 |
| 385 static void ExpectError(const char* input, | 389 static void ExpectError(const char* input, |
| 386 const char* expected) { | 390 const char* expected) { |
| 387 V8::Initialize(NULL); | 391 V8::Initialize(NULL); |
| 388 v8::HandleScope scope; | 392 v8::HandleScope scope; |
| 389 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); | 393 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); |
| 390 FlatStringReader reader(Isolate::Current(), CStrVector(input)); | 394 FlatStringReader reader(Isolate::Current(), CStrVector(input)); |
| 391 RegExpCompileData result; | 395 RegExpCompileData result; |
| 392 CHECK(!v8::internal::RegExpParser::ParseRegExp(&reader, false, &result)); | 396 CHECK(!v8::internal::RegExpParser::ParseRegExp( |
| 397 &reader, false, &result, Isolate::Current()->runtime_zone())); |
| 393 CHECK(result.tree == NULL); | 398 CHECK(result.tree == NULL); |
| 394 CHECK(!result.error.is_null()); | 399 CHECK(!result.error.is_null()); |
| 395 SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS); | 400 SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS); |
| 396 CHECK_EQ(expected, *str); | 401 CHECK_EQ(expected, *str); |
| 397 } | 402 } |
| 398 | 403 |
| 399 | 404 |
| 400 TEST(Errors) { | 405 TEST(Errors) { |
| 401 V8::Initialize(NULL); | 406 V8::Initialize(NULL); |
| 402 const char* kEndBackslash = "\\ at end of pattern"; | 407 const char* kEndBackslash = "\\ at end of pattern"; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 return !IsWhiteSpace(c); | 467 return !IsWhiteSpace(c); |
| 463 } | 468 } |
| 464 | 469 |
| 465 | 470 |
| 466 static bool NotWord(uc16 c) { | 471 static bool NotWord(uc16 c) { |
| 467 return !IsRegExpWord(c); | 472 return !IsRegExpWord(c); |
| 468 } | 473 } |
| 469 | 474 |
| 470 | 475 |
| 471 static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) { | 476 static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) { |
| 472 ZoneScope scope(Isolate::Current(), DELETE_ON_EXIT); | 477 ZoneScope scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); |
| 473 Zone* zone = Isolate::Current()->zone(); | 478 Zone* zone = Isolate::Current()->runtime_zone(); |
| 474 ZoneList<CharacterRange>* ranges = | 479 ZoneList<CharacterRange>* ranges = |
| 475 new(zone) ZoneList<CharacterRange>(2, zone); | 480 new(zone) ZoneList<CharacterRange>(2, zone); |
| 476 CharacterRange::AddClassEscape(c, ranges, zone); | 481 CharacterRange::AddClassEscape(c, ranges, zone); |
| 477 for (unsigned i = 0; i < (1 << 16); i++) { | 482 for (unsigned i = 0; i < (1 << 16); i++) { |
| 478 bool in_class = false; | 483 bool in_class = false; |
| 479 for (int j = 0; !in_class && j < ranges->length(); j++) { | 484 for (int j = 0; !in_class && j < ranges->length(); j++) { |
| 480 CharacterRange& range = ranges->at(j); | 485 CharacterRange& range = ranges->at(j); |
| 481 in_class = (range.from() <= i && i <= range.to()); | 486 in_class = (range.from() <= i && i <= range.to()); |
| 482 } | 487 } |
| 483 CHECK_EQ(pred(i), in_class); | 488 CHECK_EQ(pred(i), in_class); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 496 TestCharacterClassEscapes('W', NotWord); | 501 TestCharacterClassEscapes('W', NotWord); |
| 497 } | 502 } |
| 498 | 503 |
| 499 | 504 |
| 500 static RegExpNode* Compile(const char* input, bool multiline, bool is_ascii) { | 505 static RegExpNode* Compile(const char* input, bool multiline, bool is_ascii) { |
| 501 V8::Initialize(NULL); | 506 V8::Initialize(NULL); |
| 502 Isolate* isolate = Isolate::Current(); | 507 Isolate* isolate = Isolate::Current(); |
| 503 FlatStringReader reader(isolate, CStrVector(input)); | 508 FlatStringReader reader(isolate, CStrVector(input)); |
| 504 RegExpCompileData compile_data; | 509 RegExpCompileData compile_data; |
| 505 if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline, | 510 if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline, |
| 506 &compile_data)) | 511 &compile_data, |
| 512 isolate->runtime_zone())) |
| 507 return NULL; | 513 return NULL; |
| 508 Handle<String> pattern = isolate->factory()-> | 514 Handle<String> pattern = isolate->factory()-> |
| 509 NewStringFromUtf8(CStrVector(input)); | 515 NewStringFromUtf8(CStrVector(input)); |
| 510 Handle<String> sample_subject = | 516 Handle<String> sample_subject = |
| 511 isolate->factory()->NewStringFromUtf8(CStrVector("")); | 517 isolate->factory()->NewStringFromUtf8(CStrVector("")); |
| 512 RegExpEngine::Compile(&compile_data, | 518 RegExpEngine::Compile(&compile_data, |
| 513 false, | 519 false, |
| 514 false, | 520 false, |
| 515 multiline, | 521 multiline, |
| 516 pattern, | 522 pattern, |
| 517 sample_subject, | 523 sample_subject, |
| 518 is_ascii, | 524 is_ascii, |
| 519 isolate->zone()); | 525 isolate->runtime_zone()); |
| 520 return compile_data.node; | 526 return compile_data.node; |
| 521 } | 527 } |
| 522 | 528 |
| 523 | 529 |
| 524 static void Execute(const char* input, | 530 static void Execute(const char* input, |
| 525 bool multiline, | 531 bool multiline, |
| 526 bool is_ascii, | 532 bool is_ascii, |
| 527 bool dot_output = false) { | 533 bool dot_output = false) { |
| 528 v8::HandleScope scope; | 534 v8::HandleScope scope; |
| 529 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); | 535 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); |
| 530 RegExpNode* node = Compile(input, multiline, is_ascii); | 536 RegExpNode* node = Compile(input, multiline, is_ascii); |
| 531 USE(node); | 537 USE(node); |
| 532 #ifdef DEBUG | 538 #ifdef DEBUG |
| 533 if (dot_output) { | 539 if (dot_output) { |
| 534 RegExpEngine::DotPrint(input, node, false); | 540 RegExpEngine::DotPrint(input, node, false); |
| 535 exit(0); | 541 exit(0); |
| 536 } | 542 } |
| 537 #endif // DEBUG | 543 #endif // DEBUG |
| 538 } | 544 } |
| 539 | 545 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 559 | 565 |
| 560 | 566 |
| 561 static unsigned PseudoRandom(int i, int j) { | 567 static unsigned PseudoRandom(int i, int j) { |
| 562 return ~(~((i * 781) ^ (j * 329))); | 568 return ~(~((i * 781) ^ (j * 329))); |
| 563 } | 569 } |
| 564 | 570 |
| 565 | 571 |
| 566 TEST(SplayTreeSimple) { | 572 TEST(SplayTreeSimple) { |
| 567 v8::internal::V8::Initialize(NULL); | 573 v8::internal::V8::Initialize(NULL); |
| 568 static const unsigned kLimit = 1000; | 574 static const unsigned kLimit = 1000; |
| 569 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); | 575 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); |
| 570 ZoneSplayTree<TestConfig> tree(Isolate::Current()->zone()); | 576 ZoneSplayTree<TestConfig> tree(Isolate::Current()->runtime_zone()); |
| 571 bool seen[kLimit]; | 577 bool seen[kLimit]; |
| 572 for (unsigned i = 0; i < kLimit; i++) seen[i] = false; | 578 for (unsigned i = 0; i < kLimit; i++) seen[i] = false; |
| 573 #define CHECK_MAPS_EQUAL() do { \ | 579 #define CHECK_MAPS_EQUAL() do { \ |
| 574 for (unsigned k = 0; k < kLimit; k++) \ | 580 for (unsigned k = 0; k < kLimit; k++) \ |
| 575 CHECK_EQ(seen[k], tree.Find(k, &loc)); \ | 581 CHECK_EQ(seen[k], tree.Find(k, &loc)); \ |
| 576 } while (false) | 582 } while (false) |
| 577 for (int i = 0; i < 50; i++) { | 583 for (int i = 0; i < 50; i++) { |
| 578 for (int j = 0; j < 50; j++) { | 584 for (int j = 0; j < 50; j++) { |
| 579 unsigned next = PseudoRandom(i, j) % kLimit; | 585 unsigned next = PseudoRandom(i, j) % kLimit; |
| 580 if (seen[next]) { | 586 if (seen[next]) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 Vector<uc16> range(ranges[i], 2 * kRangeSize); | 633 Vector<uc16> range(ranges[i], 2 * kRangeSize); |
| 628 for (int j = 0; j < 2 * kRangeSize; j++) { | 634 for (int j = 0; j < 2 * kRangeSize; j++) { |
| 629 range[j] = PseudoRandom(i + 25, j + 87) % kLimit; | 635 range[j] = PseudoRandom(i + 25, j + 87) % kLimit; |
| 630 } | 636 } |
| 631 range.Sort(); | 637 range.Sort(); |
| 632 for (int j = 1; j < 2 * kRangeSize; j++) { | 638 for (int j = 1; j < 2 * kRangeSize; j++) { |
| 633 CHECK(range[j-1] <= range[j]); | 639 CHECK(range[j-1] <= range[j]); |
| 634 } | 640 } |
| 635 } | 641 } |
| 636 // Enter test data into dispatch table. | 642 // Enter test data into dispatch table. |
| 637 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); | 643 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); |
| 638 DispatchTable table(Isolate::Current()->zone()); | 644 DispatchTable table(Isolate::Current()->runtime_zone()); |
| 639 for (int i = 0; i < kRangeCount; i++) { | 645 for (int i = 0; i < kRangeCount; i++) { |
| 640 uc16* range = ranges[i]; | 646 uc16* range = ranges[i]; |
| 641 for (int j = 0; j < 2 * kRangeSize; j += 2) | 647 for (int j = 0; j < 2 * kRangeSize; j += 2) |
| 642 table.AddRange(CharacterRange(range[j], range[j + 1]), i, | 648 table.AddRange(CharacterRange(range[j], range[j + 1]), i, |
| 643 Isolate::Current()->zone()); | 649 Isolate::Current()->runtime_zone()); |
| 644 } | 650 } |
| 645 // Check that the table looks as we would expect | 651 // Check that the table looks as we would expect |
| 646 for (int p = 0; p < kLimit; p++) { | 652 for (int p = 0; p < kLimit; p++) { |
| 647 OutSet* outs = table.Get(p); | 653 OutSet* outs = table.Get(p); |
| 648 for (int j = 0; j < kRangeCount; j++) { | 654 for (int j = 0; j < kRangeCount; j++) { |
| 649 uc16* range = ranges[j]; | 655 uc16* range = ranges[j]; |
| 650 bool is_on = false; | 656 bool is_on = false; |
| 651 for (int k = 0; !is_on && (k < 2 * kRangeSize); k += 2) | 657 for (int k = 0; !is_on && (k < 2 * kRangeSize); k += 2) |
| 652 is_on = (range[k] <= p && p <= range[k + 1]); | 658 is_on = (range[k] <= p && p <= range[k + 1]); |
| 653 CHECK_EQ(is_on, outs->Get(j)); | 659 CHECK_EQ(is_on, outs->Get(j)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 typedef RegExpMacroAssemblerX64 ArchRegExpMacroAssembler; | 701 typedef RegExpMacroAssemblerX64 ArchRegExpMacroAssembler; |
| 696 #elif V8_TARGET_ARCH_ARM | 702 #elif V8_TARGET_ARCH_ARM |
| 697 typedef RegExpMacroAssemblerARM ArchRegExpMacroAssembler; | 703 typedef RegExpMacroAssemblerARM ArchRegExpMacroAssembler; |
| 698 #elif V8_TARGET_ARCH_MIPS | 704 #elif V8_TARGET_ARCH_MIPS |
| 699 typedef RegExpMacroAssemblerMIPS ArchRegExpMacroAssembler; | 705 typedef RegExpMacroAssemblerMIPS ArchRegExpMacroAssembler; |
| 700 #endif | 706 #endif |
| 701 | 707 |
| 702 class ContextInitializer { | 708 class ContextInitializer { |
| 703 public: | 709 public: |
| 704 ContextInitializer() | 710 ContextInitializer() |
| 705 : env_(), scope_(), zone_(Isolate::Current(), DELETE_ON_EXIT) { | 711 : env_(), scope_(), zone_(Isolate::Current()->runtime_zone(), |
| 712 DELETE_ON_EXIT) { |
| 706 env_ = v8::Context::New(); | 713 env_ = v8::Context::New(); |
| 707 env_->Enter(); | 714 env_->Enter(); |
| 708 } | 715 } |
| 709 ~ContextInitializer() { | 716 ~ContextInitializer() { |
| 710 env_->Exit(); | 717 env_->Exit(); |
| 711 env_.Dispose(); | 718 env_.Dispose(); |
| 712 } | 719 } |
| 713 private: | 720 private: |
| 714 v8::Persistent<v8::Context> env_; | 721 v8::Persistent<v8::Context> env_; |
| 715 v8::HandleScope scope_; | 722 v8::HandleScope scope_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 734 Isolate::Current()); | 741 Isolate::Current()); |
| 735 } | 742 } |
| 736 | 743 |
| 737 | 744 |
| 738 TEST(MacroAssemblerNativeSuccess) { | 745 TEST(MacroAssemblerNativeSuccess) { |
| 739 v8::V8::Initialize(); | 746 v8::V8::Initialize(); |
| 740 ContextInitializer initializer; | 747 ContextInitializer initializer; |
| 741 Factory* factory = Isolate::Current()->factory(); | 748 Factory* factory = Isolate::Current()->factory(); |
| 742 | 749 |
| 743 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, | 750 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, |
| 744 Isolate::Current()->zone()); | 751 Isolate::Current()->runtime_zone()); |
| 745 | 752 |
| 746 m.Succeed(); | 753 m.Succeed(); |
| 747 | 754 |
| 748 Handle<String> source = factory->NewStringFromAscii(CStrVector("")); | 755 Handle<String> source = factory->NewStringFromAscii(CStrVector("")); |
| 749 Handle<Object> code_object = m.GetCode(source); | 756 Handle<Object> code_object = m.GetCode(source); |
| 750 Handle<Code> code = Handle<Code>::cast(code_object); | 757 Handle<Code> code = Handle<Code>::cast(code_object); |
| 751 | 758 |
| 752 int captures[4] = {42, 37, 87, 117}; | 759 int captures[4] = {42, 37, 87, 117}; |
| 753 Handle<String> input = factory->NewStringFromAscii(CStrVector("foofoo")); | 760 Handle<String> input = factory->NewStringFromAscii(CStrVector("foofoo")); |
| 754 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 761 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 770 CHECK_EQ(-1, captures[3]); | 777 CHECK_EQ(-1, captures[3]); |
| 771 } | 778 } |
| 772 | 779 |
| 773 | 780 |
| 774 TEST(MacroAssemblerNativeSimple) { | 781 TEST(MacroAssemblerNativeSimple) { |
| 775 v8::V8::Initialize(); | 782 v8::V8::Initialize(); |
| 776 ContextInitializer initializer; | 783 ContextInitializer initializer; |
| 777 Factory* factory = Isolate::Current()->factory(); | 784 Factory* factory = Isolate::Current()->factory(); |
| 778 | 785 |
| 779 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, | 786 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, |
| 780 Isolate::Current()->zone()); | 787 Isolate::Current()->runtime_zone()); |
| 781 | 788 |
| 782 uc16 foo_chars[3] = {'f', 'o', 'o'}; | 789 uc16 foo_chars[3] = {'f', 'o', 'o'}; |
| 783 Vector<const uc16> foo(foo_chars, 3); | 790 Vector<const uc16> foo(foo_chars, 3); |
| 784 | 791 |
| 785 Label fail; | 792 Label fail; |
| 786 m.CheckCharacters(foo, 0, &fail, true); | 793 m.CheckCharacters(foo, 0, &fail, true); |
| 787 m.WriteCurrentPositionToRegister(0, 0); | 794 m.WriteCurrentPositionToRegister(0, 0); |
| 788 m.AdvanceCurrentPosition(3); | 795 m.AdvanceCurrentPosition(3); |
| 789 m.WriteCurrentPositionToRegister(1, 0); | 796 m.WriteCurrentPositionToRegister(1, 0); |
| 790 m.Succeed(); | 797 m.Succeed(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); | 835 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); |
| 829 } | 836 } |
| 830 | 837 |
| 831 | 838 |
| 832 TEST(MacroAssemblerNativeSimpleUC16) { | 839 TEST(MacroAssemblerNativeSimpleUC16) { |
| 833 v8::V8::Initialize(); | 840 v8::V8::Initialize(); |
| 834 ContextInitializer initializer; | 841 ContextInitializer initializer; |
| 835 Factory* factory = Isolate::Current()->factory(); | 842 Factory* factory = Isolate::Current()->factory(); |
| 836 | 843 |
| 837 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4, | 844 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4, |
| 838 Isolate::Current()->zone()); | 845 Isolate::Current()->runtime_zone()); |
| 839 | 846 |
| 840 uc16 foo_chars[3] = {'f', 'o', 'o'}; | 847 uc16 foo_chars[3] = {'f', 'o', 'o'}; |
| 841 Vector<const uc16> foo(foo_chars, 3); | 848 Vector<const uc16> foo(foo_chars, 3); |
| 842 | 849 |
| 843 Label fail; | 850 Label fail; |
| 844 m.CheckCharacters(foo, 0, &fail, true); | 851 m.CheckCharacters(foo, 0, &fail, true); |
| 845 m.WriteCurrentPositionToRegister(0, 0); | 852 m.WriteCurrentPositionToRegister(0, 0); |
| 846 m.AdvanceCurrentPosition(3); | 853 m.AdvanceCurrentPosition(3); |
| 847 m.WriteCurrentPositionToRegister(1, 0); | 854 m.WriteCurrentPositionToRegister(1, 0); |
| 848 m.Succeed(); | 855 m.Succeed(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); | 898 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); |
| 892 } | 899 } |
| 893 | 900 |
| 894 | 901 |
| 895 TEST(MacroAssemblerNativeBacktrack) { | 902 TEST(MacroAssemblerNativeBacktrack) { |
| 896 v8::V8::Initialize(); | 903 v8::V8::Initialize(); |
| 897 ContextInitializer initializer; | 904 ContextInitializer initializer; |
| 898 Factory* factory = Isolate::Current()->factory(); | 905 Factory* factory = Isolate::Current()->factory(); |
| 899 | 906 |
| 900 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, | 907 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, |
| 901 Isolate::Current()->zone()); | 908 Isolate::Current()->runtime_zone()); |
| 902 | 909 |
| 903 Label fail; | 910 Label fail; |
| 904 Label backtrack; | 911 Label backtrack; |
| 905 m.LoadCurrentCharacter(10, &fail); | 912 m.LoadCurrentCharacter(10, &fail); |
| 906 m.Succeed(); | 913 m.Succeed(); |
| 907 m.Bind(&fail); | 914 m.Bind(&fail); |
| 908 m.PushBacktrack(&backtrack); | 915 m.PushBacktrack(&backtrack); |
| 909 m.LoadCurrentCharacter(10, NULL); | 916 m.LoadCurrentCharacter(10, NULL); |
| 910 m.Succeed(); | 917 m.Succeed(); |
| 911 m.Bind(&backtrack); | 918 m.Bind(&backtrack); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 930 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); | 937 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); |
| 931 } | 938 } |
| 932 | 939 |
| 933 | 940 |
| 934 TEST(MacroAssemblerNativeBackReferenceASCII) { | 941 TEST(MacroAssemblerNativeBackReferenceASCII) { |
| 935 v8::V8::Initialize(); | 942 v8::V8::Initialize(); |
| 936 ContextInitializer initializer; | 943 ContextInitializer initializer; |
| 937 Factory* factory = Isolate::Current()->factory(); | 944 Factory* factory = Isolate::Current()->factory(); |
| 938 | 945 |
| 939 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, | 946 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, |
| 940 Isolate::Current()->zone()); | 947 Isolate::Current()->runtime_zone()); |
| 941 | 948 |
| 942 m.WriteCurrentPositionToRegister(0, 0); | 949 m.WriteCurrentPositionToRegister(0, 0); |
| 943 m.AdvanceCurrentPosition(2); | 950 m.AdvanceCurrentPosition(2); |
| 944 m.WriteCurrentPositionToRegister(1, 0); | 951 m.WriteCurrentPositionToRegister(1, 0); |
| 945 Label nomatch; | 952 Label nomatch; |
| 946 m.CheckNotBackReference(0, &nomatch); | 953 m.CheckNotBackReference(0, &nomatch); |
| 947 m.Fail(); | 954 m.Fail(); |
| 948 m.Bind(&nomatch); | 955 m.Bind(&nomatch); |
| 949 m.AdvanceCurrentPosition(2); | 956 m.AdvanceCurrentPosition(2); |
| 950 Label missing_match; | 957 Label missing_match; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 978 CHECK_EQ(-1, output[3]); | 985 CHECK_EQ(-1, output[3]); |
| 979 } | 986 } |
| 980 | 987 |
| 981 | 988 |
| 982 TEST(MacroAssemblerNativeBackReferenceUC16) { | 989 TEST(MacroAssemblerNativeBackReferenceUC16) { |
| 983 v8::V8::Initialize(); | 990 v8::V8::Initialize(); |
| 984 ContextInitializer initializer; | 991 ContextInitializer initializer; |
| 985 Factory* factory = Isolate::Current()->factory(); | 992 Factory* factory = Isolate::Current()->factory(); |
| 986 | 993 |
| 987 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4, | 994 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4, |
| 988 Isolate::Current()->zone()); | 995 Isolate::Current()->runtime_zone()); |
| 989 | 996 |
| 990 m.WriteCurrentPositionToRegister(0, 0); | 997 m.WriteCurrentPositionToRegister(0, 0); |
| 991 m.AdvanceCurrentPosition(2); | 998 m.AdvanceCurrentPosition(2); |
| 992 m.WriteCurrentPositionToRegister(1, 0); | 999 m.WriteCurrentPositionToRegister(1, 0); |
| 993 Label nomatch; | 1000 Label nomatch; |
| 994 m.CheckNotBackReference(0, &nomatch); | 1001 m.CheckNotBackReference(0, &nomatch); |
| 995 m.Fail(); | 1002 m.Fail(); |
| 996 m.Bind(&nomatch); | 1003 m.Bind(&nomatch); |
| 997 m.AdvanceCurrentPosition(2); | 1004 m.AdvanceCurrentPosition(2); |
| 998 Label missing_match; | 1005 Label missing_match; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1029 } | 1036 } |
| 1030 | 1037 |
| 1031 | 1038 |
| 1032 | 1039 |
| 1033 TEST(MacroAssemblernativeAtStart) { | 1040 TEST(MacroAssemblernativeAtStart) { |
| 1034 v8::V8::Initialize(); | 1041 v8::V8::Initialize(); |
| 1035 ContextInitializer initializer; | 1042 ContextInitializer initializer; |
| 1036 Factory* factory = Isolate::Current()->factory(); | 1043 Factory* factory = Isolate::Current()->factory(); |
| 1037 | 1044 |
| 1038 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, | 1045 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, |
| 1039 Isolate::Current()->zone()); | 1046 Isolate::Current()->runtime_zone()); |
| 1040 | 1047 |
| 1041 Label not_at_start, newline, fail; | 1048 Label not_at_start, newline, fail; |
| 1042 m.CheckNotAtStart(¬_at_start); | 1049 m.CheckNotAtStart(¬_at_start); |
| 1043 // Check that prevchar = '\n' and current = 'f'. | 1050 // Check that prevchar = '\n' and current = 'f'. |
| 1044 m.CheckCharacter('\n', &newline); | 1051 m.CheckCharacter('\n', &newline); |
| 1045 m.Bind(&fail); | 1052 m.Bind(&fail); |
| 1046 m.Fail(); | 1053 m.Fail(); |
| 1047 m.Bind(&newline); | 1054 m.Bind(&newline); |
| 1048 m.LoadCurrentCharacter(0, &fail); | 1055 m.LoadCurrentCharacter(0, &fail); |
| 1049 m.CheckNotCharacter('f', &fail); | 1056 m.CheckNotCharacter('f', &fail); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); | 1094 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
| 1088 } | 1095 } |
| 1089 | 1096 |
| 1090 | 1097 |
| 1091 TEST(MacroAssemblerNativeBackRefNoCase) { | 1098 TEST(MacroAssemblerNativeBackRefNoCase) { |
| 1092 v8::V8::Initialize(); | 1099 v8::V8::Initialize(); |
| 1093 ContextInitializer initializer; | 1100 ContextInitializer initializer; |
| 1094 Factory* factory = Isolate::Current()->factory(); | 1101 Factory* factory = Isolate::Current()->factory(); |
| 1095 | 1102 |
| 1096 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, | 1103 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, |
| 1097 Isolate::Current()->zone()); | 1104 Isolate::Current()->runtime_zone()); |
| 1098 | 1105 |
| 1099 Label fail, succ; | 1106 Label fail, succ; |
| 1100 | 1107 |
| 1101 m.WriteCurrentPositionToRegister(0, 0); | 1108 m.WriteCurrentPositionToRegister(0, 0); |
| 1102 m.WriteCurrentPositionToRegister(2, 0); | 1109 m.WriteCurrentPositionToRegister(2, 0); |
| 1103 m.AdvanceCurrentPosition(3); | 1110 m.AdvanceCurrentPosition(3); |
| 1104 m.WriteCurrentPositionToRegister(3, 0); | 1111 m.WriteCurrentPositionToRegister(3, 0); |
| 1105 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "AbC". | 1112 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "AbC". |
| 1106 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "ABC". | 1113 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "ABC". |
| 1107 Label expected_fail; | 1114 Label expected_fail; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 } | 1152 } |
| 1146 | 1153 |
| 1147 | 1154 |
| 1148 | 1155 |
| 1149 TEST(MacroAssemblerNativeRegisters) { | 1156 TEST(MacroAssemblerNativeRegisters) { |
| 1150 v8::V8::Initialize(); | 1157 v8::V8::Initialize(); |
| 1151 ContextInitializer initializer; | 1158 ContextInitializer initializer; |
| 1152 Factory* factory = Isolate::Current()->factory(); | 1159 Factory* factory = Isolate::Current()->factory(); |
| 1153 | 1160 |
| 1154 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 6, | 1161 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 6, |
| 1155 Isolate::Current()->zone()); | 1162 Isolate::Current()->runtime_zone()); |
| 1156 | 1163 |
| 1157 uc16 foo_chars[3] = {'f', 'o', 'o'}; | 1164 uc16 foo_chars[3] = {'f', 'o', 'o'}; |
| 1158 Vector<const uc16> foo(foo_chars, 3); | 1165 Vector<const uc16> foo(foo_chars, 3); |
| 1159 | 1166 |
| 1160 enum registers { out1, out2, out3, out4, out5, out6, sp, loop_cnt }; | 1167 enum registers { out1, out2, out3, out4, out5, out6, sp, loop_cnt }; |
| 1161 Label fail; | 1168 Label fail; |
| 1162 Label backtrack; | 1169 Label backtrack; |
| 1163 m.WriteCurrentPositionToRegister(out1, 0); // Output: [0] | 1170 m.WriteCurrentPositionToRegister(out1, 0); // Output: [0] |
| 1164 m.PushRegister(out1, RegExpMacroAssembler::kNoStackLimitCheck); | 1171 m.PushRegister(out1, RegExpMacroAssembler::kNoStackLimitCheck); |
| 1165 m.PushBacktrack(&backtrack); | 1172 m.PushBacktrack(&backtrack); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 } | 1255 } |
| 1249 | 1256 |
| 1250 | 1257 |
| 1251 TEST(MacroAssemblerStackOverflow) { | 1258 TEST(MacroAssemblerStackOverflow) { |
| 1252 v8::V8::Initialize(); | 1259 v8::V8::Initialize(); |
| 1253 ContextInitializer initializer; | 1260 ContextInitializer initializer; |
| 1254 Isolate* isolate = Isolate::Current(); | 1261 Isolate* isolate = Isolate::Current(); |
| 1255 Factory* factory = isolate->factory(); | 1262 Factory* factory = isolate->factory(); |
| 1256 | 1263 |
| 1257 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, | 1264 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, |
| 1258 Isolate::Current()->zone()); | 1265 Isolate::Current()->runtime_zone()); |
| 1259 | 1266 |
| 1260 Label loop; | 1267 Label loop; |
| 1261 m.Bind(&loop); | 1268 m.Bind(&loop); |
| 1262 m.PushBacktrack(&loop); | 1269 m.PushBacktrack(&loop); |
| 1263 m.GoTo(&loop); | 1270 m.GoTo(&loop); |
| 1264 | 1271 |
| 1265 Handle<String> source = | 1272 Handle<String> source = |
| 1266 factory->NewStringFromAscii(CStrVector("<stack overflow test>")); | 1273 factory->NewStringFromAscii(CStrVector("<stack overflow test>")); |
| 1267 Handle<Object> code_object = m.GetCode(source); | 1274 Handle<Object> code_object = m.GetCode(source); |
| 1268 Handle<Code> code = Handle<Code>::cast(code_object); | 1275 Handle<Code> code = Handle<Code>::cast(code_object); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1287 } | 1294 } |
| 1288 | 1295 |
| 1289 | 1296 |
| 1290 TEST(MacroAssemblerNativeLotsOfRegisters) { | 1297 TEST(MacroAssemblerNativeLotsOfRegisters) { |
| 1291 v8::V8::Initialize(); | 1298 v8::V8::Initialize(); |
| 1292 ContextInitializer initializer; | 1299 ContextInitializer initializer; |
| 1293 Isolate* isolate = Isolate::Current(); | 1300 Isolate* isolate = Isolate::Current(); |
| 1294 Factory* factory = isolate->factory(); | 1301 Factory* factory = isolate->factory(); |
| 1295 | 1302 |
| 1296 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 2, | 1303 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 2, |
| 1297 Isolate::Current()->zone()); | 1304 Isolate::Current()->runtime_zone()); |
| 1298 | 1305 |
| 1299 // At least 2048, to ensure the allocated space for registers | 1306 // At least 2048, to ensure the allocated space for registers |
| 1300 // span one full page. | 1307 // span one full page. |
| 1301 const int large_number = 8000; | 1308 const int large_number = 8000; |
| 1302 m.WriteCurrentPositionToRegister(large_number, 42); | 1309 m.WriteCurrentPositionToRegister(large_number, 42); |
| 1303 m.WriteCurrentPositionToRegister(0, 0); | 1310 m.WriteCurrentPositionToRegister(0, 0); |
| 1304 m.WriteCurrentPositionToRegister(1, 1); | 1311 m.WriteCurrentPositionToRegister(1, 1); |
| 1305 Label done; | 1312 Label done; |
| 1306 m.CheckNotBackReference(0, &done); // Performs a system-stack push. | 1313 m.CheckNotBackReference(0, &done); // Performs a system-stack push. |
| 1307 m.Bind(&done); | 1314 m.Bind(&done); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1405 } | 1412 } |
| 1406 | 1413 |
| 1407 #endif // V8_INTERPRETED_REGEXP | 1414 #endif // V8_INTERPRETED_REGEXP |
| 1408 | 1415 |
| 1409 | 1416 |
| 1410 TEST(AddInverseToTable) { | 1417 TEST(AddInverseToTable) { |
| 1411 v8::internal::V8::Initialize(NULL); | 1418 v8::internal::V8::Initialize(NULL); |
| 1412 static const int kLimit = 1000; | 1419 static const int kLimit = 1000; |
| 1413 static const int kRangeCount = 16; | 1420 static const int kRangeCount = 16; |
| 1414 for (int t = 0; t < 10; t++) { | 1421 for (int t = 0; t < 10; t++) { |
| 1415 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); | 1422 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); |
| 1416 Zone* zone = Isolate::Current()->zone(); | 1423 Zone* zone = Isolate::Current()->runtime_zone(); |
| 1417 ZoneList<CharacterRange>* ranges = | 1424 ZoneList<CharacterRange>* ranges = |
| 1418 new(zone) | 1425 new(zone) |
| 1419 ZoneList<CharacterRange>(kRangeCount, zone); | 1426 ZoneList<CharacterRange>(kRangeCount, zone); |
| 1420 for (int i = 0; i < kRangeCount; i++) { | 1427 for (int i = 0; i < kRangeCount; i++) { |
| 1421 int from = PseudoRandom(t + 87, i + 25) % kLimit; | 1428 int from = PseudoRandom(t + 87, i + 25) % kLimit; |
| 1422 int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20)); | 1429 int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20)); |
| 1423 if (to > kLimit) to = kLimit; | 1430 if (to > kLimit) to = kLimit; |
| 1424 ranges->Add(CharacterRange(from, to), zone); | 1431 ranges->Add(CharacterRange(from, to), zone); |
| 1425 } | 1432 } |
| 1426 DispatchTable table(zone); | 1433 DispatchTable table(zone); |
| 1427 DispatchTableConstructor cons(&table, false, Isolate::Current()->zone()); | 1434 DispatchTableConstructor cons(&table, false, |
| 1435 Isolate::Current()->runtime_zone()); |
| 1428 cons.set_choice_index(0); | 1436 cons.set_choice_index(0); |
| 1429 cons.AddInverse(ranges); | 1437 cons.AddInverse(ranges); |
| 1430 for (int i = 0; i < kLimit; i++) { | 1438 for (int i = 0; i < kLimit; i++) { |
| 1431 bool is_on = false; | 1439 bool is_on = false; |
| 1432 for (int j = 0; !is_on && j < kRangeCount; j++) | 1440 for (int j = 0; !is_on && j < kRangeCount; j++) |
| 1433 is_on = ranges->at(j).Contains(i); | 1441 is_on = ranges->at(j).Contains(i); |
| 1434 OutSet* set = table.Get(i); | 1442 OutSet* set = table.Get(i); |
| 1435 CHECK_EQ(is_on, set->Get(0) == false); | 1443 CHECK_EQ(is_on, set->Get(0) == false); |
| 1436 } | 1444 } |
| 1437 } | 1445 } |
| 1438 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); | 1446 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); |
| 1439 Zone* zone = Isolate::Current()->zone(); | 1447 Zone* zone = Isolate::Current()->runtime_zone(); |
| 1440 ZoneList<CharacterRange>* ranges = | 1448 ZoneList<CharacterRange>* ranges = |
| 1441 new(zone) ZoneList<CharacterRange>(1, zone); | 1449 new(zone) ZoneList<CharacterRange>(1, zone); |
| 1442 ranges->Add(CharacterRange(0xFFF0, 0xFFFE), zone); | 1450 ranges->Add(CharacterRange(0xFFF0, 0xFFFE), zone); |
| 1443 DispatchTable table(zone); | 1451 DispatchTable table(zone); |
| 1444 DispatchTableConstructor cons(&table, false, Isolate::Current()->zone()); | 1452 DispatchTableConstructor cons(&table, false, |
| 1453 Isolate::Current()->runtime_zone()); |
| 1445 cons.set_choice_index(0); | 1454 cons.set_choice_index(0); |
| 1446 cons.AddInverse(ranges); | 1455 cons.AddInverse(ranges); |
| 1447 CHECK(!table.Get(0xFFFE)->Get(0)); | 1456 CHECK(!table.Get(0xFFFE)->Get(0)); |
| 1448 CHECK(table.Get(0xFFFF)->Get(0)); | 1457 CHECK(table.Get(0xFFFF)->Get(0)); |
| 1449 } | 1458 } |
| 1450 | 1459 |
| 1451 | 1460 |
| 1452 static uc32 canonicalize(uc32 c) { | 1461 static uc32 canonicalize(uc32 c) { |
| 1453 unibrow::uchar canon[unibrow::Ecma262Canonicalize::kMaxWidth]; | 1462 unibrow::uchar canon[unibrow::Ecma262Canonicalize::kMaxWidth]; |
| 1454 int count = unibrow::Ecma262Canonicalize::Convert(c, '\0', canon, NULL); | 1463 int count = unibrow::Ecma262Canonicalize::Convert(c, '\0', canon, NULL); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1542 CHECK_EQ(length, length2); | 1551 CHECK_EQ(length, length2); |
| 1543 for (int k = 0; k < length; k++) | 1552 for (int k = 0; k < length; k++) |
| 1544 CHECK_EQ(static_cast<int>(chars[k]), static_cast<int>(chars2[k])); | 1553 CHECK_EQ(static_cast<int>(chars[k]), static_cast<int>(chars2[k])); |
| 1545 } | 1554 } |
| 1546 } | 1555 } |
| 1547 } | 1556 } |
| 1548 | 1557 |
| 1549 | 1558 |
| 1550 static void TestRangeCaseIndependence(CharacterRange input, | 1559 static void TestRangeCaseIndependence(CharacterRange input, |
| 1551 Vector<CharacterRange> expected) { | 1560 Vector<CharacterRange> expected) { |
| 1552 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); | 1561 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); |
| 1553 Zone* zone = Isolate::Current()->zone(); | 1562 Zone* zone = Isolate::Current()->runtime_zone(); |
| 1554 int count = expected.length(); | 1563 int count = expected.length(); |
| 1555 ZoneList<CharacterRange>* list = | 1564 ZoneList<CharacterRange>* list = |
| 1556 new(zone) ZoneList<CharacterRange>(count, zone); | 1565 new(zone) ZoneList<CharacterRange>(count, zone); |
| 1557 input.AddCaseEquivalents(list, false, zone); | 1566 input.AddCaseEquivalents(list, false, zone); |
| 1558 CHECK_EQ(count, list->length()); | 1567 CHECK_EQ(count, list->length()); |
| 1559 for (int i = 0; i < list->length(); i++) { | 1568 for (int i = 0; i < list->length(); i++) { |
| 1560 CHECK_EQ(expected[i].from(), list->at(i).from()); | 1569 CHECK_EQ(expected[i].from(), list->at(i).from()); |
| 1561 CHECK_EQ(expected[i].to(), list->at(i).to()); | 1570 CHECK_EQ(expected[i].to(), list->at(i).to()); |
| 1562 } | 1571 } |
| 1563 } | 1572 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1608 CharacterRange range = ranges->at(i); | 1617 CharacterRange range = ranges->at(i); |
| 1609 if (range.from() <= c && c <= range.to()) | 1618 if (range.from() <= c && c <= range.to()) |
| 1610 return true; | 1619 return true; |
| 1611 } | 1620 } |
| 1612 return false; | 1621 return false; |
| 1613 } | 1622 } |
| 1614 | 1623 |
| 1615 | 1624 |
| 1616 TEST(CharClassDifference) { | 1625 TEST(CharClassDifference) { |
| 1617 v8::internal::V8::Initialize(NULL); | 1626 v8::internal::V8::Initialize(NULL); |
| 1618 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); | 1627 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); |
| 1619 Zone* zone = Isolate::Current()->zone(); | 1628 Zone* zone = Isolate::Current()->runtime_zone(); |
| 1620 ZoneList<CharacterRange>* base = | 1629 ZoneList<CharacterRange>* base = |
| 1621 new(zone) ZoneList<CharacterRange>(1, zone); | 1630 new(zone) ZoneList<CharacterRange>(1, zone); |
| 1622 base->Add(CharacterRange::Everything(), zone); | 1631 base->Add(CharacterRange::Everything(), zone); |
| 1623 Vector<const int> overlay = CharacterRange::GetWordBounds(); | 1632 Vector<const int> overlay = CharacterRange::GetWordBounds(); |
| 1624 ZoneList<CharacterRange>* included = NULL; | 1633 ZoneList<CharacterRange>* included = NULL; |
| 1625 ZoneList<CharacterRange>* excluded = NULL; | 1634 ZoneList<CharacterRange>* excluded = NULL; |
| 1626 CharacterRange::Split(base, overlay, &included, &excluded, | 1635 CharacterRange::Split(base, overlay, &included, &excluded, |
| 1627 Isolate::Current()->zone()); | 1636 Isolate::Current()->runtime_zone()); |
| 1628 for (int i = 0; i < (1 << 16); i++) { | 1637 for (int i = 0; i < (1 << 16); i++) { |
| 1629 bool in_base = InClass(i, base); | 1638 bool in_base = InClass(i, base); |
| 1630 if (in_base) { | 1639 if (in_base) { |
| 1631 bool in_overlay = false; | 1640 bool in_overlay = false; |
| 1632 for (int j = 0; !in_overlay && j < overlay.length(); j += 2) { | 1641 for (int j = 0; !in_overlay && j < overlay.length(); j += 2) { |
| 1633 if (overlay[j] <= i && i < overlay[j+1]) | 1642 if (overlay[j] <= i && i < overlay[j+1]) |
| 1634 in_overlay = true; | 1643 in_overlay = true; |
| 1635 } | 1644 } |
| 1636 CHECK_EQ(in_overlay, InClass(i, included)); | 1645 CHECK_EQ(in_overlay, InClass(i, included)); |
| 1637 CHECK_EQ(!in_overlay, InClass(i, excluded)); | 1646 CHECK_EQ(!in_overlay, InClass(i, excluded)); |
| 1638 } else { | 1647 } else { |
| 1639 CHECK(!InClass(i, included)); | 1648 CHECK(!InClass(i, included)); |
| 1640 CHECK(!InClass(i, excluded)); | 1649 CHECK(!InClass(i, excluded)); |
| 1641 } | 1650 } |
| 1642 } | 1651 } |
| 1643 } | 1652 } |
| 1644 | 1653 |
| 1645 | 1654 |
| 1646 TEST(CanonicalizeCharacterSets) { | 1655 TEST(CanonicalizeCharacterSets) { |
| 1647 v8::internal::V8::Initialize(NULL); | 1656 v8::internal::V8::Initialize(NULL); |
| 1648 ZoneScope scope(Isolate::Current(), DELETE_ON_EXIT); | 1657 ZoneScope scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); |
| 1649 Zone* zone = Isolate::Current()->zone(); | 1658 Zone* zone = Isolate::Current()->runtime_zone(); |
| 1650 ZoneList<CharacterRange>* list = | 1659 ZoneList<CharacterRange>* list = |
| 1651 new(zone) ZoneList<CharacterRange>(4, zone); | 1660 new(zone) ZoneList<CharacterRange>(4, zone); |
| 1652 CharacterSet set(list); | 1661 CharacterSet set(list); |
| 1653 | 1662 |
| 1654 list->Add(CharacterRange(10, 20), zone); | 1663 list->Add(CharacterRange(10, 20), zone); |
| 1655 list->Add(CharacterRange(30, 40), zone); | 1664 list->Add(CharacterRange(30, 40), zone); |
| 1656 list->Add(CharacterRange(50, 60), zone); | 1665 list->Add(CharacterRange(50, 60), zone); |
| 1657 set.Canonicalize(); | 1666 set.Canonicalize(); |
| 1658 ASSERT_EQ(3, list->length()); | 1667 ASSERT_EQ(3, list->length()); |
| 1659 ASSERT_EQ(10, list->at(0).from()); | 1668 ASSERT_EQ(10, list->at(0).from()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1701 list->Add(CharacterRange(20, 20), zone); | 1710 list->Add(CharacterRange(20, 20), zone); |
| 1702 set.Canonicalize(); | 1711 set.Canonicalize(); |
| 1703 ASSERT_EQ(1, list->length()); | 1712 ASSERT_EQ(1, list->length()); |
| 1704 ASSERT_EQ(10, list->at(0).from()); | 1713 ASSERT_EQ(10, list->at(0).from()); |
| 1705 ASSERT_EQ(30, list->at(0).to()); | 1714 ASSERT_EQ(30, list->at(0).to()); |
| 1706 } | 1715 } |
| 1707 | 1716 |
| 1708 | 1717 |
| 1709 TEST(CharacterRangeMerge) { | 1718 TEST(CharacterRangeMerge) { |
| 1710 v8::internal::V8::Initialize(NULL); | 1719 v8::internal::V8::Initialize(NULL); |
| 1711 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); | 1720 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); |
| 1712 ZoneList<CharacterRange> l1(4, Isolate::Current()->zone()); | 1721 ZoneList<CharacterRange> l1(4, Isolate::Current()->runtime_zone()); |
| 1713 ZoneList<CharacterRange> l2(4, Isolate::Current()->zone()); | 1722 ZoneList<CharacterRange> l2(4, Isolate::Current()->runtime_zone()); |
| 1714 Zone* zone = Isolate::Current()->zone(); | 1723 Zone* zone = Isolate::Current()->runtime_zone(); |
| 1715 // Create all combinations of intersections of ranges, both singletons and | 1724 // Create all combinations of intersections of ranges, both singletons and |
| 1716 // longer. | 1725 // longer. |
| 1717 | 1726 |
| 1718 int offset = 0; | 1727 int offset = 0; |
| 1719 | 1728 |
| 1720 // The five kinds of singleton intersections: | 1729 // The five kinds of singleton intersections: |
| 1721 // X | 1730 // X |
| 1722 // Y - outside before | 1731 // Y - outside before |
| 1723 // Y - outside touching start | 1732 // Y - outside touching start |
| 1724 // Y - overlap | 1733 // Y - overlap |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1782 l1.Add(CharacterRange::Range(offset + 31, offset + 52), zone); | 1791 l1.Add(CharacterRange::Range(offset + 31, offset + 52), zone); |
| 1783 for (int i = 0; i < 6; i++) { | 1792 for (int i = 0; i < 6; i++) { |
| 1784 l2.Add(CharacterRange::Range(offset + 2, offset + 5), zone); | 1793 l2.Add(CharacterRange::Range(offset + 2, offset + 5), zone); |
| 1785 l2.Add(CharacterRange::Singleton(offset + 8), zone); | 1794 l2.Add(CharacterRange::Singleton(offset + 8), zone); |
| 1786 offset += 9; | 1795 offset += 9; |
| 1787 } | 1796 } |
| 1788 | 1797 |
| 1789 ASSERT(CharacterRange::IsCanonical(&l1)); | 1798 ASSERT(CharacterRange::IsCanonical(&l1)); |
| 1790 ASSERT(CharacterRange::IsCanonical(&l2)); | 1799 ASSERT(CharacterRange::IsCanonical(&l2)); |
| 1791 | 1800 |
| 1792 ZoneList<CharacterRange> first_only(4, Isolate::Current()->zone()); | 1801 ZoneList<CharacterRange> first_only(4, Isolate::Current()->runtime_zone()); |
| 1793 ZoneList<CharacterRange> second_only(4, Isolate::Current()->zone()); | 1802 ZoneList<CharacterRange> second_only(4, Isolate::Current()->runtime_zone()); |
| 1794 ZoneList<CharacterRange> both(4, Isolate::Current()->zone()); | 1803 ZoneList<CharacterRange> both(4, Isolate::Current()->runtime_zone()); |
| 1795 } | 1804 } |
| 1796 | 1805 |
| 1797 | 1806 |
| 1798 TEST(Graph) { | 1807 TEST(Graph) { |
| 1799 V8::Initialize(NULL); | 1808 V8::Initialize(NULL); |
| 1800 Execute("\\b\\w+\\b", false, true, true); | 1809 Execute("\\b\\w+\\b", false, true, true); |
| 1801 } | 1810 } |
| OLD | NEW |