| Index: test/cctest/test-api.cc
|
| diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
|
| index 80f91d39bfb00ed8eddf7fb1b91ae3327b891992..0099610eb1959ebb38173ffcb3f304c1b2ec738a 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);
|
| @@ -7879,3 +7891,45 @@ 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 uint32_t* stack_limit;
|
| +
|
| +static v8::Handle<Value> GetStackLimitCallback(const v8::Arguments& args) {
|
| + stack_limit = reinterpret_cast<uint32_t*>(i::StackGuard::jslimit());
|
| + return v8::Undefined();
|
| +}
|
| +
|
| +
|
| +// Must use GENERATED_CODE_STACK_LIMIT to run on the ARM simulator,
|
| +// and we must have 'this' to use GENERATED_CODE_STACK_LIMIT, hence
|
| +// this class.
|
| +class StackLimitHelper {
|
| + public:
|
| + uint32_t* ComputeStackLimit(uint bytes) {
|
| + return reinterpret_cast<uint32_t*>(GENERATED_CODE_STACK_LIMIT(bytes));
|
| + }
|
| +};
|
| +
|
| +
|
| +TEST(SetResourceConstraints) {
|
| + StackLimitHelper here;
|
| + static const int K = 1024;
|
| + uint32_t* set_limit = here.ComputeStackLimit(128 * K);
|
| +
|
| + // Set stack limit.
|
| + v8::ResourceConstraints constraints;
|
| + constraints.set_stack_limit(set_limit);
|
| + CHECK(v8::SetResourceConstraints(&constraints));
|
| +
|
| + // Execute a script.
|
| + 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);
|
| + CompileRun("get_stack_limit();");
|
| +
|
| + CHECK(stack_limit == set_limit);
|
| +}
|
|
|