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 1798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1809 ZoneList<CharacterRange> first_only(4, &zone); | 1809 ZoneList<CharacterRange> first_only(4, &zone); |
1810 ZoneList<CharacterRange> second_only(4, &zone); | 1810 ZoneList<CharacterRange> second_only(4, &zone); |
1811 ZoneList<CharacterRange> both(4, &zone); | 1811 ZoneList<CharacterRange> both(4, &zone); |
1812 } | 1812 } |
1813 | 1813 |
1814 | 1814 |
1815 TEST(Graph) { | 1815 TEST(Graph) { |
1816 V8::Initialize(NULL); | 1816 V8::Initialize(NULL); |
1817 Execute("\\b\\w+\\b", false, true, true); | 1817 Execute("\\b\\w+\\b", false, true, true); |
1818 } | 1818 } |
| 1819 |
| 1820 |
| 1821 class TimeoutThread : public i::Thread { |
| 1822 public: |
| 1823 explicit TimeoutThread(v8::Isolate* isolate) |
| 1824 : Thread("TimeoutThread"), isolate_(isolate) {} |
| 1825 |
| 1826 virtual void Run() { |
| 1827 OS::Sleep(500); // Wait a bit before terminating thread. |
| 1828 v8::V8::TerminateExecution(isolate_); |
| 1829 } |
| 1830 |
| 1831 private: |
| 1832 v8::Isolate* isolate_; |
| 1833 }; |
| 1834 |
| 1835 |
| 1836 // Test that a regular expression execution can be interrupted and |
| 1837 // survive a garbage collection. |
| 1838 TEST(RegExpInterruption) { |
| 1839 v8::HandleScope scope(CcTest::isolate()); |
| 1840 LocalContext env; |
| 1841 |
| 1842 TimeoutThread timeout_thread(CcTest::isolate()); |
| 1843 v8::TryCatch try_catch; |
| 1844 |
| 1845 timeout_thread.Start(); |
| 1846 // Run a regexp that does not terminate in reasonable time unless forced. |
| 1847 CompileRun("/((a*)*)*b/.exec('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')"); |
| 1848 CHECK(try_catch.HasTerminated()); |
| 1849 |
| 1850 timeout_thread.Join(); |
| 1851 } |
OLD | NEW |