[base] Move v8memory.h to base/memory.h
v8memory.h does not have V8 specific definitions, and having it in base makes it clear that every component may include the file. It also ensures that including it does not create spurious dependencies on v8_base. Change-Id: I565f63b25f33a9ada19d7b2ac5990863ab17f4a7 Bug: v8:9183, v8:8855 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1657923 Commit-Queue: Sigurd Schneider <sigurds@chromium.org> Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#62309}
This commit is contained in:
parent
a1ba0a85e5
commit
dd65ef6a9a
2
BUILD.gn
2
BUILD.gn
@ -2110,7 +2110,6 @@ v8_source_set("v8_base_without_compiler") {
|
||||
"src/common/checks.h",
|
||||
"src/common/ptr-compr-inl.h",
|
||||
"src/common/ptr-compr.h",
|
||||
"src/common/v8memory.h",
|
||||
"src/compiler-dispatcher/compiler-dispatcher.cc",
|
||||
"src/compiler-dispatcher/compiler-dispatcher.h",
|
||||
"src/compiler-dispatcher/optimizing-compile-dispatcher.cc",
|
||||
@ -3449,6 +3448,7 @@ v8_component("v8_libbase") {
|
||||
"src/base/logging.h",
|
||||
"src/base/lsan.h",
|
||||
"src/base/macros.h",
|
||||
"src/base/memory.h",
|
||||
"src/base/once.cc",
|
||||
"src/base/once.h",
|
||||
"src/base/optional.h",
|
||||
|
@ -2,14 +2,16 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_COMMON_V8MEMORY_H_
|
||||
#define V8_COMMON_V8MEMORY_H_
|
||||
#ifndef V8_BASE_MEMORY_H_
|
||||
#define V8_BASE_MEMORY_H_
|
||||
|
||||
#include "src/base/macros.h"
|
||||
#include "src/common/globals.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
namespace base {
|
||||
|
||||
using Address = uintptr_t;
|
||||
using byte = uint8_t;
|
||||
|
||||
// Memory provides an interface to 'raw' memory. It encapsulates the casts
|
||||
// that typically are needed when incompatible pointer types are used.
|
||||
@ -39,22 +41,6 @@ static inline void WriteUnalignedValue(Address p, V value) {
|
||||
memcpy(reinterpret_cast<void*>(p), &value, sizeof(V));
|
||||
}
|
||||
|
||||
static inline uint16_t ReadUnalignedUInt16(Address p) {
|
||||
return ReadUnalignedValue<uint16_t>(p);
|
||||
}
|
||||
|
||||
static inline void WriteUnalignedUInt16(Address p, uint16_t value) {
|
||||
WriteUnalignedValue(p, value);
|
||||
}
|
||||
|
||||
static inline uint32_t ReadUnalignedUInt32(Address p) {
|
||||
return ReadUnalignedValue<uint32_t>(p);
|
||||
}
|
||||
|
||||
static inline void WriteUnalignedUInt32(Address p, uint32_t value) {
|
||||
WriteUnalignedValue(p, value);
|
||||
}
|
||||
|
||||
template <typename V>
|
||||
static inline V ReadLittleEndianValue(Address p) {
|
||||
#if defined(V8_TARGET_LITTLE_ENDIAN)
|
||||
@ -93,7 +79,7 @@ static inline void WriteLittleEndianValue(V* p, V value) {
|
||||
WriteLittleEndianValue<V>(reinterpret_cast<Address>(p), value);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace base
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_COMMON_V8MEMORY_H_
|
||||
#endif // V8_BASE_MEMORY_H_
|
@ -7,9 +7,9 @@
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "src/base/memory.h"
|
||||
#include "src/codegen/arm64/assembler-arm64.h"
|
||||
#include "src/codegen/assembler.h"
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/debug/debug.h"
|
||||
#include "src/objects/objects-inl.h"
|
||||
#include "src/objects/smi.h"
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
#include <forward_list>
|
||||
|
||||
#include "src/base/memory.h"
|
||||
#include "src/codegen/code-comments.h"
|
||||
#include "src/codegen/cpu-features.h"
|
||||
#include "src/codegen/external-reference.h"
|
||||
@ -55,6 +56,10 @@ class ApiFunction;
|
||||
|
||||
namespace internal {
|
||||
|
||||
using base::Memory;
|
||||
using base::ReadUnalignedValue;
|
||||
using base::WriteUnalignedValue;
|
||||
|
||||
// Forward declarations.
|
||||
class EmbeddedData;
|
||||
class InstructionStream;
|
||||
|
@ -5,8 +5,8 @@
|
||||
#ifndef V8_CODEGEN_SAFEPOINT_TABLE_H_
|
||||
#define V8_CODEGEN_SAFEPOINT_TABLE_H_
|
||||
|
||||
#include "src/base/memory.h"
|
||||
#include "src/common/assert-scope.h"
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/utils/allocation.h"
|
||||
#include "src/utils/utils.h"
|
||||
#include "src/zone/zone-chunk-list.h"
|
||||
@ -76,22 +76,23 @@ class SafepointTable {
|
||||
|
||||
unsigned GetPcOffset(unsigned index) const {
|
||||
DCHECK(index < length_);
|
||||
return Memory<uint32_t>(GetPcOffsetLocation(index));
|
||||
return base::Memory<uint32_t>(GetPcOffsetLocation(index));
|
||||
}
|
||||
|
||||
int GetTrampolinePcOffset(unsigned index) const {
|
||||
DCHECK(index < length_);
|
||||
return Memory<int>(GetTrampolineLocation(index));
|
||||
return base::Memory<int>(GetTrampolineLocation(index));
|
||||
}
|
||||
|
||||
unsigned find_return_pc(unsigned pc_offset);
|
||||
|
||||
SafepointEntry GetEntry(unsigned index) const {
|
||||
DCHECK(index < length_);
|
||||
unsigned deopt_index = Memory<uint32_t>(GetEncodedInfoLocation(index));
|
||||
uint8_t* bits = &Memory<uint8_t>(entries_ + (index * entry_size_));
|
||||
unsigned deopt_index =
|
||||
base::Memory<uint32_t>(GetEncodedInfoLocation(index));
|
||||
uint8_t* bits = &base::Memory<uint8_t>(entries_ + (index * entry_size_));
|
||||
int trampoline_pc =
|
||||
has_deopt_ ? Memory<int>(GetTrampolineLocation(index)) : -1;
|
||||
has_deopt_ ? base::Memory<int>(GetTrampolineLocation(index)) : -1;
|
||||
return SafepointEntry(deopt_index, bits, trampoline_pc);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "src/codegen/x64/assembler-x64.h"
|
||||
|
||||
#include "src/base/cpu.h"
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/base/memory.h"
|
||||
#include "src/debug/debug.h"
|
||||
#include "src/objects/objects-inl.h"
|
||||
|
||||
|
@ -582,7 +582,8 @@ void EhFrameDisassembler::DumpDwarfDirectives(std::ostream& stream, // NOLINT
|
||||
void EhFrameDisassembler::DisassembleToStream(std::ostream& stream) { // NOLINT
|
||||
// The encoded CIE size does not include the size field itself.
|
||||
const int cie_size =
|
||||
ReadUnalignedUInt32(reinterpret_cast<Address>(start_)) + kInt32Size;
|
||||
base::ReadUnalignedValue<uint32_t>(reinterpret_cast<Address>(start_)) +
|
||||
kInt32Size;
|
||||
const int fde_offset = cie_size;
|
||||
|
||||
const byte* cie_directives_start =
|
||||
@ -597,12 +598,13 @@ void EhFrameDisassembler::DisassembleToStream(std::ostream& stream) { // NOLINT
|
||||
reinterpret_cast<Address>(start_) + fde_offset +
|
||||
EhFrameConstants::kProcedureAddressOffsetInFde;
|
||||
int32_t procedure_offset =
|
||||
ReadUnalignedValue<int32_t>(procedure_offset_address);
|
||||
base::ReadUnalignedValue<int32_t>(procedure_offset_address);
|
||||
|
||||
Address procedure_size_address = reinterpret_cast<Address>(start_) +
|
||||
fde_offset +
|
||||
EhFrameConstants::kProcedureSizeOffsetInFde;
|
||||
uint32_t procedure_size = ReadUnalignedUInt32(procedure_size_address);
|
||||
uint32_t procedure_size =
|
||||
base::ReadUnalignedValue<uint32_t>(procedure_size_address);
|
||||
|
||||
const byte* fde_start = start_ + fde_offset;
|
||||
stream << reinterpret_cast<const void*>(fde_start) << " .eh_frame: FDE\n"
|
||||
|
@ -6,9 +6,9 @@
|
||||
#define V8_DIAGNOSTICS_EH_FRAME_H_
|
||||
|
||||
#include "src/base/compiler-specific.h"
|
||||
#include "src/base/memory.h"
|
||||
#include "src/codegen/register-arch.h"
|
||||
#include "src/common/globals.h"
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/zone/zone-containers.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -144,11 +144,11 @@ class V8_EXPORT_PRIVATE EhFrameWriter {
|
||||
}
|
||||
void PatchInt32(int base_offset, uint32_t value) {
|
||||
DCHECK_EQ(
|
||||
ReadUnalignedUInt32(reinterpret_cast<Address>(eh_frame_buffer_.data()) +
|
||||
base_offset),
|
||||
base::ReadUnalignedValue<uint32_t>(
|
||||
reinterpret_cast<Address>(eh_frame_buffer_.data()) + base_offset),
|
||||
kInt32Placeholder);
|
||||
DCHECK_LT(base_offset + kInt32Size, eh_frame_offset());
|
||||
WriteUnalignedUInt32(
|
||||
base::WriteUnalignedValue<uint32_t>(
|
||||
reinterpret_cast<Address>(eh_frame_buffer_.data()) + base_offset,
|
||||
value);
|
||||
}
|
||||
@ -216,7 +216,9 @@ class V8_EXPORT_PRIVATE EhFrameIterator {
|
||||
|
||||
void SkipCie() {
|
||||
DCHECK_EQ(next_, start_);
|
||||
next_ += ReadUnalignedUInt32(reinterpret_cast<Address>(next_)) + kInt32Size;
|
||||
next_ +=
|
||||
base::ReadUnalignedValue<uint32_t>(reinterpret_cast<Address>(next_)) +
|
||||
kInt32Size;
|
||||
}
|
||||
|
||||
void SkipToFdeDirectives() {
|
||||
@ -267,7 +269,7 @@ class V8_EXPORT_PRIVATE EhFrameIterator {
|
||||
T GetNextValue() {
|
||||
T result;
|
||||
DCHECK_LE(next_ + sizeof(result), end_);
|
||||
result = ReadUnalignedValue<T>(reinterpret_cast<Address>(next_));
|
||||
result = base::ReadUnalignedValue<T>(reinterpret_cast<Address>(next_));
|
||||
next_ += sizeof(result);
|
||||
return result;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
#ifndef V8_EXECUTION_FRAMES_INL_H_
|
||||
#define V8_EXECUTION_FRAMES_INL_H_
|
||||
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/base/memory.h"
|
||||
#include "src/execution/frame-constants.h"
|
||||
#include "src/execution/frames.h"
|
||||
#include "src/execution/isolate.h"
|
||||
@ -48,11 +48,11 @@ inline Address StackHandler::address() const {
|
||||
|
||||
inline StackHandler* StackHandler::next() const {
|
||||
const int offset = StackHandlerConstants::kNextOffset;
|
||||
return FromAddress(Memory<Address>(address() + offset));
|
||||
return FromAddress(base::Memory<Address>(address() + offset));
|
||||
}
|
||||
|
||||
inline Address StackHandler::next_address() const {
|
||||
return Memory<Address>(address() + StackHandlerConstants::kNextOffset);
|
||||
return base::Memory<Address>(address() + StackHandlerConstants::kNextOffset);
|
||||
}
|
||||
|
||||
inline StackHandler* StackHandler::FromAddress(Address address) {
|
||||
@ -112,21 +112,22 @@ inline Object BuiltinExitFrame::receiver_slot_object() const {
|
||||
|
||||
const int receiverOffset = BuiltinExitFrameConstants::kNewTargetOffset +
|
||||
(argc - 1) * kSystemPointerSize;
|
||||
return Object(Memory<Address>(fp() + receiverOffset));
|
||||
return Object(base::Memory<Address>(fp() + receiverOffset));
|
||||
}
|
||||
|
||||
inline Object BuiltinExitFrame::argc_slot_object() const {
|
||||
return Object(Memory<Address>(fp() + BuiltinExitFrameConstants::kArgcOffset));
|
||||
return Object(
|
||||
base::Memory<Address>(fp() + BuiltinExitFrameConstants::kArgcOffset));
|
||||
}
|
||||
|
||||
inline Object BuiltinExitFrame::target_slot_object() const {
|
||||
return Object(
|
||||
Memory<Address>(fp() + BuiltinExitFrameConstants::kTargetOffset));
|
||||
base::Memory<Address>(fp() + BuiltinExitFrameConstants::kTargetOffset));
|
||||
}
|
||||
|
||||
inline Object BuiltinExitFrame::new_target_slot_object() const {
|
||||
return Object(
|
||||
Memory<Address>(fp() + BuiltinExitFrameConstants::kNewTargetOffset));
|
||||
return Object(base::Memory<Address>(
|
||||
fp() + BuiltinExitFrameConstants::kNewTargetOffset));
|
||||
}
|
||||
|
||||
inline StandardFrame::StandardFrame(StackFrameIteratorBase* iterator)
|
||||
@ -134,20 +135,20 @@ inline StandardFrame::StandardFrame(StackFrameIteratorBase* iterator)
|
||||
}
|
||||
|
||||
inline Object StandardFrame::GetExpression(int index) const {
|
||||
return Object(Memory<Address>(GetExpressionAddress(index)));
|
||||
return Object(base::Memory<Address>(GetExpressionAddress(index)));
|
||||
}
|
||||
|
||||
inline void StandardFrame::SetExpression(int index, Object value) {
|
||||
Memory<Address>(GetExpressionAddress(index)) = value.ptr();
|
||||
base::Memory<Address>(GetExpressionAddress(index)) = value.ptr();
|
||||
}
|
||||
|
||||
inline Address StandardFrame::caller_fp() const {
|
||||
return Memory<Address>(fp() + StandardFrameConstants::kCallerFPOffset);
|
||||
return base::Memory<Address>(fp() + StandardFrameConstants::kCallerFPOffset);
|
||||
}
|
||||
|
||||
|
||||
inline Address StandardFrame::caller_pc() const {
|
||||
return Memory<Address>(ComputePCAddress(fp()));
|
||||
return base::Memory<Address>(ComputePCAddress(fp()));
|
||||
}
|
||||
|
||||
|
||||
@ -163,14 +164,14 @@ inline Address StandardFrame::ComputeConstantPoolAddress(Address fp) {
|
||||
|
||||
inline bool StandardFrame::IsArgumentsAdaptorFrame(Address fp) {
|
||||
intptr_t frame_type =
|
||||
Memory<intptr_t>(fp + TypedFrameConstants::kFrameTypeOffset);
|
||||
base::Memory<intptr_t>(fp + TypedFrameConstants::kFrameTypeOffset);
|
||||
return frame_type == StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR);
|
||||
}
|
||||
|
||||
|
||||
inline bool StandardFrame::IsConstructFrame(Address fp) {
|
||||
intptr_t frame_type =
|
||||
Memory<intptr_t>(fp + TypedFrameConstants::kFrameTypeOffset);
|
||||
base::Memory<intptr_t>(fp + TypedFrameConstants::kFrameTypeOffset);
|
||||
return frame_type == StackFrame::TypeToMarker(StackFrame::CONSTRUCT);
|
||||
}
|
||||
|
||||
@ -187,7 +188,7 @@ Address JavaScriptFrame::GetParameterSlot(int index) const {
|
||||
}
|
||||
|
||||
inline void JavaScriptFrame::set_receiver(Object value) {
|
||||
Memory<Address>(GetParameterSlot(-1)) = value.ptr();
|
||||
base::Memory<Address>(GetParameterSlot(-1)) = value.ptr();
|
||||
}
|
||||
|
||||
inline bool JavaScriptFrame::has_adapted_arguments() const {
|
||||
@ -196,7 +197,7 @@ inline bool JavaScriptFrame::has_adapted_arguments() const {
|
||||
|
||||
inline Object JavaScriptFrame::function_slot_object() const {
|
||||
const int offset = JavaScriptFrameConstants::kFunctionOffset;
|
||||
return Object(Memory<Address>(fp() + offset));
|
||||
return Object(base::Memory<Address>(fp() + offset));
|
||||
}
|
||||
|
||||
inline StubFrame::StubFrame(StackFrameIteratorBase* iterator)
|
||||
|
@ -5,8 +5,8 @@
|
||||
#ifndef V8_HEAP_REMEMBERED_SET_H_
|
||||
#define V8_HEAP_REMEMBERED_SET_H_
|
||||
|
||||
#include "src/base/memory.h"
|
||||
#include "src/codegen/reloc-info.h"
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/heap/heap.h"
|
||||
#include "src/heap/slot-set.h"
|
||||
#include "src/heap/spaces.h"
|
||||
@ -309,7 +309,7 @@ class UpdateTypedSlotHelper {
|
||||
SlotCallbackResult result = callback(FullMaybeObjectSlot(&code));
|
||||
DCHECK(!HasWeakHeapObjectTag(code));
|
||||
if (code != old_code) {
|
||||
Memory<Address>(entry_address) = code.entry();
|
||||
base::Memory<Address>(entry_address) = code.entry();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ void IsolateAllocator::CommitPagesForIsolate(Address heap_address) {
|
||||
if (Heap::ShouldZapGarbage()) {
|
||||
for (Address address = committed_region_address;
|
||||
address < committed_region_size; address += kSystemPointerSize) {
|
||||
Memory<Address>(address) = static_cast<Address>(kZapValue);
|
||||
base::Memory<Address>(address) = static_cast<Address>(kZapValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,12 @@ include_rules = [
|
||||
"+src/base/compiler-specific.h",
|
||||
"+src/base/logging.h",
|
||||
"+src/base/macros.h",
|
||||
"+src/base/memory.h",
|
||||
"+src/base/platform/platform.h",
|
||||
"+src/base/platform/mutex.h",
|
||||
"+src/base/safe_conversions.h",
|
||||
"+src/base/template-utils.h",
|
||||
"+src/base/v8-fallthrough.h",
|
||||
"+src/common/v8memory.h",
|
||||
"+src/numbers/conversions.h",
|
||||
"+src/inspector",
|
||||
"+src/tracing",
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "src/inspector/v8-debugger-script.h"
|
||||
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/base/memory.h"
|
||||
#include "src/inspector/inspected-context.h"
|
||||
#include "src/inspector/string-util.h"
|
||||
#include "src/inspector/v8-debugger-agent-impl.h"
|
||||
@ -44,7 +44,7 @@ String16 calculateHash(v8::Isolate* isolate, v8::Local<v8::String> source) {
|
||||
size_t sizeInBytes = sizeof(UChar) * written;
|
||||
data = reinterpret_cast<const uint32_t*>(buffer.get());
|
||||
for (size_t i = 0; i < sizeInBytes / 4; ++i) {
|
||||
uint32_t d = v8::internal::ReadUnalignedUInt32(
|
||||
uint32_t d = v8::base::ReadUnalignedValue<uint32_t>(
|
||||
reinterpret_cast<v8::internal::Address>(data + i));
|
||||
#if V8_TARGET_LITTLE_ENDIAN
|
||||
uint32_t v = d;
|
||||
|
@ -334,8 +334,8 @@ void BytecodeArrayWriter::PatchJumpWith16BitOperand(size_t jump_location,
|
||||
// The jump fits within the range of an Imm16 operand, so cancel
|
||||
// the reservation and jump directly.
|
||||
constant_array_builder()->DiscardReservedEntry(OperandSize::kShort);
|
||||
WriteUnalignedUInt16(reinterpret_cast<Address>(operand_bytes),
|
||||
static_cast<uint16_t>(delta));
|
||||
base::WriteUnalignedValue<uint16_t>(
|
||||
reinterpret_cast<Address>(operand_bytes), static_cast<uint16_t>(delta));
|
||||
} else {
|
||||
// The jump does not fit within the range of an Imm16 operand, so
|
||||
// commit reservation putting the offset into the constant pool,
|
||||
@ -344,8 +344,8 @@ void BytecodeArrayWriter::PatchJumpWith16BitOperand(size_t jump_location,
|
||||
OperandSize::kShort, Smi::FromInt(delta));
|
||||
jump_bytecode = GetJumpWithConstantOperand(jump_bytecode);
|
||||
bytecodes()->at(jump_location) = Bytecodes::ToByte(jump_bytecode);
|
||||
WriteUnalignedUInt16(reinterpret_cast<Address>(operand_bytes),
|
||||
static_cast<uint16_t>(entry));
|
||||
base::WriteUnalignedValue<uint16_t>(
|
||||
reinterpret_cast<Address>(operand_bytes), static_cast<uint16_t>(entry));
|
||||
}
|
||||
DCHECK(bytecodes()->at(operand_location) == k8BitJumpPlaceholder &&
|
||||
bytecodes()->at(operand_location + 1) == k8BitJumpPlaceholder);
|
||||
@ -359,8 +359,8 @@ void BytecodeArrayWriter::PatchJumpWith32BitOperand(size_t jump_location,
|
||||
Bytecodes::FromByte(bytecodes()->at(jump_location))));
|
||||
constant_array_builder()->DiscardReservedEntry(OperandSize::kQuad);
|
||||
uint8_t operand_bytes[4];
|
||||
WriteUnalignedUInt32(reinterpret_cast<Address>(operand_bytes),
|
||||
static_cast<uint32_t>(delta));
|
||||
base::WriteUnalignedValue<uint32_t>(reinterpret_cast<Address>(operand_bytes),
|
||||
static_cast<uint32_t>(delta));
|
||||
size_t operand_location = jump_location + 1;
|
||||
DCHECK(bytecodes()->at(operand_location) == k8BitJumpPlaceholder &&
|
||||
bytecodes()->at(operand_location + 1) == k8BitJumpPlaceholder &&
|
||||
|
@ -42,9 +42,11 @@ int32_t BytecodeDecoder::DecodeSignedOperand(Address operand_start,
|
||||
case OperandSize::kByte:
|
||||
return *reinterpret_cast<const int8_t*>(operand_start);
|
||||
case OperandSize::kShort:
|
||||
return static_cast<int16_t>(ReadUnalignedUInt16(operand_start));
|
||||
return static_cast<int16_t>(
|
||||
base::ReadUnalignedValue<uint16_t>(operand_start));
|
||||
case OperandSize::kQuad:
|
||||
return static_cast<int32_t>(ReadUnalignedUInt32(operand_start));
|
||||
return static_cast<int32_t>(
|
||||
base::ReadUnalignedValue<uint32_t>(operand_start));
|
||||
case OperandSize::kNone:
|
||||
UNREACHABLE();
|
||||
}
|
||||
@ -60,9 +62,9 @@ uint32_t BytecodeDecoder::DecodeUnsignedOperand(Address operand_start,
|
||||
case OperandSize::kByte:
|
||||
return *reinterpret_cast<const uint8_t*>(operand_start);
|
||||
case OperandSize::kShort:
|
||||
return ReadUnalignedUInt16(operand_start);
|
||||
return base::ReadUnalignedValue<uint16_t>(operand_start);
|
||||
case OperandSize::kQuad:
|
||||
return ReadUnalignedUInt32(operand_start);
|
||||
return base::ReadUnalignedValue<uint32_t>(operand_start);
|
||||
case OperandSize::kNone:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
@ -7,8 +7,8 @@
|
||||
|
||||
#include "src/objects/code.h"
|
||||
|
||||
#include "src/base/memory.h"
|
||||
#include "src/codegen/code-desc.h"
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/execution/isolate.h"
|
||||
#include "src/interpreter/bytecode-register.h"
|
||||
#include "src/objects/dictionary.h"
|
||||
@ -575,7 +575,7 @@ Code Code::GetCodeFromTargetAddress(Address address) {
|
||||
}
|
||||
|
||||
Code Code::GetObjectFromEntryAddress(Address location_of_address) {
|
||||
Address code_entry = Memory<Address>(location_of_address);
|
||||
Address code_entry = base::Memory<Address>(location_of_address);
|
||||
HeapObject code = HeapObject::FromAddress(code_entry - Code::kHeaderSize);
|
||||
// Unchecked cast because we can't rely on the map currently
|
||||
// not being a forwarding pointer.
|
||||
|
@ -2901,7 +2901,7 @@ class TypedElementsAccessor
|
||||
// fields (external pointers, doubles and BigInt data) are only
|
||||
// kTaggedSize aligned so we have to use unaligned pointer friendly way of
|
||||
// accessing them in order to avoid undefined behavior in C++ code.
|
||||
WriteUnalignedValue<ElementType>(
|
||||
base::WriteUnalignedValue<ElementType>(
|
||||
reinterpret_cast<Address>(data_ptr + entry), value);
|
||||
} else {
|
||||
data_ptr[entry] = value;
|
||||
@ -2941,7 +2941,7 @@ class TypedElementsAccessor
|
||||
// fields (external pointers, doubles and BigInt data) are only
|
||||
// kTaggedSize aligned so we have to use unaligned pointer friendly way of
|
||||
// accessing them in order to avoid undefined behavior in C++ code.
|
||||
result = ReadUnalignedValue<ElementType>(
|
||||
result = base::ReadUnalignedValue<ElementType>(
|
||||
reinterpret_cast<Address>(data_ptr + entry));
|
||||
} else {
|
||||
result = data_ptr[entry];
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "src/objects/embedder-data-slot.h"
|
||||
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/base/memory.h"
|
||||
#include "src/heap/heap-write-barrier-inl.h"
|
||||
#include "src/objects/embedder-data-array.h"
|
||||
#include "src/objects/js-objects-inl.h"
|
||||
|
@ -323,7 +323,7 @@ uint64_t FixedDoubleArray::get_representation(int index) {
|
||||
DCHECK(index >= 0 && index < this->length());
|
||||
int offset = kHeaderSize + index * kDoubleSize;
|
||||
// Bug(v8:8875): Doubles may be unaligned.
|
||||
return ReadUnalignedValue<uint64_t>(field_address(offset));
|
||||
return base::ReadUnalignedValue<uint64_t>(field_address(offset));
|
||||
}
|
||||
|
||||
Handle<Object> FixedDoubleArray::get(FixedDoubleArray array, int index,
|
||||
@ -355,7 +355,7 @@ void FixedDoubleArray::set_the_hole(int index) {
|
||||
DCHECK(map() != GetReadOnlyRoots().fixed_cow_array_map() &&
|
||||
map() != GetReadOnlyRoots().fixed_array_map());
|
||||
int offset = kHeaderSize + index * kDoubleSize;
|
||||
WriteUnalignedValue<uint64_t>(field_address(offset), kHoleNanInt64);
|
||||
base::WriteUnalignedValue<uint64_t>(field_address(offset), kHoleNanInt64);
|
||||
}
|
||||
|
||||
bool FixedDoubleArray::is_the_hole(Isolate* isolate, int index) {
|
||||
|
@ -31,11 +31,11 @@ void HeapNumberBase::set_value(double value) {
|
||||
|
||||
uint64_t HeapNumberBase::value_as_bits() const {
|
||||
// Bug(v8:8875): HeapNumber's double may be unaligned.
|
||||
return ReadUnalignedValue<uint64_t>(field_address(kValueOffset));
|
||||
return base::ReadUnalignedValue<uint64_t>(field_address(kValueOffset));
|
||||
}
|
||||
|
||||
void HeapNumberBase::set_value_as_bits(uint64_t bits) {
|
||||
WriteUnalignedValue<uint64_t>(field_address(kValueOffset), bits);
|
||||
base::WriteUnalignedValue<uint64_t>(field_address(kValueOffset), bits);
|
||||
}
|
||||
|
||||
int HeapNumberBase::get_exponent() {
|
||||
|
@ -14,7 +14,7 @@
|
||||
// for fields that can be written to and read from multiple threads at the same
|
||||
// time. See comments in src/base/atomicops.h for the memory ordering sematics.
|
||||
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/base/memory.h"
|
||||
|
||||
// Since this changes visibility, it should always be last in a class
|
||||
// definition.
|
||||
|
@ -15,8 +15,8 @@
|
||||
#include "src/objects/objects.h"
|
||||
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/memory.h"
|
||||
#include "src/builtins/builtins.h"
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/handles/handles-inl.h"
|
||||
#include "src/heap/factory.h"
|
||||
#include "src/heap/heap-write-barrier-inl.h"
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "src/base/build_config.h"
|
||||
#include "src/base/flags.h"
|
||||
#include "src/base/logging.h"
|
||||
#include "src/base/memory.h"
|
||||
#include "src/codegen/constants-arch.h"
|
||||
#include "src/common/assert-scope.h"
|
||||
#include "src/common/checks.h"
|
||||
@ -625,9 +626,9 @@ class Object : public TaggedImpl<HeapObjectReferenceType::STRONG, Address> {
|
||||
#endif
|
||||
if (std::is_same<T, double>::value || v8_pointer_compression_unaligned) {
|
||||
// Bug(v8:8875) Double fields may be unaligned.
|
||||
return ReadUnalignedValue<T>(field_address(offset));
|
||||
return base::ReadUnalignedValue<T>(field_address(offset));
|
||||
} else {
|
||||
return Memory<T>(field_address(offset));
|
||||
return base::Memory<T>(field_address(offset));
|
||||
}
|
||||
}
|
||||
|
||||
@ -642,9 +643,9 @@ class Object : public TaggedImpl<HeapObjectReferenceType::STRONG, Address> {
|
||||
#endif
|
||||
if (std::is_same<T, double>::value || v8_pointer_compression_unaligned) {
|
||||
// Bug(v8:8875) Double fields may be unaligned.
|
||||
WriteUnalignedValue<T>(field_address(offset), value);
|
||||
base::WriteUnalignedValue<T>(field_address(offset), value);
|
||||
} else {
|
||||
Memory<T>(field_address(offset)) = value;
|
||||
base::Memory<T>(field_address(offset)) = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ TQ_OBJECT_CONSTRUCTORS_IMPL(Oddball)
|
||||
|
||||
void Oddball::set_to_number_raw_as_bits(uint64_t bits) {
|
||||
// Bug(v8:8875): HeapNumber's double may be unaligned.
|
||||
WriteUnalignedValue<uint64_t>(field_address(kToNumberRawOffset), bits);
|
||||
base::WriteUnalignedValue<uint64_t>(field_address(kToNumberRawOffset), bits);
|
||||
}
|
||||
|
||||
byte Oddball::kind() const {
|
||||
|
@ -5,8 +5,8 @@
|
||||
#ifndef V8_OBJECTS_SLOTS_H_
|
||||
#define V8_OBJECTS_SLOTS_H_
|
||||
|
||||
#include "src/base/memory.h"
|
||||
#include "src/common/globals.h"
|
||||
#include "src/common/v8memory.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -192,11 +192,11 @@ class UnalignedSlot : public SlotBase<UnalignedSlot<T>, T, 1> {
|
||||
Reference(const Reference&) V8_NOEXCEPT = default;
|
||||
|
||||
Reference& operator=(const Reference& other) V8_NOEXCEPT {
|
||||
WriteUnalignedValue<T>(address_, other.value());
|
||||
base::WriteUnalignedValue<T>(address_, other.value());
|
||||
return *this;
|
||||
}
|
||||
Reference& operator=(T value) {
|
||||
WriteUnalignedValue<T>(address_, value);
|
||||
base::WriteUnalignedValue<T>(address_, value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -206,8 +206,8 @@ class UnalignedSlot : public SlotBase<UnalignedSlot<T>, T, 1> {
|
||||
|
||||
void swap(Reference& other) {
|
||||
T tmp = value();
|
||||
WriteUnalignedValue<T>(address_, other.value());
|
||||
WriteUnalignedValue<T>(other.address_, tmp);
|
||||
base::WriteUnalignedValue<T>(address_, other.value());
|
||||
base::WriteUnalignedValue<T>(other.address_, tmp);
|
||||
}
|
||||
|
||||
bool operator<(const Reference& other) const {
|
||||
@ -219,7 +219,7 @@ class UnalignedSlot : public SlotBase<UnalignedSlot<T>, T, 1> {
|
||||
}
|
||||
|
||||
private:
|
||||
T value() const { return ReadUnalignedValue<T>(address_); }
|
||||
T value() const { return base::ReadUnalignedValue<T>(address_); }
|
||||
|
||||
Address address_;
|
||||
};
|
||||
|
@ -270,9 +270,9 @@ bool TickSample::GetStackSample(Isolate* v8_isolate, RegisterState* regs,
|
||||
// bytecode_array might be garbage, so don't actually dereference it. We
|
||||
// avoid the frame->GetXXX functions since they call BytecodeArray::cast,
|
||||
// which has a heap access in its DCHECK.
|
||||
i::Address bytecode_array = i::Memory<i::Address>(
|
||||
i::Address bytecode_array = base::Memory<i::Address>(
|
||||
frame->fp() + i::InterpreterFrameConstants::kBytecodeArrayFromFp);
|
||||
i::Address bytecode_offset = i::Memory<i::Address>(
|
||||
i::Address bytecode_offset = base::Memory<i::Address>(
|
||||
frame->fp() + i::InterpreterFrameConstants::kBytecodeOffsetFromFp);
|
||||
|
||||
// If the bytecode array is a heap object and the bytecode offset is a
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/base/memory.h"
|
||||
#include "src/compiler/wasm-compiler.h"
|
||||
#include "src/debug/debug.h"
|
||||
#include "src/execution/arguments-inl.h"
|
||||
@ -209,12 +209,13 @@ RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) {
|
||||
// methods that could trigger a GC are being called.
|
||||
Address arg_buf_ptr = arg_buffer;
|
||||
for (int i = 0; i < num_params; ++i) {
|
||||
#define CASE_ARG_TYPE(type, ctype) \
|
||||
case wasm::type: \
|
||||
DCHECK_EQ(wasm::ValueTypes::ElementSizeInBytes(sig->GetParam(i)), \
|
||||
sizeof(ctype)); \
|
||||
wasm_args[i] = wasm::WasmValue(ReadUnalignedValue<ctype>(arg_buf_ptr)); \
|
||||
arg_buf_ptr += sizeof(ctype); \
|
||||
#define CASE_ARG_TYPE(type, ctype) \
|
||||
case wasm::type: \
|
||||
DCHECK_EQ(wasm::ValueTypes::ElementSizeInBytes(sig->GetParam(i)), \
|
||||
sizeof(ctype)); \
|
||||
wasm_args[i] = \
|
||||
wasm::WasmValue(base::ReadUnalignedValue<ctype>(arg_buf_ptr)); \
|
||||
arg_buf_ptr += sizeof(ctype); \
|
||||
break;
|
||||
switch (sig->GetParam(i)) {
|
||||
CASE_ARG_TYPE(kWasmI32, uint32_t)
|
||||
@ -227,7 +228,8 @@ RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) {
|
||||
case wasm::kWasmExceptRef: {
|
||||
DCHECK_EQ(wasm::ValueTypes::ElementSizeInBytes(sig->GetParam(i)),
|
||||
kSystemPointerSize);
|
||||
Handle<Object> ref(ReadUnalignedValue<Object>(arg_buf_ptr), isolate);
|
||||
Handle<Object> ref(base::ReadUnalignedValue<Object>(arg_buf_ptr),
|
||||
isolate);
|
||||
wasm_args[i] = wasm::WasmValue(ref);
|
||||
arg_buf_ptr += kSystemPointerSize;
|
||||
break;
|
||||
@ -259,12 +261,12 @@ RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) {
|
||||
// also un-boxes reference types from handles into raw pointers.
|
||||
arg_buf_ptr = arg_buffer;
|
||||
for (int i = 0; i < num_returns; ++i) {
|
||||
#define CASE_RET_TYPE(type, ctype) \
|
||||
case wasm::type: \
|
||||
DCHECK_EQ(wasm::ValueTypes::ElementSizeInBytes(sig->GetReturn(i)), \
|
||||
sizeof(ctype)); \
|
||||
WriteUnalignedValue<ctype>(arg_buf_ptr, wasm_rets[i].to<ctype>()); \
|
||||
arg_buf_ptr += sizeof(ctype); \
|
||||
#define CASE_RET_TYPE(type, ctype) \
|
||||
case wasm::type: \
|
||||
DCHECK_EQ(wasm::ValueTypes::ElementSizeInBytes(sig->GetReturn(i)), \
|
||||
sizeof(ctype)); \
|
||||
base::WriteUnalignedValue<ctype>(arg_buf_ptr, wasm_rets[i].to<ctype>()); \
|
||||
arg_buf_ptr += sizeof(ctype); \
|
||||
break;
|
||||
switch (sig->GetReturn(i)) {
|
||||
CASE_RET_TYPE(kWasmI32, uint32_t)
|
||||
@ -277,7 +279,8 @@ RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) {
|
||||
case wasm::kWasmExceptRef: {
|
||||
DCHECK_EQ(wasm::ValueTypes::ElementSizeInBytes(sig->GetReturn(i)),
|
||||
kSystemPointerSize);
|
||||
WriteUnalignedValue<Object>(arg_buf_ptr, *wasm_rets[i].to_anyref());
|
||||
base::WriteUnalignedValue<Object>(arg_buf_ptr,
|
||||
*wasm_rets[i].to_anyref());
|
||||
arg_buf_ptr += kSystemPointerSize;
|
||||
break;
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
#define V8_SNAPSHOT_SERIALIZER_COMMON_H_
|
||||
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/memory.h"
|
||||
#include "src/codegen/external-reference-table.h"
|
||||
#include "src/common/globals.h"
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/objects/visitors.h"
|
||||
#include "src/sanitizer/msan.h"
|
||||
#include "src/snapshot/references.h"
|
||||
@ -344,12 +344,13 @@ class SerializedData {
|
||||
|
||||
protected:
|
||||
void SetHeaderValue(uint32_t offset, uint32_t value) {
|
||||
WriteLittleEndianValue(reinterpret_cast<Address>(data_) + offset, value);
|
||||
base::WriteLittleEndianValue(reinterpret_cast<Address>(data_) + offset,
|
||||
value);
|
||||
}
|
||||
|
||||
uint32_t GetHeaderValue(uint32_t offset) const {
|
||||
return ReadLittleEndianValue<uint32_t>(reinterpret_cast<Address>(data_) +
|
||||
offset);
|
||||
return base::ReadLittleEndianValue<uint32_t>(
|
||||
reinterpret_cast<Address>(data_) + offset);
|
||||
}
|
||||
|
||||
void AllocateData(uint32_t size);
|
||||
|
@ -98,11 +98,12 @@ class Snapshot : public AllStatic {
|
||||
uint32_t index);
|
||||
|
||||
static uint32_t GetHeaderValue(const v8::StartupData* data, uint32_t offset) {
|
||||
return ReadLittleEndianValue<uint32_t>(
|
||||
return base::ReadLittleEndianValue<uint32_t>(
|
||||
reinterpret_cast<Address>(data->data) + offset);
|
||||
}
|
||||
static void SetHeaderValue(char* data, uint32_t offset, uint32_t value) {
|
||||
WriteLittleEndianValue(reinterpret_cast<Address>(data) + offset, value);
|
||||
base::WriteLittleEndianValue(reinterpret_cast<Address>(data) + offset,
|
||||
value);
|
||||
}
|
||||
|
||||
static void CheckVersion(const v8::StartupData* data);
|
||||
|
@ -1814,24 +1814,24 @@ i::Address FuncData::v8_callback(void* data, i::Address argv) {
|
||||
for (int i = 0; i < num_param_types; ++i) {
|
||||
switch (param_types[i]->kind()) {
|
||||
case I32:
|
||||
params[i] = Val(i::ReadUnalignedValue<int32_t>(p));
|
||||
params[i] = Val(v8::base::ReadUnalignedValue<int32_t>(p));
|
||||
p += 4;
|
||||
break;
|
||||
case I64:
|
||||
params[i] = Val(i::ReadUnalignedValue<int64_t>(p));
|
||||
params[i] = Val(v8::base::ReadUnalignedValue<int64_t>(p));
|
||||
p += 8;
|
||||
break;
|
||||
case F32:
|
||||
params[i] = Val(i::ReadUnalignedValue<float32_t>(p));
|
||||
params[i] = Val(v8::base::ReadUnalignedValue<float32_t>(p));
|
||||
p += 4;
|
||||
break;
|
||||
case F64:
|
||||
params[i] = Val(i::ReadUnalignedValue<float64_t>(p));
|
||||
params[i] = Val(v8::base::ReadUnalignedValue<float64_t>(p));
|
||||
p += 8;
|
||||
break;
|
||||
case ANYREF:
|
||||
case FUNCREF: {
|
||||
i::Address raw = i::ReadUnalignedValue<i::Address>(p);
|
||||
i::Address raw = v8::base::ReadUnalignedValue<i::Address>(p);
|
||||
p += sizeof(raw);
|
||||
if (raw == i::kNullAddress) {
|
||||
params[i] = Val(nullptr);
|
||||
@ -1864,27 +1864,28 @@ i::Address FuncData::v8_callback(void* data, i::Address argv) {
|
||||
for (int i = 0; i < num_result_types; ++i) {
|
||||
switch (result_types[i]->kind()) {
|
||||
case I32:
|
||||
i::WriteUnalignedValue(p, results[i].i32());
|
||||
v8::base::WriteUnalignedValue(p, results[i].i32());
|
||||
p += 4;
|
||||
break;
|
||||
case I64:
|
||||
i::WriteUnalignedValue(p, results[i].i64());
|
||||
v8::base::WriteUnalignedValue(p, results[i].i64());
|
||||
p += 8;
|
||||
break;
|
||||
case F32:
|
||||
i::WriteUnalignedValue(p, results[i].f32());
|
||||
v8::base::WriteUnalignedValue(p, results[i].f32());
|
||||
p += 4;
|
||||
break;
|
||||
case F64:
|
||||
i::WriteUnalignedValue(p, results[i].f64());
|
||||
v8::base::WriteUnalignedValue(p, results[i].f64());
|
||||
p += 8;
|
||||
break;
|
||||
case ANYREF:
|
||||
case FUNCREF: {
|
||||
if (results[i].ref() == nullptr) {
|
||||
i::WriteUnalignedValue(p, i::kNullAddress);
|
||||
v8::base::WriteUnalignedValue(p, i::kNullAddress);
|
||||
} else {
|
||||
i::WriteUnalignedValue(p, impl(results[i].ref())->v8_object()->ptr());
|
||||
v8::base::WriteUnalignedValue(
|
||||
p, impl(results[i].ref())->v8_object()->ptr());
|
||||
}
|
||||
p += sizeof(i::Address);
|
||||
break;
|
||||
|
@ -10,8 +10,8 @@
|
||||
#include <memory>
|
||||
|
||||
#include "src/base/compiler-specific.h"
|
||||
#include "src/base/memory.h"
|
||||
#include "src/codegen/signature.h"
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/flags/flags.h"
|
||||
#include "src/utils/utils.h"
|
||||
#include "src/utils/vector.h"
|
||||
@ -299,7 +299,7 @@ class Decoder {
|
||||
} else if (!validate_size(pc, sizeof(IntType), msg)) {
|
||||
return IntType{0};
|
||||
}
|
||||
return ReadLittleEndianValue<IntType>(reinterpret_cast<Address>(pc));
|
||||
return base::ReadLittleEndianValue<IntType>(reinterpret_cast<Address>(pc));
|
||||
}
|
||||
|
||||
template <typename IntType>
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/base/memory.h"
|
||||
#include "src/utils/utils.h"
|
||||
#include "src/utils/vector.h"
|
||||
|
||||
@ -22,9 +22,9 @@ void TraceMemoryOperation(ExecutionTier tier, const MemoryTracingInfo* info,
|
||||
#define TRACE_TYPE(rep, str, format, ctype1, ctype2) \
|
||||
case MachineRepresentation::rep: \
|
||||
SNPrintF(value, str ":" format, \
|
||||
ReadLittleEndianValue<ctype1>( \
|
||||
base::ReadLittleEndianValue<ctype1>( \
|
||||
reinterpret_cast<Address>(mem_start) + info->address), \
|
||||
ReadLittleEndianValue<ctype2>( \
|
||||
base::ReadLittleEndianValue<ctype2>( \
|
||||
reinterpret_cast<Address>(mem_start) + info->address)); \
|
||||
break;
|
||||
TRACE_TYPE(kWord8, " i8", "%d / %02x", uint8_t, uint8_t)
|
||||
|
@ -25,6 +25,9 @@ namespace v8 {
|
||||
namespace internal {
|
||||
namespace wasm {
|
||||
|
||||
using base::ReadLittleEndianValue;
|
||||
using base::WriteLittleEndianValue;
|
||||
|
||||
namespace {
|
||||
byte* raw_buffer_ptr(MaybeHandle<JSArrayBuffer> buffer, int offset) {
|
||||
return static_cast<byte*>(buffer.ToHandleChecked()->backing_store()) + offset;
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "src/trap-handler/trap-handler.h"
|
||||
#endif
|
||||
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/base/memory.h"
|
||||
#include "src/utils/utils.h"
|
||||
#include "src/wasm/wasm-external-refs.h"
|
||||
|
||||
@ -37,6 +37,9 @@ namespace v8 {
|
||||
namespace internal {
|
||||
namespace wasm {
|
||||
|
||||
using base::ReadUnalignedValue;
|
||||
using base::WriteUnalignedValue;
|
||||
|
||||
void f32_trunc_wrapper(Address data) {
|
||||
WriteUnalignedValue<float>(data, truncf(ReadUnalignedValue<float>(data)));
|
||||
}
|
||||
|
@ -34,6 +34,11 @@ namespace v8 {
|
||||
namespace internal {
|
||||
namespace wasm {
|
||||
|
||||
using base::ReadLittleEndianValue;
|
||||
using base::ReadUnalignedValue;
|
||||
using base::WriteLittleEndianValue;
|
||||
using base::WriteUnalignedValue;
|
||||
|
||||
#define TRACE(...) \
|
||||
do { \
|
||||
if (FLAG_trace_wasm_interpreter) PrintF(__VA_ARGS__); \
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "src/wasm/wasm-module.h"
|
||||
#include "src/wasm/wasm-opcodes.h"
|
||||
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/base/memory.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "src/codegen/signature.h"
|
||||
#include "src/zone/zone-containers.h"
|
||||
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/base/memory.h"
|
||||
#include "src/utils/vector.h"
|
||||
#include "src/wasm/leb-helper.h"
|
||||
#include "src/wasm/local-decl-encoder.h"
|
||||
@ -36,19 +36,19 @@ class ZoneBuffer : public ZoneObject {
|
||||
|
||||
void write_u16(uint16_t x) {
|
||||
EnsureSpace(2);
|
||||
WriteLittleEndianValue<uint16_t>(reinterpret_cast<Address>(pos_), x);
|
||||
base::WriteLittleEndianValue<uint16_t>(reinterpret_cast<Address>(pos_), x);
|
||||
pos_ += 2;
|
||||
}
|
||||
|
||||
void write_u32(uint32_t x) {
|
||||
EnsureSpace(4);
|
||||
WriteLittleEndianValue<uint32_t>(reinterpret_cast<Address>(pos_), x);
|
||||
base::WriteLittleEndianValue<uint32_t>(reinterpret_cast<Address>(pos_), x);
|
||||
pos_ += 4;
|
||||
}
|
||||
|
||||
void write_u64(uint64_t x) {
|
||||
EnsureSpace(8);
|
||||
WriteLittleEndianValue<uint64_t>(reinterpret_cast<Address>(pos_), x);
|
||||
base::WriteLittleEndianValue<uint64_t>(reinterpret_cast<Address>(pos_), x);
|
||||
pos_ += 8;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "src/wasm/wasm-objects.h"
|
||||
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/base/memory.h"
|
||||
#include "src/heap/heap-write-barrier-inl.h"
|
||||
#include "src/objects/contexts-inl.h"
|
||||
#include "src/objects/foreign-inl.h"
|
||||
@ -65,7 +65,7 @@ CAST_ACCESSOR(AsmWasmData)
|
||||
/* kTaggedSize aligned so we have to use unaligned pointer friendly */ \
|
||||
/* way of accessing them in order to avoid undefined behavior in C++ */ \
|
||||
/* code. */ \
|
||||
return ReadUnalignedValue<type>(FIELD_ADDR(*this, offset)); \
|
||||
return base::ReadUnalignedValue<type>(FIELD_ADDR(*this, offset)); \
|
||||
} else { \
|
||||
return *reinterpret_cast<type const*>(FIELD_ADDR(*this, offset)); \
|
||||
} \
|
||||
@ -77,7 +77,7 @@ CAST_ACCESSOR(AsmWasmData)
|
||||
/* kTaggedSize aligned so we have to use unaligned pointer friendly */ \
|
||||
/* way of accessing them in order to avoid undefined behavior in C++ */ \
|
||||
/* code. */ \
|
||||
WriteUnalignedValue<type>(FIELD_ADDR(*this, offset), value); \
|
||||
base::WriteUnalignedValue<type>(FIELD_ADDR(*this, offset), value); \
|
||||
} else { \
|
||||
*reinterpret_cast<type*>(FIELD_ADDR(*this, offset)) = value; \
|
||||
} \
|
||||
@ -148,19 +148,19 @@ Address WasmGlobalObject::address() const {
|
||||
}
|
||||
|
||||
int32_t WasmGlobalObject::GetI32() {
|
||||
return ReadLittleEndianValue<int32_t>(address());
|
||||
return base::ReadLittleEndianValue<int32_t>(address());
|
||||
}
|
||||
|
||||
int64_t WasmGlobalObject::GetI64() {
|
||||
return ReadLittleEndianValue<int64_t>(address());
|
||||
return base::ReadLittleEndianValue<int64_t>(address());
|
||||
}
|
||||
|
||||
float WasmGlobalObject::GetF32() {
|
||||
return ReadLittleEndianValue<float>(address());
|
||||
return base::ReadLittleEndianValue<float>(address());
|
||||
}
|
||||
|
||||
double WasmGlobalObject::GetF64() {
|
||||
return ReadLittleEndianValue<double>(address());
|
||||
return base::ReadLittleEndianValue<double>(address());
|
||||
}
|
||||
|
||||
Handle<Object> WasmGlobalObject::GetRef() {
|
||||
@ -170,19 +170,19 @@ Handle<Object> WasmGlobalObject::GetRef() {
|
||||
}
|
||||
|
||||
void WasmGlobalObject::SetI32(int32_t value) {
|
||||
WriteLittleEndianValue<int32_t>(address(), value);
|
||||
base::WriteLittleEndianValue<int32_t>(address(), value);
|
||||
}
|
||||
|
||||
void WasmGlobalObject::SetI64(int64_t value) {
|
||||
WriteLittleEndianValue<int64_t>(address(), value);
|
||||
base::WriteLittleEndianValue<int64_t>(address(), value);
|
||||
}
|
||||
|
||||
void WasmGlobalObject::SetF32(float value) {
|
||||
WriteLittleEndianValue<float>(address(), value);
|
||||
base::WriteLittleEndianValue<float>(address(), value);
|
||||
}
|
||||
|
||||
void WasmGlobalObject::SetF64(double value) {
|
||||
WriteLittleEndianValue<double>(address(), value);
|
||||
base::WriteLittleEndianValue<double>(address(), value);
|
||||
}
|
||||
|
||||
void WasmGlobalObject::SetAnyRef(Handle<Object> value) {
|
||||
|
@ -5,7 +5,7 @@
|
||||
#ifndef V8_WASM_WASM_VALUE_H_
|
||||
#define V8_WASM_WASM_VALUE_H_
|
||||
|
||||
#include "src/common/v8memory.h"
|
||||
#include "src/base/memory.h"
|
||||
#include "src/handles/handles.h"
|
||||
#include "src/utils/boxed-float.h"
|
||||
#include "src/wasm/wasm-opcodes.h"
|
||||
@ -35,12 +35,12 @@ class Simd128 {
|
||||
val_[i] = 0;
|
||||
}
|
||||
}
|
||||
#define DEFINE_SIMD_TYPE_SPECIFIC_METHODS(cType, sType, name, size) \
|
||||
explicit Simd128(sType val) { \
|
||||
WriteUnalignedValue<sType>(reinterpret_cast<Address>(val_), val); \
|
||||
} \
|
||||
sType to_##name() { \
|
||||
return ReadUnalignedValue<sType>(reinterpret_cast<Address>(val_)); \
|
||||
#define DEFINE_SIMD_TYPE_SPECIFIC_METHODS(cType, sType, name, size) \
|
||||
explicit Simd128(sType val) { \
|
||||
base::WriteUnalignedValue<sType>(reinterpret_cast<Address>(val_), val); \
|
||||
} \
|
||||
sType to_##name() { \
|
||||
return base::ReadUnalignedValue<sType>(reinterpret_cast<Address>(val_)); \
|
||||
}
|
||||
FOREACH_SIMD_TYPE(DEFINE_SIMD_TYPE_SPECIFIC_METHODS)
|
||||
#undef DEFINE_SIMD_TYPE_SPECIFIC_METHODS
|
||||
@ -73,18 +73,20 @@ class WasmValue {
|
||||
public:
|
||||
WasmValue() : type_(kWasmStmt), bit_pattern_{} {}
|
||||
|
||||
#define DEFINE_TYPE_SPECIFIC_METHODS(name, localtype, ctype) \
|
||||
explicit WasmValue(ctype v) : type_(localtype), bit_pattern_{} { \
|
||||
static_assert(sizeof(ctype) <= sizeof(bit_pattern_), \
|
||||
"size too big for WasmValue"); \
|
||||
WriteUnalignedValue<ctype>(reinterpret_cast<Address>(bit_pattern_), v); \
|
||||
} \
|
||||
ctype to_##name() const { \
|
||||
DCHECK_EQ(localtype, type_); \
|
||||
return to_##name##_unchecked(); \
|
||||
} \
|
||||
ctype to_##name##_unchecked() const { \
|
||||
return ReadUnalignedValue<ctype>(reinterpret_cast<Address>(bit_pattern_)); \
|
||||
#define DEFINE_TYPE_SPECIFIC_METHODS(name, localtype, ctype) \
|
||||
explicit WasmValue(ctype v) : type_(localtype), bit_pattern_{} { \
|
||||
static_assert(sizeof(ctype) <= sizeof(bit_pattern_), \
|
||||
"size too big for WasmValue"); \
|
||||
base::WriteUnalignedValue<ctype>(reinterpret_cast<Address>(bit_pattern_), \
|
||||
v); \
|
||||
} \
|
||||
ctype to_##name() const { \
|
||||
DCHECK_EQ(localtype, type_); \
|
||||
return to_##name##_unchecked(); \
|
||||
} \
|
||||
ctype to_##name##_unchecked() const { \
|
||||
return base::ReadUnalignedValue<ctype>( \
|
||||
reinterpret_cast<Address>(bit_pattern_)); \
|
||||
}
|
||||
FOREACH_WASMVAL_TYPE(DEFINE_TYPE_SPECIFIC_METHODS)
|
||||
#undef DEFINE_TYPE_SPECIFIC_METHODS
|
||||
|
@ -28,6 +28,8 @@ namespace internal {
|
||||
namespace wasm {
|
||||
namespace test_run_wasm_module {
|
||||
|
||||
using base::ReadLittleEndianValue;
|
||||
using base::WriteLittleEndianValue;
|
||||
using testing::CompileAndInstantiateForTesting;
|
||||
|
||||
namespace {
|
||||
|
@ -47,6 +47,9 @@ namespace v8 {
|
||||
namespace internal {
|
||||
namespace wasm {
|
||||
|
||||
using base::ReadLittleEndianValue;
|
||||
using base::WriteLittleEndianValue;
|
||||
|
||||
constexpr uint32_t kMaxFunctions = 10;
|
||||
constexpr uint32_t kMaxGlobalsSize = 128;
|
||||
|
||||
|
@ -69,7 +69,7 @@ class InputProvider {
|
||||
int NextInt32(int limit) {
|
||||
if (current_ + sizeof(uint32_t) > end_) return 0;
|
||||
int result =
|
||||
ReadLittleEndianValue<int>(reinterpret_cast<Address>(current_));
|
||||
base::ReadLittleEndianValue<int>(reinterpret_cast<Address>(current_));
|
||||
current_ += sizeof(uint32_t);
|
||||
return result % limit;
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ TEST_F(FunctionBodyDecoderTest, Float32Const) {
|
||||
byte code[] = {kExprF32Const, 0, 0, 0, 0};
|
||||
Address ptr = reinterpret_cast<Address>(code + 1);
|
||||
for (int i = 0; i < 30; i++) {
|
||||
WriteLittleEndianValue<float>(ptr, i * -7.75f);
|
||||
base::WriteLittleEndianValue<float>(ptr, i * -7.75f);
|
||||
ExpectValidates(sigs.f_ff(), code);
|
||||
}
|
||||
}
|
||||
@ -362,7 +362,7 @@ TEST_F(FunctionBodyDecoderTest, Float64Const) {
|
||||
byte code[] = {kExprF64Const, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
Address ptr = reinterpret_cast<Address>(code + 1);
|
||||
for (int i = 0; i < 30; i++) {
|
||||
WriteLittleEndianValue<double>(ptr, i * 33.45);
|
||||
base::WriteLittleEndianValue<double>(ptr, i * 33.45);
|
||||
ExpectValidates(sigs.d_dd(), code);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user