Skip to content
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

Merged
merged 5 commits into from
Oct 1, 2019

Conversation

bartlomieju
Copy link
Member

Follow up to #3002

@bartlomieju
Copy link
Member Author

bartlomieju commented Oct 1, 2019

Two subjects I'd like to fix before landing this change:

  1. more elegant registration of op in JS
  2. removing state argument from as many ops as possible, effectively that means that json_op and cli_op need to be adjusted to work with each other if we don't want to pass state to the op

Copy link
Member

@ry ry left a 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!

Copy link
Member Author

@bartlomieju bartlomieju left a 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.

Comment on lines +38 to +65

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))),
);
Copy link
Member Author

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;
Copy link
Member Author

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)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Ditto

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

LGTM

@ry ry merged commit 75eeac0 into denoland:master Oct 1, 2019
@bartlomieju bartlomieju deleted the feat-cli_register_op branch October 1, 2019 22:53
@ry ry mentioned this pull request Oct 5, 2019
4 tasks
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.

2 participants