Skip to content

Commit

Permalink
Add WIP V8 Preload changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ohad Rau committed Jul 10, 2019
1 parent c2ab560 commit 6d6f699
Show file tree
Hide file tree
Showing 63 changed files with 1,931 additions and 58 deletions.
3 changes: 3 additions & 0 deletions deps/v8/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1971,12 +1971,15 @@ v8_source_set("v8_base_without_compiler") {
"include/v8-util.h",
"include/v8-wasm-trap-handler-posix.h",
"include/v8.h",
"include/v8-wasm.h"
"include/v8config.h",
"src/api/api-arguments-inl.h",
"src/api/api-arguments.cc",
"src/api/api-arguments.h",
"src/api/api-natives.cc",
"src/api/api-natives.h",
"src/api/api-wasm.cc",
"src/api/api-wasm.h",
"src/api/api.cc",
"src/api/api.h",
"src/asmjs/asm-js.cc",
Expand Down
87 changes: 87 additions & 0 deletions deps/v8/include/v8-wasm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef INCLUDE_V8_WASM_H_
#define INCLUDE_V8_WASM_H_

#include <cstdint>
#include <cstddef>
#include "v8.h"

namespace v8 {
namespace wasm {

class V8_EXPORT Memory {
public:
Memory(size_t pages, uint8_t* data);
size_t size();
size_t pages();
uint8_t* data();
};

class V8_EXPORT Context {
public:
explicit Context(Memory* memory);
Context(Memory* memory, Isolate* isolate);
Memory* memory;
Isolate* isolate;
};

enum V8_EXPORT ValKind : uint8_t {
I32,
I64,
F32,
F64,
ANYREF = 128,
FUNCREF
};

class V8_EXPORT Val {
public:
Val();
Val(Val&&);
explicit Val(int32_t i);
explicit Val(int64_t i);
explicit Val(float i);
explicit Val(double i);
explicit Val(void* r);

Val& operator=(Val&&);

ValKind kind() const;
int32_t i32() const;
int64_t i64() const;
float f32() const;
double f64() const;
void* ref() const;
};

class V8_EXPORT FuncType {
public:
FuncType(std::vector<ValKind> params, std::vector<ValKind> results);

std::vector<ValKind> params() const;
std::vector<ValKind> results() const;
};

class V8_EXPORT Func {
public:
// TODO(ohadrau): Specify a better return value (Trap)
using callbackType = void (*)(const Memory*, const Val[], Val[]);

Func(const FuncType*, callbackType);

const FuncType* type();
callbackType callback();
};

void PreloadNative(Isolate* isolate,
const char* module_name,
const char* name,
Func* import);

} // namespace wasm
} // namespace v8

#endif // INCLUDE_V8_WASM_H_
Loading

0 comments on commit 6d6f699

Please sign in to comment.