-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
feat: Use Isolate.register_op in CLI, take 2 #3039
Conversation
Two subjects I'd like to fix before landing this change:
|
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.
+308 −463
This is a good indication!
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.
@ry this PR is ready for review. I hit the wall for JS API - suggestions welcome.
|
||
i.register_op("read", state_.cli_op(minimal_op(io::op_read))); | ||
i.register_op("write", state_.cli_op(minimal_op(io::op_write))); | ||
|
||
i.register_op( | ||
"exit", | ||
state_.cli_op(json_op(state_.stateful_op(os::op_exit))), | ||
); | ||
i.register_op( | ||
"is_tty", | ||
state_.cli_op(json_op(state_.stateful_op(os::op_is_tty))), | ||
); | ||
i.register_op( | ||
"env", | ||
state_.cli_op(json_op(state_.stateful_op(os::op_env))), | ||
); | ||
i.register_op( | ||
"exec_path", | ||
state_.cli_op(json_op(state_.stateful_op(os::op_exec_path))), | ||
); | ||
i.register_op( | ||
"utime", | ||
state_.cli_op(json_op(state_.stateful_op(fs::op_utime))), | ||
); | ||
i.register_op( | ||
"set_env", | ||
state_.cli_op(json_op(state_.stateful_op(os::op_set_env))), | ||
); |
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.
This is ripe for abstraction - we need to do it anyway, because there we still need to provide different ops for different workers (see #1858)
export const OP_FETCH_ASSET = 57; | ||
export const OP_DIAL_TLS = 58; | ||
export const OP_HOSTNAME = 59; | ||
export let OP_READ: number; |
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.
This solution works for now - but we need to figure out how to do it elegantly. Fundamentally we need to keep in mind that op id
cannot be retrieved until runtime (especially not during snapshotting).
Ref #3025
const ops = core.ops(); | ||
// TODO(bartlomieju): this is a prototype, we should come up with | ||
// something a bit more sophisticated | ||
for (const [name, opId] of Object.entries(ops)) { |
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.
Ditto
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
Follow up to #3002