forked from mirrors/gecko-dev
Bug 1894025 - Throw error rather than asserting when newDependentString creates string in different heap than requested r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D208958
This commit is contained in:
parent
0749f6bcdf
commit
51448578a2
2 changed files with 23 additions and 4 deletions
|
|
@ -3782,10 +3782,14 @@ static bool NewDependentString(JSContext* cx, unsigned argc, Value* vp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requiredHeap.isSome()) {
|
if (requiredHeap.isSome()) {
|
||||||
MOZ_ASSERT_IF(*requiredHeap == gc::Heap::Tenured, result->isTenured());
|
if ((*requiredHeap == gc::Heap::Tenured) != result->isTenured()) {
|
||||||
if ((*requiredHeap == gc::Heap::Default) && result->isTenured()) {
|
if (result->isTenured()) {
|
||||||
JS_ReportErrorASCII(cx, "nursery string created in tenured heap");
|
JS_ReportErrorASCII(cx, "nursery string created in tenured heap");
|
||||||
return false;
|
return false;
|
||||||
|
} else {
|
||||||
|
JS_ReportErrorASCII(cx, "tenured string created in nursery heap");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
15
js/src/jit-test/tests/gc/bug-1894025.js
Normal file
15
js/src/jit-test/tests/gc/bug-1894025.js
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
gczeal(0);
|
||||||
|
|
||||||
|
var ex;
|
||||||
|
function makeExtensibleStrFrom() {
|
||||||
|
strstrstr;
|
||||||
|
}
|
||||||
|
a = makeExtensibleStrFrom;
|
||||||
|
b = newDependentString(a, 0, 50, { tenured: false })
|
||||||
|
var exc;
|
||||||
|
try {
|
||||||
|
c = newDependentString(b, 0, { tenured: true })
|
||||||
|
} catch (e) {
|
||||||
|
exc = e;
|
||||||
|
}
|
||||||
|
assertEq(Boolean(exc), true, "b and c required to be in different heaps but are the same");
|
||||||
Loading…
Reference in a new issue