Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: vm/object_test.cc

Issue 11038004: - WeakProperty keys in other generations are black. Avoid trying to (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/assembler.h" 6 #include "vm/assembler.h"
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/object_store.h" 10 #include "vm/object_store.h"
(...skipping 2847 matching lines...) Expand 10 before | Expand all | Expand 10 after
2858 "#4 MyClass.field (dart:test-lib:25:9)\n" 2858 "#4 MyClass.field (dart:test-lib:25:9)\n"
2859 "#5 MyClass.foo.fooHelper (dart:test-lib:30:7)\n" 2859 "#5 MyClass.foo.fooHelper (dart:test-lib:30:7)\n"
2860 "#6 MyClass.foo (dart:test-lib:32:14)\n" 2860 "#6 MyClass.foo (dart:test-lib:32:14)\n"
2861 "#7 MyClass.MyClass.<anonymous closure> (dart:test-lib:21:15)\n" 2861 "#7 MyClass.MyClass.<anonymous closure> (dart:test-lib:21:15)\n"
2862 "#8 MyClass.MyClass (dart:test-lib:21:18)\n" 2862 "#8 MyClass.MyClass (dart:test-lib:21:18)\n"
2863 "#9 main.<anonymous closure> (dart:test-lib:37:10)\n" 2863 "#9 main.<anonymous closure> (dart:test-lib:37:10)\n"
2864 "#10 main (dart:test-lib:37:24)"); 2864 "#10 main (dart:test-lib:37:24)");
2865 } 2865 }
2866 2866
2867 2867
2868 TEST_CASE(WeakProperty_PreserveCrossGen) {
2869 Isolate* isolate = Isolate::Current();
2870 WeakProperty& weak = WeakProperty::Handle();
2871 {
2872 // Weak property and value in new. Key in old.
2873 HANDLESCOPE(isolate);
2874 OneByteString& key = OneByteString::Handle();
2875 key ^= OneByteString::New("key", Heap::kOld);
2876 OneByteString& value = OneByteString::Handle();
2877 value ^= OneByteString::New("value", Heap::kNew);
2878 weak ^= WeakProperty::New(Heap::kNew);
2879 weak.set_key(key);
2880 weak.set_value(value);
2881 key ^= OneByteString::null();
2882 value ^= OneByteString::null();
2883 }
2884 isolate->heap()->CollectAllGarbage();
2885 // Weak property key and value should survive due to cross-generation
2886 // pointers.
2887 EXPECT(weak.key() != Object::null());
2888 EXPECT(weak.value() != Object::null());
2889 {
2890 // Weak property and value in old. Key in new.
2891 HANDLESCOPE(isolate);
2892 OneByteString& key = OneByteString::Handle();
2893 key ^= OneByteString::New("key", Heap::kNew);
2894 OneByteString& value = OneByteString::Handle();
2895 value ^= OneByteString::New("value", Heap::kOld);
2896 weak ^= WeakProperty::New(Heap::kOld);
2897 weak.set_key(key);
2898 weak.set_value(value);
2899 key ^= OneByteString::null();
2900 value ^= OneByteString::null();
2901 }
2902 isolate->heap()->CollectAllGarbage();
2903 // Weak property key and value should survive due to cross-generation
2904 // pointers.
2905 EXPECT(weak.key() != Object::null());
2906 EXPECT(weak.value() != Object::null());
2907 {
2908 // Weak property and value in new. Key is a Smi.
2909 HANDLESCOPE(isolate);
2910 Integer& key = Integer::Handle();
2911 key ^= Integer::New(31);
2912 OneByteString& value = OneByteString::Handle();
2913 value ^= OneByteString::New("value", Heap::kNew);
2914 weak ^= WeakProperty::New(Heap::kNew);
2915 weak.set_key(key);
2916 weak.set_value(value);
2917 key ^= Integer::null();
2918 value ^= OneByteString::null();
2919 }
2920 isolate->heap()->CollectAllGarbage();
2921 // Weak property key and value should survive due to cross-generation
cshapiro 2012/10/01 22:22:14 This comment is false, no? The key is implicitly
Ivan Posva 2012/10/01 22:27:39 Done.
2922 // pointers.
2923 EXPECT(weak.key() != Object::null());
2924 EXPECT(weak.value() != Object::null());
2925 {
2926 // Weak property and value in old. Key is a Smi.
2927 HANDLESCOPE(isolate);
2928 Integer& key = Integer::Handle();
2929 key ^= Integer::New(32);
2930 OneByteString& value = OneByteString::Handle();
2931 value ^= OneByteString::New("value", Heap::kOld);
2932 weak ^= WeakProperty::New(Heap::kOld);
2933 weak.set_key(key);
2934 weak.set_value(value);
2935 key ^= OneByteString::null();
2936 value ^= OneByteString::null();
2937 }
2938 isolate->heap()->CollectAllGarbage();
2939 // Weak property key and value should survive due to cross-generation
cshapiro 2012/10/01 22:22:14 Same here.
Ivan Posva 2012/10/01 22:27:39 Done.
2940 // pointers.
2941 EXPECT(weak.key() != Object::null());
2942 EXPECT(weak.value() != Object::null());
2943 {
2944 // Weak property and value in new. Key in VM isolate.
2945 HANDLESCOPE(isolate);
2946 OneByteString& key = OneByteString::Handle();
2947 key ^= Symbols::Dot();
2948 OneByteString& value = OneByteString::Handle();
2949 value ^= OneByteString::New("value", Heap::kNew);
2950 weak ^= WeakProperty::New(Heap::kNew);
2951 weak.set_key(key);
2952 weak.set_value(value);
2953 key ^= OneByteString::null();
2954 value ^= OneByteString::null();
2955 }
2956 isolate->heap()->CollectAllGarbage();
2957 // Weak property key and value should survive due to cross-generation
2958 // pointers.
2959 EXPECT(weak.key() != Object::null());
2960 EXPECT(weak.value() != Object::null());
2961 {
2962 // Weak property and value in old. Key in VM isolate.
2963 HANDLESCOPE(isolate);
2964 OneByteString& key = OneByteString::Handle();
2965 key ^= Symbols::Dot();
2966 OneByteString& value = OneByteString::Handle();
2967 value ^= OneByteString::New("value", Heap::kOld);
2968 weak ^= WeakProperty::New(Heap::kOld);
2969 weak.set_key(key);
2970 weak.set_value(value);
2971 key ^= OneByteString::null();
2972 value ^= OneByteString::null();
2973 }
2974 isolate->heap()->CollectAllGarbage();
2975 // Weak property key and value should survive due to cross-generation
2976 // pointers.
2977 EXPECT(weak.key() != Object::null());
2978 EXPECT(weak.value() != Object::null());
2979 }
2980
2981
2868 TEST_CASE(WeakProperty_PreserveOne_NewSpace) { 2982 TEST_CASE(WeakProperty_PreserveOne_NewSpace) {
2869 Isolate* isolate = Isolate::Current(); 2983 Isolate* isolate = Isolate::Current();
2870 WeakProperty& weak = WeakProperty::Handle(); 2984 WeakProperty& weak = WeakProperty::Handle();
2871 OneByteString& key = OneByteString::Handle(); 2985 OneByteString& key = OneByteString::Handle();
2872 key ^= OneByteString::New("key"); 2986 key ^= OneByteString::New("key");
2873 { 2987 {
2874 HANDLESCOPE(isolate); 2988 HANDLESCOPE(isolate);
2875 OneByteString& value = OneByteString::Handle(); 2989 OneByteString& value = OneByteString::Handle();
2876 value ^= OneByteString::New("value"); 2990 value ^= OneByteString::New("value");
2877 weak ^= WeakProperty::New(); 2991 weak ^= WeakProperty::New();
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
3106 isolate->heap()->CollectAllGarbage(); 3220 isolate->heap()->CollectAllGarbage();
3107 EXPECT(weak1.key() == Object::null()); 3221 EXPECT(weak1.key() == Object::null());
3108 EXPECT(weak1.value() == Object::null()); 3222 EXPECT(weak1.value() == Object::null());
3109 EXPECT(weak2.key() == Object::null()); 3223 EXPECT(weak2.key() == Object::null());
3110 EXPECT(weak2.value() == Object::null()); 3224 EXPECT(weak2.value() == Object::null());
3111 } 3225 }
3112 3226
3113 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 3227 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
3114 3228
3115 } // namespace dart 3229 } // namespace dart
OLDNEW
« vm/gc_marker.cc ('K') | « vm/gc_marker.cc ('k') | vm/scavenger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698