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

Globals versioning #2444

Merged
merged 3 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified canister_templates/experimental.wasm
Binary file not shown.
Binary file modified canister_templates/stable.wasm
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,41 @@ pub fn initialize_js(
"_azleNodeWasmEnvironment",
wasmedge_quickjs::JsValue::Bool(false),
);
context
.get_global()
.set("_azleCanisterMethodNames", context.new_object().into());

context
.get_global()
.set("_azleTimerCallbacks", context.new_object().into());

context
.get_global()
.set("_azleIcTimers", context.new_object().into());

context
.get_global()
.set("_azleRejectCallbacks", context.new_object().into());

context
.get_global()
.set("_azleResolveCallbacks", context.new_object().into());

context
.get_global()
.set("_azleCallbacks", context.new_object().into());

context.get_global().set(
"_azleCanisterMethodsIndex",
wasmedge_quickjs::JsValue::Int(0),
);

context.get_global().set("_azleMethodMeta", {
let mut method_meta = context.new_object();
method_meta.set("queries", context.new_array().into());
method_meta.set("updates", context.new_array().into());
method_meta.into()
});

// TODO what do we do if there is an error in here?
context.eval_global_str("globalThis.exports = {};".to_string());
Expand All @@ -123,6 +158,7 @@ pub fn initialize_js(
"globalThis._azleRecordBenchmarks = {};",
wasm_data.record_benchmarks
));

context.eval_module_str(js.to_string(), &wasm_data.main_js_path);

run_event_loop(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ pub fn initialize_js(

globals.set("_azleExperimental", false)?;

globals.set("_azleCanisterMethodNames", Object::new(ctx.clone())?)?;

globals.set("_azleTimerCallbacks", Object::new(ctx.clone())?)?;

globals.set("_azleIcTimers", Object::new(ctx.clone())?)?;

globals.set("_azleRejectCallbacks", Object::new(ctx.clone())?)?;

globals.set("_azleResolveCallbacks", Object::new(ctx.clone())?)?;

if init {
globals.set("_azleInitCalled", true)?;
globals.set("_azlePostUpgradeCalled", false)?;
Expand Down
9 changes: 0 additions & 9 deletions src/lib/experimental/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@ globalThis._azleInsideCanister =
: true;

if (globalThis._azleInsideCanister === true) {
globalThis._azleCallbacks = {};

globalThis._azleCanisterMethodsIndex = 0;

globalThis._azleMethodMeta = {
queries: [],
updates: []
};

// Even though these are set in stable/globals
// we must set them again here because importing the url module above
// seemingly resets globalThis.TextDecoder and globalThis.TextEncoder
Expand Down
10 changes: 0 additions & 10 deletions src/lib/stable/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ globalThis._azleInsideCanister =
// TODO do we need to disable any other wasmedge-quickjs globals
// TODO that we don't think are stable yet?
if (globalThis._azleInsideCanister === true) {
globalThis._azleCanisterMethodNames = {};

globalThis._azleTimerCallbacks = {};

globalThis._azleIcTimers = {};

globalThis._azleRejectCallbacks = {};

globalThis._azleResolveCallbacks = {};

globalThis.TextDecoder = TextDecoder;
globalThis.TextEncoder = TextEncoder;

Expand Down
Loading