Skip to content

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Jun 17, 2022

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.


def parse_dylink_section(self):
if self._have_cached_section_info('dylink'):
return self._get_cached_section_info('dylink')
Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

@sbc100 sbc100 force-pushed the webassembly_python_cleanup branch from 77761f3 to 9f84e85 Compare June 17, 2022 20:25
@sbc100 sbc100 requested review from dschuff and kripken June 17, 2022 20:25
def has_name_section(self):
return self.get_custom_section('name') is not None

_done_read_imports = False
Copy link
Member

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?

Copy link
Collaborator Author

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..

Copy link
Member

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.

@sbc100 sbc100 force-pushed the webassembly_python_cleanup branch from 9f84e85 to 0a23342 Compare June 17, 2022 21:49
def has_name_section(self):
return self.get_custom_section('name') is not None

_done_read_imports = False
Copy link
Member

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.

@sbc100 sbc100 force-pushed the webassembly_python_cleanup branch from 0a23342 to 9d48fd8 Compare June 17, 2022 21:55
@sbc100
Copy link
Collaborator Author

sbc100 commented Jun 17, 2022

Seems that once is only in 3.9 .. fixed.. and created @once too.

return leb128.i.decode_reader(iobuf)[0]


# TODO(sbc): Use the builtin functools.cache once we update to python 3.9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😞

@dschuff
Copy link
Member

dschuff commented Jun 17, 2022

LGTM

@sbc100 sbc100 force-pushed the webassembly_python_cleanup branch from 9d48fd8 to 6cc9ad1 Compare June 17, 2022 22:01
@sbc100 sbc100 enabled auto-merge (squash) June 17, 2022 22:01
@sbc100 sbc100 force-pushed the webassembly_python_cleanup branch from 6cc9ad1 to 77dea47 Compare June 17, 2022 22:08
… 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.
@sbc100 sbc100 force-pushed the webassembly_python_cleanup branch from 77dea47 to af7703a Compare June 17, 2022 23:54
@sbc100 sbc100 merged commit 1706b8e into main Jun 18, 2022
@sbc100 sbc100 deleted the webassembly_python_cleanup branch June 18, 2022 00:58
sbc100 added a commit that referenced this pull request Jun 19, 2022
sbc100 added a commit that referenced this pull request Jun 19, 2022
sbc100 added a commit that referenced this pull request Jun 19, 2022
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```
sbc100 added a commit that referenced this pull request Jun 19, 2022
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```
sbc100 added a commit that referenced this pull request Jun 19, 2022
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```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants