-
Notifications
You must be signed in to change notification settings - Fork 650
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Share FileAndSourceMapIdCache between lazy compilation invocations
Summary: It is possible for the `sourceMappingURL` to be tens of MB, resulting in slow lookups, which is why this cache exists. It's not reused between lazy compilations when it's instantiated inside `BytecodeModuleGenerator`, so allow it to be passed in and store it in `BCProviderFromSrc` for lazy compilation purposes. This wasn't a problem in Hermes because the `stripSourceMappingURL` option was being provided to the lazy compilation invocations, but that seemed more fragile than just doing everything the same and reusing the cache for performance optimization. This is made easy enough by moving the definitions into their own header to avoid circular dependencies in the HBC directory. Reviewed By: neildhar Differential Revision: D68166926 fbshipit-source-id: 14f52273f4642df91dca2db0ca2011fa11b9a4f6
- Loading branch information
1 parent
9d2971f
commit ffbf125
Showing
8 changed files
with
65 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "llvh/ADT/DenseMap.h" | ||
|
||
#include <cstdint> | ||
|
||
namespace hermes::hbc { | ||
|
||
/// The filename ID and source map URL ID of a buffer. | ||
struct FileAndSourceMapId { | ||
/// ID of the filename when added to BytecodeFunctionGenerator. | ||
uint32_t filenameId; | ||
/// ID of the source map URL when added as a file to | ||
/// BytecodeFunctionGenerator. | ||
uint32_t sourceMappingUrlId; | ||
}; | ||
|
||
/// A map from buffer ID to filelname+source map. | ||
/// Looking up filename/sourcemap id for each instruction is pretty slow, | ||
/// so we cache it. | ||
using FileAndSourceMapIdCache = | ||
llvh::SmallDenseMap<unsigned, FileAndSourceMapId>; | ||
|
||
} // namespace hermes::hbc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters