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

Add isolated contexts to PythonMonkey #453

Closed

Conversation

dsetzer
Copy link

@dsetzer dsetzer commented Nov 4, 2024

Fixes #208

Implement isolated JavaScript execution contexts in PythonMonkey.

  • Define Context class in include/modules/pythonmonkey/pythonmonkey.hh to encapsulate JSContext, global object, auto realm, and job queue.
  • Implement Context class in src/modules/pythonmonkey/pythonmonkey.cc for initialization, destruction, and accessing the context.
  • Add createContext, evalInContext, and cleanupContexts functions in src/modules/pythonmonkey/pythonmonkey.cc to manage multiple contexts.
  • Update eval function in src/modules/pythonmonkey/pythonmonkey.cc to accept a context ID and evaluate JavaScript code within the specified context.
  • Update module initialization in src/modules/pythonmonkey/pythonmonkey.cc to include the context function.
  • Add SuperGlobalContext class in include/modules/pythonmonkey/pythonmonkey.hh to encapsulate shared JSContext, global object, auto realm, and job queue.
  • Implement SuperGlobalContext class in src/modules/pythonmonkey/pythonmonkey.cc for initialization and cleanup of shared resources.
  • Update Context class to reference SuperGlobalContext for shared resources.
  • Modify evalInContext function to use SuperGlobalContext for shared resources.
  • Make SuperGlobalContext accessible through a GLOBAL_CX variable.
  • Update JobQueue class in include/JobQueue.hh and src/JobQueue.cc to accept a JSContext in the constructor.
  • Update various proxy classes in src/JSMethodProxy.cc, src/JSObjectItemsProxy.cc, src/JSObjectIterProxy.cc, src/JSObjectKeysProxy.cc, src/JSObjectProxy.cc, and src/JSStringProxy.cc to use the Context object instead of the global GLOBAL_CX variable.

Fixes Distributive-Network#208

Implement isolated JavaScript execution contexts in PythonMonkey.

* Define `Context` class in `include/modules/pythonmonkey/pythonmonkey.hh` to encapsulate JSContext, global object, auto realm, and job queue.
* Implement `Context` class in `src/modules/pythonmonkey/pythonmonkey.cc` for initialization, destruction, and accessing the context.
* Add `createContext`, `evalInContext`, and `cleanupContexts` functions in `src/modules/pythonmonkey/pythonmonkey.cc` to manage multiple contexts.
* Update `eval` function in `src/modules/pythonmonkey/pythonmonkey.cc` to accept a context ID and evaluate JavaScript code within the specified context.
* Update module initialization in `src/modules/pythonmonkey/pythonmonkey.cc` to include the `context` function.
* Add `SuperGlobalContext` class in `include/modules/pythonmonkey/pythonmonkey.hh` to encapsulate shared JSContext, global object, auto realm, and job queue.
* Implement `SuperGlobalContext` class in `src/modules/pythonmonkey/pythonmonkey.cc` for initialization and cleanup of shared resources.
* Update `Context` class to reference `SuperGlobalContext` for shared resources.
* Modify `evalInContext` function to use `SuperGlobalContext` for shared resources.
* Make `SuperGlobalContext` accessible through a `GLOBAL_CX` variable.
* Update `JobQueue` class in `include/JobQueue.hh` and `src/JobQueue.cc` to accept a JSContext in the constructor.
* Update various proxy classes in `src/JSMethodProxy.cc`, `src/JSObjectItemsProxy.cc`, `src/JSObjectIterProxy.cc`, `src/JSObjectKeysProxy.cc`, `src/JSObjectProxy.cc`, and `src/JSStringProxy.cc` to use the `Context` object instead of the global `GLOBAL_CX` variable.
@dsetzer dsetzer closed this Nov 4, 2024
@dsetzer
Copy link
Author

dsetzer commented Nov 4, 2024

woops didn't mean to create this

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.

Isolating execution via separate contexts
1 participant