| Index: test/cctest/test-api.cc
|
| ===================================================================
|
| --- test/cctest/test-api.cc (revision 7186)
|
| +++ test/cctest/test-api.cc (working copy)
|
| @@ -2081,8 +2081,6 @@
|
| TEST(HugeConsStringOutOfMemory) {
|
| // It's not possible to read a snapshot into a heap with different dimensions.
|
| if (i::Snapshot::IsEnabled()) return;
|
| - v8::HandleScope scope;
|
| - LocalContext context;
|
| // Set heap limits.
|
| static const int K = 1024;
|
| v8::ResourceConstraints constraints;
|
| @@ -2093,6 +2091,9 @@
|
| // Execute a script that causes out of memory.
|
| v8::V8::IgnoreOutOfMemoryException();
|
|
|
| + v8::HandleScope scope;
|
| + LocalContext context;
|
| +
|
| // Build huge string. This should fail with out of memory exception.
|
| Local<Value> result = CompileRun(
|
| "var str = Array.prototype.join.call({length: 513}, \"A\").toUpperCase();"
|
| @@ -12887,6 +12888,66 @@
|
| }
|
|
|
|
|
| +class InitDefaultIsolateThread : public v8::internal::Thread {
|
| + public:
|
| + enum TestCase { IgnoreOOM, SetResourceConstraints, SetFatalHandler };
|
| +
|
| + explicit InitDefaultIsolateThread(TestCase testCase)
|
| + : Thread(NULL),
|
| + testCase_(testCase),
|
| + result_(false) { }
|
| +
|
| + void Run() {
|
| + switch (testCase_) {
|
| + case IgnoreOOM:
|
| + v8::V8::IgnoreOutOfMemoryException();
|
| + break;
|
| +
|
| + case SetResourceConstraints: {
|
| + static const int K = 1024;
|
| + v8::ResourceConstraints constraints;
|
| + constraints.set_max_young_space_size(256 * K);
|
| + constraints.set_max_old_space_size(4 * K * K);
|
| + v8::SetResourceConstraints(&constraints);
|
| + break;
|
| + }
|
| +
|
| + case SetFatalHandler:
|
| + v8::V8::SetFatalErrorHandler(NULL);
|
| + break;
|
| +
|
| + }
|
| + result_ = true;
|
| + }
|
| +
|
| + bool result() { return result_; }
|
| +
|
| + private:
|
| + TestCase testCase_;
|
| + bool result_;
|
| +};
|
| +
|
| +
|
| +static void InitializeTestHelper(InitDefaultIsolateThread::TestCase testCase) {
|
| + InitDefaultIsolateThread thread(testCase);
|
| + thread.Start();
|
| + thread.Join();
|
| + CHECK_EQ(thread.result(), true);
|
| +}
|
| +
|
| +TEST(InitializeDefaultIsolateOnSecondaryThread1) {
|
| + InitializeTestHelper(InitDefaultIsolateThread::IgnoreOOM);
|
| +}
|
| +
|
| +TEST(InitializeDefaultIsolateOnSecondaryThread2) {
|
| + InitializeTestHelper(InitDefaultIsolateThread::SetResourceConstraints);
|
| +}
|
| +
|
| +TEST(InitializeDefaultIsolateOnSecondaryThread3) {
|
| + InitializeTestHelper(InitDefaultIsolateThread::SetFatalHandler);
|
| +}
|
| +
|
| +
|
| TEST(StringCheckMultipleContexts) {
|
| const char* code =
|
| "(function() { return \"a\".charAt(0); })()";
|
|
|