| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 void Run(); | 110 void Run(); |
| 111 static CcTest* last() { return last_; } | 111 static CcTest* last() { return last_; } |
| 112 CcTest* prev() { return prev_; } | 112 CcTest* prev() { return prev_; } |
| 113 const char* file() { return file_; } | 113 const char* file() { return file_; } |
| 114 const char* name() { return name_; } | 114 const char* name() { return name_; } |
| 115 const char* dependency() { return dependency_; } | 115 const char* dependency() { return dependency_; } |
| 116 bool enabled() { return enabled_; } | 116 bool enabled() { return enabled_; } |
| 117 | 117 |
| 118 static v8::Isolate* isolate() { | 118 static v8::Isolate* isolate() { |
| 119 CHECK(isolate_ != NULL); | 119 CHECK(isolate_ != NULL); |
| 120 isolate_used_ = true; | 120 v8::base::NoBarrier_Store(&isolate_used_, 1); |
| 121 return isolate_; | 121 return isolate_; |
| 122 } | 122 } |
| 123 | 123 |
| 124 static i::Isolate* InitIsolateOnce() { | 124 static i::Isolate* InitIsolateOnce() { |
| 125 if (!initialize_called_) InitializeVM(); | 125 if (!initialize_called_) InitializeVM(); |
| 126 return i_isolate(); | 126 return i_isolate(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 static i::Isolate* i_isolate() { | 129 static i::Isolate* i_isolate() { |
| 130 return reinterpret_cast<i::Isolate*>(isolate()); | 130 return reinterpret_cast<i::Isolate*>(isolate()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 142 return InitIsolateOnce()->random_number_generator(); | 142 return InitIsolateOnce()->random_number_generator(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 static v8::Local<v8::Object> global() { | 145 static v8::Local<v8::Object> global() { |
| 146 return isolate()->GetCurrentContext()->Global(); | 146 return isolate()->GetCurrentContext()->Global(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 // TODO(dcarney): Remove. | 149 // TODO(dcarney): Remove. |
| 150 // This must be called first in a test. | 150 // This must be called first in a test. |
| 151 static void InitializeVM() { | 151 static void InitializeVM() { |
| 152 CHECK(!isolate_used_); | 152 CHECK(!v8::base::NoBarrier_Load(&isolate_used_)); |
| 153 CHECK(!initialize_called_); | 153 CHECK(!initialize_called_); |
| 154 initialize_called_ = true; | 154 initialize_called_ = true; |
| 155 v8::HandleScope handle_scope(CcTest::isolate()); | 155 v8::HandleScope handle_scope(CcTest::isolate()); |
| 156 v8::Context::New(CcTest::isolate())->Enter(); | 156 v8::Context::New(CcTest::isolate())->Enter(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 // Only for UNINITIALIZED_TESTs | 159 // Only for UNINITIALIZED_TESTs |
| 160 static void DisableAutomaticDispose(); | 160 static void DisableAutomaticDispose(); |
| 161 | 161 |
| 162 // Helper function to configure a context. | 162 // Helper function to configure a context. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 174 TestFunction* callback_; | 174 TestFunction* callback_; |
| 175 const char* file_; | 175 const char* file_; |
| 176 const char* name_; | 176 const char* name_; |
| 177 const char* dependency_; | 177 const char* dependency_; |
| 178 bool enabled_; | 178 bool enabled_; |
| 179 bool initialize_; | 179 bool initialize_; |
| 180 CcTest* prev_; | 180 CcTest* prev_; |
| 181 static CcTest* last_; | 181 static CcTest* last_; |
| 182 static v8::Isolate* isolate_; | 182 static v8::Isolate* isolate_; |
| 183 static bool initialize_called_; | 183 static bool initialize_called_; |
| 184 static bool isolate_used_; | 184 static v8::base::Atomic32 isolate_used_; |
| 185 }; | 185 }; |
| 186 | 186 |
| 187 // Switches between all the Api tests using the threading support. | 187 // Switches between all the Api tests using the threading support. |
| 188 // In order to get a surprising but repeatable pattern of thread | 188 // In order to get a surprising but repeatable pattern of thread |
| 189 // switching it has extra semaphores to control the order in which | 189 // switching it has extra semaphores to control the order in which |
| 190 // the tests alternate, not relying solely on the big V8 lock. | 190 // the tests alternate, not relying solely on the big V8 lock. |
| 191 // | 191 // |
| 192 // A test is augmented with calls to ApiTestFuzzer::Fuzz() in its | 192 // A test is augmented with calls to ApiTestFuzzer::Fuzz() in its |
| 193 // callbacks. This will have no effect when we are not running the | 193 // callbacks. This will have no effect when we are not running the |
| 194 // thread fuzzing test. In the thread fuzzing test it will | 194 // thread fuzzing test. In the thread fuzzing test it will |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 HandleAndZoneScope() : main_zone_(main_isolate()) {} | 563 HandleAndZoneScope() : main_zone_(main_isolate()) {} |
| 564 | 564 |
| 565 // Prefixing the below with main_ reduces a lot of naming clashes. | 565 // Prefixing the below with main_ reduces a lot of naming clashes. |
| 566 i::Zone* main_zone() { return &main_zone_; } | 566 i::Zone* main_zone() { return &main_zone_; } |
| 567 | 567 |
| 568 private: | 568 private: |
| 569 i::Zone main_zone_; | 569 i::Zone main_zone_; |
| 570 }; | 570 }; |
| 571 | 571 |
| 572 #endif // ifndef CCTEST_H_ | 572 #endif // ifndef CCTEST_H_ |
| OLD | NEW |