[wasm] external serialization APIs

V8 APIs for wasm serialization/deserialization.

BUG=v8:5072

Review-Url: https://codereview.chromium.org/2226753002
Cr-Commit-Position: refs/heads/master@{#38455}
This commit is contained in:
mtrofin 2016-08-08 11:18:59 -07:00 committed by Commit bot
parent 9b6c57045d
commit 5de4722278
5 changed files with 42 additions and 0 deletions

View File

@ -1952,6 +1952,7 @@ class V8_EXPORT Value : public Data {
*/
bool IsProxy() const;
bool IsWebAssemblyCompiledModule() const;
V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(
Local<Context> context) const;

View File

@ -2958,6 +2958,9 @@ bool Value::IsNumber() const {
bool Value::IsProxy() const { return Utils::OpenHandle(this)->IsJSProxy(); }
bool Value::IsWebAssemblyCompiledModule() const {
return Utils::OpenHandle(this)->IsWebAssemblyCompiledModule();
}
#define VALUE_IS_SPECIFIC_TYPE(Type, Class) \
bool Value::Is##Type() const { \

View File

@ -143,6 +143,12 @@ bool HeapObject::IsFixedArrayBase() const {
return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase();
}
bool HeapObject::IsWebAssemblyCompiledModule() const {
if (!IsJSObject()) return false;
return GetIsolate()->native_context()->wasm_module_constructor() ==
this->map()->GetConstructor();
}
bool HeapObject::IsFixedArray() const {
InstanceType instance_type = map()->instance_type();
return instance_type == FIXED_ARRAY_TYPE ||

View File

@ -58,6 +58,7 @@
#include "src/string-search.h"
#include "src/string-stream.h"
#include "src/utils.h"
#include "src/wasm/wasm-module.h"
#include "src/zone.h"
#ifdef ENABLE_DISASSEMBLER
@ -19006,6 +19007,17 @@ Handle<JSArrayBuffer> JSTypedArray::GetBuffer() {
return MaterializeArrayBuffer(self);
}
std::pair<std::unique_ptr<const byte>, size_t>
WebAssemblyCompiledModule::Serialize() {
// TODO(mtrofin): tie to the internal serialization API
return {std::unique_ptr<const byte>(), 0};
}
MaybeHandle<WebAssemblyCompiledModule> WebAssemblyCompiledModule::Deserialize(
Isolate* isolate, const byte* data, size_t size) {
// TODO(mtrofin): tie to the internal serialization API
return MaybeHandle<WebAssemblyCompiledModule>();
}
Handle<PropertyCell> PropertyCell::InvalidateEntry(
Handle<GlobalDictionary> dictionary, int entry) {

View File

@ -1002,6 +1002,7 @@ template <class C> inline bool Is(Object* obj);
V(JSWeakMap) \
V(JSWeakSet) \
V(JSRegExp) \
V(WebAssemblyCompiledModule) \
V(HashTable) \
V(Dictionary) \
V(UnseededNumberDictionary) \
@ -8149,6 +8150,25 @@ class JSMessageObject: public JSObject {
kSize> BodyDescriptor;
};
// A compiled web assembly module.
class WebAssemblyCompiledModule : public JSObject {
public:
// Serialize the compiled module. The returned buffer is owned by
// the caller, who may simply leave the return value drop out of
// scope, once done processing the bytes.
// TODO(mtrofin): to avoid increased memory pressure, we should
// explore a caller-provided segmented memory design.
std::pair<std::unique_ptr<const byte>, size_t> Serialize();
// Deserialize a compiled module. The buffer is owned by the caller and may
// be released after deserialization returns.
static MaybeHandle<WebAssemblyCompiledModule> Deserialize(Isolate* isolate,
const byte* data,
size_t size);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(WebAssemblyCompiledModule);
};
// Regular expressions
// The regular expression holds a single reference to a FixedArray in