MCPcopy Create free account
hub / github.com/WebAssembly/wasm-c-api / StoreImpl

Class StoreImpl

src/wasm-v8.cc:314–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

312};
313
314struct StoreImpl : Store {
315 friend own<Store> Store::make(Engine*);
316
317 v8::Isolate::CreateParams create_params_;
318 v8::Isolate* isolate_;
319 v8::Eternal<v8::Context> context_;
320 v8::Eternal<v8::String> strings_[V8_S_COUNT];
321 v8::Eternal<v8::Symbol> symbols_[V8_Y_COUNT];
322 v8::Eternal<v8::Function> functions_[V8_F_COUNT];
323 v8::Eternal<v8::Object> host_data_map_;
324 v8::Eternal<v8::Symbol> callback_symbol_;
325 v8::Persistent<v8::Object>* handle_pool_ = nullptr; // TODO: use v8::Value
326
327 StoreImpl() {
328 stats.make(Stats::STORE, this);
329 }
330
331 ~StoreImpl() {
332#ifdef WASM_API_DEBUG
333 isolate_->RequestGarbageCollectionForTesting(
334 v8::Isolate::kFullGarbageCollection);
335#endif
336 {
337 v8::HandleScope scope(isolate_);
338 while (handle_pool_ != nullptr) {
339 auto handle = handle_pool_;
340 handle_pool_ = reinterpret_cast<v8::Persistent<v8::Object>*>(
341 wasm_v8::foreign_get(handle->Get(isolate_)));
342 delete handle;
343 }
344 }
345 context()->Exit();
346 isolate_->Exit();
347 isolate_->Dispose();
348 delete create_params_.array_buffer_allocator;
349 stats.free(Stats::STORE, this);
350 }
351
352 auto isolate() const -> v8::Isolate* {
353 return isolate_;
354 }
355
356 auto context() const -> v8::Local<v8::Context> {
357 return context_.Get(isolate_);
358 }
359
360 auto v8_string(v8_string_t i) const -> v8::Local<v8::String> {
361 return strings_[i].Get(isolate_);
362 }
363 auto v8_string(v8_symbol_t i) const -> v8::Local<v8::Symbol> {
364 return symbols_[i].Get(isolate_);
365 }
366 auto v8_function(v8_function_t i) const -> v8::Local<v8::Function> {
367 return functions_[i].Get(isolate_);
368 }
369
370 auto host_data_map() const -> v8::Local<v8::Object> {
371 return host_data_map_.Get(isolate_);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected