-
Notifications
You must be signed in to change notification settings - Fork 62
Implement Promise.all #797
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
base: main
Are you sure you want to change the base?
Conversation
5013ece
to
d6226b1
Compare
...m/src/ecmascript/builtins/control_abstraction_objects/promise_objects/promise_constructor.rs
Outdated
Show resolved
Hide resolved
297b697
to
493bcde
Compare
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.
Great job so far! The heap addition looks really good, though some parts are missing.
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Outdated
Show resolved
Hide resolved
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Outdated
Show resolved
Hide resolved
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Outdated
Show resolved
Hide resolved
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Outdated
Show resolved
Hide resolved
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Outdated
Show resolved
Hide resolved
...m/src/ecmascript/builtins/control_abstraction_objects/promise_objects/promise_constructor.rs
Outdated
Show resolved
Hide resolved
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Outdated
Show resolved
Hide resolved
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Outdated
Show resolved
Hide resolved
...m/src/ecmascript/builtins/control_abstraction_objects/promise_objects/promise_constructor.rs
Show resolved
Hide resolved
b0bd7ff
to
c86a082
Compare
Hey @aapoalas, I've implemented all your suggestions, could you review again? Notes:
|
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.
Couple of small points around PromiseAll
and PromiseAllRecord
, but generally those were just nitpicks (that we do want to fix though :) ). Generally, this looks exactly correct! Now it's just a matter of finishing up the Promise.all
method itself. Great work! <3
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Outdated
Show resolved
Hide resolved
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Outdated
Show resolved
Hide resolved
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Outdated
Show resolved
Hide resolved
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Outdated
Show resolved
Hide resolved
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Outdated
Show resolved
Hide resolved
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Show resolved
Hide resolved
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Outdated
Show resolved
Hide resolved
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Show resolved
Hide resolved
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Outdated
Show resolved
Hide resolved
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Outdated
Show resolved
Hide resolved
664c2d7
to
c29a1dd
Compare
Hey @aapoalas, I've resolved your comments, and I also fixed the The code does not implement the whole spec yet, but I think it is at a good starting point. Can you review again, please? |
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Outdated
Show resolved
Hide resolved
...ontrol_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs
Outdated
Show resolved
Hide resolved
Yup, looks good to me! Now it's just the spec algorithm; great work <3 |
3f73a5e
to
95e3dad
Compare
Hey @aapoalas, I've implemented the algorithm, can you review again, please? |
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.
The code mostly looks good (just one GC lifetime / use-after-free issue), but it's not exactly what the spec says the method should do. Maybe we could pair program this over the finish line?
...m/src/ecmascript/builtins/control_abstraction_objects/promise_objects/promise_constructor.rs
Outdated
Show resolved
Hide resolved
...m/src/ecmascript/builtins/control_abstraction_objects/promise_objects/promise_constructor.rs
Show resolved
Hide resolved
...m/src/ecmascript/builtins/control_abstraction_objects/promise_objects/promise_constructor.rs
Outdated
Show resolved
Hide resolved
...m/src/ecmascript/builtins/control_abstraction_objects/promise_objects/promise_constructor.rs
Show resolved
Hide resolved
...m/src/ecmascript/builtins/control_abstraction_objects/promise_objects/promise_constructor.rs
Outdated
Show resolved
Hide resolved
...m/src/ecmascript/builtins/control_abstraction_objects/promise_objects/promise_constructor.rs
Outdated
Show resolved
Hide resolved
...m/src/ecmascript/builtins/control_abstraction_objects/promise_objects/promise_constructor.rs
Outdated
Show resolved
Hide resolved
.unbind()? | ||
.bind(gc.nogc()); | ||
|
||
let promise_all_record = agent.heap.create(PromiseAllRecord { |
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.
issue: This PromiseAll
value (which is effectively a reference to the heap) is unbound from the GC lifetime and is thus becomes use-after-free if Promise::resolve
in the array loop triggers GC.
A further issue is that this method doesn't quite do what the spec says in general. The first_arg
argument is supposed to be an iterable type (so eg. a Set or Map would be okay as well), with all the good and bad things that come with that. Supporting that whole all becomes a... whole thing :)
I'm wondering, would you want to pair-program this over the finish line? There's some busy-work to be done (around making the PromiseAll
scopable, iterating iterators), and then the "real" work of translating the spec text. I assume that may be a bit hard to do without help, so pair programming seems like it might be a good solution.
No description provided.