6a50560650
The mutable-globals proposal spec allows importing as Numbers or WebAssembly.Global values, but always exports as WebAssembly.Global. Since the value is always boxed, we can also import/export i64 values. This CL also includes support for export of mutable globals. Since the underlying ArrayBuffer that stores the global's value is shared between the module and the WebAssembly.Global object, all that needs to be done is remove the validation check. Bug: v8:7625 Change-Id: I24d763e3bc193d229a7cc33b2f2690a473c6f2bc Reviewed-on: https://chromium-review.googlesource.com/1018406 Commit-Queue: Ben Smith <binji@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#52789}
85 lines
2.0 KiB
C++
85 lines
2.0 KiB
C++
// Copyright 2011 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 V8_V8MEMORY_H_
|
|
#define V8_V8MEMORY_H_
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
|
|
// Memory provides an interface to 'raw' memory. It encapsulates the casts
|
|
// that typically are needed when incompatible pointer types are used.
|
|
|
|
class Memory {
|
|
public:
|
|
static uint8_t& uint8_at(Address addr) {
|
|
return *reinterpret_cast<uint8_t*>(addr);
|
|
}
|
|
|
|
static uint16_t& uint16_at(Address addr) {
|
|
return *reinterpret_cast<uint16_t*>(addr);
|
|
}
|
|
|
|
static uint32_t& uint32_at(Address addr) {
|
|
return *reinterpret_cast<uint32_t*>(addr);
|
|
}
|
|
|
|
static int32_t& int32_at(Address addr) {
|
|
return *reinterpret_cast<int32_t*>(addr);
|
|
}
|
|
|
|
static uint64_t& uint64_at(Address addr) {
|
|
return *reinterpret_cast<uint64_t*>(addr);
|
|
}
|
|
|
|
static int64_t& int64_at(Address addr) {
|
|
return *reinterpret_cast<int64_t*>(addr);
|
|
}
|
|
|
|
static int& int_at(Address addr) {
|
|
return *reinterpret_cast<int*>(addr);
|
|
}
|
|
|
|
static unsigned& unsigned_at(Address addr) {
|
|
return *reinterpret_cast<unsigned*>(addr);
|
|
}
|
|
|
|
static intptr_t& intptr_at(Address addr) {
|
|
return *reinterpret_cast<intptr_t*>(addr);
|
|
}
|
|
|
|
static uintptr_t& uintptr_at(Address addr) {
|
|
return *reinterpret_cast<uintptr_t*>(addr);
|
|
}
|
|
|
|
static float& float_at(Address addr) {
|
|
return *reinterpret_cast<float*>(addr);
|
|
}
|
|
|
|
static double& double_at(Address addr) {
|
|
return *reinterpret_cast<double*>(addr);
|
|
}
|
|
|
|
static Address& Address_at(Address addr) {
|
|
return *reinterpret_cast<Address*>(addr);
|
|
}
|
|
|
|
static Object*& Object_at(Address addr) {
|
|
return *reinterpret_cast<Object**>(addr);
|
|
}
|
|
|
|
static Handle<Object>& Object_Handle_at(Address addr) {
|
|
return *reinterpret_cast<Handle<Object>*>(addr);
|
|
}
|
|
|
|
static bool IsAddressInRange(Address base, Address address, uint32_t size) {
|
|
return base <= address && address < base + size;
|
|
}
|
|
};
|
|
|
|
} // namespace internal
|
|
} // namespace v8
|
|
|
|
#endif // V8_V8MEMORY_H_
|