Backed out 18 changesets (bug 1311726) for causing Hazard failures at ScriptLoader.cpp:. CLOSED TREE

Backed out changeset 0e1179305bc2 (bug 1311726)
Backed out changeset fd3a9e4f5e5e (bug 1311726)
Backed out changeset d6f6a7d13dc2 (bug 1311726)
Backed out changeset 7b266f1fbbff (bug 1311726)
Backed out changeset 9ecb9ac4f2f7 (bug 1311726)
Backed out changeset 2deb35690efb (bug 1311726)
Backed out changeset a151ddb7068d (bug 1311726)
Backed out changeset 79aac20615b8 (bug 1311726)
Backed out changeset 258188246118 (bug 1311726)
Backed out changeset 0ef6c06dac5b (bug 1311726)
Backed out changeset 340bd3d73849 (bug 1311726)
Backed out changeset d130a9772d31 (bug 1311726)
Backed out changeset 15df1b7e0208 (bug 1311726)
Backed out changeset ebc87f932050 (bug 1311726)
Backed out changeset 68ab853d072d (bug 1311726)
Backed out changeset eac12c9d76b7 (bug 1311726)
Backed out changeset beb9e9b17522 (bug 1311726)
Backed out changeset bfea110e6afe (bug 1311726)
This commit is contained in:
Butkovits Atila
2021-12-09 02:23:18 +02:00
parent 1365ffc7cd
commit 9982657a6a
9 changed files with 1297 additions and 1564 deletions

View File

@@ -5,7 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ScriptLoadRequest.h"
#include "GeckoProfiler.h"
#include "mozilla/dom/Document.h"
#include "mozilla/HoldDropJSObjects.h"
@@ -14,7 +13,6 @@
#include "mozilla/Utf8.h" // mozilla::Utf8Unit
#include "js/OffThreadScriptCompilation.h"
#include "js/SourceText.h"
#include "ModuleLoadRequest.h"
#include "nsContentUtils.h"
@@ -24,8 +22,6 @@
#include "ScriptLoadRequest.h"
#include "ScriptSettings.h"
using JS::SourceText;
namespace mozilla {
namespace dom {
@@ -276,104 +272,6 @@ void ScriptLoadRequest::SetIsLoadRequest(nsIScriptElement* aElement) {
mFetchOptions->mIsPreload = false;
}
nsresult ScriptLoadRequest::GetScriptSource(JSContext* aCx,
MaybeSourceText* aMaybeSource) {
// If there's no script text, we try to get it from the element
if (mIsInline) {
nsAutoString inlineData;
GetScriptElement()->GetScriptText(inlineData);
size_t nbytes = inlineData.Length() * sizeof(char16_t);
JS::UniqueTwoByteChars chars(
static_cast<char16_t*>(JS_malloc(aCx, nbytes)));
if (!chars) {
return NS_ERROR_OUT_OF_MEMORY;
}
memcpy(chars.get(), inlineData.get(), nbytes);
SourceText<char16_t> srcBuf;
if (!srcBuf.init(aCx, std::move(chars), inlineData.Length())) {
return NS_ERROR_OUT_OF_MEMORY;
}
aMaybeSource->construct<SourceText<char16_t>>(std::move(srcBuf));
return NS_OK;
}
size_t length = ScriptTextLength();
if (IsUTF16Text()) {
JS::UniqueTwoByteChars chars;
chars.reset(ScriptText<char16_t>().extractOrCopyRawBuffer());
if (!chars) {
JS_ReportOutOfMemory(aCx);
return NS_ERROR_OUT_OF_MEMORY;
}
SourceText<char16_t> srcBuf;
if (!srcBuf.init(aCx, std::move(chars), length)) {
return NS_ERROR_OUT_OF_MEMORY;
}
aMaybeSource->construct<SourceText<char16_t>>(std::move(srcBuf));
return NS_OK;
}
MOZ_ASSERT(IsUTF8Text());
UniquePtr<Utf8Unit[], JS::FreePolicy> chars;
chars.reset(ScriptText<Utf8Unit>().extractOrCopyRawBuffer());
if (!chars) {
JS_ReportOutOfMemory(aCx);
return NS_ERROR_OUT_OF_MEMORY;
}
SourceText<Utf8Unit> srcBuf;
if (!srcBuf.init(aCx, std::move(chars), length)) {
return NS_ERROR_OUT_OF_MEMORY;
}
aMaybeSource->construct<SourceText<Utf8Unit>>(std::move(srcBuf));
return NS_OK;
}
void ScriptLoadRequest::GetProfilerLabel(nsACString& aOutString) {
if (!profiler_is_active()) {
aOutString.Append("<script> element");
return;
}
aOutString.Append("<script");
if (IsAsyncScript()) {
aOutString.Append(" async");
} else if (IsDeferredScript()) {
aOutString.Append(" defer");
}
if (IsModuleRequest()) {
aOutString.Append(" type=\"module\"");
}
nsAutoCString url;
if (mURI) {
mURI->GetAsciiSpec(url);
} else {
url = "<unknown>";
}
if (mIsInline) {
if (GetParserCreated() != NOT_FROM_PARSER) {
aOutString.Append("> inline at line ");
aOutString.AppendInt(mLineNo);
aOutString.Append(" of ");
} else {
aOutString.Append("> inline (dynamically created) in ");
}
aOutString.Append(url);
} else {
aOutString.Append(" src=\"");
aOutString.Append(url);
aOutString.Append("\">");
}
}
//////////////////////////////////////////////////////////////
// ScriptLoadRequestList
//////////////////////////////////////////////////////////////