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

Side by Side Diff: test/cctest/test-api.cc

Issue 16528009: Deprecate the version of MakeWeak which takes an Isolate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 7 years, 6 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
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3103 matching lines...) Expand 10 before | Expand all | Expand 10 after
3114 Persistent<Value> g2s2; 3114 Persistent<Value> g2s2;
3115 Persistent<Value> g2c1; 3115 Persistent<Value> g2c1;
3116 3116
3117 WeakCallCounter counter(1234); 3117 WeakCallCounter counter(1234);
3118 3118
3119 { 3119 {
3120 HandleScope scope(iso); 3120 HandleScope scope(iso);
3121 g1s1.Reset(iso, Object::New()); 3121 g1s1.Reset(iso, Object::New());
3122 g1s2.Reset(iso, Object::New()); 3122 g1s2.Reset(iso, Object::New());
3123 g1c1.Reset(iso, Object::New()); 3123 g1c1.Reset(iso, Object::New());
3124 g1s1.MakeWeak(iso, &counter, &WeakPointerCallback); 3124 g1s1.MakeWeak(&counter, &WeakPointerCallback);
3125 g1s2.MakeWeak(iso, &counter, &WeakPointerCallback); 3125 g1s2.MakeWeak(&counter, &WeakPointerCallback);
3126 g1c1.MakeWeak(iso, &counter, &WeakPointerCallback); 3126 g1c1.MakeWeak(&counter, &WeakPointerCallback);
3127 3127
3128 g2s1.Reset(iso, Object::New()); 3128 g2s1.Reset(iso, Object::New());
3129 g2s2.Reset(iso, Object::New()); 3129 g2s2.Reset(iso, Object::New());
3130 g2c1.Reset(iso, Object::New()); 3130 g2c1.Reset(iso, Object::New());
3131 g2s1.MakeWeak(iso, &counter, &WeakPointerCallback); 3131 g2s1.MakeWeak(&counter, &WeakPointerCallback);
3132 g2s2.MakeWeak(iso, &counter, &WeakPointerCallback); 3132 g2s2.MakeWeak(&counter, &WeakPointerCallback);
3133 g2c1.MakeWeak(iso, &counter, &WeakPointerCallback); 3133 g2c1.MakeWeak(&counter, &WeakPointerCallback);
3134 } 3134 }
3135 3135
3136 Persistent<Value> root(iso, g1s1); // make a root. 3136 Persistent<Value> root(iso, g1s1); // make a root.
3137 3137
3138 // Connect group 1 and 2, make a cycle. 3138 // Connect group 1 and 2, make a cycle.
3139 { 3139 {
3140 HandleScope scope(iso); 3140 HandleScope scope(iso);
3141 CHECK(Local<Object>::New(iso, g1s2.As<Object>())-> 3141 CHECK(Local<Object>::New(iso, g1s2.As<Object>())->
3142 Set(0, Local<Value>(*g2s2))); 3142 Set(0, Local<Value>(*g2s2)));
3143 CHECK(Local<Object>::New(iso, g2s1.As<Object>())-> 3143 CHECK(Local<Object>::New(iso, g2s1.As<Object>())->
(...skipping 12 matching lines...) Expand all
3156 } 3156 }
3157 // Do a single full GC, ensure incremental marking is stopped. 3157 // Do a single full GC, ensure incremental marking is stopped.
3158 v8::internal::Heap* heap = reinterpret_cast<v8::internal::Isolate*>( 3158 v8::internal::Heap* heap = reinterpret_cast<v8::internal::Isolate*>(
3159 iso)->heap(); 3159 iso)->heap();
3160 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); 3160 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
3161 3161
3162 // All object should be alive. 3162 // All object should be alive.
3163 CHECK_EQ(0, counter.NumberOfWeakCalls()); 3163 CHECK_EQ(0, counter.NumberOfWeakCalls());
3164 3164
3165 // Weaken the root. 3165 // Weaken the root.
3166 root.MakeWeak(iso, &counter, &WeakPointerCallback); 3166 root.MakeWeak(&counter, &WeakPointerCallback);
3167 // But make children strong roots---all the objects (except for children) 3167 // But make children strong roots---all the objects (except for children)
3168 // should be collectable now. 3168 // should be collectable now.
3169 g1c1.ClearWeak(iso); 3169 g1c1.ClearWeak(iso);
3170 g2c1.ClearWeak(iso); 3170 g2c1.ClearWeak(iso);
3171 3171
3172 // Groups are deleted, rebuild groups. 3172 // Groups are deleted, rebuild groups.
3173 { 3173 {
3174 UniqueId id1(reinterpret_cast<intptr_t>(*g1s1)); 3174 UniqueId id1(reinterpret_cast<intptr_t>(*g1s1));
3175 UniqueId id2(reinterpret_cast<intptr_t>(*g2s2)); 3175 UniqueId id2(reinterpret_cast<intptr_t>(*g2s2));
3176 iso->SetObjectGroupId(g1s1, id1); 3176 iso->SetObjectGroupId(g1s1, id1);
3177 iso->SetObjectGroupId(g1s2, id1); 3177 iso->SetObjectGroupId(g1s2, id1);
3178 iso->SetReferenceFromGroup(id1, g1c1); 3178 iso->SetReferenceFromGroup(id1, g1c1);
3179 iso->SetObjectGroupId(g2s1, id2); 3179 iso->SetObjectGroupId(g2s1, id2);
3180 iso->SetObjectGroupId(g2s2, id2); 3180 iso->SetObjectGroupId(g2s2, id2);
3181 iso->SetReferenceFromGroup(id2, g2c1); 3181 iso->SetReferenceFromGroup(id2, g2c1);
3182 } 3182 }
3183 3183
3184 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); 3184 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
3185 3185
3186 // All objects should be gone. 5 global handles in total. 3186 // All objects should be gone. 5 global handles in total.
3187 CHECK_EQ(5, counter.NumberOfWeakCalls()); 3187 CHECK_EQ(5, counter.NumberOfWeakCalls());
3188 3188
3189 // And now make children weak again and collect them. 3189 // And now make children weak again and collect them.
3190 g1c1.MakeWeak(iso, &counter, &WeakPointerCallback); 3190 g1c1.MakeWeak(&counter, &WeakPointerCallback);
3191 g2c1.MakeWeak(iso, &counter, &WeakPointerCallback); 3191 g2c1.MakeWeak(&counter, &WeakPointerCallback);
3192 3192
3193 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); 3193 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
3194 CHECK_EQ(7, counter.NumberOfWeakCalls()); 3194 CHECK_EQ(7, counter.NumberOfWeakCalls());
3195 } 3195 }
3196 3196
3197 3197
3198 THREADED_TEST(ApiObjectGroupsCycle) { 3198 THREADED_TEST(ApiObjectGroupsCycle) {
3199 LocalContext env; 3199 LocalContext env;
3200 v8::Isolate* iso = env->GetIsolate(); 3200 v8::Isolate* iso = env->GetIsolate();
3201 HandleScope scope(iso); 3201 HandleScope scope(iso);
3202 3202
3203 WeakCallCounter counter(1234); 3203 WeakCallCounter counter(1234);
3204 3204
3205 Persistent<Value> g1s1; 3205 Persistent<Value> g1s1;
3206 Persistent<Value> g1s2; 3206 Persistent<Value> g1s2;
3207 Persistent<Value> g2s1; 3207 Persistent<Value> g2s1;
3208 Persistent<Value> g2s2; 3208 Persistent<Value> g2s2;
3209 Persistent<Value> g3s1; 3209 Persistent<Value> g3s1;
3210 Persistent<Value> g3s2; 3210 Persistent<Value> g3s2;
3211 Persistent<Value> g4s1; 3211 Persistent<Value> g4s1;
3212 Persistent<Value> g4s2; 3212 Persistent<Value> g4s2;
3213 3213
3214 { 3214 {
3215 HandleScope scope(iso); 3215 HandleScope scope(iso);
3216 g1s1.Reset(iso, Object::New()); 3216 g1s1.Reset(iso, Object::New());
3217 g1s2.Reset(iso, Object::New()); 3217 g1s2.Reset(iso, Object::New());
3218 g1s1.MakeWeak(iso, &counter, &WeakPointerCallback); 3218 g1s1.MakeWeak(&counter, &WeakPointerCallback);
3219 g1s2.MakeWeak(iso, &counter, &WeakPointerCallback); 3219 g1s2.MakeWeak(&counter, &WeakPointerCallback);
3220 CHECK(g1s1.IsWeak(iso)); 3220 CHECK(g1s1.IsWeak(iso));
3221 CHECK(g1s2.IsWeak(iso)); 3221 CHECK(g1s2.IsWeak(iso));
3222 3222
3223 g2s1.Reset(iso, Object::New()); 3223 g2s1.Reset(iso, Object::New());
3224 g2s2.Reset(iso, Object::New()); 3224 g2s2.Reset(iso, Object::New());
3225 g2s1.MakeWeak(iso, &counter, &WeakPointerCallback); 3225 g2s1.MakeWeak(&counter, &WeakPointerCallback);
3226 g2s2.MakeWeak(iso, &counter, &WeakPointerCallback); 3226 g2s2.MakeWeak(&counter, &WeakPointerCallback);
3227 CHECK(g2s1.IsWeak(iso)); 3227 CHECK(g2s1.IsWeak(iso));
3228 CHECK(g2s2.IsWeak(iso)); 3228 CHECK(g2s2.IsWeak(iso));
3229 3229
3230 g3s1.Reset(iso, Object::New()); 3230 g3s1.Reset(iso, Object::New());
3231 g3s2.Reset(iso, Object::New()); 3231 g3s2.Reset(iso, Object::New());
3232 g3s1.MakeWeak(iso, &counter, &WeakPointerCallback); 3232 g3s1.MakeWeak(&counter, &WeakPointerCallback);
3233 g3s2.MakeWeak(iso, &counter, &WeakPointerCallback); 3233 g3s2.MakeWeak(&counter, &WeakPointerCallback);
3234 CHECK(g3s1.IsWeak(iso)); 3234 CHECK(g3s1.IsWeak(iso));
3235 CHECK(g3s2.IsWeak(iso)); 3235 CHECK(g3s2.IsWeak(iso));
3236 3236
3237 g4s1.Reset(iso, Object::New()); 3237 g4s1.Reset(iso, Object::New());
3238 g4s2.Reset(iso, Object::New()); 3238 g4s2.Reset(iso, Object::New());
3239 g4s1.MakeWeak(iso, &counter, &WeakPointerCallback); 3239 g4s1.MakeWeak(&counter, &WeakPointerCallback);
3240 g4s2.MakeWeak(iso, &counter, &WeakPointerCallback); 3240 g4s2.MakeWeak(&counter, &WeakPointerCallback);
3241 CHECK(g4s1.IsWeak(iso)); 3241 CHECK(g4s1.IsWeak(iso));
3242 CHECK(g4s2.IsWeak(iso)); 3242 CHECK(g4s2.IsWeak(iso));
3243 } 3243 }
3244 3244
3245 Persistent<Value> root(iso, g1s1); // make a root. 3245 Persistent<Value> root(iso, g1s1); // make a root.
3246 3246
3247 // Connect groups. We're building the following cycle: 3247 // Connect groups. We're building the following cycle:
3248 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other 3248 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other
3249 // groups. 3249 // groups.
3250 { 3250 {
(...skipping 16 matching lines...) Expand all
3267 } 3267 }
3268 // Do a single full GC 3268 // Do a single full GC
3269 v8::internal::Heap* heap = reinterpret_cast<v8::internal::Isolate*>( 3269 v8::internal::Heap* heap = reinterpret_cast<v8::internal::Isolate*>(
3270 iso)->heap(); 3270 iso)->heap();
3271 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); 3271 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
3272 3272
3273 // All object should be alive. 3273 // All object should be alive.
3274 CHECK_EQ(0, counter.NumberOfWeakCalls()); 3274 CHECK_EQ(0, counter.NumberOfWeakCalls());
3275 3275
3276 // Weaken the root. 3276 // Weaken the root.
3277 root.MakeWeak(iso, &counter, &WeakPointerCallback); 3277 root.MakeWeak(&counter, &WeakPointerCallback);
3278 3278
3279 // Groups are deleted, rebuild groups. 3279 // Groups are deleted, rebuild groups.
3280 { 3280 {
3281 UniqueId id1(reinterpret_cast<intptr_t>(*g1s1)); 3281 UniqueId id1(reinterpret_cast<intptr_t>(*g1s1));
3282 UniqueId id2(reinterpret_cast<intptr_t>(*g2s1)); 3282 UniqueId id2(reinterpret_cast<intptr_t>(*g2s1));
3283 UniqueId id3(reinterpret_cast<intptr_t>(*g3s1)); 3283 UniqueId id3(reinterpret_cast<intptr_t>(*g3s1));
3284 UniqueId id4(reinterpret_cast<intptr_t>(*g4s1)); 3284 UniqueId id4(reinterpret_cast<intptr_t>(*g4s1));
3285 iso->SetObjectGroupId(g1s1, id1); 3285 iso->SetObjectGroupId(g1s1, id1);
3286 iso->SetObjectGroupId(g1s2, id1); 3286 iso->SetObjectGroupId(g1s2, id1);
3287 iso->SetReferenceFromGroup(id1, g2s1); 3287 iso->SetReferenceFromGroup(id1, g2s1);
(...skipping 30 matching lines...) Expand all
3318 Persistent<Value> g1s2; 3318 Persistent<Value> g1s2;
3319 Persistent<Value> g2s1; 3319 Persistent<Value> g2s1;
3320 Persistent<Value> g2s2; 3320 Persistent<Value> g2s2;
3321 Persistent<Value> g3s1; 3321 Persistent<Value> g3s1;
3322 Persistent<Value> g3s2; 3322 Persistent<Value> g3s2;
3323 3323
3324 { 3324 {
3325 HandleScope scope(iso); 3325 HandleScope scope(iso);
3326 g1s1.Reset(iso, Object::New()); 3326 g1s1.Reset(iso, Object::New());
3327 g1s2.Reset(iso, Object::New()); 3327 g1s2.Reset(iso, Object::New());
3328 g1s1.MakeWeak(iso, &counter, &WeakPointerCallback); 3328 g1s1.MakeWeak(&counter, &WeakPointerCallback);
3329 g1s2.MakeWeak(iso, &counter, &WeakPointerCallback); 3329 g1s2.MakeWeak(&counter, &WeakPointerCallback);
3330 3330
3331 g2s1.Reset(iso, Object::New()); 3331 g2s1.Reset(iso, Object::New());
3332 g2s2.Reset(iso, Object::New()); 3332 g2s2.Reset(iso, Object::New());
3333 g2s1.MakeWeak(iso, &counter, &WeakPointerCallback); 3333 g2s1.MakeWeak(&counter, &WeakPointerCallback);
3334 g2s2.MakeWeak(iso, &counter, &WeakPointerCallback); 3334 g2s2.MakeWeak(&counter, &WeakPointerCallback);
3335 3335
3336 g3s1.Reset(iso, Object::New()); 3336 g3s1.Reset(iso, Object::New());
3337 g3s2.Reset(iso, Object::New()); 3337 g3s2.Reset(iso, Object::New());
3338 g3s1.MakeWeak(iso, &counter, &WeakPointerCallback); 3338 g3s1.MakeWeak(&counter, &WeakPointerCallback);
3339 g3s2.MakeWeak(iso, &counter, &WeakPointerCallback); 3339 g3s2.MakeWeak(&counter, &WeakPointerCallback);
3340 } 3340 }
3341 3341
3342 // Make a root. 3342 // Make a root.
3343 Persistent<Value> root(iso, g1s1); 3343 Persistent<Value> root(iso, g1s1);
3344 root.MarkPartiallyDependent(iso); 3344 root.MarkPartiallyDependent(iso);
3345 3345
3346 // Connect groups. We're building the following cycle: 3346 // Connect groups. We're building the following cycle:
3347 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other 3347 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other
3348 // groups. 3348 // groups.
3349 { 3349 {
(...skipping 19 matching lines...) Expand all
3369 } 3369 }
3370 3370
3371 v8::internal::Heap* heap = reinterpret_cast<v8::internal::Isolate*>( 3371 v8::internal::Heap* heap = reinterpret_cast<v8::internal::Isolate*>(
3372 iso)->heap(); 3372 iso)->heap();
3373 heap->CollectGarbage(i::NEW_SPACE); 3373 heap->CollectGarbage(i::NEW_SPACE);
3374 3374
3375 // All objects should be alive. 3375 // All objects should be alive.
3376 CHECK_EQ(0, counter.NumberOfWeakCalls()); 3376 CHECK_EQ(0, counter.NumberOfWeakCalls());
3377 3377
3378 // Weaken the root. 3378 // Weaken the root.
3379 root.MakeWeak(iso, &counter, &WeakPointerCallback); 3379 root.MakeWeak(&counter, &WeakPointerCallback);
3380 root.MarkPartiallyDependent(iso); 3380 root.MarkPartiallyDependent(iso);
3381 3381
3382 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 3382 v8::Isolate* isolate = v8::Isolate::GetCurrent();
3383 // Groups are deleted, rebuild groups. 3383 // Groups are deleted, rebuild groups.
3384 { 3384 {
3385 HandleScope handle_scope(iso); 3385 HandleScope handle_scope(iso);
3386 g1s1.MarkPartiallyDependent(isolate); 3386 g1s1.MarkPartiallyDependent(isolate);
3387 g1s2.MarkPartiallyDependent(isolate); 3387 g1s2.MarkPartiallyDependent(isolate);
3388 g2s1.MarkPartiallyDependent(isolate); 3388 g2s1.MarkPartiallyDependent(isolate);
3389 g2s2.MarkPartiallyDependent(isolate); 3389 g2s2.MarkPartiallyDependent(isolate);
(...skipping 2879 matching lines...) Expand 10 before | Expand all | Expand 10 after
6269 const AccessorInfo& info) { 6269 const AccessorInfo& info) {
6270 Whammy* whammy = 6270 Whammy* whammy =
6271 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value()); 6271 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value());
6272 6272
6273 v8::Persistent<v8::Object>& prev = whammy->objects_[whammy->cursor_]; 6273 v8::Persistent<v8::Object>& prev = whammy->objects_[whammy->cursor_];
6274 6274
6275 v8::Handle<v8::Object> obj = v8::Object::New(); 6275 v8::Handle<v8::Object> obj = v8::Object::New();
6276 if (!prev.IsEmpty()) { 6276 if (!prev.IsEmpty()) {
6277 v8::Local<v8::Object>::New(info.GetIsolate(), prev) 6277 v8::Local<v8::Object>::New(info.GetIsolate(), prev)
6278 ->Set(v8_str("next"), obj); 6278 ->Set(v8_str("next"), obj);
6279 prev.MakeWeak<Value, Snorkel>(info.GetIsolate(), 6279 prev.MakeWeak<Value, Snorkel>(new Snorkel(), &HandleWeakReference);
6280 new Snorkel(),
6281 &HandleWeakReference);
6282 whammy->objects_[whammy->cursor_].Clear(); 6280 whammy->objects_[whammy->cursor_].Clear();
6283 } 6281 }
6284 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj); 6282 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj);
6285 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; 6283 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount;
6286 return whammy->getScript()->Run(); 6284 return whammy->getScript()->Run();
6287 } 6285 }
6288 6286
6289 THREADED_TEST(WeakReference) { 6287 THREADED_TEST(WeakReference) {
6290 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); 6288 v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
6291 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New(); 6289 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
6333 v8::Persistent<v8::Object> object_a, object_b; 6331 v8::Persistent<v8::Object> object_a, object_b;
6334 6332
6335 { 6333 {
6336 v8::HandleScope handle_scope(iso); 6334 v8::HandleScope handle_scope(iso);
6337 object_a.Reset(iso, v8::Object::New()); 6335 object_a.Reset(iso, v8::Object::New());
6338 object_b.Reset(iso, v8::Object::New()); 6336 object_b.Reset(iso, v8::Object::New());
6339 } 6337 }
6340 6338
6341 bool object_a_disposed = false; 6339 bool object_a_disposed = false;
6342 bool object_b_disposed = false; 6340 bool object_b_disposed = false;
6343 object_a.MakeWeak(iso, &object_a_disposed, &DisposeAndSetFlag); 6341 object_a.MakeWeak(&object_a_disposed, &DisposeAndSetFlag);
6344 object_b.MakeWeak(iso, &object_b_disposed, &DisposeAndSetFlag); 6342 object_b.MakeWeak(&object_b_disposed, &DisposeAndSetFlag);
6345 CHECK(!object_b.IsIndependent(iso)); 6343 CHECK(!object_b.IsIndependent(iso));
6346 object_a.MarkIndependent(iso); 6344 object_a.MarkIndependent(iso);
6347 object_b.MarkIndependent(iso); 6345 object_b.MarkIndependent(iso);
6348 CHECK(object_b.IsIndependent(iso)); 6346 CHECK(object_b.IsIndependent(iso));
6349 HEAP->PerformScavenge(); 6347 HEAP->PerformScavenge();
6350 CHECK(object_a_disposed); 6348 CHECK(object_a_disposed);
6351 CHECK(object_b_disposed); 6349 CHECK(object_b_disposed);
6352 } 6350 }
6353 6351
6354 6352
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
6395 GCInvoker invoke_gc[kNumberOfGCTypes] = {&InvokeScavenge, &InvokeMarkSweep}; 6393 GCInvoker invoke_gc[kNumberOfGCTypes] = {&InvokeScavenge, &InvokeMarkSweep};
6396 6394
6397 for (int outer_gc = 0; outer_gc < kNumberOfGCTypes; outer_gc++) { 6395 for (int outer_gc = 0; outer_gc < kNumberOfGCTypes; outer_gc++) {
6398 for (int inner_gc = 0; inner_gc < kNumberOfGCTypes; inner_gc++) { 6396 for (int inner_gc = 0; inner_gc < kNumberOfGCTypes; inner_gc++) {
6399 v8::Persistent<v8::Object> object; 6397 v8::Persistent<v8::Object> object;
6400 { 6398 {
6401 v8::HandleScope handle_scope(isolate); 6399 v8::HandleScope handle_scope(isolate);
6402 object.Reset(isolate, v8::Object::New()); 6400 object.Reset(isolate, v8::Object::New());
6403 } 6401 }
6404 bool disposed = false; 6402 bool disposed = false;
6405 object.MakeWeak(isolate, &disposed, gc_forcing_callback[inner_gc]); 6403 object.MakeWeak(&disposed, gc_forcing_callback[inner_gc]);
6406 object.MarkIndependent(isolate); 6404 object.MarkIndependent(isolate);
6407 invoke_gc[outer_gc](); 6405 invoke_gc[outer_gc]();
6408 CHECK(disposed); 6406 CHECK(disposed);
6409 } 6407 }
6410 } 6408 }
6411 } 6409 }
6412 6410
6413 6411
6414 static void RevivingCallback(v8::Isolate* isolate, 6412 static void RevivingCallback(v8::Isolate* isolate,
6415 v8::Persistent<v8::Object>* obj, 6413 v8::Persistent<v8::Object>* obj,
(...skipping 12 matching lines...) Expand all
6428 v8::Persistent<v8::Object> object; 6426 v8::Persistent<v8::Object> object;
6429 { 6427 {
6430 v8::HandleScope handle_scope(isolate); 6428 v8::HandleScope handle_scope(isolate);
6431 v8::Local<v8::Object> o = v8::Object::New(); 6429 v8::Local<v8::Object> o = v8::Object::New();
6432 object.Reset(isolate, o); 6430 object.Reset(isolate, o);
6433 o->Set(v8_str("x"), v8::Integer::New(1)); 6431 o->Set(v8_str("x"), v8::Integer::New(1));
6434 v8::Local<String> y_str = v8_str("y"); 6432 v8::Local<String> y_str = v8_str("y");
6435 o->Set(y_str, y_str); 6433 o->Set(y_str, y_str);
6436 } 6434 }
6437 bool revived = false; 6435 bool revived = false;
6438 object.MakeWeak(isolate, &revived, &RevivingCallback); 6436 object.MakeWeak(&revived, &RevivingCallback);
6439 object.MarkIndependent(isolate); 6437 object.MarkIndependent(isolate);
6440 HEAP->PerformScavenge(); 6438 HEAP->PerformScavenge();
6441 CHECK(revived); 6439 CHECK(revived);
6442 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); 6440 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
6443 { 6441 {
6444 v8::HandleScope handle_scope(isolate); 6442 v8::HandleScope handle_scope(isolate);
6445 v8::Local<v8::Object> o = v8::Local<v8::Object>::New(isolate, object); 6443 v8::Local<v8::Object> o = v8::Local<v8::Object>::New(isolate, object);
6446 v8::Local<String> y_str = v8_str("y"); 6444 v8::Local<String> y_str = v8_str("y");
6447 CHECK_EQ(v8::Integer::New(1), o->Get(v8_str("x"))); 6445 CHECK_EQ(v8::Integer::New(1), o->Get(v8_str("x")));
6448 CHECK(o->Get(y_str)->Equals(y_str)); 6446 CHECK(o->Get(y_str)->Equals(y_str));
(...skipping 5705 matching lines...) Expand 10 before | Expand all | Expand 10 after
12154 { 12152 {
12155 v8::HandleScope scope(isolate); 12153 v8::HandleScope scope(isolate);
12156 some_object.Reset(isolate, v8::Object::New()); 12154 some_object.Reset(isolate, v8::Object::New());
12157 handle1.Reset(isolate, v8::Object::New()); 12155 handle1.Reset(isolate, v8::Object::New());
12158 handle2.Reset(isolate, v8::Object::New()); 12156 handle2.Reset(isolate, v8::Object::New());
12159 } 12157 }
12160 // Note: order is implementation dependent alas: currently 12158 // Note: order is implementation dependent alas: currently
12161 // global handle nodes are processed by PostGarbageCollectionProcessing 12159 // global handle nodes are processed by PostGarbageCollectionProcessing
12162 // in reverse allocation order, so if second allocated handle is deleted, 12160 // in reverse allocation order, so if second allocated handle is deleted,
12163 // weak callback of the first handle would be able to 'reallocate' it. 12161 // weak callback of the first handle would be able to 'reallocate' it.
12164 handle1.MakeWeak<v8::Value, void>(isolate, 12162 handle1.MakeWeak<v8::Value, void>(NULL, NewPersistentHandleCallback);
12165 NULL,
12166 NewPersistentHandleCallback);
12167 handle2.Dispose(isolate); 12163 handle2.Dispose(isolate);
12168 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 12164 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
12169 } 12165 }
12170 12166
12171 12167
12172 v8::Persistent<v8::Object> to_be_disposed; 12168 v8::Persistent<v8::Object> to_be_disposed;
12173 12169
12174 void DisposeAndForceGcCallback(v8::Isolate* isolate, 12170 void DisposeAndForceGcCallback(v8::Isolate* isolate,
12175 v8::Persistent<v8::Value>* handle, 12171 v8::Persistent<v8::Value>* handle,
12176 void*) { 12172 void*) {
12177 to_be_disposed.Dispose(isolate); 12173 to_be_disposed.Dispose(isolate);
12178 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 12174 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
12179 handle->Dispose(isolate); 12175 handle->Dispose(isolate);
12180 } 12176 }
12181 12177
12182 12178
12183 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { 12179 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) {
12184 LocalContext context; 12180 LocalContext context;
12185 v8::Isolate* isolate = context->GetIsolate(); 12181 v8::Isolate* isolate = context->GetIsolate();
12186 12182
12187 v8::Persistent<v8::Object> handle1, handle2; 12183 v8::Persistent<v8::Object> handle1, handle2;
12188 { 12184 {
12189 v8::HandleScope scope(isolate); 12185 v8::HandleScope scope(isolate);
12190 handle1.Reset(isolate, v8::Object::New()); 12186 handle1.Reset(isolate, v8::Object::New());
12191 handle2.Reset(isolate, v8::Object::New()); 12187 handle2.Reset(isolate, v8::Object::New());
12192 } 12188 }
12193 handle1.MakeWeak<v8::Value, void>(isolate, NULL, DisposeAndForceGcCallback); 12189 handle1.MakeWeak<v8::Value, void>(NULL, DisposeAndForceGcCallback);
12194 to_be_disposed.Reset(isolate, handle2); 12190 to_be_disposed.Reset(isolate, handle2);
12195 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 12191 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
12196 } 12192 }
12197 12193
12198 void DisposingCallback(v8::Isolate* isolate, 12194 void DisposingCallback(v8::Isolate* isolate,
12199 v8::Persistent<v8::Value>* handle, 12195 v8::Persistent<v8::Value>* handle,
12200 void*) { 12196 void*) {
12201 handle->Dispose(isolate); 12197 handle->Dispose(isolate);
12202 } 12198 }
12203 12199
(...skipping 10 matching lines...) Expand all
12214 LocalContext context; 12210 LocalContext context;
12215 v8::Isolate* isolate = context->GetIsolate(); 12211 v8::Isolate* isolate = context->GetIsolate();
12216 12212
12217 v8::Persistent<v8::Object> handle1, handle2, handle3; 12213 v8::Persistent<v8::Object> handle1, handle2, handle3;
12218 { 12214 {
12219 v8::HandleScope scope(isolate); 12215 v8::HandleScope scope(isolate);
12220 handle3.Reset(isolate, v8::Object::New()); 12216 handle3.Reset(isolate, v8::Object::New());
12221 handle2.Reset(isolate, v8::Object::New()); 12217 handle2.Reset(isolate, v8::Object::New());
12222 handle1.Reset(isolate, v8::Object::New()); 12218 handle1.Reset(isolate, v8::Object::New());
12223 } 12219 }
12224 handle2.MakeWeak<v8::Value, void>(isolate, NULL, DisposingCallback); 12220 handle2.MakeWeak<v8::Value, void>(NULL, DisposingCallback);
12225 handle3.MakeWeak<v8::Value, void>(isolate, NULL, HandleCreatingCallback); 12221 handle3.MakeWeak<v8::Value, void>(NULL, HandleCreatingCallback);
12226 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 12222 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
12227 } 12223 }
12228 12224
12229 12225
12230 THREADED_TEST(CheckForCrossContextObjectLiterals) { 12226 THREADED_TEST(CheckForCrossContextObjectLiterals) {
12231 v8::V8::Initialize(); 12227 v8::V8::Initialize();
12232 12228
12233 const int nof = 2; 12229 const int nof = 2;
12234 const char* sources[nof] = { 12230 const char* sources[nof] = {
12235 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }", 12231 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }",
(...skipping 7125 matching lines...) Expand 10 before | Expand all | Expand 10 after
19361 i::Semaphore* sem_; 19357 i::Semaphore* sem_;
19362 volatile int sem_value_; 19358 volatile int sem_value_;
19363 }; 19359 };
19364 19360
19365 19361
19366 THREADED_TEST(SemaphoreInterruption) { 19362 THREADED_TEST(SemaphoreInterruption) {
19367 ThreadInterruptTest().RunTest(); 19363 ThreadInterruptTest().RunTest();
19368 } 19364 }
19369 19365
19370 #endif // WIN32 19366 #endif // WIN32
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698