1 // Copyright 2019 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_WASM_C_API_H_ 6 #define V8_WASM_C_API_H_ 7 8 #include "include/v8.h" 9 #include "src/common/globals.h" 10 #include "src/handles/handles.h" 11 #include "third_party/wasm-api/wasm.hh" 12 13 namespace v8 { 14 namespace internal { 15 16 class JSWeakMap; 17 18 } // namespace internal 19 } // namespace v8 20 21 namespace wasm { 22 23 class StoreImpl { 24 public: 25 ~StoreImpl(); 26 isolate()27 v8::Isolate* isolate() const { return isolate_; } i_isolate()28 i::Isolate* i_isolate() const { 29 return reinterpret_cast<i::Isolate*>(isolate_); 30 } 31 context()32 v8::Local<v8::Context> context() const { return context_.Get(isolate_); } 33 get(i::Isolate * isolate)34 static StoreImpl* get(i::Isolate* isolate) { 35 return static_cast<StoreImpl*>( 36 reinterpret_cast<v8::Isolate*>(isolate)->GetData(0)); 37 } 38 39 void SetHostInfo(i::Handle<i::Object> object, void* info, 40 void (*finalizer)(void*)); 41 void* GetHostInfo(i::Handle<i::Object> key); 42 43 private: 44 friend own<Store> Store::make(Engine*); 45 46 StoreImpl() = default; 47 48 v8::Isolate::CreateParams create_params_; 49 v8::Isolate* isolate_ = nullptr; 50 v8::Eternal<v8::Context> context_; 51 i::Handle<i::JSWeakMap> host_info_map_; 52 }; 53 54 } // namespace wasm 55 56 #endif // V8_WASM_C_API_H_ 57