Skip to content

Commit

Permalink
don't save the sourceMapURL unless -g3 is set
Browse files Browse the repository at this point in the history
Summary:
The source map URL is only needed by the debugger, so there is no point
in storing it unless we are compiling with fill debug info. This becomes
a real issue if the URL is a data URL and contains the entire source map
- the size can be significant.

Reviewed By: neildhar

Differential Revision: D49274449

fbshipit-source-id: ebb483915fccf884126bd6051c3c5dc13dd2cddd
  • Loading branch information
Tzvetan Mikov authored and facebook-github-bot committed Sep 15, 2023
1 parent 8f9ff00 commit 6d04fa1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/BCGen/HBC/ISel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,18 @@ inline FileAndSourceMapId HBCISel::obtainFileAndSourceMapId(
uint32_t currentFilenameId = BCFGen_->addFilename(filename);
uint32_t currentSourceMappingUrlId;

auto sourceMappingUrl = sm.getSourceMappingUrl(bufId);
llvh::StringRef sourceMappingUrl{};
// Only fetch the source map URL if we are not stripping it and if we are
// generating full debug info.
if (!bytecodeGenerationOptions_.stripSourceMappingURL &&
F_->getContext().getDebugInfoSetting() >= DebugInfoSetting::ALL) {
sourceMappingUrl = sm.getSourceMappingUrl(bufId);
}

// Lazily compiled functions ask to strip the source mapping URL because
// it was already encoded in the top level module, and it could be a 1MB+
// data url that we don't want to duplicate once per function.
if (sourceMappingUrl.empty() ||
bytecodeGenerationOptions_.stripSourceMappingURL) {
if (sourceMappingUrl.empty()) {
currentSourceMappingUrlId = facebook::hermes::debugger::kInvalidBreakpoint;
} else {
// NOTE: this is potentially a very expensive operation, since the source
Expand Down

0 comments on commit 6d04fa1

Please sign in to comment.