aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/test/cctest/cctest.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-11-10 02:02:27 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2013-11-11 02:40:36 +0100
commitf230a1cf749e984439b5bb9729d9db9f48472827 (patch)
tree153596de2251b717ad79823f23fabf4c140d6d35 /deps/v8/test/cctest/cctest.cc
parenta12870c823b9b67110b27a470fcac342cf1dfbd6 (diff)
downloadandroid-node-v8-f230a1cf749e984439b5bb9729d9db9f48472827.tar.gz
android-node-v8-f230a1cf749e984439b5bb9729d9db9f48472827.tar.bz2
android-node-v8-f230a1cf749e984439b5bb9729d9db9f48472827.zip
v8: upgrade to 3.22.24
This commit removes the simple/test-event-emitter-memory-leak test for being unreliable with the new garbage collector: the memory pressure exerted by the test case is too low for the garbage collector to kick in. It can be made to work again by limiting the heap size with the --max_old_space_size=x flag but that won't be very reliable across platforms and architectures.
Diffstat (limited to 'deps/v8/test/cctest/cctest.cc')
-rw-r--r--deps/v8/test/cctest/cctest.cc75
1 files changed, 47 insertions, 28 deletions
diff --git a/deps/v8/test/cctest/cctest.cc b/deps/v8/test/cctest/cctest.cc
index 616c6a3a6b..4aa9c7eb71 100644
--- a/deps/v8/test/cctest/cctest.cc
+++ b/deps/v8/test/cctest/cctest.cc
@@ -29,13 +29,20 @@
#include "cctest.h"
#include "debug.h"
+enum InitializationState {kUnset, kUnintialized, kInitialized};
+static InitializationState initialization_state_ = kUnset;
+static bool disable_automatic_dispose_ = false;
CcTest* CcTest::last_ = NULL;
+bool CcTest::initialize_called_ = false;
+bool CcTest::isolate_used_ = false;
+v8::Isolate* CcTest::isolate_ = NULL;
CcTest::CcTest(TestFunction* callback, const char* file, const char* name,
- const char* dependency, bool enabled)
- : callback_(callback), name_(name), dependency_(dependency), prev_(last_) {
+ const char* dependency, bool enabled, bool initialize)
+ : callback_(callback), name_(name), dependency_(dependency),
+ enabled_(enabled), initialize_(initialize), prev_(last_) {
// Find the base name of this test (const_cast required on Windows).
char *basename = strrchr(const_cast<char *>(file), '/');
if (!basename) {
@@ -51,35 +58,49 @@ CcTest::CcTest(TestFunction* callback, const char* file, const char* name,
if (extension) *extension = 0;
// Install this test in the list of tests
file_ = basename;
- enabled_ = enabled;
prev_ = last_;
last_ = this;
}
-v8::Persistent<v8::Context> CcTest::context_;
+void CcTest::Run() {
+ if (!initialize_) {
+ CHECK(initialization_state_ != kInitialized);
+ initialization_state_ = kUnintialized;
+ CHECK(CcTest::isolate_ == NULL);
+ } else {
+ CHECK(initialization_state_ != kUnintialized);
+ initialization_state_ = kInitialized;
+ if (isolate_ == NULL) {
+ isolate_ = v8::Isolate::New();
+ }
+ isolate_->Enter();
+ }
+ callback_();
+ if (initialize_) {
+ isolate_->Exit();
+ }
+}
-void CcTest::InitializeVM(CcTestExtensionFlags extensions) {
- const char* extension_names[kMaxExtensions];
- int extension_count = 0;
-#define CHECK_EXTENSION_FLAG(Name, Id) \
- if (extensions.Contains(Name##_ID)) extension_names[extension_count++] = Id;
- EXTENSION_LIST(CHECK_EXTENSION_FLAG)
-#undef CHECK_EXTENSION_FLAG
- v8::Isolate* isolate = default_isolate();
- if (context_.IsEmpty()) {
- v8::HandleScope scope(isolate);
+v8::Local<v8::Context> CcTest::NewContext(CcTestExtensionFlags extensions,
+ v8::Isolate* isolate) {
+ const char* extension_names[kMaxExtensions];
+ int extension_count = 0;
+ #define CHECK_EXTENSION_FLAG(Name, Id) \
+ if (extensions.Contains(Name##_ID)) extension_names[extension_count++] = Id;
+ EXTENSION_LIST(CHECK_EXTENSION_FLAG)
+ #undef CHECK_EXTENSION_FLAG
v8::ExtensionConfiguration config(extension_count, extension_names);
v8::Local<v8::Context> context = v8::Context::New(isolate, &config);
- context_.Reset(isolate, context);
- }
- {
- v8::HandleScope scope(isolate);
- v8::Local<v8::Context> context =
- v8::Local<v8::Context>::New(isolate, context_);
- context->Enter();
- }
+ CHECK(!context.IsEmpty());
+ return context;
+}
+
+
+void CcTest::DisableAutomaticDispose() {
+ CHECK_EQ(kUnintialized, initialization_state_);
+ disable_automatic_dispose_ = true;
}
@@ -95,9 +116,6 @@ static void PrintTestList(CcTest* current) {
}
-v8::Isolate* CcTest::default_isolate_;
-
-
class CcTestArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
virtual void* Allocate(size_t length) { return malloc(length); }
virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
@@ -115,13 +133,14 @@ static void SuggestTestHarness(int tests) {
int main(int argc, char* argv[]) {
+ v8::V8::InitializeICU();
+ i::Isolate::SetCrashIfDefaultIsolateInitialized();
+
v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
CcTestArrayBufferAllocator array_buffer_allocator;
v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
- CcTest::set_default_isolate(v8::Isolate::GetCurrent());
- CHECK(CcTest::default_isolate() != NULL);
int tests_run = 0;
bool print_run_count = true;
for (int i = 1; i < argc; i++) {
@@ -169,7 +188,7 @@ int main(int argc, char* argv[]) {
}
if (print_run_count && tests_run != 1)
printf("Ran %i tests.\n", tests_run);
- v8::V8::Dispose();
+ if (!disable_automatic_dispose_) v8::V8::Dispose();
return 0;
}