| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include <stdlib.h> | 28 #include <stdlib.h> |
| 29 | 29 |
| 30 #include "v8.h" | 30 #include "v8.h" |
| 31 | 31 |
| 32 #include "api.h" | 32 #include "api.h" |
| 33 #include "compilation-cache.h" | 33 #include "compilation-cache.h" |
| 34 #include "execution.h" |
| 34 #include "snapshot.h" | 35 #include "snapshot.h" |
| 35 #include "platform.h" | 36 #include "platform.h" |
| 36 #include "top.h" | 37 #include "top.h" |
| 37 #include "cctest.h" | 38 #include "cctest.h" |
| 38 | 39 |
| 40 #if V8_TARGET_ARCH_IA32 |
| 41 #include "ia32/simulator-ia32.h" |
| 42 #elif V8_TARGET_ARCH_X64 |
| 43 #include "x64/simulator-x64.h" |
| 44 #elif V8_TARGET_ARCH_ARM |
| 45 #include "arm/simulator-arm.h" |
| 46 #else |
| 47 #error Unsupported target architecture. |
| 48 #endif |
| 49 |
| 50 |
| 39 static bool IsNaN(double x) { | 51 static bool IsNaN(double x) { |
| 40 #ifdef WIN32 | 52 #ifdef WIN32 |
| 41 return _isnan(x); | 53 return _isnan(x); |
| 42 #else | 54 #else |
| 43 return isnan(x); | 55 return isnan(x); |
| 44 #endif | 56 #endif |
| 45 } | 57 } |
| 46 | 58 |
| 47 using ::v8::ObjectTemplate; | 59 using ::v8::ObjectTemplate; |
| 48 using ::v8::Value; | 60 using ::v8::Value; |
| (...skipping 7823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7872 CHECK(strstr(*stack, "at foo (stack-trace-test") != NULL); | 7884 CHECK(strstr(*stack, "at foo (stack-trace-test") != NULL); |
| 7873 } | 7885 } |
| 7874 | 7886 |
| 7875 | 7887 |
| 7876 // Test that idle notification can be handled when V8 has not yet been | 7888 // Test that idle notification can be handled when V8 has not yet been |
| 7877 // set up. | 7889 // set up. |
| 7878 THREADED_TEST(IdleNotification) { | 7890 THREADED_TEST(IdleNotification) { |
| 7879 for (int i = 0; i < 100; i++) v8::V8::IdleNotification(true); | 7891 for (int i = 0; i < 100; i++) v8::V8::IdleNotification(true); |
| 7880 for (int i = 0; i < 100; i++) v8::V8::IdleNotification(false); | 7892 for (int i = 0; i < 100; i++) v8::V8::IdleNotification(false); |
| 7881 } | 7893 } |
| 7894 |
| 7895 |
| 7896 static uint32_t* stack_limit; |
| 7897 |
| 7898 static v8::Handle<Value> GetStackLimitCallback(const v8::Arguments& args) { |
| 7899 stack_limit = reinterpret_cast<uint32_t*>(i::StackGuard::jslimit()); |
| 7900 return v8::Undefined(); |
| 7901 } |
| 7902 |
| 7903 |
| 7904 // Must use GENERATED_CODE_STACK_LIMIT to run on the ARM simulator, |
| 7905 // and we must have 'this' to use GENERATED_CODE_STACK_LIMIT, hence |
| 7906 // this class. |
| 7907 class StackLimitHelper { |
| 7908 public: |
| 7909 uint32_t* ComputeStackLimit(uint bytes) { |
| 7910 return reinterpret_cast<uint32_t*>(GENERATED_CODE_STACK_LIMIT(bytes)); |
| 7911 } |
| 7912 }; |
| 7913 |
| 7914 |
| 7915 TEST(SetResourceConstraints) { |
| 7916 StackLimitHelper here; |
| 7917 static const int K = 1024; |
| 7918 uint32_t* set_limit = here.ComputeStackLimit(128 * K); |
| 7919 |
| 7920 // Set stack limit. |
| 7921 v8::ResourceConstraints constraints; |
| 7922 constraints.set_stack_limit(set_limit); |
| 7923 CHECK(v8::SetResourceConstraints(&constraints)); |
| 7924 |
| 7925 // Execute a script. |
| 7926 v8::HandleScope scope; |
| 7927 LocalContext env; |
| 7928 Local<v8::FunctionTemplate> fun_templ = |
| 7929 v8::FunctionTemplate::New(GetStackLimitCallback); |
| 7930 Local<Function> fun = fun_templ->GetFunction(); |
| 7931 env->Global()->Set(v8_str("get_stack_limit"), fun); |
| 7932 CompileRun("get_stack_limit();"); |
| 7933 |
| 7934 CHECK(stack_limit == set_limit); |
| 7935 } |
| OLD | NEW |