| Index: test/cctest/test-api.cc
|
| diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
|
| index 80f91d39bfb00ed8eddf7fb1b91ae3327b891992..22686fd35817d787e99bca2aa2d8a2f7710d6c30 100644
|
| --- a/test/cctest/test-api.cc
|
| +++ b/test/cctest/test-api.cc
|
| @@ -31,11 +31,23 @@
|
|
|
| #include "api.h"
|
| #include "compilation-cache.h"
|
| +#include "execution.h"
|
| #include "snapshot.h"
|
| #include "platform.h"
|
| #include "top.h"
|
| #include "cctest.h"
|
|
|
| +#if V8_TARGET_ARCH_IA32
|
| +#include "ia32/simulator-ia32.h"
|
| +#elif V8_TARGET_ARCH_X64
|
| +#include "x64/simulator-x64.h"
|
| +#elif V8_TARGET_ARCH_ARM
|
| +#include "arm/simulator-arm.h"
|
| +#else
|
| +#error Unsupported target architecture.
|
| +#endif
|
| +
|
| +
|
| static bool IsNaN(double x) {
|
| #ifdef WIN32
|
| return _isnan(x);
|
| @@ -1726,10 +1738,10 @@ TEST(OutOfMemory) {
|
| if (v8::internal::Snapshot::IsEnabled()) return;
|
| // Set heap limits.
|
| static const int K = 1024;
|
| - v8::ResourceConstraints constraints;
|
| + v8::HeapResourceConstraints constraints;
|
| constraints.set_max_young_space_size(256 * K);
|
| constraints.set_max_old_space_size(4 * K * K);
|
| - v8::SetResourceConstraints(&constraints);
|
| + v8::SetHeapResourceConstraints(&constraints);
|
|
|
| // Execute a script that causes out of memory.
|
| v8::HandleScope scope;
|
| @@ -1767,10 +1779,10 @@ TEST(OutOfMemoryNested) {
|
| if (v8::internal::Snapshot::IsEnabled()) return;
|
| // Set heap limits.
|
| static const int K = 1024;
|
| - v8::ResourceConstraints constraints;
|
| + v8::HeapResourceConstraints constraints;
|
| constraints.set_max_young_space_size(256 * K);
|
| constraints.set_max_old_space_size(4 * K * K);
|
| - v8::SetResourceConstraints(&constraints);
|
| + v8::SetHeapResourceConstraints(&constraints);
|
|
|
| v8::HandleScope scope;
|
| Local<ObjectTemplate> templ = ObjectTemplate::New();
|
| @@ -1798,10 +1810,10 @@ TEST(HugeConsStringOutOfMemory) {
|
| LocalContext context;
|
| // Set heap limits.
|
| static const int K = 1024;
|
| - v8::ResourceConstraints constraints;
|
| + v8::HeapResourceConstraints constraints;
|
| constraints.set_max_young_space_size(256 * K);
|
| constraints.set_max_old_space_size(2 * K * K);
|
| - v8::SetResourceConstraints(&constraints);
|
| + v8::SetHeapResourceConstraints(&constraints);
|
|
|
| // Execute a script that causes out of memory.
|
| v8::V8::IgnoreOutOfMemoryException();
|
| @@ -6379,9 +6391,7 @@ THREADED_TEST(Regress54) {
|
| }
|
|
|
|
|
| -// If part of the threaded tests, this test makes ThreadingTest fail
|
| -// on mac.
|
| -TEST(CatchStackOverflow) {
|
| +THREADED_TEST(CatchStackOverflow) {
|
| v8::HandleScope scope;
|
| LocalContext context;
|
| v8::TryCatch try_catch;
|
| @@ -6391,6 +6401,13 @@ TEST(CatchStackOverflow) {
|
| "}"
|
| ""
|
| "f();"));
|
| +
|
| + // the default thread stack size on OS X ia32/x64 is 512K/1M, which
|
| + // is too small for the 512K default V8 stack limit
|
| + static const int K = 1024;
|
| + uint32_t here;
|
| + v8::SetStackLimit(&here - 256 * K / sizeof(uint32_t*));
|
| +
|
| v8::Handle<v8::Value> result = script->Run();
|
| CHECK(result.IsEmpty());
|
| }
|
| @@ -7879,3 +7896,34 @@ THREADED_TEST(IdleNotification) {
|
| for (int i = 0; i < 100; i++) v8::V8::IdleNotification(true);
|
| for (int i = 0; i < 100; i++) v8::V8::IdleNotification(false);
|
| }
|
| +
|
| +
|
| +static uintptr_t js_limit;
|
| +
|
| +
|
| +static v8::Handle<Value> GetStackLimitCallback(const v8::Arguments& args) {
|
| + js_limit = i::StackGuard::jslimit();
|
| + return v8::Undefined();
|
| +}
|
| +
|
| +
|
| +THREADED_TEST(SetStackLimit) {
|
| + v8::HandleScope scope;
|
| + LocalContext env;
|
| + Local<v8::FunctionTemplate> fun_templ =
|
| + v8::FunctionTemplate::New(GetStackLimitCallback);
|
| + Local<Function> fun = fun_templ->GetFunction();
|
| + env->Global()->Set(v8_str("get_stack_limit"), fun);
|
| +
|
| + // Set the stack limit.
|
| + static const int K = 1024;
|
| + uint32_t here;
|
| + uint32_t* limit = &here - 128 * K / sizeof(uint32_t*);
|
| + v8::SetStackLimit(limit);
|
| + CompileRun("get_stack_limit();");
|
| +
|
| + // Must use GENERATED_CODE_STACK_LIMIT to run on the ARM simulator.
|
| + uintptr_t expected_limit =
|
| + GENERATED_CODE_STACK_LIMIT(reinterpret_cast<uintptr_t>(limit));
|
| + CHECK(expected_limit == js_limit);
|
| +}
|
|
|