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

Unified Diff: test/cctest/cctest.h

Issue 426233002: Land the Fan (disabled) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback, rebase and "git cl format" Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/zone-containers.h ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/cctest.h
diff --git a/test/cctest/cctest.h b/test/cctest/cctest.h
index fc6ec398fd03a1464a9cb1e618b67612a17b72ff..c99520ba542f8b9b40dfd038b5a313457977ef17 100644
--- a/test/cctest/cctest.h
+++ b/test/cctest/cctest.h
@@ -30,6 +30,8 @@
#include "src/v8.h"
+#include "src/isolate-inl.h"
+
#ifndef TEST
#define TEST(Name) \
static void Test##Name(); \
@@ -112,6 +114,11 @@ class CcTest {
return isolate_;
}
+ static i::Isolate* InitIsolateOnce() {
+ if (!initialize_called_) InitializeVM();
+ return i_isolate();
+ }
+
static i::Isolate* i_isolate() {
return reinterpret_cast<i::Isolate*>(isolate());
}
@@ -124,6 +131,10 @@ class CcTest {
return reinterpret_cast<TestHeap*>(i_isolate()->heap());
}
+ static v8::base::RandomNumberGenerator* random_number_generator() {
+ return InitIsolateOnce()->random_number_generator();
+ }
+
static v8::Local<v8::Object> global() {
return isolate()->GetCurrentContext()->Global();
}
@@ -506,4 +517,30 @@ class HeapObjectsTracker {
};
+class InitializedHandleScope {
+ public:
+ InitializedHandleScope()
+ : main_isolate_(CcTest::InitIsolateOnce()),
+ handle_scope_(main_isolate_) {}
+
+ // Prefixing the below with main_ reduces a lot of naming clashes.
+ i::Isolate* main_isolate() { return main_isolate_; }
+
+ private:
+ i::Isolate* main_isolate_;
+ i::HandleScope handle_scope_;
+};
+
+
+class HandleAndZoneScope : public InitializedHandleScope {
+ public:
+ HandleAndZoneScope() : main_zone_(main_isolate()) {}
+
+ // Prefixing the below with main_ reduces a lot of naming clashes.
+ i::Zone* main_zone() { return &main_zone_; }
+
+ private:
+ i::Zone main_zone_;
+};
+
#endif // ifndef CCTEST_H_
« no previous file with comments | « src/zone-containers.h ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698