Skip to content

Commit

Permalink
Bug 1743357 - Part 3: Remove CompilationStencil::steal. r=nbp
Browse files Browse the repository at this point in the history
Depends on D132356

Differential Revision: https://phabricator.services.mozilla.com/D132357
  • Loading branch information
arai-a committed Nov 30, 2021
1 parent f477e80 commit 494b4dd
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 83 deletions.
3 changes: 0 additions & 3 deletions js/src/frontend/CompilationStencil.h
Original file line number Diff line number Diff line change
Expand Up @@ -1148,9 +1148,6 @@ struct CompilationStencil {
return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf);
}

// Steal ExtensibleCompilationStencil content.
[[nodiscard]] bool steal(JSContext* cx, ExtensibleCompilationStencil&& other);

bool isModule() const;

#ifdef DEBUG
Expand Down
80 changes: 0 additions & 80 deletions js/src/frontend/Stencil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2533,86 +2533,6 @@ void ExtensibleCompilationStencil::assertNoExternalDependency() const {
}
#endif // DEBUG

template <typename T, typename VectorT>
bool CopyVectorToSpan(JSContext* cx, LifoAlloc& alloc, mozilla::Span<T>& span,
VectorT& vec) {
auto len = vec.length();
if (len == 0) {
return true;
}

auto* p = alloc.newArrayUninitialized<T>(len);
if (!p) {
js::ReportOutOfMemory(cx);
return false;
}
span = mozilla::Span(p, len);
memcpy(span.data(), vec.begin(), sizeof(T) * len);
return true;
}

bool CompilationStencil::steal(JSContext* cx,
ExtensibleCompilationStencil&& other) {
#ifdef DEBUG
other.assertNoExternalDependency();
#endif

canLazilyParse = other.canLazilyParse;
functionKey = other.functionKey;

MOZ_ASSERT(alloc.isEmpty());
alloc.steal(&other.alloc);

if (!CopyVectorToSpan(cx, alloc, scriptData, other.scriptData)) {
return false;
}

if (!CopyVectorToSpan(cx, alloc, scriptExtra, other.scriptExtra)) {
return false;
}

if (!CopyVectorToSpan(cx, alloc, gcThingData, other.gcThingData)) {
return false;
}

if (!CopyVectorToSpan(cx, alloc, scopeData, other.scopeData)) {
return false;
}

if (!CopyVectorToSpan(cx, alloc, scopeNames, other.scopeNames)) {
return false;
}

if (!CopyVectorToSpan(cx, alloc, regExpData, other.regExpData)) {
return false;
}

if (!CopyVectorToSpan(cx, alloc, bigIntData, other.bigIntData)) {
return false;
}

if (!CopyVectorToSpan(cx, alloc, objLiteralData, other.objLiteralData)) {
return false;
}

if (!CopyVectorToSpan(cx, alloc, parserAtomData,
other.parserAtoms.entries())) {
return false;
}

sharedData = std::move(other.sharedData);

moduleMetadata = std::move(other.moduleMetadata);

asmJS = std::move(other.asmJS);

#ifdef DEBUG
assertNoExternalDependency();
#endif

return true;
}

template <typename T, typename VectorT>
[[nodiscard]] bool CopySpanToVector(JSContext* cx, VectorT& vec,
mozilla::Span<T>& span) {
Expand Down

0 comments on commit 494b4dd

Please sign in to comment.