OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 20 matching lines...) Expand all Loading... |
31 #include "v8.h" | 31 #include "v8.h" |
32 | 32 |
33 #include "string-stream.h" | 33 #include "string-stream.h" |
34 #include "cctest.h" | 34 #include "cctest.h" |
35 #include "zone-inl.h" | 35 #include "zone-inl.h" |
36 #include "parser.h" | 36 #include "parser.h" |
37 #include "ast.h" | 37 #include "ast.h" |
38 #include "jsregexp.h" | 38 #include "jsregexp.h" |
39 #include "regexp-macro-assembler.h" | 39 #include "regexp-macro-assembler.h" |
40 #include "regexp-macro-assembler-irregexp.h" | 40 #include "regexp-macro-assembler-irregexp.h" |
41 #ifdef V8_NATIVE_REGEXP | 41 #ifdef V8_INTERPRETED_REGEXP |
| 42 #include "interpreter-irregexp.h" |
| 43 #else // V8_INTERPRETED_REGEXP |
42 #ifdef V8_TARGET_ARCH_ARM | 44 #ifdef V8_TARGET_ARCH_ARM |
43 #include "arm/macro-assembler-arm.h" | 45 #include "arm/macro-assembler-arm.h" |
44 #include "arm/regexp-macro-assembler-arm.h" | 46 #include "arm/regexp-macro-assembler-arm.h" |
45 #endif | 47 #endif |
46 #ifdef V8_TARGET_ARCH_X64 | 48 #ifdef V8_TARGET_ARCH_X64 |
47 #include "x64/macro-assembler-x64.h" | 49 #include "x64/macro-assembler-x64.h" |
48 #include "x64/regexp-macro-assembler-x64.h" | 50 #include "x64/regexp-macro-assembler-x64.h" |
49 #endif | 51 #endif |
50 #ifdef V8_TARGET_ARCH_IA32 | 52 #ifdef V8_TARGET_ARCH_IA32 |
51 #include "ia32/macro-assembler-ia32.h" | 53 #include "ia32/macro-assembler-ia32.h" |
52 #include "ia32/regexp-macro-assembler-ia32.h" | 54 #include "ia32/regexp-macro-assembler-ia32.h" |
53 #endif | 55 #endif |
54 #else | 56 #endif // V8_INTERPRETED_REGEXP |
55 #include "interpreter-irregexp.h" | |
56 #endif | |
57 | 57 |
58 using namespace v8::internal; | 58 using namespace v8::internal; |
59 | 59 |
60 | 60 |
61 static bool CheckParse(const char* input) { | 61 static bool CheckParse(const char* input) { |
62 V8::Initialize(NULL); | 62 V8::Initialize(NULL); |
63 v8::HandleScope scope; | 63 v8::HandleScope scope; |
64 ZoneScope zone_scope(DELETE_ON_EXIT); | 64 ZoneScope zone_scope(DELETE_ON_EXIT); |
65 FlatStringReader reader(CStrVector(input)); | 65 FlatStringReader reader(CStrVector(input)); |
66 RegExpCompileData result; | 66 RegExpCompileData result; |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 CHECK_PARSE_ERROR("a{10,20}+b"); | 638 CHECK_PARSE_ERROR("a{10,20}+b"); |
639 | 639 |
640 FLAG_regexp_possessive_quantifier = old_flag_value; | 640 FLAG_regexp_possessive_quantifier = old_flag_value; |
641 } | 641 } |
642 | 642 |
643 #endif | 643 #endif |
644 | 644 |
645 // Tests of interpreter. | 645 // Tests of interpreter. |
646 | 646 |
647 | 647 |
648 #ifdef V8_NATIVE_REGEXP | 648 #ifndef V8_INTERPRETED_REGEXP |
649 | 649 |
650 #if V8_TARGET_ARCH_IA32 | 650 #if V8_TARGET_ARCH_IA32 |
651 typedef RegExpMacroAssemblerIA32 ArchRegExpMacroAssembler; | 651 typedef RegExpMacroAssemblerIA32 ArchRegExpMacroAssembler; |
652 #elif V8_TARGET_ARCH_X64 | 652 #elif V8_TARGET_ARCH_X64 |
653 typedef RegExpMacroAssemblerX64 ArchRegExpMacroAssembler; | 653 typedef RegExpMacroAssemblerX64 ArchRegExpMacroAssembler; |
654 #elif V8_TARGET_ARCH_ARM | 654 #elif V8_TARGET_ARCH_ARM |
655 typedef RegExpMacroAssemblerARM ArchRegExpMacroAssembler; | 655 typedef RegExpMacroAssemblerARM ArchRegExpMacroAssembler; |
656 #elif V8_TARGET_ARCH_MIPS | 656 #elif V8_TARGET_ARCH_MIPS |
657 typedef RegExpMacroAssembler ArchRegExpMacroAssembler; | 657 typedef RegExpMacroAssembler ArchRegExpMacroAssembler; |
658 #endif | 658 #endif |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1260 start_adr + input->length(), | 1260 start_adr + input->length(), |
1261 captures); | 1261 captures); |
1262 | 1262 |
1263 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); | 1263 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
1264 CHECK_EQ(0, captures[0]); | 1264 CHECK_EQ(0, captures[0]); |
1265 CHECK_EQ(42, captures[1]); | 1265 CHECK_EQ(42, captures[1]); |
1266 | 1266 |
1267 Top::clear_pending_exception(); | 1267 Top::clear_pending_exception(); |
1268 } | 1268 } |
1269 | 1269 |
1270 #else // ! V8_REGEX_NATIVE | 1270 #else // V8_INTERPRETED_REGEXP |
1271 | 1271 |
1272 TEST(MacroAssembler) { | 1272 TEST(MacroAssembler) { |
1273 V8::Initialize(NULL); | 1273 V8::Initialize(NULL); |
1274 byte codes[1024]; | 1274 byte codes[1024]; |
1275 RegExpMacroAssemblerIrregexp m(Vector<byte>(codes, 1024)); | 1275 RegExpMacroAssemblerIrregexp m(Vector<byte>(codes, 1024)); |
1276 // ^f(o)o. | 1276 // ^f(o)o. |
1277 Label fail, fail2, start; | 1277 Label fail, fail2, start; |
1278 uc16 foo_chars[3]; | 1278 uc16 foo_chars[3]; |
1279 foo_chars[0] = 'f'; | 1279 foo_chars[0] = 'f'; |
1280 foo_chars[1] = 'o'; | 1280 foo_chars[1] = 'o'; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 CHECK_EQ(84, captures[4]); | 1325 CHECK_EQ(84, captures[4]); |
1326 | 1326 |
1327 const uc16 str2[] = {'b', 'a', 'r', 'f', 'o', 'o'}; | 1327 const uc16 str2[] = {'b', 'a', 'r', 'f', 'o', 'o'}; |
1328 Handle<String> f2_16 = | 1328 Handle<String> f2_16 = |
1329 Factory::NewStringFromTwoByte(Vector<const uc16>(str2, 6)); | 1329 Factory::NewStringFromTwoByte(Vector<const uc16>(str2, 6)); |
1330 | 1330 |
1331 CHECK(!IrregexpInterpreter::Match(array, f2_16, captures, 0)); | 1331 CHECK(!IrregexpInterpreter::Match(array, f2_16, captures, 0)); |
1332 CHECK_EQ(42, captures[0]); | 1332 CHECK_EQ(42, captures[0]); |
1333 } | 1333 } |
1334 | 1334 |
1335 #endif // ! V8_REGEXP_NATIVE | 1335 #endif // V8_INTERPRETED_REGEXP |
1336 | 1336 |
1337 | 1337 |
1338 TEST(AddInverseToTable) { | 1338 TEST(AddInverseToTable) { |
1339 static const int kLimit = 1000; | 1339 static const int kLimit = 1000; |
1340 static const int kRangeCount = 16; | 1340 static const int kRangeCount = 16; |
1341 for (int t = 0; t < 10; t++) { | 1341 for (int t = 0; t < 10; t++) { |
1342 ZoneScope zone_scope(DELETE_ON_EXIT); | 1342 ZoneScope zone_scope(DELETE_ON_EXIT); |
1343 ZoneList<CharacterRange>* ranges = | 1343 ZoneList<CharacterRange>* ranges = |
1344 new ZoneList<CharacterRange>(kRangeCount); | 1344 new ZoneList<CharacterRange>(kRangeCount); |
1345 for (int i = 0; i < kRangeCount; i++) { | 1345 for (int i = 0; i < kRangeCount; i++) { |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1792 bool in_second = CharacterInSet(&l2, i); | 1792 bool in_second = CharacterInSet(&l2, i); |
1793 CHECK((in_first || in_second) == CharacterInSet(&all, i)); | 1793 CHECK((in_first || in_second) == CharacterInSet(&all, i)); |
1794 } | 1794 } |
1795 } | 1795 } |
1796 | 1796 |
1797 | 1797 |
1798 TEST(Graph) { | 1798 TEST(Graph) { |
1799 V8::Initialize(NULL); | 1799 V8::Initialize(NULL); |
1800 Execute("\\b\\w+\\b", false, true, true); | 1800 Execute("\\b\\w+\\b", false, true, true); |
1801 } | 1801 } |
OLD | NEW |