OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 14 matching lines...) Expand all Loading... |
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 <limits.h> | 28 #include <limits.h> |
29 | 29 |
30 #ifndef WIN32 | 30 #ifndef WIN32 |
31 #include <signal.h> // kill | 31 #include <signal.h> // kill |
32 #include <unistd.h> // getpid | 32 #include <unistd.h> // getpid |
33 #endif // WIN32 | 33 #endif // WIN32 |
34 | 34 |
35 // TODO(dcarney): remove | |
36 #define V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR | |
37 #define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT | |
38 #define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW | |
39 | |
40 #include "v8.h" | 35 #include "v8.h" |
41 | 36 |
42 #include "api.h" | 37 #include "api.h" |
43 #include "arguments.h" | 38 #include "arguments.h" |
44 #include "isolate.h" | 39 #include "isolate.h" |
45 #include "compilation-cache.h" | 40 #include "compilation-cache.h" |
46 #include "execution.h" | 41 #include "execution.h" |
47 #include "objects.h" | 42 #include "objects.h" |
48 #include "snapshot.h" | 43 #include "snapshot.h" |
49 #include "platform.h" | 44 #include "platform.h" |
(...skipping 2725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2775 CHECK_EQ('3', *char_ptr); | 2770 CHECK_EQ('3', *char_ptr); |
2776 i::DeleteArray(data); | 2771 i::DeleteArray(data); |
2777 } | 2772 } |
2778 | 2773 |
2779 | 2774 |
2780 THREADED_TEST(GlobalHandle) { | 2775 THREADED_TEST(GlobalHandle) { |
2781 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 2776 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
2782 v8::Persistent<String> global; | 2777 v8::Persistent<String> global; |
2783 { | 2778 { |
2784 v8::HandleScope scope(isolate); | 2779 v8::HandleScope scope(isolate); |
2785 Local<String> str = v8_str("str"); | 2780 global.Reset(isolate, v8_str("str")); |
2786 global = v8::Persistent<String>::New(isolate, str); | |
2787 } | 2781 } |
2788 CHECK_EQ(global->Length(), 3); | |
2789 global.Dispose(isolate); | |
2790 | |
2791 { | 2782 { |
2792 v8::HandleScope scope(isolate); | 2783 v8::HandleScope scope(isolate); |
2793 Local<String> str = v8_str("str"); | 2784 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); |
2794 global = v8::Persistent<String>::New(isolate, str); | |
2795 } | 2785 } |
2796 CHECK_EQ(global->Length(), 3); | 2786 global.Dispose(); |
2797 global.Dispose(isolate); | 2787 global.Clear(); |
| 2788 { |
| 2789 v8::HandleScope scope(isolate); |
| 2790 global.Reset(isolate, v8_str("str")); |
| 2791 } |
| 2792 { |
| 2793 v8::HandleScope scope(isolate); |
| 2794 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); |
| 2795 } |
| 2796 global.Dispose(); |
2798 } | 2797 } |
2799 | 2798 |
2800 | 2799 |
2801 THREADED_TEST(ResettingGlobalHandle) { | 2800 THREADED_TEST(ResettingGlobalHandle) { |
2802 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 2801 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
2803 v8::internal::GlobalHandles* global_handles = NULL; | |
2804 int initial_handle_count = 0; | |
2805 v8::Persistent<String> global; | 2802 v8::Persistent<String> global; |
2806 { | 2803 { |
2807 v8::HandleScope scope(isolate); | 2804 v8::HandleScope scope(isolate); |
2808 Local<String> str = v8_str("str"); | 2805 global.Reset(isolate, v8_str("str")); |
2809 global_handles = | |
2810 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); | |
2811 initial_handle_count = global_handles->NumberOfGlobalHandles(); | |
2812 global = v8::Persistent<String>::New(isolate, str); | |
2813 } | 2806 } |
2814 CHECK_EQ(global->Length(), 3); | 2807 v8::internal::GlobalHandles* global_handles = |
2815 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count + 1); | 2808 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); |
| 2809 int initial_handle_count = global_handles->NumberOfGlobalHandles(); |
2816 { | 2810 { |
2817 v8::HandleScope scope(isolate); | 2811 v8::HandleScope scope(isolate); |
2818 Local<String> str = v8_str("longer"); | 2812 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); |
2819 global.Reset(isolate, str); | |
2820 } | 2813 } |
2821 CHECK_EQ(global->Length(), 6); | 2814 { |
2822 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count + 1); | 2815 v8::HandleScope scope(isolate); |
| 2816 global.Reset(isolate, v8_str("longer")); |
| 2817 } |
| 2818 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count); |
| 2819 { |
| 2820 v8::HandleScope scope(isolate); |
| 2821 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 6); |
| 2822 } |
2823 global.Dispose(isolate); | 2823 global.Dispose(isolate); |
2824 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count); | 2824 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count - 1); |
2825 } | 2825 } |
2826 | 2826 |
2827 | 2827 |
2828 THREADED_TEST(ResettingGlobalHandleToEmpty) { | 2828 THREADED_TEST(ResettingGlobalHandleToEmpty) { |
2829 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 2829 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
2830 v8::internal::GlobalHandles* global_handles = NULL; | |
2831 int initial_handle_count = 0; | |
2832 v8::Persistent<String> global; | 2830 v8::Persistent<String> global; |
2833 { | 2831 { |
2834 v8::HandleScope scope(isolate); | 2832 v8::HandleScope scope(isolate); |
2835 Local<String> str = v8_str("str"); | 2833 global.Reset(isolate, v8_str("str")); |
2836 global_handles = | |
2837 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); | |
2838 initial_handle_count = global_handles->NumberOfGlobalHandles(); | |
2839 global = v8::Persistent<String>::New(isolate, str); | |
2840 } | 2834 } |
2841 CHECK_EQ(global->Length(), 3); | 2835 v8::internal::GlobalHandles* global_handles = |
2842 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count + 1); | 2836 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); |
| 2837 int initial_handle_count = global_handles->NumberOfGlobalHandles(); |
| 2838 { |
| 2839 v8::HandleScope scope(isolate); |
| 2840 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); |
| 2841 } |
2843 { | 2842 { |
2844 v8::HandleScope scope(isolate); | 2843 v8::HandleScope scope(isolate); |
2845 Local<String> empty; | 2844 Local<String> empty; |
2846 global.Reset(isolate, empty); | 2845 global.Reset(isolate, empty); |
2847 } | 2846 } |
2848 CHECK(global.IsEmpty()); | 2847 CHECK(global.IsEmpty()); |
2849 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count); | 2848 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count - 1); |
2850 } | 2849 } |
2851 | 2850 |
2852 | 2851 |
2853 THREADED_TEST(ClearAndLeakGlobal) { | 2852 THREADED_TEST(ClearAndLeakGlobal) { |
2854 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 2853 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
2855 v8::internal::GlobalHandles* global_handles = NULL; | 2854 v8::internal::GlobalHandles* global_handles = NULL; |
2856 int initial_handle_count = 0; | 2855 int initial_handle_count = 0; |
2857 v8::Persistent<String> global; | 2856 v8::Persistent<String> global; |
2858 { | 2857 { |
2859 v8::HandleScope scope(isolate); | 2858 v8::HandleScope scope(isolate); |
2860 Local<String> str = v8_str("str"); | 2859 Local<String> str = v8_str("str"); |
2861 global_handles = | 2860 global_handles = |
2862 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); | 2861 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); |
2863 initial_handle_count = global_handles->NumberOfGlobalHandles(); | 2862 initial_handle_count = global_handles->NumberOfGlobalHandles(); |
2864 global = v8::Persistent<String>::New(isolate, str); | 2863 global.Reset(isolate, str); |
2865 } | 2864 } |
2866 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count + 1); | 2865 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count + 1); |
2867 String* str = global.ClearAndLeak(); | 2866 String* str = global.ClearAndLeak(); |
2868 CHECK(global.IsEmpty()); | 2867 CHECK(global.IsEmpty()); |
2869 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count + 1); | 2868 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count + 1); |
2870 v8::Persistent<String>* new_global = | 2869 v8::Persistent<String>* new_global = |
2871 reinterpret_cast<v8::Persistent<String>*>(&str); | 2870 reinterpret_cast<v8::Persistent<String>*>(&str); |
2872 new_global->Dispose(); | 2871 new_global->Dispose(); |
2873 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count); | 2872 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count); |
2874 } | 2873 } |
(...skipping 15 matching lines...) Expand all Loading... |
2890 int id() { return id_; } | 2889 int id() { return id_; } |
2891 void increment() { number_of_weak_calls_++; } | 2890 void increment() { number_of_weak_calls_++; } |
2892 int NumberOfWeakCalls() { return number_of_weak_calls_; } | 2891 int NumberOfWeakCalls() { return number_of_weak_calls_; } |
2893 private: | 2892 private: |
2894 int id_; | 2893 int id_; |
2895 int number_of_weak_calls_; | 2894 int number_of_weak_calls_; |
2896 }; | 2895 }; |
2897 | 2896 |
2898 | 2897 |
2899 static void WeakPointerCallback(v8::Isolate* isolate, | 2898 static void WeakPointerCallback(v8::Isolate* isolate, |
2900 Persistent<Object>* handle, | 2899 Persistent<Value>* handle, |
2901 WeakCallCounter* counter) { | 2900 WeakCallCounter* counter) { |
2902 CHECK_EQ(1234, counter->id()); | 2901 CHECK_EQ(1234, counter->id()); |
2903 counter->increment(); | 2902 counter->increment(); |
2904 handle->Dispose(isolate); | 2903 handle->Dispose(isolate); |
2905 } | 2904 } |
2906 | 2905 |
2907 | 2906 |
2908 THREADED_TEST(ApiObjectGroups) { | 2907 THREADED_TEST(ApiObjectGroups) { |
2909 LocalContext env; | 2908 LocalContext env; |
2910 v8::Isolate* iso = env->GetIsolate(); | 2909 v8::Isolate* iso = env->GetIsolate(); |
2911 HandleScope scope(iso); | 2910 HandleScope scope(iso); |
2912 | 2911 |
2913 Persistent<Object> g1s1; | 2912 Persistent<Value> g1s1; |
2914 Persistent<Object> g1s2; | 2913 Persistent<Value> g1s2; |
2915 Persistent<Object> g1c1; | 2914 Persistent<Value> g1c1; |
2916 Persistent<Object> g2s1; | 2915 Persistent<Value> g2s1; |
2917 Persistent<Object> g2s2; | 2916 Persistent<Value> g2s2; |
2918 Persistent<Object> g2c1; | 2917 Persistent<Value> g2c1; |
2919 | 2918 |
2920 WeakCallCounter counter(1234); | 2919 WeakCallCounter counter(1234); |
2921 | 2920 |
2922 { | 2921 { |
2923 HandleScope scope(iso); | 2922 HandleScope scope(iso); |
2924 g1s1 = Persistent<Object>::New(iso, Object::New()); | 2923 g1s1.Reset(iso, Object::New()); |
2925 g1s2 = Persistent<Object>::New(iso, Object::New()); | 2924 g1s2.Reset(iso, Object::New()); |
2926 g1c1 = Persistent<Object>::New(iso, Object::New()); | 2925 g1c1.Reset(iso, Object::New()); |
2927 g1s1.MakeWeak(iso, &counter, &WeakPointerCallback); | 2926 g1s1.MakeWeak(iso, &counter, &WeakPointerCallback); |
2928 g1s2.MakeWeak(iso, &counter, &WeakPointerCallback); | 2927 g1s2.MakeWeak(iso, &counter, &WeakPointerCallback); |
2929 g1c1.MakeWeak(iso, &counter, &WeakPointerCallback); | 2928 g1c1.MakeWeak(iso, &counter, &WeakPointerCallback); |
2930 | 2929 |
2931 g2s1 = Persistent<Object>::New(iso, Object::New()); | 2930 g2s1.Reset(iso, Object::New()); |
2932 g2s2 = Persistent<Object>::New(iso, Object::New()); | 2931 g2s2.Reset(iso, Object::New()); |
2933 g2c1 = Persistent<Object>::New(iso, Object::New()); | 2932 g2c1.Reset(iso, Object::New()); |
2934 g2s1.MakeWeak(iso, &counter, &WeakPointerCallback); | 2933 g2s1.MakeWeak(iso, &counter, &WeakPointerCallback); |
2935 g2s2.MakeWeak(iso, &counter, &WeakPointerCallback); | 2934 g2s2.MakeWeak(iso, &counter, &WeakPointerCallback); |
2936 g2c1.MakeWeak(iso, &counter, &WeakPointerCallback); | 2935 g2c1.MakeWeak(iso, &counter, &WeakPointerCallback); |
2937 } | 2936 } |
2938 | 2937 |
2939 Persistent<Object> root = Persistent<Object>::New(iso, g1s1); // make a root. | 2938 Persistent<Value> root(iso, g1s1); // make a root. |
2940 | 2939 |
2941 // Connect group 1 and 2, make a cycle. | 2940 // Connect group 1 and 2, make a cycle. |
2942 CHECK(g1s2->Set(0, Local<Value>(*g2s2))); | 2941 { |
2943 CHECK(g2s1->Set(0, Local<Value>(*g1s1))); | 2942 HandleScope scope(iso); |
| 2943 CHECK(Local<Object>::New(iso, g1s2.As<Object>())-> |
| 2944 Set(0, Local<Value>(*g2s2))); |
| 2945 CHECK(Local<Object>::New(iso, g2s1.As<Object>())-> |
| 2946 Set(0, Local<Value>(*g1s1))); |
| 2947 } |
2944 | 2948 |
2945 { | 2949 { |
2946 UniqueId id1(reinterpret_cast<intptr_t>(*g1s1)); | 2950 UniqueId id1(reinterpret_cast<intptr_t>(*g1s1)); |
2947 UniqueId id2(reinterpret_cast<intptr_t>(*g2s2)); | 2951 UniqueId id2(reinterpret_cast<intptr_t>(*g2s2)); |
2948 iso->SetObjectGroupId(g1s1, id1); | 2952 iso->SetObjectGroupId(g1s1, id1); |
2949 iso->SetObjectGroupId(g1s2, id1); | 2953 iso->SetObjectGroupId(g1s2, id1); |
2950 iso->SetReferenceFromGroup(id1, g1c1); | 2954 iso->SetReferenceFromGroup(id1, g1c1); |
2951 iso->SetObjectGroupId(g2s1, id2); | 2955 iso->SetObjectGroupId(g2s1, id2); |
2952 iso->SetObjectGroupId(g2s2, id2); | 2956 iso->SetObjectGroupId(g2s2, id2); |
2953 iso->SetReferenceFromGroup(id2, g2c1); | 2957 iso->SetReferenceFromGroup(id2, g2c1); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2993 } | 2997 } |
2994 | 2998 |
2995 | 2999 |
2996 THREADED_TEST(ApiObjectGroupsCycle) { | 3000 THREADED_TEST(ApiObjectGroupsCycle) { |
2997 LocalContext env; | 3001 LocalContext env; |
2998 v8::Isolate* iso = env->GetIsolate(); | 3002 v8::Isolate* iso = env->GetIsolate(); |
2999 HandleScope scope(iso); | 3003 HandleScope scope(iso); |
3000 | 3004 |
3001 WeakCallCounter counter(1234); | 3005 WeakCallCounter counter(1234); |
3002 | 3006 |
3003 Persistent<Object> g1s1; | 3007 Persistent<Value> g1s1; |
3004 Persistent<Object> g1s2; | 3008 Persistent<Value> g1s2; |
3005 Persistent<Object> g2s1; | 3009 Persistent<Value> g2s1; |
3006 Persistent<Object> g2s2; | 3010 Persistent<Value> g2s2; |
3007 Persistent<Object> g3s1; | 3011 Persistent<Value> g3s1; |
3008 Persistent<Object> g3s2; | 3012 Persistent<Value> g3s2; |
3009 Persistent<Object> g4s1; | 3013 Persistent<Value> g4s1; |
3010 Persistent<Object> g4s2; | 3014 Persistent<Value> g4s2; |
3011 | 3015 |
3012 { | 3016 { |
3013 HandleScope scope(iso); | 3017 HandleScope scope(iso); |
3014 g1s1 = Persistent<Object>::New(iso, Object::New()); | 3018 g1s1.Reset(iso, Object::New()); |
3015 g1s2 = Persistent<Object>::New(iso, Object::New()); | 3019 g1s2.Reset(iso, Object::New()); |
3016 g1s1.MakeWeak(iso, &counter, &WeakPointerCallback); | 3020 g1s1.MakeWeak(iso, &counter, &WeakPointerCallback); |
3017 g1s2.MakeWeak(iso, &counter, &WeakPointerCallback); | 3021 g1s2.MakeWeak(iso, &counter, &WeakPointerCallback); |
3018 CHECK(g1s1.IsWeak(iso)); | 3022 CHECK(g1s1.IsWeak(iso)); |
3019 CHECK(g1s2.IsWeak(iso)); | 3023 CHECK(g1s2.IsWeak(iso)); |
3020 | 3024 |
3021 g2s1 = Persistent<Object>::New(iso, Object::New()); | 3025 g2s1.Reset(iso, Object::New()); |
3022 g2s2 = Persistent<Object>::New(iso, Object::New()); | 3026 g2s2.Reset(iso, Object::New()); |
3023 g2s1.MakeWeak(iso, &counter, &WeakPointerCallback); | 3027 g2s1.MakeWeak(iso, &counter, &WeakPointerCallback); |
3024 g2s2.MakeWeak(iso, &counter, &WeakPointerCallback); | 3028 g2s2.MakeWeak(iso, &counter, &WeakPointerCallback); |
3025 CHECK(g2s1.IsWeak(iso)); | 3029 CHECK(g2s1.IsWeak(iso)); |
3026 CHECK(g2s2.IsWeak(iso)); | 3030 CHECK(g2s2.IsWeak(iso)); |
3027 | 3031 |
3028 g3s1 = Persistent<Object>::New(iso, Object::New()); | 3032 g3s1.Reset(iso, Object::New()); |
3029 g3s2 = Persistent<Object>::New(iso, Object::New()); | 3033 g3s2.Reset(iso, Object::New()); |
3030 g3s1.MakeWeak(iso, &counter, &WeakPointerCallback); | 3034 g3s1.MakeWeak(iso, &counter, &WeakPointerCallback); |
3031 g3s2.MakeWeak(iso, &counter, &WeakPointerCallback); | 3035 g3s2.MakeWeak(iso, &counter, &WeakPointerCallback); |
3032 CHECK(g3s1.IsWeak(iso)); | 3036 CHECK(g3s1.IsWeak(iso)); |
3033 CHECK(g3s2.IsWeak(iso)); | 3037 CHECK(g3s2.IsWeak(iso)); |
3034 | 3038 |
3035 g4s1 = Persistent<Object>::New(iso, Object::New()); | 3039 g4s1.Reset(iso, Object::New()); |
3036 g4s2 = Persistent<Object>::New(iso, Object::New()); | 3040 g4s2.Reset(iso, Object::New()); |
3037 g4s1.MakeWeak(iso, &counter, &WeakPointerCallback); | 3041 g4s1.MakeWeak(iso, &counter, &WeakPointerCallback); |
3038 g4s2.MakeWeak(iso, &counter, &WeakPointerCallback); | 3042 g4s2.MakeWeak(iso, &counter, &WeakPointerCallback); |
3039 CHECK(g4s1.IsWeak(iso)); | 3043 CHECK(g4s1.IsWeak(iso)); |
3040 CHECK(g4s2.IsWeak(iso)); | 3044 CHECK(g4s2.IsWeak(iso)); |
3041 } | 3045 } |
3042 | 3046 |
3043 Persistent<Object> root = Persistent<Object>::New(iso, g1s1); // make a root. | 3047 Persistent<Value> root(iso, g1s1); // make a root. |
3044 | 3048 |
3045 // Connect groups. We're building the following cycle: | 3049 // Connect groups. We're building the following cycle: |
3046 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other | 3050 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other |
3047 // groups. | 3051 // groups. |
3048 { | 3052 { |
3049 UniqueId id1(reinterpret_cast<intptr_t>(*g1s1)); | 3053 UniqueId id1(reinterpret_cast<intptr_t>(*g1s1)); |
3050 UniqueId id2(reinterpret_cast<intptr_t>(*g2s1)); | 3054 UniqueId id2(reinterpret_cast<intptr_t>(*g2s1)); |
3051 UniqueId id3(reinterpret_cast<intptr_t>(*g3s1)); | 3055 UniqueId id3(reinterpret_cast<intptr_t>(*g3s1)); |
3052 UniqueId id4(reinterpret_cast<intptr_t>(*g4s1)); | 3056 UniqueId id4(reinterpret_cast<intptr_t>(*g4s1)); |
3053 iso->SetObjectGroupId(g1s1, id1); | 3057 iso->SetObjectGroupId(g1s1, id1); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3105 // on the buildbots, so was made non-threaded for the time being. | 3109 // on the buildbots, so was made non-threaded for the time being. |
3106 TEST(ApiObjectGroupsCycleForScavenger) { | 3110 TEST(ApiObjectGroupsCycleForScavenger) { |
3107 i::FLAG_stress_compaction = false; | 3111 i::FLAG_stress_compaction = false; |
3108 i::FLAG_gc_global = false; | 3112 i::FLAG_gc_global = false; |
3109 LocalContext env; | 3113 LocalContext env; |
3110 v8::Isolate* iso = env->GetIsolate(); | 3114 v8::Isolate* iso = env->GetIsolate(); |
3111 HandleScope scope(iso); | 3115 HandleScope scope(iso); |
3112 | 3116 |
3113 WeakCallCounter counter(1234); | 3117 WeakCallCounter counter(1234); |
3114 | 3118 |
3115 Persistent<Object> g1s1; | 3119 Persistent<Value> g1s1; |
3116 Persistent<Object> g1s2; | 3120 Persistent<Value> g1s2; |
3117 Persistent<Object> g2s1; | 3121 Persistent<Value> g2s1; |
3118 Persistent<Object> g2s2; | 3122 Persistent<Value> g2s2; |
3119 Persistent<Object> g3s1; | 3123 Persistent<Value> g3s1; |
3120 Persistent<Object> g3s2; | 3124 Persistent<Value> g3s2; |
3121 | 3125 |
3122 { | 3126 { |
3123 HandleScope scope(iso); | 3127 HandleScope scope(iso); |
3124 g1s1 = Persistent<Object>::New(iso, Object::New()); | 3128 g1s1.Reset(iso, Object::New()); |
3125 g1s2 = Persistent<Object>::New(iso, Object::New()); | 3129 g1s2.Reset(iso, Object::New()); |
3126 g1s1.MakeWeak(iso, &counter, &WeakPointerCallback); | 3130 g1s1.MakeWeak(iso, &counter, &WeakPointerCallback); |
3127 g1s2.MakeWeak(iso, &counter, &WeakPointerCallback); | 3131 g1s2.MakeWeak(iso, &counter, &WeakPointerCallback); |
3128 | 3132 |
3129 g2s1 = Persistent<Object>::New(iso, Object::New()); | 3133 g2s1.Reset(iso, Object::New()); |
3130 g2s2 = Persistent<Object>::New(iso, Object::New()); | 3134 g2s2.Reset(iso, Object::New()); |
3131 g2s1.MakeWeak(iso, &counter, &WeakPointerCallback); | 3135 g2s1.MakeWeak(iso, &counter, &WeakPointerCallback); |
3132 g2s2.MakeWeak(iso, &counter, &WeakPointerCallback); | 3136 g2s2.MakeWeak(iso, &counter, &WeakPointerCallback); |
3133 | 3137 |
3134 g3s1 = Persistent<Object>::New(iso, Object::New()); | 3138 g3s1.Reset(iso, Object::New()); |
3135 g3s2 = Persistent<Object>::New(iso, Object::New()); | 3139 g3s2.Reset(iso, Object::New()); |
3136 g3s1.MakeWeak(iso, &counter, &WeakPointerCallback); | 3140 g3s1.MakeWeak(iso, &counter, &WeakPointerCallback); |
3137 g3s2.MakeWeak(iso, &counter, &WeakPointerCallback); | 3141 g3s2.MakeWeak(iso, &counter, &WeakPointerCallback); |
3138 } | 3142 } |
3139 | 3143 |
3140 // Make a root. | 3144 // Make a root. |
3141 Persistent<Object> root = Persistent<Object>::New(iso, g1s1); | 3145 Persistent<Value> root(iso, g1s1); |
3142 root.MarkPartiallyDependent(iso); | 3146 root.MarkPartiallyDependent(iso); |
3143 | 3147 |
3144 // Connect groups. We're building the following cycle: | 3148 // Connect groups. We're building the following cycle: |
3145 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other | 3149 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other |
3146 // groups. | 3150 // groups. |
3147 { | 3151 { |
| 3152 HandleScope handle_scope(iso); |
3148 g1s1.MarkPartiallyDependent(iso); | 3153 g1s1.MarkPartiallyDependent(iso); |
3149 g1s2.MarkPartiallyDependent(iso); | 3154 g1s2.MarkPartiallyDependent(iso); |
3150 g2s1.MarkPartiallyDependent(iso); | 3155 g2s1.MarkPartiallyDependent(iso); |
3151 g2s2.MarkPartiallyDependent(iso); | 3156 g2s2.MarkPartiallyDependent(iso); |
3152 g3s1.MarkPartiallyDependent(iso); | 3157 g3s1.MarkPartiallyDependent(iso); |
3153 g3s2.MarkPartiallyDependent(iso); | 3158 g3s2.MarkPartiallyDependent(iso); |
3154 iso->SetObjectGroupId(g1s1, UniqueId(1)); | 3159 iso->SetObjectGroupId(g1s1, UniqueId(1)); |
3155 iso->SetObjectGroupId(g1s2, UniqueId(1)); | 3160 iso->SetObjectGroupId(g1s2, UniqueId(1)); |
3156 g1s1->Set(v8_str("x"), Local<Value>(*g2s1)); | 3161 Local<Object>::New(iso, g1s1.As<Object>())->Set(v8_str("x"), |
| 3162 Local<Value>(*g2s1)); |
3157 iso->SetObjectGroupId(g2s1, UniqueId(2)); | 3163 iso->SetObjectGroupId(g2s1, UniqueId(2)); |
3158 iso->SetObjectGroupId(g2s2, UniqueId(2)); | 3164 iso->SetObjectGroupId(g2s2, UniqueId(2)); |
3159 g2s1->Set(v8_str("x"), Local<Value>(*g3s1)); | 3165 Local<Object>::New(iso, g2s1.As<Object>())->Set(v8_str("x"), |
| 3166 Local<Value>(*g3s1)); |
3160 iso->SetObjectGroupId(g3s1, UniqueId(3)); | 3167 iso->SetObjectGroupId(g3s1, UniqueId(3)); |
3161 iso->SetObjectGroupId(g3s2, UniqueId(3)); | 3168 iso->SetObjectGroupId(g3s2, UniqueId(3)); |
3162 g3s1->Set(v8_str("x"), Local<Value>(*g1s1)); | 3169 Local<Object>::New(iso, g3s1.As<Object>())->Set(v8_str("x"), |
| 3170 Local<Value>(*g1s1)); |
3163 } | 3171 } |
3164 | 3172 |
3165 v8::internal::Heap* heap = reinterpret_cast<v8::internal::Isolate*>( | 3173 v8::internal::Heap* heap = reinterpret_cast<v8::internal::Isolate*>( |
3166 iso)->heap(); | 3174 iso)->heap(); |
3167 heap->CollectGarbage(i::NEW_SPACE); | 3175 heap->CollectGarbage(i::NEW_SPACE); |
3168 | 3176 |
3169 // All objects should be alive. | 3177 // All objects should be alive. |
3170 CHECK_EQ(0, counter.NumberOfWeakCalls()); | 3178 CHECK_EQ(0, counter.NumberOfWeakCalls()); |
3171 | 3179 |
3172 // Weaken the root. | 3180 // Weaken the root. |
3173 root.MakeWeak(iso, &counter, &WeakPointerCallback); | 3181 root.MakeWeak(iso, &counter, &WeakPointerCallback); |
3174 root.MarkPartiallyDependent(iso); | 3182 root.MarkPartiallyDependent(iso); |
3175 | 3183 |
3176 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 3184 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
3177 // Groups are deleted, rebuild groups. | 3185 // Groups are deleted, rebuild groups. |
3178 { | 3186 { |
| 3187 HandleScope handle_scope(iso); |
3179 g1s1.MarkPartiallyDependent(isolate); | 3188 g1s1.MarkPartiallyDependent(isolate); |
3180 g1s2.MarkPartiallyDependent(isolate); | 3189 g1s2.MarkPartiallyDependent(isolate); |
3181 g2s1.MarkPartiallyDependent(isolate); | 3190 g2s1.MarkPartiallyDependent(isolate); |
3182 g2s2.MarkPartiallyDependent(isolate); | 3191 g2s2.MarkPartiallyDependent(isolate); |
3183 g3s1.MarkPartiallyDependent(isolate); | 3192 g3s1.MarkPartiallyDependent(isolate); |
3184 g3s2.MarkPartiallyDependent(isolate); | 3193 g3s2.MarkPartiallyDependent(isolate); |
3185 iso->SetObjectGroupId(g1s1, UniqueId(1)); | 3194 iso->SetObjectGroupId(g1s1, UniqueId(1)); |
3186 iso->SetObjectGroupId(g1s2, UniqueId(1)); | 3195 iso->SetObjectGroupId(g1s2, UniqueId(1)); |
3187 g1s1->Set(v8_str("x"), Local<Value>(*g2s1)); | 3196 Local<Object>::New(iso, g1s1.As<Object>())->Set(v8_str("x"), |
| 3197 Local<Value>(*g2s1)); |
3188 iso->SetObjectGroupId(g2s1, UniqueId(2)); | 3198 iso->SetObjectGroupId(g2s1, UniqueId(2)); |
3189 iso->SetObjectGroupId(g2s2, UniqueId(2)); | 3199 iso->SetObjectGroupId(g2s2, UniqueId(2)); |
3190 g2s1->Set(v8_str("x"), Local<Value>(*g3s1)); | 3200 Local<Object>::New(iso, g2s1.As<Object>())->Set(v8_str("x"), |
| 3201 Local<Value>(*g3s1)); |
3191 iso->SetObjectGroupId(g3s1, UniqueId(3)); | 3202 iso->SetObjectGroupId(g3s1, UniqueId(3)); |
3192 iso->SetObjectGroupId(g3s2, UniqueId(3)); | 3203 iso->SetObjectGroupId(g3s2, UniqueId(3)); |
3193 g3s1->Set(v8_str("x"), Local<Value>(*g1s1)); | 3204 Local<Object>::New(iso, g3s1.As<Object>())->Set(v8_str("x"), |
| 3205 Local<Value>(*g1s1)); |
3194 } | 3206 } |
3195 | 3207 |
3196 heap->CollectGarbage(i::NEW_SPACE); | 3208 heap->CollectGarbage(i::NEW_SPACE); |
3197 | 3209 |
3198 // All objects should be gone. 7 global handles in total. | 3210 // All objects should be gone. 7 global handles in total. |
3199 CHECK_EQ(7, counter.NumberOfWeakCalls()); | 3211 CHECK_EQ(7, counter.NumberOfWeakCalls()); |
3200 } | 3212 } |
3201 | 3213 |
3202 | 3214 |
3203 THREADED_TEST(ScriptException) { | 3215 THREADED_TEST(ScriptException) { |
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4322 CHECK(!v8_str("5")->StrictEquals(v8_num(5))); | 4334 CHECK(!v8_str("5")->StrictEquals(v8_num(5))); |
4323 CHECK(v8_num(1)->StrictEquals(v8_num(1))); | 4335 CHECK(v8_num(1)->StrictEquals(v8_num(1))); |
4324 CHECK(!v8_num(1)->StrictEquals(v8_num(2))); | 4336 CHECK(!v8_num(1)->StrictEquals(v8_num(2))); |
4325 CHECK(v8_num(0)->StrictEquals(v8_num(-0))); | 4337 CHECK(v8_num(0)->StrictEquals(v8_num(-0))); |
4326 Local<Value> not_a_number = v8_num(i::OS::nan_value()); | 4338 Local<Value> not_a_number = v8_num(i::OS::nan_value()); |
4327 CHECK(!not_a_number->StrictEquals(not_a_number)); | 4339 CHECK(!not_a_number->StrictEquals(not_a_number)); |
4328 CHECK(v8::False()->StrictEquals(v8::False())); | 4340 CHECK(v8::False()->StrictEquals(v8::False())); |
4329 CHECK(!v8::False()->StrictEquals(v8::Undefined())); | 4341 CHECK(!v8::False()->StrictEquals(v8::Undefined())); |
4330 | 4342 |
4331 v8::Handle<v8::Object> obj = v8::Object::New(); | 4343 v8::Handle<v8::Object> obj = v8::Object::New(); |
4332 v8::Persistent<v8::Object> alias = | 4344 v8::Persistent<v8::Object> alias(isolate, obj); |
4333 v8::Persistent<v8::Object>::New(isolate, obj); | |
4334 CHECK(alias->StrictEquals(obj)); | 4345 CHECK(alias->StrictEquals(obj)); |
4335 alias.Dispose(isolate); | 4346 alias.Dispose(isolate); |
4336 } | 4347 } |
4337 | 4348 |
4338 | 4349 |
4339 THREADED_TEST(MultiRun) { | 4350 THREADED_TEST(MultiRun) { |
4340 LocalContext context; | 4351 LocalContext context; |
4341 v8::HandleScope scope(context->GetIsolate()); | 4352 v8::HandleScope scope(context->GetIsolate()); |
4342 Local<Script> script = Script::Compile(v8_str("x")); | 4353 Local<Script> script = Script::Compile(v8_str("x")); |
4343 for (int i = 0; i < 10; i++) | 4354 for (int i = 0; i < 10; i++) |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4623 v8::Persistent<Value> xValue; | 4634 v8::Persistent<Value> xValue; |
4624 | 4635 |
4625 | 4636 |
4626 static void SetXValue(Local<String> name, | 4637 static void SetXValue(Local<String> name, |
4627 Local<Value> value, | 4638 Local<Value> value, |
4628 const AccessorInfo& info) { | 4639 const AccessorInfo& info) { |
4629 CHECK_EQ(value, v8_num(4)); | 4640 CHECK_EQ(value, v8_num(4)); |
4630 CHECK_EQ(info.Data(), v8_str("donut")); | 4641 CHECK_EQ(info.Data(), v8_str("donut")); |
4631 CHECK_EQ(name, v8_str("x")); | 4642 CHECK_EQ(name, v8_str("x")); |
4632 CHECK(xValue.IsEmpty()); | 4643 CHECK(xValue.IsEmpty()); |
4633 xValue = v8::Persistent<Value>::New(info.GetIsolate(), value); | 4644 xValue.Reset(info.GetIsolate(), value); |
4634 } | 4645 } |
4635 | 4646 |
4636 | 4647 |
4637 THREADED_TEST(SimplePropertyWrite) { | 4648 THREADED_TEST(SimplePropertyWrite) { |
4638 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4649 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
4639 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4650 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4640 templ->SetAccessor(v8_str("x"), GetXValue, SetXValue, v8_str("donut")); | 4651 templ->SetAccessor(v8_str("x"), GetXValue, SetXValue, v8_str("donut")); |
4641 LocalContext context; | 4652 LocalContext context; |
4642 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 4653 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
4643 Local<Script> script = Script::Compile(v8_str("obj.x = 4")); | 4654 Local<Script> script = Script::Compile(v8_str("obj.x = 4")); |
4644 for (int i = 0; i < 10; i++) { | 4655 for (int i = 0; i < 10; i++) { |
4645 CHECK(xValue.IsEmpty()); | 4656 CHECK(xValue.IsEmpty()); |
4646 script->Run(); | 4657 script->Run(); |
4647 CHECK_EQ(v8_num(4), Handle<Value>(*xValue)); | 4658 CHECK_EQ(v8_num(4), Handle<Value>(*xValue)); |
4648 xValue.Dispose(context->GetIsolate()); | 4659 xValue.Dispose(context->GetIsolate()); |
4649 xValue = v8::Persistent<Value>(); | 4660 xValue.Clear(); |
4650 } | 4661 } |
4651 } | 4662 } |
4652 | 4663 |
4653 | 4664 |
4654 THREADED_TEST(SetterOnly) { | 4665 THREADED_TEST(SetterOnly) { |
4655 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4666 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
4656 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4667 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4657 templ->SetAccessor(v8_str("x"), NULL, SetXValue, v8_str("donut")); | 4668 templ->SetAccessor(v8_str("x"), NULL, SetXValue, v8_str("donut")); |
4658 LocalContext context; | 4669 LocalContext context; |
4659 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 4670 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
4660 Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); | 4671 Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); |
4661 for (int i = 0; i < 10; i++) { | 4672 for (int i = 0; i < 10; i++) { |
4662 CHECK(xValue.IsEmpty()); | 4673 CHECK(xValue.IsEmpty()); |
4663 script->Run(); | 4674 script->Run(); |
4664 CHECK_EQ(v8_num(4), Handle<Value>(*xValue)); | 4675 CHECK_EQ(v8_num(4), Handle<Value>(*xValue)); |
4665 xValue.Dispose(context->GetIsolate()); | 4676 xValue.Dispose(context->GetIsolate()); |
4666 xValue = v8::Persistent<Value>(); | 4677 xValue.Clear(); |
4667 } | 4678 } |
4668 } | 4679 } |
4669 | 4680 |
4670 | 4681 |
4671 THREADED_TEST(NoAccessors) { | 4682 THREADED_TEST(NoAccessors) { |
4672 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4683 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
4673 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4684 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4674 templ->SetAccessor(v8_str("x"), | 4685 templ->SetAccessor(v8_str("x"), |
4675 static_cast<v8::AccessorGetter>(NULL), | 4686 static_cast<v8::AccessorGetter>(NULL), |
4676 NULL, | 4687 NULL, |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5519 } | 5530 } |
5520 | 5531 |
5521 | 5532 |
5522 template <typename T> static void USE(T) { } | 5533 template <typename T> static void USE(T) { } |
5523 | 5534 |
5524 | 5535 |
5525 // This test is not intended to be run, just type checked. | 5536 // This test is not intended to be run, just type checked. |
5526 static inline void PersistentHandles(v8::Isolate* isolate) { | 5537 static inline void PersistentHandles(v8::Isolate* isolate) { |
5527 USE(PersistentHandles); | 5538 USE(PersistentHandles); |
5528 Local<String> str = v8_str("foo"); | 5539 Local<String> str = v8_str("foo"); |
5529 v8::Persistent<String> p_str = v8::Persistent<String>::New(isolate, str); | 5540 v8::Persistent<String> p_str(isolate, str); |
5530 USE(p_str); | 5541 p_str.Dispose(); |
5531 Local<Script> scr = Script::Compile(v8_str("")); | 5542 Local<Script> scr = Script::Compile(v8_str("")); |
5532 v8::Persistent<Script> p_scr = v8::Persistent<Script>::New(isolate, scr); | 5543 v8::Persistent<Script> p_scr(isolate, scr); |
5533 USE(p_scr); | 5544 p_scr.Dispose(); |
5534 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5545 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
5535 v8::Persistent<ObjectTemplate> p_templ = | 5546 v8::Persistent<ObjectTemplate> p_templ(isolate, templ); |
5536 v8::Persistent<ObjectTemplate>::New(isolate, templ); | 5547 p_templ.Dispose(); |
5537 USE(p_templ); | |
5538 } | 5548 } |
5539 | 5549 |
5540 | 5550 |
5541 static v8::Handle<Value> HandleLogDelegator(const v8::Arguments& args) { | 5551 static v8::Handle<Value> HandleLogDelegator(const v8::Arguments& args) { |
5542 ApiTestFuzzer::Fuzz(); | 5552 ApiTestFuzzer::Fuzz(); |
5543 return v8::Undefined(); | 5553 return v8::Undefined(); |
5544 } | 5554 } |
5545 | 5555 |
5546 | 5556 |
5547 THREADED_TEST(GlobalObjectTemplate) { | 5557 THREADED_TEST(GlobalObjectTemplate) { |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6031 public: | 6041 public: |
6032 Snorkel() { index_ = global_index++; } | 6042 Snorkel() { index_ = global_index++; } |
6033 int index_; | 6043 int index_; |
6034 }; | 6044 }; |
6035 | 6045 |
6036 class Whammy { | 6046 class Whammy { |
6037 public: | 6047 public: |
6038 explicit Whammy(v8::Isolate* isolate) : cursor_(0), isolate_(isolate) { } | 6048 explicit Whammy(v8::Isolate* isolate) : cursor_(0), isolate_(isolate) { } |
6039 ~Whammy() { script_.Dispose(isolate_); } | 6049 ~Whammy() { script_.Dispose(isolate_); } |
6040 v8::Handle<Script> getScript() { | 6050 v8::Handle<Script> getScript() { |
6041 if (script_.IsEmpty()) { | 6051 if (script_.IsEmpty()) script_.Reset(isolate_, v8_compile("({}).blammo")); |
6042 script_ = v8::Persistent<Script>::New(isolate_, | |
6043 v8_compile("({}).blammo")); | |
6044 } | |
6045 return Local<Script>(*script_); | 6052 return Local<Script>(*script_); |
6046 } | 6053 } |
6047 | 6054 |
6048 public: | 6055 public: |
6049 static const int kObjectCount = 256; | 6056 static const int kObjectCount = 256; |
6050 int cursor_; | 6057 int cursor_; |
6051 v8::Isolate* isolate_; | 6058 v8::Isolate* isolate_; |
6052 v8::Persistent<v8::Object> objects_[kObjectCount]; | 6059 v8::Persistent<v8::Object> objects_[kObjectCount]; |
6053 v8::Persistent<Script> script_; | 6060 v8::Persistent<Script> script_; |
6054 }; | 6061 }; |
6055 | 6062 |
6056 static void HandleWeakReference(v8::Isolate* isolate, | 6063 static void HandleWeakReference(v8::Isolate* isolate, |
6057 v8::Persistent<v8::Value>* obj, | 6064 v8::Persistent<v8::Value>* obj, |
6058 Snorkel* snorkel) { | 6065 Snorkel* snorkel) { |
6059 delete snorkel; | 6066 delete snorkel; |
6060 obj->ClearWeak(isolate); | 6067 obj->ClearWeak(isolate); |
6061 } | 6068 } |
6062 | 6069 |
6063 v8::Handle<Value> WhammyPropertyGetter(Local<String> name, | 6070 v8::Handle<Value> WhammyPropertyGetter(Local<String> name, |
6064 const AccessorInfo& info) { | 6071 const AccessorInfo& info) { |
6065 Whammy* whammy = | 6072 Whammy* whammy = |
6066 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value()); | 6073 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value()); |
6067 | 6074 |
6068 v8::Persistent<v8::Object> prev = whammy->objects_[whammy->cursor_]; | 6075 v8::Persistent<v8::Object>& prev = whammy->objects_[whammy->cursor_]; |
6069 | 6076 |
6070 v8::Handle<v8::Object> obj = v8::Object::New(); | 6077 v8::Handle<v8::Object> obj = v8::Object::New(); |
6071 v8::Persistent<v8::Object> global = | |
6072 v8::Persistent<v8::Object>::New(info.GetIsolate(), obj); | |
6073 if (!prev.IsEmpty()) { | 6078 if (!prev.IsEmpty()) { |
6074 prev->Set(v8_str("next"), obj); | 6079 prev->Set(v8_str("next"), obj); |
6075 prev.MakeWeak<Value, Snorkel>(info.GetIsolate(), | 6080 prev.MakeWeak<Value, Snorkel>(info.GetIsolate(), |
6076 new Snorkel(), | 6081 new Snorkel(), |
6077 &HandleWeakReference); | 6082 &HandleWeakReference); |
6078 whammy->objects_[whammy->cursor_].Clear(); | 6083 whammy->objects_[whammy->cursor_].Clear(); |
6079 } | 6084 } |
6080 whammy->objects_[whammy->cursor_] = global; | 6085 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj); |
6081 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; | 6086 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; |
6082 return whammy->getScript()->Run(); | 6087 return whammy->getScript()->Run(); |
6083 } | 6088 } |
6084 | 6089 |
6085 THREADED_TEST(WeakReference) { | 6090 THREADED_TEST(WeakReference) { |
6086 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6091 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
6087 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New(); | 6092 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New(); |
6088 Whammy* whammy = new Whammy(v8::Isolate::GetCurrent()); | 6093 Whammy* whammy = new Whammy(v8::Isolate::GetCurrent()); |
6089 templ->SetNamedPropertyHandler(WhammyPropertyGetter, | 6094 templ->SetNamedPropertyHandler(WhammyPropertyGetter, |
6090 0, 0, 0, 0, | 6095 0, 0, 0, 0, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6123 THREADED_TEST(IndependentWeakHandle) { | 6128 THREADED_TEST(IndependentWeakHandle) { |
6124 v8::Isolate* iso = v8::Isolate::GetCurrent(); | 6129 v8::Isolate* iso = v8::Isolate::GetCurrent(); |
6125 v8::HandleScope scope(iso); | 6130 v8::HandleScope scope(iso); |
6126 v8::Handle<Context> context = Context::New(iso); | 6131 v8::Handle<Context> context = Context::New(iso); |
6127 Context::Scope context_scope(context); | 6132 Context::Scope context_scope(context); |
6128 | 6133 |
6129 v8::Persistent<v8::Object> object_a, object_b; | 6134 v8::Persistent<v8::Object> object_a, object_b; |
6130 | 6135 |
6131 { | 6136 { |
6132 v8::HandleScope handle_scope(iso); | 6137 v8::HandleScope handle_scope(iso); |
6133 object_a = v8::Persistent<v8::Object>::New(iso, v8::Object::New()); | 6138 object_a.Reset(iso, v8::Object::New()); |
6134 object_b = v8::Persistent<v8::Object>::New(iso, v8::Object::New()); | 6139 object_b.Reset(iso, v8::Object::New()); |
6135 } | 6140 } |
6136 | 6141 |
6137 bool object_a_disposed = false; | 6142 bool object_a_disposed = false; |
6138 bool object_b_disposed = false; | 6143 bool object_b_disposed = false; |
6139 object_a.MakeWeak(iso, &object_a_disposed, &DisposeAndSetFlag); | 6144 object_a.MakeWeak(iso, &object_a_disposed, &DisposeAndSetFlag); |
6140 object_b.MakeWeak(iso, &object_b_disposed, &DisposeAndSetFlag); | 6145 object_b.MakeWeak(iso, &object_b_disposed, &DisposeAndSetFlag); |
6141 CHECK(!object_b.IsIndependent(iso)); | 6146 CHECK(!object_b.IsIndependent(iso)); |
6142 object_a.MarkIndependent(iso); | 6147 object_a.MarkIndependent(iso); |
6143 object_b.MarkIndependent(iso); | 6148 object_b.MarkIndependent(iso); |
6144 CHECK(object_b.IsIndependent(iso)); | 6149 CHECK(object_b.IsIndependent(iso)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6188 {&ForceScavenge, &ForceMarkSweep}; | 6193 {&ForceScavenge, &ForceMarkSweep}; |
6189 | 6194 |
6190 typedef void (*GCInvoker)(); | 6195 typedef void (*GCInvoker)(); |
6191 GCInvoker invoke_gc[kNumberOfGCTypes] = {&InvokeScavenge, &InvokeMarkSweep}; | 6196 GCInvoker invoke_gc[kNumberOfGCTypes] = {&InvokeScavenge, &InvokeMarkSweep}; |
6192 | 6197 |
6193 for (int outer_gc = 0; outer_gc < kNumberOfGCTypes; outer_gc++) { | 6198 for (int outer_gc = 0; outer_gc < kNumberOfGCTypes; outer_gc++) { |
6194 for (int inner_gc = 0; inner_gc < kNumberOfGCTypes; inner_gc++) { | 6199 for (int inner_gc = 0; inner_gc < kNumberOfGCTypes; inner_gc++) { |
6195 v8::Persistent<v8::Object> object; | 6200 v8::Persistent<v8::Object> object; |
6196 { | 6201 { |
6197 v8::HandleScope handle_scope(isolate); | 6202 v8::HandleScope handle_scope(isolate); |
6198 object = v8::Persistent<v8::Object>::New(isolate, v8::Object::New()); | 6203 object.Reset(isolate, v8::Object::New()); |
6199 } | 6204 } |
6200 bool disposed = false; | 6205 bool disposed = false; |
6201 object.MakeWeak(isolate, &disposed, gc_forcing_callback[inner_gc]); | 6206 object.MakeWeak(isolate, &disposed, gc_forcing_callback[inner_gc]); |
6202 object.MarkIndependent(isolate); | 6207 object.MarkIndependent(isolate); |
6203 invoke_gc[outer_gc](); | 6208 invoke_gc[outer_gc](); |
6204 CHECK(disposed); | 6209 CHECK(disposed); |
6205 } | 6210 } |
6206 } | 6211 } |
6207 } | 6212 } |
6208 | 6213 |
6209 | 6214 |
6210 static void RevivingCallback(v8::Isolate* isolate, | 6215 static void RevivingCallback(v8::Isolate* isolate, |
6211 v8::Persistent<v8::Object>* obj, | 6216 v8::Persistent<v8::Object>* obj, |
6212 bool* data) { | 6217 bool* data) { |
6213 obj->ClearWeak(isolate); | 6218 obj->ClearWeak(isolate); |
6214 *(data) = true; | 6219 *(data) = true; |
6215 } | 6220 } |
6216 | 6221 |
6217 | 6222 |
6218 THREADED_TEST(IndependentHandleRevival) { | 6223 THREADED_TEST(IndependentHandleRevival) { |
6219 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 6224 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
6220 v8::HandleScope scope(isolate); | 6225 v8::HandleScope scope(isolate); |
6221 v8::Handle<Context> context = Context::New(isolate); | 6226 v8::Handle<Context> context = Context::New(isolate); |
6222 Context::Scope context_scope(context); | 6227 Context::Scope context_scope(context); |
6223 | 6228 |
6224 v8::Persistent<v8::Object> object; | 6229 v8::Persistent<v8::Object> object; |
6225 { | 6230 { |
6226 v8::HandleScope handle_scope(isolate); | 6231 v8::HandleScope handle_scope(isolate); |
6227 object = v8::Persistent<v8::Object>::New(isolate, v8::Object::New()); | 6232 object.Reset(isolate, v8::Object::New()); |
6228 object->Set(v8_str("x"), v8::Integer::New(1)); | 6233 object->Set(v8_str("x"), v8::Integer::New(1)); |
6229 v8::Local<String> y_str = v8_str("y"); | 6234 v8::Local<String> y_str = v8_str("y"); |
6230 object->Set(y_str, y_str); | 6235 object->Set(y_str, y_str); |
6231 } | 6236 } |
6232 bool revived = false; | 6237 bool revived = false; |
6233 object.MakeWeak(isolate, &revived, &RevivingCallback); | 6238 object.MakeWeak(isolate, &revived, &RevivingCallback); |
6234 object.MarkIndependent(isolate); | 6239 object.MarkIndependent(isolate); |
6235 HEAP->PerformScavenge(); | 6240 HEAP->PerformScavenge(); |
6236 CHECK(revived); | 6241 CHECK(revived); |
6237 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 6242 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
(...skipping 5690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11928 } | 11933 } |
11929 | 11934 |
11930 | 11935 |
11931 v8::Persistent<v8::Object> some_object; | 11936 v8::Persistent<v8::Object> some_object; |
11932 v8::Persistent<v8::Object> bad_handle; | 11937 v8::Persistent<v8::Object> bad_handle; |
11933 | 11938 |
11934 void NewPersistentHandleCallback(v8::Isolate* isolate, | 11939 void NewPersistentHandleCallback(v8::Isolate* isolate, |
11935 v8::Persistent<v8::Value>* handle, | 11940 v8::Persistent<v8::Value>* handle, |
11936 void*) { | 11941 void*) { |
11937 v8::HandleScope scope(isolate); | 11942 v8::HandleScope scope(isolate); |
11938 bad_handle = v8::Persistent<v8::Object>::New(isolate, some_object); | 11943 bad_handle.Reset(isolate, some_object); |
11939 handle->Dispose(isolate); | 11944 handle->Dispose(isolate); |
11940 } | 11945 } |
11941 | 11946 |
11942 | 11947 |
11943 THREADED_TEST(NewPersistentHandleFromWeakCallback) { | 11948 THREADED_TEST(NewPersistentHandleFromWeakCallback) { |
11944 LocalContext context; | 11949 LocalContext context; |
11945 v8::Isolate* isolate = context->GetIsolate(); | 11950 v8::Isolate* isolate = context->GetIsolate(); |
11946 | 11951 |
11947 v8::Persistent<v8::Object> handle1, handle2; | 11952 v8::Persistent<v8::Object> handle1, handle2; |
11948 { | 11953 { |
11949 v8::HandleScope scope(isolate); | 11954 v8::HandleScope scope(isolate); |
11950 some_object = v8::Persistent<v8::Object>::New(isolate, v8::Object::New()); | 11955 some_object.Reset(isolate, v8::Object::New()); |
11951 handle1 = v8::Persistent<v8::Object>::New(isolate, v8::Object::New()); | 11956 handle1.Reset(isolate, v8::Object::New()); |
11952 handle2 = v8::Persistent<v8::Object>::New(isolate, v8::Object::New()); | 11957 handle2.Reset(isolate, v8::Object::New()); |
11953 } | 11958 } |
11954 // Note: order is implementation dependent alas: currently | 11959 // Note: order is implementation dependent alas: currently |
11955 // global handle nodes are processed by PostGarbageCollectionProcessing | 11960 // global handle nodes are processed by PostGarbageCollectionProcessing |
11956 // in reverse allocation order, so if second allocated handle is deleted, | 11961 // in reverse allocation order, so if second allocated handle is deleted, |
11957 // weak callback of the first handle would be able to 'reallocate' it. | 11962 // weak callback of the first handle would be able to 'reallocate' it. |
11958 handle1.MakeWeak<v8::Value, void>(isolate, | 11963 handle1.MakeWeak<v8::Value, void>(isolate, |
11959 NULL, | 11964 NULL, |
11960 NewPersistentHandleCallback); | 11965 NewPersistentHandleCallback); |
11961 handle2.Dispose(isolate); | 11966 handle2.Dispose(isolate); |
11962 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 11967 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
(...skipping 11 matching lines...) Expand all Loading... |
11974 } | 11979 } |
11975 | 11980 |
11976 | 11981 |
11977 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { | 11982 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { |
11978 LocalContext context; | 11983 LocalContext context; |
11979 v8::Isolate* isolate = context->GetIsolate(); | 11984 v8::Isolate* isolate = context->GetIsolate(); |
11980 | 11985 |
11981 v8::Persistent<v8::Object> handle1, handle2; | 11986 v8::Persistent<v8::Object> handle1, handle2; |
11982 { | 11987 { |
11983 v8::HandleScope scope(isolate); | 11988 v8::HandleScope scope(isolate); |
11984 handle1 = v8::Persistent<v8::Object>::New(isolate, v8::Object::New()); | 11989 handle1.Reset(isolate, v8::Object::New()); |
11985 handle2 = v8::Persistent<v8::Object>::New(isolate, v8::Object::New()); | 11990 handle2.Reset(isolate, v8::Object::New()); |
11986 } | 11991 } |
11987 handle1.MakeWeak<v8::Value, void>(isolate, NULL, DisposeAndForceGcCallback); | 11992 handle1.MakeWeak<v8::Value, void>(isolate, NULL, DisposeAndForceGcCallback); |
11988 to_be_disposed = handle2; | 11993 to_be_disposed.Reset(isolate, handle2); |
11989 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 11994 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
11990 } | 11995 } |
11991 | 11996 |
11992 void DisposingCallback(v8::Isolate* isolate, | 11997 void DisposingCallback(v8::Isolate* isolate, |
11993 v8::Persistent<v8::Value>* handle, | 11998 v8::Persistent<v8::Value>* handle, |
11994 void*) { | 11999 void*) { |
11995 handle->Dispose(isolate); | 12000 handle->Dispose(isolate); |
11996 } | 12001 } |
11997 | 12002 |
11998 void HandleCreatingCallback(v8::Isolate* isolate, | 12003 void HandleCreatingCallback(v8::Isolate* isolate, |
11999 v8::Persistent<v8::Value>* handle, | 12004 v8::Persistent<v8::Value>* handle, |
12000 void*) { | 12005 void*) { |
12001 v8::HandleScope scope(isolate); | 12006 v8::HandleScope scope(isolate); |
12002 v8::Persistent<v8::Object>::New(isolate, v8::Object::New()); | 12007 v8::Persistent<v8::Object>::New(isolate, v8::Object::New()); |
12003 handle->Dispose(isolate); | 12008 handle->Dispose(isolate); |
12004 } | 12009 } |
12005 | 12010 |
12006 | 12011 |
12007 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { | 12012 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { |
12008 LocalContext context; | 12013 LocalContext context; |
12009 v8::Isolate* isolate = context->GetIsolate(); | 12014 v8::Isolate* isolate = context->GetIsolate(); |
12010 | 12015 |
12011 v8::Persistent<v8::Object> handle1, handle2, handle3; | 12016 v8::Persistent<v8::Object> handle1, handle2, handle3; |
12012 { | 12017 { |
12013 v8::HandleScope scope(isolate); | 12018 v8::HandleScope scope(isolate); |
12014 handle3 = v8::Persistent<v8::Object>::New(isolate, v8::Object::New()); | 12019 handle3.Reset(isolate, v8::Object::New()); |
12015 handle2 = v8::Persistent<v8::Object>::New(isolate, v8::Object::New()); | 12020 handle2.Reset(isolate, v8::Object::New()); |
12016 handle1 = v8::Persistent<v8::Object>::New(isolate, v8::Object::New()); | 12021 handle1.Reset(isolate, v8::Object::New()); |
12017 } | 12022 } |
12018 handle2.MakeWeak<v8::Value, void>(isolate, NULL, DisposingCallback); | 12023 handle2.MakeWeak<v8::Value, void>(isolate, NULL, DisposingCallback); |
12019 handle3.MakeWeak<v8::Value, void>(isolate, NULL, HandleCreatingCallback); | 12024 handle3.MakeWeak<v8::Value, void>(isolate, NULL, HandleCreatingCallback); |
12020 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 12025 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
12021 } | 12026 } |
12022 | 12027 |
12023 | 12028 |
12024 THREADED_TEST(CheckForCrossContextObjectLiterals) { | 12029 THREADED_TEST(CheckForCrossContextObjectLiterals) { |
12025 v8::V8::Initialize(); | 12030 v8::V8::Initialize(); |
12026 | 12031 |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12465 // count set on instances. | 12470 // count set on instances. |
12466 THREADED_TEST(Regress54) { | 12471 THREADED_TEST(Regress54) { |
12467 LocalContext context; | 12472 LocalContext context; |
12468 v8::Isolate* isolate = context->GetIsolate(); | 12473 v8::Isolate* isolate = context->GetIsolate(); |
12469 v8::HandleScope outer(isolate); | 12474 v8::HandleScope outer(isolate); |
12470 static v8::Persistent<v8::ObjectTemplate> templ; | 12475 static v8::Persistent<v8::ObjectTemplate> templ; |
12471 if (templ.IsEmpty()) { | 12476 if (templ.IsEmpty()) { |
12472 v8::HandleScope inner(isolate); | 12477 v8::HandleScope inner(isolate); |
12473 v8::Handle<v8::ObjectTemplate> local = v8::ObjectTemplate::New(); | 12478 v8::Handle<v8::ObjectTemplate> local = v8::ObjectTemplate::New(); |
12474 local->SetInternalFieldCount(1); | 12479 local->SetInternalFieldCount(1); |
12475 templ = | 12480 templ.Reset(isolate, inner.Close(local)); |
12476 v8::Persistent<v8::ObjectTemplate>::New(isolate, inner.Close(local)); | |
12477 } | 12481 } |
12478 v8::Handle<v8::Object> result = templ->NewInstance(); | 12482 v8::Handle<v8::Object> result = templ->NewInstance(); |
12479 CHECK_EQ(1, result->InternalFieldCount()); | 12483 CHECK_EQ(1, result->InternalFieldCount()); |
12480 } | 12484 } |
12481 | 12485 |
12482 | 12486 |
12483 // If part of the threaded tests, this test makes ThreadingTest fail | 12487 // If part of the threaded tests, this test makes ThreadingTest fail |
12484 // on mac. | 12488 // on mac. |
12485 TEST(CatchStackOverflow) { | 12489 TEST(CatchStackOverflow) { |
12486 LocalContext context; | 12490 LocalContext context; |
(...skipping 4999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17486 " } catch(e) {" | 17490 " } catch(e) {" |
17487 " return e.toString();" | 17491 " return e.toString();" |
17488 " }" | 17492 " }" |
17489 "})()", | 17493 "})()", |
17490 "ReferenceError: cell is not defined"); | 17494 "ReferenceError: cell is not defined"); |
17491 } | 17495 } |
17492 | 17496 |
17493 | 17497 |
17494 class Visitor42 : public v8::PersistentHandleVisitor { | 17498 class Visitor42 : public v8::PersistentHandleVisitor { |
17495 public: | 17499 public: |
17496 explicit Visitor42(v8::Persistent<v8::Object> object) | 17500 explicit Visitor42(v8::Persistent<v8::Object>* object) |
17497 : counter_(0), object_(object) { } | 17501 : counter_(0), object_(object) { } |
17498 | 17502 |
17499 #ifdef V8_USE_OLD_STYLE_PERSISTENT_HANDLE_VISITORS | 17503 #ifdef V8_USE_OLD_STYLE_PERSISTENT_HANDLE_VISITORS |
17500 virtual void VisitPersistentHandle(Persistent<Value> value, | 17504 virtual void VisitPersistentHandle(Persistent<Value> value, |
17501 uint16_t class_id) { | 17505 uint16_t class_id) { |
17502 VisitPersistentHandle(&value, class_id); | 17506 VisitPersistentHandle(&value, class_id); |
17503 } | 17507 } |
17504 #endif | 17508 #endif |
17505 | 17509 |
17506 virtual void VisitPersistentHandle(Persistent<Value>* value, | 17510 virtual void VisitPersistentHandle(Persistent<Value>* value, |
17507 uint16_t class_id) { | 17511 uint16_t class_id) { |
17508 if (class_id == 42) { | 17512 if (class_id != 42) return; |
17509 CHECK((*value)->IsObject()); | 17513 CHECK_EQ(42, value->WrapperClassId()); |
17510 v8::Persistent<v8::Object> visited = | 17514 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
17511 v8::Persistent<v8::Object>::Cast(*value); | 17515 v8::HandleScope handle_scope(isolate); |
17512 CHECK_EQ(42, visited.WrapperClassId(v8::Isolate::GetCurrent())); | 17516 v8::Handle<v8::Value> handle = v8::Local<v8::Value>::New(isolate, *value); |
17513 CHECK_EQ(Handle<Value>(*object_), Handle<Value>(*visited)); | 17517 v8::Handle<v8::Value> object = |
17514 ++counter_; | 17518 v8::Local<v8::Object>::New(isolate, *object_); |
17515 } | 17519 CHECK(handle->IsObject()); |
| 17520 CHECK_EQ(Handle<Object>::Cast(handle), object); |
| 17521 ++counter_; |
17516 } | 17522 } |
17517 | 17523 |
17518 int counter_; | 17524 int counter_; |
17519 v8::Persistent<v8::Object> object_; | 17525 v8::Persistent<v8::Object>* object_; |
17520 }; | 17526 }; |
17521 | 17527 |
17522 | 17528 |
17523 TEST(PersistentHandleVisitor) { | 17529 TEST(PersistentHandleVisitor) { |
17524 LocalContext context; | 17530 LocalContext context; |
17525 v8::Isolate* isolate = context->GetIsolate(); | 17531 v8::Isolate* isolate = context->GetIsolate(); |
17526 v8::HandleScope scope(isolate); | 17532 v8::HandleScope scope(isolate); |
17527 v8::Persistent<v8::Object> object = | 17533 v8::Persistent<v8::Object> object(isolate, v8::Object::New()); |
17528 v8::Persistent<v8::Object>::New(isolate, v8::Object::New()); | |
17529 CHECK_EQ(0, object.WrapperClassId(isolate)); | 17534 CHECK_EQ(0, object.WrapperClassId(isolate)); |
17530 object.SetWrapperClassId(isolate, 42); | 17535 object.SetWrapperClassId(isolate, 42); |
17531 CHECK_EQ(42, object.WrapperClassId(isolate)); | 17536 CHECK_EQ(42, object.WrapperClassId(isolate)); |
17532 | 17537 |
17533 Visitor42 visitor(object); | 17538 Visitor42 visitor(&object); |
17534 v8::V8::VisitHandlesWithClassIds(&visitor); | 17539 v8::V8::VisitHandlesWithClassIds(&visitor); |
17535 CHECK_EQ(1, visitor.counter_); | 17540 CHECK_EQ(1, visitor.counter_); |
17536 | 17541 |
17537 object.Dispose(isolate); | 17542 object.Dispose(isolate); |
17538 } | 17543 } |
17539 | 17544 |
17540 | 17545 |
17541 TEST(WrapperClassId) { | 17546 TEST(WrapperClassId) { |
17542 LocalContext context; | 17547 LocalContext context; |
17543 v8::Isolate* isolate = context->GetIsolate(); | 17548 v8::Isolate* isolate = context->GetIsolate(); |
17544 v8::HandleScope scope(isolate); | 17549 v8::HandleScope scope(isolate); |
17545 v8::Persistent<v8::Object> object = | 17550 v8::Persistent<v8::Object> object(isolate, v8::Object::New()); |
17546 v8::Persistent<v8::Object>::New(isolate, v8::Object::New()); | |
17547 CHECK_EQ(0, object.WrapperClassId(isolate)); | 17551 CHECK_EQ(0, object.WrapperClassId(isolate)); |
17548 object.SetWrapperClassId(isolate, 65535); | 17552 object.SetWrapperClassId(isolate, 65535); |
17549 CHECK_EQ(65535, object.WrapperClassId(isolate)); | 17553 CHECK_EQ(65535, object.WrapperClassId(isolate)); |
17550 object.Dispose(isolate); | 17554 object.Dispose(isolate); |
17551 } | 17555 } |
17552 | 17556 |
17553 | 17557 |
17554 TEST(PersistentHandleInNewSpaceVisitor) { | 17558 TEST(PersistentHandleInNewSpaceVisitor) { |
17555 LocalContext context; | 17559 LocalContext context; |
17556 v8::Isolate* isolate = context->GetIsolate(); | 17560 v8::Isolate* isolate = context->GetIsolate(); |
17557 v8::HandleScope scope(isolate); | 17561 v8::HandleScope scope(isolate); |
17558 v8::Persistent<v8::Object> object1 = | 17562 v8::Persistent<v8::Object> object1(isolate, v8::Object::New()); |
17559 v8::Persistent<v8::Object>::New(isolate, v8::Object::New()); | |
17560 CHECK_EQ(0, object1.WrapperClassId(isolate)); | 17563 CHECK_EQ(0, object1.WrapperClassId(isolate)); |
17561 object1.SetWrapperClassId(isolate, 42); | 17564 object1.SetWrapperClassId(isolate, 42); |
17562 CHECK_EQ(42, object1.WrapperClassId(isolate)); | 17565 CHECK_EQ(42, object1.WrapperClassId(isolate)); |
17563 | 17566 |
17564 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 17567 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
17565 | 17568 |
17566 v8::Persistent<v8::Object> object2 = | 17569 v8::Persistent<v8::Object> object2(isolate, v8::Object::New()); |
17567 v8::Persistent<v8::Object>::New(isolate, v8::Object::New()); | |
17568 CHECK_EQ(0, object2.WrapperClassId(isolate)); | 17570 CHECK_EQ(0, object2.WrapperClassId(isolate)); |
17569 object2.SetWrapperClassId(isolate, 42); | 17571 object2.SetWrapperClassId(isolate, 42); |
17570 CHECK_EQ(42, object2.WrapperClassId(isolate)); | 17572 CHECK_EQ(42, object2.WrapperClassId(isolate)); |
17571 | 17573 |
17572 Visitor42 visitor(object2); | 17574 Visitor42 visitor(&object2); |
17573 v8::V8::VisitHandlesForPartialDependence(isolate, &visitor); | 17575 v8::V8::VisitHandlesForPartialDependence(isolate, &visitor); |
17574 CHECK_EQ(1, visitor.counter_); | 17576 CHECK_EQ(1, visitor.counter_); |
17575 | 17577 |
17576 object1.Dispose(isolate); | 17578 object1.Dispose(isolate); |
17577 object2.Dispose(isolate); | 17579 object2.Dispose(isolate); |
17578 } | 17580 } |
17579 | 17581 |
17580 | 17582 |
17581 TEST(RegExp) { | 17583 TEST(RegExp) { |
17582 LocalContext context; | 17584 LocalContext context; |
(...skipping 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19060 i::Semaphore* sem_; | 19062 i::Semaphore* sem_; |
19061 volatile int sem_value_; | 19063 volatile int sem_value_; |
19062 }; | 19064 }; |
19063 | 19065 |
19064 | 19066 |
19065 THREADED_TEST(SemaphoreInterruption) { | 19067 THREADED_TEST(SemaphoreInterruption) { |
19066 ThreadInterruptTest().RunTest(); | 19068 ThreadInterruptTest().RunTest(); |
19067 } | 19069 } |
19068 | 19070 |
19069 #endif // WIN32 | 19071 #endif // WIN32 |
OLD | NEW |