Store snapshot templates in isolate, not context.

This lets us load the isolate without having to create a temp/dummy context
just to get the templates.

Call ContextDisposedNotification when a context is removed. Supposedly this can
help/hint to the isolate about memory management.
This commit is contained in:
Karl Seguin
2026-01-05 19:05:44 +08:00
parent 2322cb9b83
commit 86f4ea108d
5 changed files with 8 additions and 7 deletions

View File

@@ -93,14 +93,10 @@ pub fn init(allocator: Allocator, platform: *const Platform, snapshot: *Snapshot
var temp_scope: js.HandleScope = undefined;
temp_scope.init(isolate);
defer temp_scope.deinit();
const context_handle = isolate.createContextHandle(null, null);
v8.v8__Context__Enter(context_handle);
defer v8.v8__Context__Exit(context_handle);
inline for (JsApis, 0..) |JsApi, i| {
JsApi.Meta.class_id = i;
const data = v8.v8__Context__GetDataFromSnapshotOnce(context_handle, snapshot.data_start + i);
const data = v8.v8__Isolate__GetDataFromSnapshotOnce(isolate.handle, snapshot.data_start + i);
const function_handle: *const v8.FunctionTemplate = @ptrCast(data);
// Make function template global/persistent
v8.v8__Global__New(isolate.handle, @ptrCast(function_handle), &globals[i]);