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

Side by Side Diff: test/cctest/cctest.h

Issue 11970009: Make the Isolate parameter mandatory in Locker and Unlocker classes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Added TODO. Created 7 years, 11 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
« no previous file with comments | « src/v8threads.cc ('k') | test/cctest/cctest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, false); \ 50 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, false); \
51 static void Test##Name() 51 static void Test##Name()
52 #endif 52 #endif
53 53
54 class CcTest { 54 class CcTest {
55 public: 55 public:
56 typedef void (TestFunction)(); 56 typedef void (TestFunction)();
57 CcTest(TestFunction* callback, const char* file, const char* name, 57 CcTest(TestFunction* callback, const char* file, const char* name,
58 const char* dependency, bool enabled); 58 const char* dependency, bool enabled);
59 void Run() { callback_(); } 59 void Run() { callback_(); }
60 static int test_count();
61 static CcTest* last() { return last_; } 60 static CcTest* last() { return last_; }
62 CcTest* prev() { return prev_; } 61 CcTest* prev() { return prev_; }
63 const char* file() { return file_; } 62 const char* file() { return file_; }
64 const char* name() { return name_; } 63 const char* name() { return name_; }
65 const char* dependency() { return dependency_; } 64 const char* dependency() { return dependency_; }
66 bool enabled() { return enabled_; } 65 bool enabled() { return enabled_; }
66 static void set_default_isolate(v8::Isolate* default_isolate) {
67 default_isolate_ = default_isolate;
68 }
69 static v8::Isolate* default_isolate() { return default_isolate_; }
70
67 private: 71 private:
68 TestFunction* callback_; 72 TestFunction* callback_;
69 const char* file_; 73 const char* file_;
70 const char* name_; 74 const char* name_;
71 const char* dependency_; 75 const char* dependency_;
72 bool enabled_; 76 bool enabled_;
73 static CcTest* last_; 77 static CcTest* last_;
74 CcTest* prev_; 78 CcTest* prev_;
79 static v8::Isolate* default_isolate_;
75 }; 80 };
76 81
77 // Switches between all the Api tests using the threading support. 82 // Switches between all the Api tests using the threading support.
78 // In order to get a surprising but repeatable pattern of thread 83 // In order to get a surprising but repeatable pattern of thread
79 // switching it has extra semaphores to control the order in which 84 // switching it has extra semaphores to control the order in which
80 // the tests alternate, not relying solely on the big V8 lock. 85 // the tests alternate, not relying solely on the big V8 lock.
81 // 86 //
82 // A test is augmented with calls to ApiTestFuzzer::Fuzz() in its 87 // A test is augmented with calls to ApiTestFuzzer::Fuzz() in its
83 // callbacks. This will have no effect when we are not running the 88 // callbacks. This will have no effect when we are not running the
84 // thread fuzzing test. In the thread fuzzing test it will 89 // thread fuzzing test. In the thread fuzzing test it will
85 // pseudorandomly select a successor thread and switch execution 90 // pseudorandomly select a successor thread and switch execution
86 // to that thread, suspending the current test. 91 // to that thread, suspending the current test.
87 class ApiTestFuzzer: public v8::internal::Thread { 92 class ApiTestFuzzer: public v8::internal::Thread {
88 public: 93 public:
89 void CallTest(); 94 void CallTest();
90 explicit ApiTestFuzzer(int num)
91 : Thread("ApiTestFuzzer"),
92 test_number_(num),
93 gate_(v8::internal::OS::CreateSemaphore(0)),
94 active_(true) {
95 }
96 ~ApiTestFuzzer() { delete gate_; }
97 95
98 // The ApiTestFuzzer is also a Thread, so it has a Run method. 96 // The ApiTestFuzzer is also a Thread, so it has a Run method.
99 virtual void Run(); 97 virtual void Run();
100 98
101 enum PartOfTest { FIRST_PART, 99 enum PartOfTest { FIRST_PART,
102 SECOND_PART, 100 SECOND_PART,
103 THIRD_PART, 101 THIRD_PART,
104 FOURTH_PART, 102 FOURTH_PART,
105 LAST_PART = FOURTH_PART }; 103 LAST_PART = FOURTH_PART };
106 104
107 static void SetUp(PartOfTest part); 105 static void SetUp(PartOfTest part);
108 static void RunAllTests(); 106 static void RunAllTests();
109 static void TearDown(); 107 static void TearDown();
110 // This method switches threads if we are running the Threading test. 108 // This method switches threads if we are running the Threading test.
111 // Otherwise it does nothing. 109 // Otherwise it does nothing.
112 static void Fuzz(); 110 static void Fuzz();
113 111
114 private: 112 private:
113 explicit ApiTestFuzzer(int num)
114 : Thread("ApiTestFuzzer"),
115 test_number_(num),
116 gate_(v8::internal::OS::CreateSemaphore(0)),
117 active_(true) {
118 }
119 ~ApiTestFuzzer() { delete gate_; }
120
115 static bool fuzzing_; 121 static bool fuzzing_;
116 static int tests_being_run_; 122 static int tests_being_run_;
117 static int current_; 123 static int current_;
118 static int active_tests_; 124 static int active_tests_;
119 static bool NextThread(); 125 static bool NextThread();
120 int test_number_; 126 int test_number_;
121 v8::internal::Semaphore* gate_; 127 v8::internal::Semaphore* gate_;
122 bool active_; 128 bool active_;
123 void ContextSwitch(); 129 void ContextSwitch();
124 static int GetNextTestNumber(); 130 static int GetNextTestNumber();
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { 253 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) {
248 int old_linear_size = static_cast<int>(space->limit() - space->top()); 254 int old_linear_size = static_cast<int>(space->limit() - space->top());
249 space->Free(space->top(), old_linear_size); 255 space->Free(space->top(), old_linear_size);
250 space->SetTop(space->limit(), space->limit()); 256 space->SetTop(space->limit(), space->limit());
251 space->ResetFreeList(); 257 space->ResetFreeList();
252 space->ClearStats(); 258 space->ClearStats();
253 } 259 }
254 260
255 261
256 #endif // ifndef CCTEST_H_ 262 #endif // ifndef CCTEST_H_
OLDNEW
« no previous file with comments | « src/v8threads.cc ('k') | test/cctest/cctest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698