Bug 1252075 - use UniquePtr instead of ScopedDeletePtr in testGCHeapPostBarriers; r=terrence
authorNathan Froyd <froydnj@mozilla.com>
Wed, 02 Mar 2016 21:04:33 -0500
changeset 323032 e49424ca0ddf8ad7e957db8e9a391aadda81f890
parent 323031 570ffd0108950e6076f4b3ced57a9cc3b51066a2
child 323033 8be0c24081c6ea4b7fc6c33b484ee73df64850d9
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs1252075
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1252075 - use UniquePtr instead of ScopedDeletePtr in testGCHeapPostBarriers; r=terrence
js/src/jsapi-tests/testGCHeapPostBarriers.cpp
--- a/js/src/jsapi-tests/testGCHeapPostBarriers.cpp
+++ b/js/src/jsapi-tests/testGCHeapPostBarriers.cpp
@@ -1,20 +1,20 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 * vim: set ts=8 sts=4 et sw=4 tw=99:
 */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "mozilla/UniquePtr.h"
+
 #include "js/RootingAPI.h"
 #include "jsapi-tests/tests.h"
 
-using mozilla::ScopedDeletePtr;
-
 BEGIN_TEST(testGCHeapPostBarriers)
 {
 #ifdef JS_GC_ZEAL
     AutoLeaveZeal nozeal(cx);
 #endif /* JS_GC_ZEAL */
 
     /* Sanity check - objects start in the nursery and then become tenured. */
     JS_GC(cx->runtime());
@@ -41,31 +41,32 @@ Passthrough(bool value)
 template <typename T>
 bool
 TestHeapPostBarriers(T initialObj)
 {
     CHECK(initialObj != nullptr);
     CHECK(js::gc::IsInsideNursery(initialObj));
 
     /* Construct Heap<> wrapper. */
-    ScopedDeletePtr<JS::Heap<T>> heapData(new JS::Heap<T>);
-    CHECK(heapData.get());
-    CHECK(Passthrough(heapData->get() == nullptr));
+    auto heapDataStorage = mozilla::MakeUnique<char[]>(sizeof(JS::Heap<T>));
+    auto* heapData = new (heapDataStorage.get()) JS::Heap<T>();
+    CHECK(heapData);
+    CHECK(Passthrough(*heapData == nullptr));
     *heapData = initialObj;
 
     /* Store the pointer as an integer so that the hazard analysis will miss it. */
     uintptr_t initialObjAsInt = uintptr_t(initialObj);
 
     /* Perform minor GC and check heap wrapper is udated with new pointer. */
     cx->minorGC(JS::gcreason::API);
-    CHECK(uintptr_t(heapData->get()) != initialObjAsInt);
-    CHECK(!js::gc::IsInsideNursery(heapData->get()));
+    CHECK(uintptr_t(heapData) != initialObjAsInt);
+    CHECK(!js::gc::IsInsideNursery(*heapData));
 
     /* Check object is definitely still alive. */
-    JS::Rooted<T> obj(cx, heapData->get());
+    JS::Rooted<T> obj(cx, *heapData);
     JS::RootedValue value(cx);
     CHECK(JS_GetProperty(cx, obj, "x", &value));
     CHECK(value.isInt32());
     CHECK(value.toInt32() == 42);
 
     return true;
 }