| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 9324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9335 | 9335 |
| 9336 | 9336 |
| 9337 void ApiTestFuzzer::Setup(PartOfTest part) { | 9337 void ApiTestFuzzer::Setup(PartOfTest part) { |
| 9338 linear_congruential_generator = i::FLAG_testing_prng_seed; | 9338 linear_congruential_generator = i::FLAG_testing_prng_seed; |
| 9339 fuzzing_ = true; | 9339 fuzzing_ = true; |
| 9340 int count = RegisterThreadedTest::count(); | 9340 int count = RegisterThreadedTest::count(); |
| 9341 int start = count * part / (LAST_PART + 1); | 9341 int start = count * part / (LAST_PART + 1); |
| 9342 int end = (count * (part + 1) / (LAST_PART + 1)) - 1; | 9342 int end = (count * (part + 1) / (LAST_PART + 1)) - 1; |
| 9343 active_tests_ = tests_being_run_ = end - start + 1; | 9343 active_tests_ = tests_being_run_ = end - start + 1; |
| 9344 for (int i = 0; i < tests_being_run_; i++) { | 9344 for (int i = 0; i < tests_being_run_; i++) { |
| 9345 RegisterThreadedTest::nth(i)->fuzzer_ = new ApiTestFuzzer( | 9345 RegisterThreadedTest::nth(i)->fuzzer_ = new ApiTestFuzzer(i + start); |
| 9346 i::Isolate::Current(), i + start); | |
| 9347 } | 9346 } |
| 9348 for (int i = 0; i < active_tests_; i++) { | 9347 for (int i = 0; i < active_tests_; i++) { |
| 9349 RegisterThreadedTest::nth(i)->fuzzer_->Start(); | 9348 RegisterThreadedTest::nth(i)->fuzzer_->Start(); |
| 9350 } | 9349 } |
| 9351 } | 9350 } |
| 9352 | 9351 |
| 9353 | 9352 |
| 9354 static void CallTestNumber(int test_number) { | 9353 static void CallTestNumber(int test_number) { |
| 9355 (RegisterThreadedTest::nth(test_number)->callback())(); | 9354 (RegisterThreadedTest::nth(test_number)->callback())(); |
| 9356 } | 9355 } |
| (...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10452 class RegExpInterruptTest { | 10451 class RegExpInterruptTest { |
| 10453 public: | 10452 public: |
| 10454 RegExpInterruptTest() : block_(NULL) {} | 10453 RegExpInterruptTest() : block_(NULL) {} |
| 10455 ~RegExpInterruptTest() { delete block_; } | 10454 ~RegExpInterruptTest() { delete block_; } |
| 10456 void RunTest() { | 10455 void RunTest() { |
| 10457 block_ = i::OS::CreateSemaphore(0); | 10456 block_ = i::OS::CreateSemaphore(0); |
| 10458 gc_count_ = 0; | 10457 gc_count_ = 0; |
| 10459 gc_during_regexp_ = 0; | 10458 gc_during_regexp_ = 0; |
| 10460 regexp_success_ = false; | 10459 regexp_success_ = false; |
| 10461 gc_success_ = false; | 10460 gc_success_ = false; |
| 10462 GCThread gc_thread(i::Isolate::Current(), this); | 10461 GCThread gc_thread(this); |
| 10463 gc_thread.Start(); | 10462 gc_thread.Start(); |
| 10464 v8::Locker::StartPreemption(1); | 10463 v8::Locker::StartPreemption(1); |
| 10465 | 10464 |
| 10466 LongRunningRegExp(); | 10465 LongRunningRegExp(); |
| 10467 { | 10466 { |
| 10468 v8::Unlocker unlock; | 10467 v8::Unlocker unlock; |
| 10469 gc_thread.Join(); | 10468 gc_thread.Join(); |
| 10470 } | 10469 } |
| 10471 v8::Locker::StopPreemption(); | 10470 v8::Locker::StopPreemption(); |
| 10472 CHECK(regexp_success_); | 10471 CHECK(regexp_success_); |
| 10473 CHECK(gc_success_); | 10472 CHECK(gc_success_); |
| 10474 } | 10473 } |
| 10475 | 10474 |
| 10476 private: | 10475 private: |
| 10477 // Number of garbage collections required. | 10476 // Number of garbage collections required. |
| 10478 static const int kRequiredGCs = 5; | 10477 static const int kRequiredGCs = 5; |
| 10479 | 10478 |
| 10480 class GCThread : public i::Thread { | 10479 class GCThread : public i::Thread { |
| 10481 public: | 10480 public: |
| 10482 explicit GCThread(i::Isolate* isolate, RegExpInterruptTest* test) | 10481 explicit GCThread(RegExpInterruptTest* test) |
| 10483 : Thread(isolate, "GCThread"), test_(test) {} | 10482 : Thread("GCThread"), test_(test) {} |
| 10484 virtual void Run() { | 10483 virtual void Run() { |
| 10485 test_->CollectGarbage(); | 10484 test_->CollectGarbage(); |
| 10486 } | 10485 } |
| 10487 private: | 10486 private: |
| 10488 RegExpInterruptTest* test_; | 10487 RegExpInterruptTest* test_; |
| 10489 }; | 10488 }; |
| 10490 | 10489 |
| 10491 void CollectGarbage() { | 10490 void CollectGarbage() { |
| 10492 block_->Wait(); | 10491 block_->Wait(); |
| 10493 while (gc_during_regexp_ < kRequiredGCs) { | 10492 while (gc_during_regexp_ < kRequiredGCs) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10575 class ApplyInterruptTest { | 10574 class ApplyInterruptTest { |
| 10576 public: | 10575 public: |
| 10577 ApplyInterruptTest() : block_(NULL) {} | 10576 ApplyInterruptTest() : block_(NULL) {} |
| 10578 ~ApplyInterruptTest() { delete block_; } | 10577 ~ApplyInterruptTest() { delete block_; } |
| 10579 void RunTest() { | 10578 void RunTest() { |
| 10580 block_ = i::OS::CreateSemaphore(0); | 10579 block_ = i::OS::CreateSemaphore(0); |
| 10581 gc_count_ = 0; | 10580 gc_count_ = 0; |
| 10582 gc_during_apply_ = 0; | 10581 gc_during_apply_ = 0; |
| 10583 apply_success_ = false; | 10582 apply_success_ = false; |
| 10584 gc_success_ = false; | 10583 gc_success_ = false; |
| 10585 GCThread gc_thread(i::Isolate::Current(), this); | 10584 GCThread gc_thread(this); |
| 10586 gc_thread.Start(); | 10585 gc_thread.Start(); |
| 10587 v8::Locker::StartPreemption(1); | 10586 v8::Locker::StartPreemption(1); |
| 10588 | 10587 |
| 10589 LongRunningApply(); | 10588 LongRunningApply(); |
| 10590 { | 10589 { |
| 10591 v8::Unlocker unlock; | 10590 v8::Unlocker unlock; |
| 10592 gc_thread.Join(); | 10591 gc_thread.Join(); |
| 10593 } | 10592 } |
| 10594 v8::Locker::StopPreemption(); | 10593 v8::Locker::StopPreemption(); |
| 10595 CHECK(apply_success_); | 10594 CHECK(apply_success_); |
| 10596 CHECK(gc_success_); | 10595 CHECK(gc_success_); |
| 10597 } | 10596 } |
| 10598 | 10597 |
| 10599 private: | 10598 private: |
| 10600 // Number of garbage collections required. | 10599 // Number of garbage collections required. |
| 10601 static const int kRequiredGCs = 2; | 10600 static const int kRequiredGCs = 2; |
| 10602 | 10601 |
| 10603 class GCThread : public i::Thread { | 10602 class GCThread : public i::Thread { |
| 10604 public: | 10603 public: |
| 10605 explicit GCThread(i::Isolate* isolate, ApplyInterruptTest* test) | 10604 explicit GCThread(ApplyInterruptTest* test) |
| 10606 : Thread(isolate, "GCThread"), test_(test) {} | 10605 : Thread("GCThread"), test_(test) {} |
| 10607 virtual void Run() { | 10606 virtual void Run() { |
| 10608 test_->CollectGarbage(); | 10607 test_->CollectGarbage(); |
| 10609 } | 10608 } |
| 10610 private: | 10609 private: |
| 10611 ApplyInterruptTest* test_; | 10610 ApplyInterruptTest* test_; |
| 10612 }; | 10611 }; |
| 10613 | 10612 |
| 10614 void CollectGarbage() { | 10613 void CollectGarbage() { |
| 10615 block_->Wait(); | 10614 block_->Wait(); |
| 10616 while (gc_during_apply_ < kRequiredGCs) { | 10615 while (gc_during_apply_ < kRequiredGCs) { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10870 | 10869 |
| 10871 // Inject the input as a global variable. | 10870 // Inject the input as a global variable. |
| 10872 i::Handle<i::String> input_name = | 10871 i::Handle<i::String> input_name = |
| 10873 FACTORY->NewStringFromAscii(i::Vector<const char>("input", 5)); | 10872 FACTORY->NewStringFromAscii(i::Vector<const char>("input", 5)); |
| 10874 i::Isolate::Current()->global_context()->global()->SetProperty( | 10873 i::Isolate::Current()->global_context()->global()->SetProperty( |
| 10875 *input_name, | 10874 *input_name, |
| 10876 *input_, | 10875 *input_, |
| 10877 NONE, | 10876 NONE, |
| 10878 i::kNonStrictMode)->ToObjectChecked(); | 10877 i::kNonStrictMode)->ToObjectChecked(); |
| 10879 | 10878 |
| 10880 MorphThread morph_thread(i::Isolate::Current(), this); | 10879 MorphThread morph_thread(this); |
| 10881 morph_thread.Start(); | 10880 morph_thread.Start(); |
| 10882 v8::Locker::StartPreemption(1); | 10881 v8::Locker::StartPreemption(1); |
| 10883 LongRunningRegExp(); | 10882 LongRunningRegExp(); |
| 10884 { | 10883 { |
| 10885 v8::Unlocker unlock; | 10884 v8::Unlocker unlock; |
| 10886 morph_thread.Join(); | 10885 morph_thread.Join(); |
| 10887 } | 10886 } |
| 10888 v8::Locker::StopPreemption(); | 10887 v8::Locker::StopPreemption(); |
| 10889 CHECK(regexp_success_); | 10888 CHECK(regexp_success_); |
| 10890 CHECK(morph_success_); | 10889 CHECK(morph_success_); |
| 10891 } | 10890 } |
| 10892 | 10891 |
| 10893 private: | 10892 private: |
| 10894 // Number of string modifications required. | 10893 // Number of string modifications required. |
| 10895 static const int kRequiredModifications = 5; | 10894 static const int kRequiredModifications = 5; |
| 10896 static const int kMaxModifications = 100; | 10895 static const int kMaxModifications = 100; |
| 10897 | 10896 |
| 10898 class MorphThread : public i::Thread { | 10897 class MorphThread : public i::Thread { |
| 10899 public: | 10898 public: |
| 10900 explicit MorphThread(i::Isolate* isolate, | 10899 explicit MorphThread(RegExpStringModificationTest* test) |
| 10901 RegExpStringModificationTest* test) | 10900 : Thread("MorphThread"), test_(test) {} |
| 10902 : Thread(isolate, "MorphThread"), test_(test) {} | |
| 10903 virtual void Run() { | 10901 virtual void Run() { |
| 10904 test_->MorphString(); | 10902 test_->MorphString(); |
| 10905 } | 10903 } |
| 10906 private: | 10904 private: |
| 10907 RegExpStringModificationTest* test_; | 10905 RegExpStringModificationTest* test_; |
| 10908 }; | 10906 }; |
| 10909 | 10907 |
| 10910 void MorphString() { | 10908 void MorphString() { |
| 10911 block_->Wait(); | 10909 block_->Wait(); |
| 10912 while (morphs_during_regexp_ < kRequiredModifications && | 10910 while (morphs_during_regexp_ < kRequiredModifications && |
| (...skipping 2796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13709 " return fib(n-1) + fib(n-2);" | 13707 " return fib(n-1) + fib(n-2);" |
| 13710 "}" | 13708 "}" |
| 13711 "fib(%d)", limit); | 13709 "fib(%d)", limit); |
| 13712 Local<Value> value = CompileRun(code.start()); | 13710 Local<Value> value = CompileRun(code.start()); |
| 13713 CHECK(value->IsNumber()); | 13711 CHECK(value->IsNumber()); |
| 13714 return static_cast<int>(value->NumberValue()); | 13712 return static_cast<int>(value->NumberValue()); |
| 13715 } | 13713 } |
| 13716 | 13714 |
| 13717 class IsolateThread : public v8::internal::Thread { | 13715 class IsolateThread : public v8::internal::Thread { |
| 13718 public: | 13716 public: |
| 13719 explicit IsolateThread(v8::Isolate* isolate, int fib_limit) | 13717 IsolateThread(v8::Isolate* isolate, int fib_limit) |
| 13720 : Thread(NULL, "IsolateThread"), | 13718 : Thread("IsolateThread"), |
| 13721 isolate_(isolate), | 13719 isolate_(isolate), |
| 13722 fib_limit_(fib_limit), | 13720 fib_limit_(fib_limit), |
| 13723 result_(0) { } | 13721 result_(0) { } |
| 13724 | 13722 |
| 13725 void Run() { | 13723 void Run() { |
| 13726 result_ = CalcFibonacci(isolate_, fib_limit_); | 13724 result_ = CalcFibonacci(isolate_, fib_limit_); |
| 13727 } | 13725 } |
| 13728 | 13726 |
| 13729 int result() { return result_; } | 13727 int result() { return result_; } |
| 13730 | 13728 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13790 enum TestCase { | 13788 enum TestCase { |
| 13791 IgnoreOOM, | 13789 IgnoreOOM, |
| 13792 SetResourceConstraints, | 13790 SetResourceConstraints, |
| 13793 SetFatalHandler, | 13791 SetFatalHandler, |
| 13794 SetCounterFunction, | 13792 SetCounterFunction, |
| 13795 SetCreateHistogramFunction, | 13793 SetCreateHistogramFunction, |
| 13796 SetAddHistogramSampleFunction | 13794 SetAddHistogramSampleFunction |
| 13797 }; | 13795 }; |
| 13798 | 13796 |
| 13799 explicit InitDefaultIsolateThread(TestCase testCase) | 13797 explicit InitDefaultIsolateThread(TestCase testCase) |
| 13800 : Thread(NULL, "InitDefaultIsolateThread"), | 13798 : Thread("InitDefaultIsolateThread"), |
| 13801 testCase_(testCase), | 13799 testCase_(testCase), |
| 13802 result_(false) { } | 13800 result_(false) { } |
| 13803 | 13801 |
| 13804 void Run() { | 13802 void Run() { |
| 13805 switch (testCase_) { | 13803 switch (testCase_) { |
| 13806 case IgnoreOOM: | 13804 case IgnoreOOM: |
| 13807 v8::V8::IgnoreOutOfMemoryException(); | 13805 v8::V8::IgnoreOutOfMemoryException(); |
| 13808 break; | 13806 break; |
| 13809 | 13807 |
| 13810 case SetResourceConstraints: { | 13808 case SetResourceConstraints: { |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14460 | 14458 |
| 14461 THREADED_TEST(CallAPIFunctionOnNonObject) { | 14459 THREADED_TEST(CallAPIFunctionOnNonObject) { |
| 14462 v8::HandleScope scope; | 14460 v8::HandleScope scope; |
| 14463 LocalContext context; | 14461 LocalContext context; |
| 14464 Handle<FunctionTemplate> templ = v8::FunctionTemplate::New(NonObjectThis); | 14462 Handle<FunctionTemplate> templ = v8::FunctionTemplate::New(NonObjectThis); |
| 14465 Handle<Function> function = templ->GetFunction(); | 14463 Handle<Function> function = templ->GetFunction(); |
| 14466 context->Global()->Set(v8_str("f"), function); | 14464 context->Global()->Set(v8_str("f"), function); |
| 14467 TryCatch try_catch; | 14465 TryCatch try_catch; |
| 14468 CompileRun("f.call(2)"); | 14466 CompileRun("f.call(2)"); |
| 14469 } | 14467 } |
| OLD | NEW |