Bug 1198090 - Use AutoInitGCManagedObject when creating UnboxedLayout in TryConvertToUnboxedLayout() r=terrence

This commit is contained in:
Jon Coppeard 2015-08-25 17:01:43 +01:00
parent b045b2738e
commit d892dd0449
3 changed files with 18 additions and 3 deletions

View File

@ -0,0 +1,12 @@
// |jit-test| allow-oom
if (!('oomAtAllocation' in this))
quit();
for (let a of [
null, function() {}, function() {}, null, function() {}, function() {},
function() {}, null, null, null, null, null, null, null, null,
function() {}, null, null, null, function() {}
]) {
oomAtAllocation(5);
}

View File

@ -2180,6 +2180,10 @@ class MOZ_STACK_CLASS AutoInitGCManagedObject
return ptr_.get() != nullptr;
}
T* get() {
return ptr_.get();
}
T* release() {
return ptr_.release();
}

View File

@ -2006,8 +2006,7 @@ js::TryConvertToUnboxedLayout(ExclusiveContext* cx, Shape* templateShape,
return true;
}
UniquePtr<UnboxedLayout, JS::DeletePolicy<UnboxedLayout> > layout;
layout.reset(group->zone()->new_<UnboxedLayout>());
AutoInitGCManagedObject<UnboxedLayout> layout(group->zone()->make_unique<UnboxedLayout>());
if (!layout)
return false;
@ -2063,7 +2062,7 @@ js::TryConvertToUnboxedLayout(ExclusiveContext* cx, Shape* templateShape,
}
group->setClasp(clasp);
group->setUnboxedLayout(layout.get());
group->setUnboxedLayout(layout.release());
size_t valueCursor = 0;
for (size_t i = 0; i < PreliminaryObjectArray::COUNT; i++) {