小编mhk*_*mhk的帖子

从嵌入式 v8 调用 WebAssembly,无需 JS

我想直接从我的嵌入式 v8 使用 WebAssembly,而不需要通过 JavaScript 绕道。我使用了提供的hello - world 示例和. 但是,我对如何提取该函数感到困惑。如有帮助,将不胜感激。v8.hadd

#include <include/v8.h>

#include <include/libplatform/libplatform.h>

#include <stdlib.h>
#include <unistd.h>

using v8::HandleScope;
using v8::Isolate;
using v8::Local;
using v8::Promise;
using v8::WasmModuleObjectBuilderStreaming;

int main(int argc, char* argv[]) {
  v8::V8::InitializeICUDefaultLocation(argv[0]);
  v8::V8::InitializeExternalStartupData(argv[0]);
  std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform();
  v8::V8::InitializePlatform(platform.get());
  v8::V8::Initialize();
  Isolate::CreateParams create_params;
  create_params.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator();
  Isolate* isolate = Isolate::New(create_params);
  Isolate::Scope isolate_scope(isolate);
  HandleScope scope(isolate);

  WasmModuleObjectBuilderStreaming stream(isolate);

  // Use the v8 API to generate a WebAssembly module.
  //
  // |bytes| contains the binary format for the following …
Run Code Online (Sandbox Code Playgroud)

c++ v8 webassembly

5
推荐指数
1
解决办法
3015
查看次数

标签 统计

c++ ×1

v8 ×1

webassembly ×1