Backed out changeset 873ca890a187 (bug 1827072) for causing nightly as release bustages. CLOSED TREE

This commit is contained in:
Cosmin Sabou 2023-04-14 09:37:53 +03:00
parent 075869d7bf
commit fc457bde73
4 changed files with 10 additions and 23 deletions

View File

@ -3358,10 +3358,6 @@ static bool NewString(JSContext* cx, unsigned argc, Value* vp) {
if (capacity < len) {
capacity = len;
}
if (len == 0) {
JS_ReportErrorASCII(cx, "Cannot set capacity of empty string");
return false;
}
if (stable.isLatin1()) {
auto news = cx->make_pod_arena_array<JS::Latin1Char>(
js::StringBufferArena, capacity);

View File

@ -1,2 +0,0 @@
try { newString("", { capacity: 1 }); } catch (e) { };
newString("x", { capacity: 2, tenured: true });

View File

@ -395,19 +395,6 @@ void JSString::dumpRepresentationHeader(js::GenericPrinter& out,
out.putChar('\n');
}
JSExtensibleString& JSLinearString::makeExtensible(size_t capacity) {
MOZ_ASSERT(!isDependent());
MOZ_ASSERT(!isInline());
MOZ_ASSERT(!isAtom());
MOZ_ASSERT(!isExternal());
MOZ_ASSERT(capacity >= length());
js::RemoveCellMemory(this, allocSize(), js::MemoryUse::StringContents);
setLengthAndFlags(length(), flags() | EXTENSIBLE_FLAGS);
d.s.u3.capacity = capacity;
js::AddCellMemory(this, allocSize(), js::MemoryUse::StringContents);
return asExtensible();
}
void JSLinearString::dumpRepresentationChars(js::GenericPrinter& out,
int indent) const {
if (hasLatin1Chars()) {

View File

@ -843,10 +843,16 @@ class JSLinearString : public JSString {
JSContext* cx, js::UniquePtr<CharT[], JS::FreePolicy> chars,
size_t length, js::gc::InitialHeap heap);
// Convert a plain linear string to an extensible string. For testing. The
// caller must ensure that it is a plain or extensible string already, and
// that `capacity` is adequate.
JSExtensibleString& makeExtensible(size_t capacity);
JSExtensibleString& makeExtensible(size_t capacity) {
MOZ_ASSERT(!isDependent());
MOZ_ASSERT(!isInline());
MOZ_ASSERT(!isAtom());
MOZ_ASSERT(!isExternal());
MOZ_ASSERT(capacity >= length());
setLengthAndFlags(length(), flags() | EXTENSIBLE_FLAGS);
d.s.u3.capacity = capacity;
return asExtensible();
}
template <typename CharT>
MOZ_ALWAYS_INLINE const CharT* nonInlineChars(