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

Commits on Nov 4, 2024

  1. Add isolated contexts to PythonMonkey

    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 committed Nov 4, 2024
    Configuration menu
    Copy the full SHA
    32f4dac View commit details
    Browse the repository at this point in the history