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

Unified Diff: test/cctest/test-heap-profiler.cc

Issue 2900603004: [heap] Add --stress-incremental-marking flag. (Closed)
Patch Set: rebase Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: test/cctest/test-heap-profiler.cc
diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc
index b96e1615669ef1574aec21ce34d244d23aabc538..552434ed8b5faeb2df65963dbcf24c1caee7438d 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -2021,6 +2021,7 @@ bool HasWeakGlobalHandle() {
static void PersistentHandleCallback(
const v8::WeakCallbackInfo<v8::Persistent<v8::Object> >& data) {
data.GetParameter()->Reset();
+ delete data.GetParameter();
}
@@ -2030,12 +2031,16 @@ TEST(WeakGlobalHandle) {
CHECK(!HasWeakGlobalHandle());
- v8::Persistent<v8::Object> handle(env->GetIsolate(),
- v8::Object::New(env->GetIsolate()));
- handle.SetWeak(&handle, PersistentHandleCallback,
- v8::WeakCallbackType::kParameter);
+ // We cannot stack allocate the handle because the weak callback
+ // can be invoked in the message loop after returning from this function.
+ v8::Persistent<v8::Object>* handle = new v8::Persistent<v8::Object>();
+
+ handle->Reset(env->GetIsolate(), v8::Object::New(env->GetIsolate()));
+ handle->SetWeak(handle, PersistentHandleCallback,
+ v8::WeakCallbackType::kParameter);
CHECK(HasWeakGlobalHandle());
+ CcTest::CollectAllGarbage();
}
« src/heap/heap.cc ('K') | « test/cctest/test-api.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698