MySQL 9.3.0
Source Code Documentation
jit_executor::CommonContext Class Reference

Specialization of the Polyglot_common_context to provide MRS specific logging functions as well as the MRS specific engine to be used across the different contexts. More...

#include <jit_executor_common_context.h>

Inheritance diagram for jit_executor::CommonContext:
[legend]

Public Member Functions

 CommonContext (const std::shared_ptr< shcore::polyglot::IFile_system > &fs, const std::vector< std::string > &module_files, const shcore::Dictionary_t &globals, const std::vector< std::string > &isolate_args)
 
 ~CommonContext () override
 
void initialize (const std::vector< std::string > &isolate_args) override
 
void finalize () override
 
bool start ()
 
bool got_fatal_error () const
 
std::string error () const
 
const std::shared_ptr< shcore::polyglot::IFile_system > & file_system () const
 
const shcore::Dictionary_tglobals () const
 
- Public Member Functions inherited from shcore::polyglot::Polyglot_common_context
 Polyglot_common_context ()=default
 
virtual ~Polyglot_common_context ()=default
 
poly_reference engine () const
 
poly_isolate isolate () const
 
poly_thread thread () const
 
void clean_collectables ()
 
Collectable_registrycollectable_registry ()
 

Private Member Functions

void life_cycle_thread ()
 When persisting objects in GraalVM (creating references so they are available across threads/contexts), a reference should be created. More...
 
void fatal_error () override
 
void flush () override
 
void log (const char *bytes, size_t length) override
 
shcore::polyglot::Garbage_collector::Config gc_config () override
 
poly_engine create_engine () override
 Creates the shared engine for the different contexts created with this handler. More...
 

Private Attributes

std::shared_ptr< JavaScriptm_base_context
 
std::shared_ptr< shcore::polyglot::IFile_systemm_file_system
 
std::vector< std::string > m_module_files
 
std::vector< shcore::polyglot::Storem_cached_sources
 
shcore::Dictionary_t m_globals
 
std::unique_ptr< std::thread > m_life_cycle_thread
 
std::mutex m_mutex
 
std::condition_variable m_init_condition
 
bool m_initialized = false
 
bool m_terminated = false
 
std::mutex m_finish_mutex
 
std::condition_variable m_finish_condition
 
bool m_fatal_error
 
std::string m_fatal_error_description
 
std::vector< std::string > m_isolate_args
 

Static Private Attributes

static bool m_global_fatal_error = false
 

Additional Inherited Members

- Protected Attributes inherited from shcore::polyglot::Polyglot_common_context
poly_isolate m_isolate = nullptr
 
poly_thread m_thread = nullptr
 

Detailed Description

Specialization of the Polyglot_common_context to provide MRS specific logging functions as well as the MRS specific engine to be used across the different contexts.

NOTE: Using a shared engine across contexts is meant to enable code sharing, however, even it is enabled, the module files are being loaded on every created context.

Constructor & Destructor Documentation

◆ CommonContext()

jit_executor::CommonContext::CommonContext ( const std::shared_ptr< shcore::polyglot::IFile_system > &  fs,
const std::vector< std::string > &  module_files,
const shcore::Dictionary_t globals,
const std::vector< std::string > &  isolate_args 
)

◆ ~CommonContext()

jit_executor::CommonContext::~CommonContext ( )
override

Member Function Documentation

◆ create_engine()

poly_engine jit_executor::CommonContext::create_engine ( )
overrideprivatevirtual

Creates the shared engine for the different contexts created with this handler.

Returning nullptr (or removing this implementation) would enable the default behavior for Graal which is to create an engine for every context.

Reimplemented from shcore::polyglot::Polyglot_common_context.

◆ error()

std::string jit_executor::CommonContext::error ( ) const
inline

◆ fatal_error()

void jit_executor::CommonContext::fatal_error ( )
overrideprivatevirtual

◆ file_system()

const std::shared_ptr< shcore::polyglot::IFile_system > & jit_executor::CommonContext::file_system ( ) const
inline

◆ finalize()

void jit_executor::CommonContext::finalize ( )
overridevirtual

◆ flush()

void jit_executor::CommonContext::flush ( )
overrideprivatevirtual

◆ gc_config()

shcore::polyglot::Garbage_collector::Config jit_executor::CommonContext::gc_config ( )
inlineoverrideprivatevirtual

◆ globals()

const shcore::Dictionary_t & jit_executor::CommonContext::globals ( ) const
inline

◆ got_fatal_error()

bool jit_executor::CommonContext::got_fatal_error ( ) const
inline

◆ initialize()

void jit_executor::CommonContext::initialize ( const std::vector< std::string > &  isolate_args)
overridevirtual

◆ life_cycle_thread()

void jit_executor::CommonContext::life_cycle_thread ( )
private

When persisting objects in GraalVM (creating references so they are available across threads/contexts), a reference should be created.

Releasing the references should be done on the same thread where they were created.

This function controls the life cycle of the common context, to guarantee the above condition.

◆ log()

void jit_executor::CommonContext::log ( const char *  bytes,
size_t  length 
)
overrideprivatevirtual

◆ start()

bool jit_executor::CommonContext::start ( )

Member Data Documentation

◆ m_base_context

std::shared_ptr<JavaScript> jit_executor::CommonContext::m_base_context
private

◆ m_cached_sources

std::vector<shcore::polyglot::Store> jit_executor::CommonContext::m_cached_sources
private

◆ m_fatal_error

bool jit_executor::CommonContext::m_fatal_error
private

◆ m_fatal_error_description

std::string jit_executor::CommonContext::m_fatal_error_description
private

◆ m_file_system

std::shared_ptr<shcore::polyglot::IFile_system> jit_executor::CommonContext::m_file_system
private

◆ m_finish_condition

std::condition_variable jit_executor::CommonContext::m_finish_condition
private

◆ m_finish_mutex

std::mutex jit_executor::CommonContext::m_finish_mutex
private

◆ m_global_fatal_error

bool jit_executor::CommonContext::m_global_fatal_error = false
staticprivate

◆ m_globals

shcore::Dictionary_t jit_executor::CommonContext::m_globals
private

◆ m_init_condition

std::condition_variable jit_executor::CommonContext::m_init_condition
private

◆ m_initialized

bool jit_executor::CommonContext::m_initialized = false
private

◆ m_isolate_args

std::vector<std::string> jit_executor::CommonContext::m_isolate_args
private

◆ m_life_cycle_thread

std::unique_ptr<std::thread> jit_executor::CommonContext::m_life_cycle_thread
private

◆ m_module_files

std::vector<std::string> jit_executor::CommonContext::m_module_files
private

◆ m_mutex

std::mutex jit_executor::CommonContext::m_mutex
private

◆ m_terminated

bool jit_executor::CommonContext::m_terminated = false
private

The documentation for this class was generated from the following files: