-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Simplify extract_metadata.py by moving logic in tools/webassembly.py. NFC #17255
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
Conversation
tools/webassembly.py
Outdated
|
|
||
| def parse_dylink_section(self): | ||
| if self._have_cached_section_info('dylink'): | ||
| return self._get_cached_section_info('dylink') |
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.
I should probably turn this into a decorator... but maybe as a followup.
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.
Oh wait.. I can just use @functools memoization instead of all this.
77761f3 to
9f84e85
Compare
tools/webassembly.py
Outdated
| def has_name_section(self): | ||
| return self.get_custom_section('name') is not None | ||
|
|
||
| _done_read_imports = False |
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.
can this just be turned into @cache too?
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.
Its seems like a slightly different use case.. since it doesn't return anything. But in theory yes I think so..
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.
Ah, right, it would be a bit weird. Well, either way is fine; I just noticed that it was asymmetric.
9f84e85 to
0a23342
Compare
tools/webassembly.py
Outdated
| def has_name_section(self): | ||
| return self.get_custom_section('name') is not None | ||
|
|
||
| _done_read_imports = False |
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.
Ah, right, it would be a bit weird. Well, either way is fine; I just noticed that it was asymmetric.
0a23342 to
9d48fd8
Compare
|
Seems that |
| return leb128.i.decode_reader(iobuf)[0] | ||
|
|
||
|
|
||
| # TODO(sbc): Use the builtin functools.cache once we update to python 3.9 |
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.
😞
|
LGTM |
9d48fd8 to
6cc9ad1
Compare
6cc9ad1 to
77dea47
Compare
… NFC This creates a caching layer and some extra helper functions on the module object which avoid the need to track start such as the number of imports elements of a given type.
77dea47 to
af7703a
Compare
These was a bug in my imlemenation of `@cache` that I added in #17255 where it was keeping the underlying wasm file open and never actually closing it. This is because I was using the incoming arguments as the hash key instead of their hash value. The bug only manifested on windows where open files are locked in some way prevented futher actions from modifying them and resulting is a strange error: ```llvm-objcopy.exe: error: permission denied```
These was a bug in my imlemenation of `@cache` that I added in #17255 where it was keeping the underlying wasm file open and never actually closing it. This is because I was using the incoming arguments as the hash key instead of their hash value. The bug only manifested on windows where open files are locked in some way prevented futher actions from modifying them and resulting is a strange error: ```llvm-objcopy.exe: error: permission denied```
These was a bug in my implementation of `@cache` that I added in #17255 where it was keeping the underlying wasm file open and never actually closing it. This is because I was using the incoming arguments as the hash key instead of their hash value. The bug only manifested on windows where open files are locked in some way prevented further actions from modifying them and resulting is a strange error: ```llvm-objcopy.exe: error: permission denied```
This creates a caching layer and some extra helper functions on the
module object which avoid the need to track start such as the number
of imports elements of a given type.