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

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

Issue 10386090: Implement loop for global regexps in regexp assembler. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix bugs, add tests, port to x64 and arm. Created 8 years, 7 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
OLDNEW
1 // Copyright 2008 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
11 // with the distribution. 11 // with the distribution.
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 Isolate* isolate = Isolate::Current(); 499 Isolate* isolate = Isolate::Current();
500 FlatStringReader reader(isolate, CStrVector(input)); 500 FlatStringReader reader(isolate, CStrVector(input));
501 RegExpCompileData compile_data; 501 RegExpCompileData compile_data;
502 if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline, 502 if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline,
503 &compile_data)) 503 &compile_data))
504 return NULL; 504 return NULL;
505 Handle<String> pattern = isolate->factory()-> 505 Handle<String> pattern = isolate->factory()->
506 NewStringFromUtf8(CStrVector(input)); 506 NewStringFromUtf8(CStrVector(input));
507 Handle<String> sample_subject = 507 Handle<String> sample_subject =
508 isolate->factory()->NewStringFromUtf8(CStrVector("")); 508 isolate->factory()->NewStringFromUtf8(CStrVector(""));
509 RegExpEngine::Compile( 509 RegExpEngine::Compile(&compile_data,
510 &compile_data, false, multiline, pattern, sample_subject, is_ascii); 510 false,
511 false,
512 multiline,
513 pattern,
514 sample_subject,
515 is_ascii);
511 return compile_data.node; 516 return compile_data.node;
512 } 517 }
513 518
514 519
515 static void Execute(const char* input, 520 static void Execute(const char* input,
516 bool multiline, 521 bool multiline,
517 bool is_ascii, 522 bool is_ascii,
518 bool dot_output = false) { 523 bool dot_output = false) {
519 v8::HandleScope scope; 524 v8::HandleScope scope;
520 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); 525 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 const byte* input_start, 718 const byte* input_start,
714 const byte* input_end, 719 const byte* input_end,
715 int* captures) { 720 int* captures) {
716 return NativeRegExpMacroAssembler::Execute( 721 return NativeRegExpMacroAssembler::Execute(
717 code, 722 code,
718 input, 723 input,
719 start_offset, 724 start_offset,
720 input_start, 725 input_start,
721 input_end, 726 input_end,
722 captures, 727 captures,
728 0,
723 Isolate::Current()); 729 Isolate::Current());
724 } 730 }
725 731
726 732
727 TEST(MacroAssemblerNativeSuccess) { 733 TEST(MacroAssemblerNativeSuccess) {
728 v8::V8::Initialize(); 734 v8::V8::Initialize();
729 ContextInitializer initializer; 735 ContextInitializer initializer;
730 Factory* factory = Isolate::Current()->factory(); 736 Factory* factory = Isolate::Current()->factory();
731 737
732 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4); 738 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4);
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 997
992 const uc16 input_data[6] = {'f', 0x2028, 'o', 'o', 'f', 0x2028}; 998 const uc16 input_data[6] = {'f', 0x2028, 'o', 'o', 'f', 0x2028};
993 Handle<String> input = 999 Handle<String> input =
994 factory->NewStringFromTwoByte(Vector<const uc16>(input_data, 6)); 1000 factory->NewStringFromTwoByte(Vector<const uc16>(input_data, 6));
995 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input); 1001 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input);
996 Address start_adr = seq_input->GetCharsAddress(); 1002 Address start_adr = seq_input->GetCharsAddress();
997 1003
998 int output[4]; 1004 int output[4];
999 NativeRegExpMacroAssembler::Result result = 1005 NativeRegExpMacroAssembler::Result result =
1000 Execute(*code, 1006 Execute(*code,
1001 *input, 1007 *input,
1002 0, 1008 0,
1003 start_adr, 1009 start_adr,
1004 start_adr + input->length() * 2, 1010 start_adr + input->length() * 2,
1005 output); 1011 output);
1006 1012
1007 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); 1013 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result);
1008 CHECK_EQ(0, output[0]); 1014 CHECK_EQ(0, output[0]);
1009 CHECK_EQ(2, output[1]); 1015 CHECK_EQ(2, output[1]);
1010 CHECK_EQ(6, output[2]); 1016 CHECK_EQ(6, output[2]);
1011 CHECK_EQ(-1, output[3]); 1017 CHECK_EQ(-1, output[3]);
1012 } 1018 }
1013 1019
1014 1020
1015 1021
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 ZoneList<CharacterRange> first_only(4); 1764 ZoneList<CharacterRange> first_only(4);
1759 ZoneList<CharacterRange> second_only(4); 1765 ZoneList<CharacterRange> second_only(4);
1760 ZoneList<CharacterRange> both(4); 1766 ZoneList<CharacterRange> both(4);
1761 } 1767 }
1762 1768
1763 1769
1764 TEST(Graph) { 1770 TEST(Graph) {
1765 V8::Initialize(NULL); 1771 V8::Initialize(NULL);
1766 Execute("\\b\\w+\\b", false, true, true); 1772 Execute("\\b\\w+\\b", false, true, true);
1767 } 1773 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698