-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
internal: data-oriented storage for TLib
#797
Merged
chore-runner
merged 3 commits into
nim-works:devel
from
zerbina:data-oriented-lib-storage
Jul 15, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -29,6 +29,7 @@ import | |||||
idents, | ||||||
], | ||||||
compiler/utils/[ | ||||||
containers, | ||||||
pathutils, | ||||||
btrees, | ||||||
ropes, | ||||||
|
@@ -98,6 +99,8 @@ type | |||||
enumToStringProcs*: Table[ItemId, LazySym] | ||||||
emittedTypeInfo*: Table[string, FileIndex] | ||||||
|
||||||
libs*: seq[seq[TLib]] ## indexed by ``LibId`` | ||||||
|
||||||
startupPackedConfig*: PackedConfig | ||||||
packageSyms*: TStrTable | ||||||
deps*: IntSet # the dependency graph or potentially its transitive closure. | ||||||
|
@@ -377,6 +380,24 @@ proc getToStringProc*(g: ModuleGraph; t: PType): PSym = | |||||
proc setToStringProc*(g: ModuleGraph; t: PType; value: PSym) = | ||||||
g.enumToStringProcs[t.itemId] = LazySym(sym: value) | ||||||
|
||||||
func getLib*(g: ModuleGraph, id: LibId): var TLib = | ||||||
assert not isNil(id), "id is 'none'" | ||||||
result = g.libs[id.module][id.index - 1] | ||||||
|
||||||
proc addLib*(g: ModuleGraph, module: int, lib: sink TLib): LibId = | ||||||
## Registers (adds) `lib` with the given module and returns the ID through | ||||||
## which the instance can be accessed from now on. | ||||||
g.libs[module].add lib | ||||||
# the index is 1-based, so we can directly use the length | ||||||
result = LibId(module: module.int32, index: g.libs[module].len.uint32) | ||||||
|
||||||
proc storeLibs*(g: ModuleGraph, module: int) = | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
jk jk 😆 |
||||||
## Writes the ``TLib`` instances associated with `module` to the module's | ||||||
## packed representation. Only relevant for IC. | ||||||
if g.config.symbolFiles != disabledSf: | ||||||
for lib in g.libs[module].items: | ||||||
storeLib(g.encoders[module], g.packed[module].fromDisk, lib) | ||||||
|
||||||
iterator methodsForGeneric*(g: ModuleGraph; t: PType): (int, PSym) = | ||||||
if g.methodsPerType.contains(t.itemId): | ||||||
for it in mitems g.methodsPerType[t.itemId]: | ||||||
|
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth adding a
unknownLibId
or the like as a constant below to further 'reserve' the concept of the default valueLibId(module: 0, index: 0)
as none.Update: reading more of the PR, there is a similar tuple type for IC, so we wouldn't end up using that const/this object type all that much. Seems less worth it practically speaking, mostly there to signal intent.