Replace libc functions with base wrappers
Bug: v8:10927 Change-Id: Icbdc0d7329ddd466e7d67a954246a35795b4dece Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2507310 Commit-Queue: Ulan Degenbaev <ulan@chromium.org> Reviewed-by: Peter Marshall <petermarshall@chromium.org> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Reviewed-by: Toon Verwaest <verwaest@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#71220}
This commit is contained in:
parent
c1710dee65
commit
ba681fdb93
46
BUILD.gn
46
BUILD.gn
@ -1983,6 +1983,12 @@ v8_header_set("v8_headers") {
|
||||
deps = [ ":v8_version" ]
|
||||
}
|
||||
|
||||
v8_source_set("v8_wrappers") {
|
||||
configs = [ ":internal_config" ]
|
||||
|
||||
sources = [ "src/base/platform/wrappers.h" ]
|
||||
}
|
||||
|
||||
# This is split out to share basic headers with Torque.
|
||||
v8_header_set("v8_shared_internal_headers") {
|
||||
visibility = [ ":*" ] # Only targets in this file can depend on this.
|
||||
@ -3822,6 +3828,7 @@ v8_source_set("v8_base_without_compiler") {
|
||||
":v8_shared_internal_headers",
|
||||
":v8_tracing",
|
||||
":v8_version",
|
||||
":v8_wrappers",
|
||||
"src/inspector:inspector",
|
||||
]
|
||||
|
||||
@ -3986,7 +3993,10 @@ v8_source_set("torque_base") {
|
||||
|
||||
deps = [ ":v8_shared_internal_headers" ]
|
||||
|
||||
public_deps = [ ":v8_libbase" ]
|
||||
public_deps = [
|
||||
":v8_libbase",
|
||||
":v8_wrappers",
|
||||
]
|
||||
|
||||
# The use of exceptions for Torque in violation of the Chromium style-guide
|
||||
# is justified by the fact that it is only used from the non-essential
|
||||
@ -4109,8 +4119,6 @@ v8_component("v8_libbase") {
|
||||
"src/base/platform/semaphore.h",
|
||||
"src/base/platform/time.cc",
|
||||
"src/base/platform/time.h",
|
||||
"src/base/platform/wrappers.h",
|
||||
"src/base/platform/wrappers_std.cc",
|
||||
"src/base/region-allocator.cc",
|
||||
"src/base/region-allocator.h",
|
||||
"src/base/ring-buffer.h",
|
||||
@ -4135,7 +4143,7 @@ v8_component("v8_libbase") {
|
||||
|
||||
deps = [ ":v8_headers" ]
|
||||
|
||||
public_deps = []
|
||||
public_deps = [ ":v8_wrappers" ]
|
||||
|
||||
data = []
|
||||
|
||||
@ -4288,10 +4296,13 @@ v8_component("v8_libplatform") {
|
||||
|
||||
public_configs = [ ":libplatform_config" ]
|
||||
|
||||
public_deps = []
|
||||
|
||||
deps = [
|
||||
":v8_headers",
|
||||
":v8_libbase",
|
||||
":v8_tracing",
|
||||
":v8_wrappers",
|
||||
]
|
||||
|
||||
if (v8_use_perfetto) {
|
||||
@ -4639,6 +4650,7 @@ if (current_toolchain == v8_snapshot_toolchain) {
|
||||
":v8_libplatform",
|
||||
":v8_maybe_icu",
|
||||
":v8_tracing",
|
||||
":v8_wrappers",
|
||||
"//build/win:default_exe_manifest",
|
||||
]
|
||||
}
|
||||
@ -4982,6 +4994,7 @@ v8_executable("d8") {
|
||||
":v8_libbase",
|
||||
":v8_libplatform",
|
||||
":v8_tracing",
|
||||
":v8_wrappers",
|
||||
"//build/win:default_exe_manifest",
|
||||
]
|
||||
|
||||
@ -5120,7 +5133,10 @@ v8_fuzzer("json_fuzzer") {
|
||||
v8_source_set("multi_return_fuzzer") {
|
||||
sources = [ "test/fuzzer/multi-return.cc" ]
|
||||
|
||||
deps = [ ":fuzzer_support" ]
|
||||
deps = [
|
||||
":fuzzer_support",
|
||||
":v8_wrappers",
|
||||
]
|
||||
|
||||
configs = [
|
||||
":external_config",
|
||||
@ -5134,7 +5150,10 @@ v8_fuzzer("multi_return_fuzzer") {
|
||||
v8_source_set("parser_fuzzer") {
|
||||
sources = [ "test/fuzzer/parser.cc" ]
|
||||
|
||||
deps = [ ":fuzzer_support" ]
|
||||
deps = [
|
||||
":fuzzer_support",
|
||||
":v8_wrappers",
|
||||
]
|
||||
|
||||
configs = [
|
||||
":external_config",
|
||||
@ -5151,7 +5170,10 @@ v8_source_set("regexp_builtins_fuzzer") {
|
||||
"test/fuzzer/regexp_builtins/mjsunit.js.h",
|
||||
]
|
||||
|
||||
deps = [ ":fuzzer_support" ]
|
||||
deps = [
|
||||
":fuzzer_support",
|
||||
":v8_wrappers",
|
||||
]
|
||||
|
||||
configs = [
|
||||
":external_config",
|
||||
@ -5165,7 +5187,10 @@ v8_fuzzer("regexp_builtins_fuzzer") {
|
||||
v8_source_set("regexp_fuzzer") {
|
||||
sources = [ "test/fuzzer/regexp.cc" ]
|
||||
|
||||
deps = [ ":fuzzer_support" ]
|
||||
deps = [
|
||||
":fuzzer_support",
|
||||
":v8_wrappers",
|
||||
]
|
||||
|
||||
configs = [
|
||||
":external_config",
|
||||
@ -5204,6 +5229,7 @@ v8_source_set("wasm_fuzzer") {
|
||||
deps = [
|
||||
":fuzzer_support",
|
||||
":lib_wasm_fuzzer_common",
|
||||
":v8_wrappers",
|
||||
":wasm_test_common",
|
||||
]
|
||||
|
||||
@ -5222,6 +5248,7 @@ v8_source_set("wasm_async_fuzzer") {
|
||||
deps = [
|
||||
":fuzzer_support",
|
||||
":lib_wasm_fuzzer_common",
|
||||
":v8_wrappers",
|
||||
":wasm_test_common",
|
||||
]
|
||||
|
||||
@ -5243,6 +5270,7 @@ v8_source_set("wasm_code_fuzzer") {
|
||||
deps = [
|
||||
":fuzzer_support",
|
||||
":lib_wasm_fuzzer_common",
|
||||
":v8_wrappers",
|
||||
":wasm_test_common",
|
||||
]
|
||||
|
||||
@ -5284,6 +5312,7 @@ v8_source_set("wasm_compile_fuzzer") {
|
||||
deps = [
|
||||
":fuzzer_support",
|
||||
":lib_wasm_fuzzer_common",
|
||||
":v8_wrappers",
|
||||
":wasm_test_common",
|
||||
]
|
||||
|
||||
@ -5301,6 +5330,7 @@ v8_source_set("inspector_fuzzer") {
|
||||
|
||||
deps = [
|
||||
":fuzzer_support",
|
||||
":v8_wrappers",
|
||||
"test/inspector:inspector_test",
|
||||
]
|
||||
|
||||
|
@ -131,6 +131,7 @@
|
||||
#include "include/v8-wasm-trap-handler-win.h"
|
||||
#include "src/trap-handler/handler-inside-win.h"
|
||||
#if defined(V8_OS_WIN64)
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/diagnostics/unwinding-info-win64.h"
|
||||
#endif // V8_OS_WIN64
|
||||
#endif // V8_OS_WIN
|
||||
@ -549,7 +550,7 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
|
||||
// See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79839
|
||||
void* data = __linux_calloc(length, 1);
|
||||
#else
|
||||
void* data = calloc(length, 1);
|
||||
void* data = base::Calloc(length, 1);
|
||||
#endif
|
||||
return data;
|
||||
}
|
||||
@ -560,12 +561,12 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
|
||||
// See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79839
|
||||
void* data = __linux_malloc(length);
|
||||
#else
|
||||
void* data = malloc(length);
|
||||
void* data = base::Malloc(length);
|
||||
#endif
|
||||
return data;
|
||||
}
|
||||
|
||||
void Free(void* data, size_t) override { free(data); }
|
||||
void Free(void* data, size_t) override { base::Free(data); }
|
||||
|
||||
void* Reallocate(void* data, size_t old_length, size_t new_length) override {
|
||||
#if V8_OS_AIX && _LINUX_SOURCE_COMPAT
|
||||
@ -573,7 +574,7 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
|
||||
// See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79839
|
||||
void* new_data = __linux_realloc(data, new_length);
|
||||
#else
|
||||
void* new_data = realloc(data, new_length);
|
||||
void* new_data = base::Realloc(data, new_length);
|
||||
#endif
|
||||
if (new_length > old_length) {
|
||||
memset(reinterpret_cast<uint8_t*>(new_data) + old_length, 0,
|
||||
@ -3148,11 +3149,11 @@ void* ValueSerializer::Delegate::ReallocateBufferMemory(void* old_buffer,
|
||||
size_t size,
|
||||
size_t* actual_size) {
|
||||
*actual_size = size;
|
||||
return realloc(old_buffer, size);
|
||||
return base::Realloc(old_buffer, size);
|
||||
}
|
||||
|
||||
void ValueSerializer::Delegate::FreeBufferMemory(void* buffer) {
|
||||
return free(buffer);
|
||||
return base::Free(buffer);
|
||||
}
|
||||
|
||||
struct ValueSerializer::PrivateData {
|
||||
@ -5319,7 +5320,7 @@ static int WriteUtf8Impl(i::Vector<const Char> string, char* write_start,
|
||||
for (int i = read_index; i < up_to; i++) char_mask |= read_start[i];
|
||||
if ((char_mask & 0x80) == 0) {
|
||||
int copy_length = up_to - read_index;
|
||||
memcpy(current_write, read_start + read_index, copy_length);
|
||||
base::Memcpy(current_write, read_start + read_index, copy_length);
|
||||
current_write += copy_length;
|
||||
read_index = up_to;
|
||||
} else {
|
||||
@ -7370,7 +7371,7 @@ void* v8::ArrayBuffer::Allocator::Reallocate(void* data, size_t old_length,
|
||||
reinterpret_cast<uint8_t*>(AllocateUninitialized(new_length));
|
||||
if (new_data == nullptr) return nullptr;
|
||||
size_t bytes_to_copy = std::min(old_length, new_length);
|
||||
memcpy(new_data, data, bytes_to_copy);
|
||||
base::Memcpy(new_data, data, bytes_to_copy);
|
||||
if (new_length > bytes_to_copy) {
|
||||
memset(new_data + bytes_to_copy, 0, new_length - bytes_to_copy);
|
||||
}
|
||||
@ -7677,7 +7678,7 @@ size_t v8::ArrayBufferView::CopyContents(void* dest, size_t byte_length) {
|
||||
isolate);
|
||||
source = reinterpret_cast<char*>(typed_array->DataPtr());
|
||||
}
|
||||
memcpy(dest, source + byte_offset, bytes_to_copy);
|
||||
base::Memcpy(dest, source + byte_offset, bytes_to_copy);
|
||||
}
|
||||
return bytes_to_copy;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "src/base/hashmap-entry.h"
|
||||
#include "src/base/logging.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/common/globals.h"
|
||||
#include "src/heap/factory-inl.h"
|
||||
#include "src/heap/local-factory-inl.h"
|
||||
@ -403,7 +404,7 @@ const AstRawString* AstValueFactory::GetString(
|
||||
// Copy literal contents for later comparison.
|
||||
int length = literal_bytes.length();
|
||||
byte* new_literal_bytes = zone()->NewArray<byte>(length);
|
||||
memcpy(new_literal_bytes, literal_bytes.begin(), length);
|
||||
base::Memcpy(new_literal_bytes, literal_bytes.begin(), length);
|
||||
AstRawString* new_string = zone()->New<AstRawString>(
|
||||
is_one_byte, Vector<const byte>(new_literal_bytes, length),
|
||||
raw_hash_field);
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "src/ast/scopes.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/base/logging.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/builtins/builtins-constructor.h"
|
||||
#include "src/builtins/builtins.h"
|
||||
#include "src/common/assert-scope.h"
|
||||
@ -266,7 +267,7 @@ std::unique_ptr<char[]> FunctionLiteral::GetDebugName() const {
|
||||
}
|
||||
}
|
||||
std::unique_ptr<char[]> result(new char[result_vec.size() + 1]);
|
||||
memcpy(result.get(), result_vec.data(), result_vec.size());
|
||||
base::Memcpy(result.get(), result_vec.data(), result_vec.size());
|
||||
result[result_vec.size()] = '\0';
|
||||
return result;
|
||||
}
|
||||
|
@ -41,9 +41,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "src/base/logging.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#if V8_OS_WIN
|
||||
#include "src/base/win32-headers.h" // NOLINT
|
||||
#endif
|
||||
@ -164,7 +166,7 @@ static uint32_t ReadELFHWCaps() {
|
||||
result = static_cast<uint32_t>(getauxval(AT_HWCAP));
|
||||
#else
|
||||
// Read the ELF HWCAP flags by parsing /proc/self/auxv.
|
||||
FILE* fp = fopen("/proc/self/auxv", "r");
|
||||
FILE* fp = base::Fopen("/proc/self/auxv", "r");
|
||||
if (fp != nullptr) {
|
||||
struct {
|
||||
uint32_t tag;
|
||||
@ -180,7 +182,7 @@ static uint32_t ReadELFHWCaps() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
base::Fclose(fp);
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
@ -238,7 +240,7 @@ class CPUInfo final {
|
||||
// required because files under /proc do not always return a valid size
|
||||
// when using fseek(0, SEEK_END) + ftell(). Nor can the be mmap()-ed.
|
||||
static const char PATHNAME[] = "/proc/cpuinfo";
|
||||
FILE* fp = fopen(PATHNAME, "r");
|
||||
FILE* fp = base::Fopen(PATHNAME, "r");
|
||||
if (fp != nullptr) {
|
||||
for (;;) {
|
||||
char buffer[256];
|
||||
@ -248,12 +250,12 @@ class CPUInfo final {
|
||||
}
|
||||
datalen_ += n;
|
||||
}
|
||||
fclose(fp);
|
||||
base::Fclose(fp);
|
||||
}
|
||||
|
||||
// Read the contents of the cpuinfo file.
|
||||
data_ = new char[datalen_ + 1];
|
||||
fp = fopen(PATHNAME, "r");
|
||||
fp = base::Fopen(PATHNAME, "r");
|
||||
if (fp != nullptr) {
|
||||
for (size_t offset = 0; offset < datalen_; ) {
|
||||
size_t n = fread(data_ + offset, 1, datalen_ - offset, fp);
|
||||
@ -262,7 +264,7 @@ class CPUInfo final {
|
||||
}
|
||||
offset += n;
|
||||
}
|
||||
fclose(fp);
|
||||
base::Fclose(fp);
|
||||
}
|
||||
|
||||
// Zero-terminate the data.
|
||||
@ -311,7 +313,7 @@ class CPUInfo final {
|
||||
size_t len = q - p;
|
||||
char* result = new char[len + 1];
|
||||
if (result != nullptr) {
|
||||
memcpy(result, p, len);
|
||||
base::Memcpy(result, p, len);
|
||||
result[len] = '\0';
|
||||
}
|
||||
return result;
|
||||
@ -440,7 +442,7 @@ CPU::CPU()
|
||||
is_fp64_mode_(false),
|
||||
has_non_stop_time_stamp_counter_(false),
|
||||
has_msa_(false) {
|
||||
memcpy(vendor_, "Unknown", 8);
|
||||
base::Memcpy(vendor_, "Unknown", 8);
|
||||
|
||||
#if defined(STARBOARD)
|
||||
if (StarboardDetectCPU()) {
|
||||
@ -461,7 +463,7 @@ CPU::CPU()
|
||||
__cpuid(cpu_info, 0);
|
||||
unsigned num_ids = cpu_info[0];
|
||||
std::swap(cpu_info[2], cpu_info[3]);
|
||||
memcpy(vendor_, cpu_info + 1, 12);
|
||||
base::Memcpy(vendor_, cpu_info + 1, 12);
|
||||
vendor_[12] = '\0';
|
||||
|
||||
// Interpret CPU feature information.
|
||||
@ -737,7 +739,7 @@ CPU::CPU()
|
||||
#if V8_OS_LINUX
|
||||
// Read processor info from /proc/self/auxv.
|
||||
char* auxv_cpu_type = nullptr;
|
||||
FILE* fp = fopen("/proc/self/auxv", "r");
|
||||
FILE* fp = base::Fopen("/proc/self/auxv", "r");
|
||||
if (fp != nullptr) {
|
||||
#if V8_TARGET_ARCH_PPC64
|
||||
Elf64_auxv_t entry;
|
||||
@ -761,7 +763,7 @@ CPU::CPU()
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
base::Fclose(fp);
|
||||
}
|
||||
|
||||
part_ = -1;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace base {
|
||||
@ -21,8 +22,8 @@ std::unique_ptr<char[]> RelativePath(const char* exec_path, const char* name) {
|
||||
}
|
||||
size_t name_length = strlen(name);
|
||||
auto buffer = std::make_unique<char[]>(basename_start + name_length + 1);
|
||||
if (basename_start > 0) memcpy(buffer.get(), exec_path, basename_start);
|
||||
memcpy(buffer.get() + basename_start, name, name_length);
|
||||
if (basename_start > 0) base::Memcpy(buffer.get(), exec_path, basename_start);
|
||||
base::Memcpy(buffer.get() + basename_start, name, name_length);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,11 @@
|
||||
#define V8_BASE_FREE_DELETER_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace base {
|
||||
|
||||
@ -20,7 +23,7 @@ namespace base {
|
||||
// std::unique_ptr<int, base::FreeDeleter> foo_ptr(
|
||||
// static_cast<int*>(malloc(sizeof(int))));
|
||||
struct FreeDeleter {
|
||||
inline void operator()(void* ptr) const { free(ptr); }
|
||||
inline void operator()(void* ptr) const { base::Free(ptr); }
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/hashmap-entry.h"
|
||||
#include "src/base/logging.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace base {
|
||||
@ -22,11 +23,11 @@ class DefaultAllocationPolicy {
|
||||
public:
|
||||
template <typename T, typename TypeTag = T[]>
|
||||
V8_INLINE T* NewArray(size_t length) {
|
||||
return static_cast<T*>(malloc(length * sizeof(T)));
|
||||
return static_cast<T*>(base::Malloc(length * sizeof(T)));
|
||||
}
|
||||
template <typename T, typename TypeTag = T[]>
|
||||
V8_INLINE void DeleteArray(T* p, size_t length) {
|
||||
free(p);
|
||||
base::Free(p);
|
||||
}
|
||||
};
|
||||
|
||||
@ -197,7 +198,7 @@ TemplateHashMapImpl<Key, Value, MatchFun, AllocationPolicy>::
|
||||
impl_.capacity_ = original->capacity();
|
||||
impl_.occupancy_ = original->occupancy();
|
||||
impl_.map_ = impl_.allocator().template NewArray<Entry>(capacity());
|
||||
memcpy(impl_.map_, original->impl_.map_, capacity() * sizeof(Entry));
|
||||
base::Memcpy(impl_.map_, original->impl_.map_, capacity() * sizeof(Entry));
|
||||
}
|
||||
|
||||
template <typename Key, typename Value, typename MatchFun,
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "src/base/compiler-specific.h"
|
||||
#include "src/base/logging.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
|
||||
// No-op macro which is used to work around MSVC's funky VA_ARGS support.
|
||||
#define EXPAND(x) x
|
||||
@ -104,7 +105,7 @@ V8_INLINE Dest bit_cast(Source const& source) {
|
||||
static_assert(sizeof(Dest) == sizeof(Source),
|
||||
"source and dest must be same size");
|
||||
Dest dest;
|
||||
memcpy(&dest, &source, sizeof(dest));
|
||||
v8::base::Memcpy(&dest, &source, sizeof(dest));
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define V8_BASE_MEMORY_H_
|
||||
|
||||
#include "src/base/macros.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace base {
|
||||
@ -31,14 +32,14 @@ template <typename V>
|
||||
static inline V ReadUnalignedValue(Address p) {
|
||||
ASSERT_TRIVIALLY_COPYABLE(V);
|
||||
V r;
|
||||
memcpy(&r, reinterpret_cast<void*>(p), sizeof(V));
|
||||
base::Memcpy(&r, reinterpret_cast<void*>(p), sizeof(V));
|
||||
return r;
|
||||
}
|
||||
|
||||
template <typename V>
|
||||
static inline void WriteUnalignedValue(Address p, V value) {
|
||||
ASSERT_TRIVIALLY_COPYABLE(V);
|
||||
memcpy(reinterpret_cast<void*>(p), &value, sizeof(V));
|
||||
base::Memcpy(reinterpret_cast<void*>(p), &value, sizeof(V));
|
||||
}
|
||||
|
||||
template <typename V>
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "src/base/page-allocator.h"
|
||||
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
|
||||
#if V8_OS_MACOSX
|
||||
#include <sys/mman.h> // For MAP_JIT.
|
||||
@ -108,7 +109,7 @@ PageAllocator::AllocateSharedPages(size_t size, const void* original_address) {
|
||||
void* ptr =
|
||||
base::OS::AllocateShared(size, base::OS::MemoryPermission::kReadWrite);
|
||||
CHECK_NOT_NULL(ptr);
|
||||
memcpy(ptr, original_address, size);
|
||||
base::Memcpy(ptr, original_address, size);
|
||||
bool success = base::OS::SetPermissions(
|
||||
ptr, size, base::OS::MemoryPermission::kReadWrite);
|
||||
CHECK(success);
|
||||
|
@ -7,23 +7,65 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "src/base/base-export.h"
|
||||
|
||||
#if defined(V8_OS_STARBOARD)
|
||||
#include "starboard/memory.h"
|
||||
#endif
|
||||
|
||||
namespace v8 {
|
||||
namespace base {
|
||||
|
||||
void* Malloc(size_t size);
|
||||
#if !defined(V8_OS_STARBOARD)
|
||||
|
||||
void* Realloc(void* memory, size_t size);
|
||||
// Common libstd implementations.
|
||||
// inline implementations are preferred here due to performance concerns.
|
||||
inline void* Malloc(size_t size) { return malloc(size); }
|
||||
|
||||
void Free(void* memory);
|
||||
inline void* Realloc(void* memory, size_t size) {
|
||||
return realloc(memory, size);
|
||||
}
|
||||
|
||||
void* Calloc(size_t count, size_t size);
|
||||
inline void Free(void* memory) { return free(memory); }
|
||||
|
||||
void* Memcpy(void* dest, const void* source, size_t count);
|
||||
inline void* Calloc(size_t count, size_t size) { return calloc(count, size); }
|
||||
|
||||
FILE* Fopen(const char* filename, const char* mode);
|
||||
inline void* Memcpy(void* dest, const void* source, size_t count) {
|
||||
return memcpy(dest, source, count);
|
||||
}
|
||||
|
||||
int Fclose(FILE* stream);
|
||||
inline FILE* Fopen(const char* filename, const char* mode) {
|
||||
return fopen(filename, mode);
|
||||
}
|
||||
|
||||
inline int Fclose(FILE* stream) { return fclose(stream); }
|
||||
|
||||
#else // V8_OS_STARBOARD
|
||||
|
||||
inline void* Malloc(size_t size) { return SbMemoryAlloc(size); }
|
||||
|
||||
inline void* Realloc(void* memory, size_t size) {
|
||||
return SbMemoryReallocate(memory, size);
|
||||
}
|
||||
|
||||
inline void Free(void* memory) { return SbMemoryDeallocate(memory); }
|
||||
|
||||
inline void* Calloc(size_t count, size_t size) {
|
||||
return SbMemoryCalloc(count, size);
|
||||
}
|
||||
|
||||
inline void* Memcpy(void* dest, const void* source, size_t count) {
|
||||
return SbMemoryCopy(dest, source, count);
|
||||
}
|
||||
|
||||
inline FILE* Fopen(const char* filename, const char* mode) { return NULL; }
|
||||
|
||||
inline int Fclose(FILE* stream) { return -1; }
|
||||
|
||||
#endif // V8_OS_STARBOARD
|
||||
|
||||
} // namespace base
|
||||
} // namespace v8
|
||||
|
@ -1,31 +0,0 @@
|
||||
// Copyright 2020 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.
|
||||
|
||||
#include "starboard/memory.h"
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace base {
|
||||
|
||||
void* Malloc(size_t size) { return SbMemoryAlloc(size); }
|
||||
|
||||
void* Realloc(void* memory, size_t size) {
|
||||
return SbMemoryReallocate(memory, size);
|
||||
}
|
||||
|
||||
void Free(void* memory) { return SbMemoryDeallocate(memory); }
|
||||
|
||||
void* Calloc(size_t count, size_t size) { return SbMemoryCalloc(count, size); }
|
||||
|
||||
void* Memcpy(void* dest, const void* source, size_t count) {
|
||||
return SbMemoryCopy(dest, source, count);
|
||||
}
|
||||
|
||||
FILE* Fopen(const char* filename, const char* mode) { return NULL; }
|
||||
|
||||
int Fclose(FILE* stream) { return -1; }
|
||||
|
||||
} // namespace base
|
||||
} // namespace v8
|
@ -1,34 +0,0 @@
|
||||
// Copyright 2020 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.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace base {
|
||||
|
||||
void* Malloc(size_t size) { return malloc(size); }
|
||||
|
||||
void* Realloc(void* memory, size_t size) { return realloc(memory, size); }
|
||||
|
||||
void Free(void* memory) { return free(memory); }
|
||||
|
||||
void* Calloc(size_t count, size_t size) { return calloc(count, size); }
|
||||
|
||||
void* Memcpy(void* dest, const void* source, size_t count) {
|
||||
return memcpy(dest, source, count);
|
||||
}
|
||||
|
||||
FILE* Fopen(const char* filename, const char* mode) {
|
||||
return fopen(filename, mode);
|
||||
}
|
||||
|
||||
int Fclose(FILE* stream) { return fclose(stream); }
|
||||
|
||||
} // namespace base
|
||||
} // namespace v8
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/macros.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace base {
|
||||
@ -33,11 +34,11 @@ class SmallVector {
|
||||
SmallVector(SmallVector&& other) V8_NOEXCEPT { *this = std::move(other); }
|
||||
SmallVector(std::initializer_list<T> init) {
|
||||
resize_no_init(init.size());
|
||||
memcpy(begin_, init.begin(), sizeof(T) * init.size());
|
||||
base::Memcpy(begin_, init.begin(), sizeof(T) * init.size());
|
||||
}
|
||||
|
||||
~SmallVector() {
|
||||
if (is_big()) free(begin_);
|
||||
if (is_big()) base::Free(begin_);
|
||||
}
|
||||
|
||||
SmallVector& operator=(const SmallVector& other) V8_NOEXCEPT {
|
||||
@ -45,11 +46,11 @@ class SmallVector {
|
||||
size_t other_size = other.size();
|
||||
if (capacity() < other_size) {
|
||||
// Create large-enough heap-allocated storage.
|
||||
if (is_big()) free(begin_);
|
||||
begin_ = reinterpret_cast<T*>(malloc(sizeof(T) * other_size));
|
||||
if (is_big()) base::Free(begin_);
|
||||
begin_ = reinterpret_cast<T*>(base::Malloc(sizeof(T) * other_size));
|
||||
end_of_storage_ = begin_ + other_size;
|
||||
}
|
||||
memcpy(begin_, other.begin_, sizeof(T) * other_size);
|
||||
base::Memcpy(begin_, other.begin_, sizeof(T) * other_size);
|
||||
end_ = begin_ + other_size;
|
||||
return *this;
|
||||
}
|
||||
@ -57,7 +58,7 @@ class SmallVector {
|
||||
SmallVector& operator=(SmallVector&& other) V8_NOEXCEPT {
|
||||
if (this == &other) return *this;
|
||||
if (other.is_big()) {
|
||||
if (is_big()) free(begin_);
|
||||
if (is_big()) base::Free(begin_);
|
||||
begin_ = other.begin_;
|
||||
end_ = other.end_;
|
||||
end_of_storage_ = other.end_of_storage_;
|
||||
@ -65,7 +66,7 @@ class SmallVector {
|
||||
} else {
|
||||
DCHECK_GE(capacity(), other.size()); // Sanity check.
|
||||
size_t other_size = other.size();
|
||||
memcpy(begin_, other.begin_, sizeof(T) * other_size);
|
||||
base::Memcpy(begin_, other.begin_, sizeof(T) * other_size);
|
||||
end_ = begin_ + other_size;
|
||||
}
|
||||
return *this;
|
||||
@ -151,9 +152,10 @@ class SmallVector {
|
||||
size_t in_use = end_ - begin_;
|
||||
size_t new_capacity =
|
||||
base::bits::RoundUpToPowerOfTwo(std::max(min_capacity, 2 * capacity()));
|
||||
T* new_storage = reinterpret_cast<T*>(malloc(sizeof(T) * new_capacity));
|
||||
memcpy(new_storage, begin_, sizeof(T) * in_use);
|
||||
if (is_big()) free(begin_);
|
||||
T* new_storage =
|
||||
reinterpret_cast<T*>(base::Malloc(sizeof(T) * new_capacity));
|
||||
base::Memcpy(new_storage, begin_, sizeof(T) * in_use);
|
||||
if (is_big()) base::Free(begin_);
|
||||
begin_ = new_storage;
|
||||
end_ = new_storage + in_use;
|
||||
end_of_storage_ = new_storage + new_capacity;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "src/base/macros.h"
|
||||
#include "src/base/platform/mutex.h"
|
||||
#include "src/base/platform/time.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace base {
|
||||
@ -60,11 +61,11 @@ RandomNumberGenerator::RandomNumberGenerator() {
|
||||
SetSeed(seed);
|
||||
#else
|
||||
// Gather entropy from /dev/urandom if available.
|
||||
FILE* fp = fopen("/dev/urandom", "rb");
|
||||
FILE* fp = base::Fopen("/dev/urandom", "rb");
|
||||
if (fp != nullptr) {
|
||||
int64_t seed;
|
||||
size_t n = fread(&seed, sizeof(seed), 1, fp);
|
||||
fclose(fp);
|
||||
base::Fclose(fp);
|
||||
if (n == 1) {
|
||||
SetSeed(seed);
|
||||
return;
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#if defined(V8_USE_PERFETTO)
|
||||
#include "protos/perfetto/trace/track_event/debug_annotation.pbzero.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#endif
|
||||
|
||||
namespace v8 {
|
||||
@ -40,8 +41,8 @@ class MaybeUtf8 {
|
||||
// strings, the bytes we get from SeqOneByteString are not. buf_ is
|
||||
// guaranteed to be null terminated.
|
||||
DisallowHeapAllocation no_gc;
|
||||
memcpy(buf_, Handle<SeqOneByteString>::cast(string)->GetChars(no_gc),
|
||||
len);
|
||||
base::Memcpy(
|
||||
buf_, Handle<SeqOneByteString>::cast(string)->GetChars(no_gc), len);
|
||||
}
|
||||
} else {
|
||||
Local<v8::String> local = Utils::ToLocal(string);
|
||||
|
@ -27,6 +27,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(V8_OS_WIN)
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/diagnostics/unwinding-info-win64.h"
|
||||
#endif // V8_OS_WIN
|
||||
|
||||
@ -2589,7 +2590,7 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
|
||||
STATIC_ASSERT(sizeof(instruction) == kInstrSize);
|
||||
DCHECK_LE(pc_ + sizeof(instruction), buffer_start_ + buffer_->size());
|
||||
|
||||
memcpy(pc_, &instruction, sizeof(instruction));
|
||||
base::Memcpy(pc_, &instruction, sizeof(instruction));
|
||||
pc_ += sizeof(instruction);
|
||||
CheckBuffer();
|
||||
}
|
||||
@ -2601,7 +2602,7 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
|
||||
|
||||
// TODO(all): Somehow register we have some data here. Then we can
|
||||
// disassemble it correctly.
|
||||
memcpy(pc_, data, size);
|
||||
base::Memcpy(pc_, data, size);
|
||||
pc_ += size;
|
||||
CheckBuffer();
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
// Satisfy cpplint check, but don't include platform-specific header. It is
|
||||
// included recursively via macro-assembler.h.
|
||||
#if 0
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/arm64/macro-assembler-arm64.h"
|
||||
#endif
|
||||
|
||||
@ -372,7 +373,7 @@ void TurboAssembler::Movi32bitHelper(const VRegister& vd, uint64_t imm) {
|
||||
DCHECK(is_uint32(imm));
|
||||
|
||||
uint8_t bytes[sizeof(imm)];
|
||||
memcpy(bytes, &imm, sizeof(imm));
|
||||
base::Memcpy(bytes, &imm, sizeof(imm));
|
||||
|
||||
// All bytes are either 0x00 or 0xFF.
|
||||
{
|
||||
|
@ -12,7 +12,10 @@
|
||||
#if defined(DEBUG) && defined(V8_OS_LINUX) && !defined(V8_OS_ANDROID)
|
||||
#define SYMBOLIZE_FUNCTION
|
||||
#include <execinfo.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#endif // DEBUG && V8_OS_LINUX && !V8_OS_ANDROID
|
||||
|
||||
namespace v8 {
|
||||
@ -98,7 +101,7 @@ const char* ExternalReferenceTable::ResolveSymbol(void* address) {
|
||||
const char* name = names[0];
|
||||
// The array of names is malloc'ed. However, each name string is static
|
||||
// and do not need to be freed.
|
||||
free(names);
|
||||
base::Free(names);
|
||||
return name;
|
||||
#else
|
||||
return "<unresolved>";
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "src/wasm/wasm-external-refs.h"
|
||||
|
||||
#ifdef V8_INTL_SUPPORT
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/objects/intl-objects.h"
|
||||
#endif // V8_INTL_SUPPORT
|
||||
|
||||
@ -610,7 +611,7 @@ void* libc_memchr(void* string, int character, size_t search_length) {
|
||||
FUNCTION_REFERENCE(libc_memchr_function, libc_memchr)
|
||||
|
||||
void* libc_memcpy(void* dest, const void* src, size_t n) {
|
||||
return memcpy(dest, src, n);
|
||||
return base::Memcpy(dest, src, n);
|
||||
}
|
||||
|
||||
FUNCTION_REFERENCE(libc_memcpy_function, libc_memcpy)
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "src/codegen/optimized-compilation-info.h"
|
||||
|
||||
#include "src/api/api.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/source-position.h"
|
||||
#include "src/debug/debug.h"
|
||||
#include "src/execution/isolate.h"
|
||||
@ -154,7 +155,7 @@ std::unique_ptr<char[]> OptimizedCompilationInfo::GetDebugName() const {
|
||||
Vector<const char> name_vec = debug_name_;
|
||||
if (name_vec.empty()) name_vec = ArrayVector("unknown");
|
||||
std::unique_ptr<char[]> name(new char[name_vec.length() + 1]);
|
||||
memcpy(name.get(), name_vec.begin(), name_vec.length());
|
||||
base::Memcpy(name.get(), name_vec.begin(), name_vec.length());
|
||||
name[name_vec.length()] = '\0';
|
||||
return name;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/cpu.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/assembler-inl.h"
|
||||
#include "src/codegen/macro-assembler.h"
|
||||
#include "src/codegen/string-constants.h"
|
||||
@ -2002,7 +2003,7 @@ void Assembler::Nop(int n) {
|
||||
EnsureSpace ensure_space(this);
|
||||
int nop_bytes = std::min(n, 9);
|
||||
const char* sequence = kNopSequences + kNopOffsets[nop_bytes];
|
||||
memcpy(pc_, sequence, nop_bytes);
|
||||
base::Memcpy(pc_, sequence, nop_bytes);
|
||||
pc_ += nop_bytes;
|
||||
n -= nop_bytes;
|
||||
} while (n);
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/enum-set.h"
|
||||
#include "src/base/iterator.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/compiler/backend/instruction-selector-impl.h"
|
||||
#include "src/compiler/node-matchers.h"
|
||||
#include "src/compiler/node-properties.h"
|
||||
@ -2656,7 +2657,7 @@ void InstructionSelector::VisitI32x4DotI16x8S(Node* node) {
|
||||
void InstructionSelector::VisitS128Const(Node* node) {
|
||||
ArmOperandGenerator g(this);
|
||||
uint32_t val[kSimd128Size / sizeof(uint32_t)];
|
||||
memcpy(val, S128ImmediateParameterOf(node->op()).data(), kSimd128Size);
|
||||
base::Memcpy(val, S128ImmediateParameterOf(node->op()).data(), kSimd128Size);
|
||||
// If all bytes are zeros, avoid emitting code for generic constants.
|
||||
bool all_zeros = !(val[0] || val[1] || val[2] || val[3]);
|
||||
bool all_ones = val[0] == UINT32_MAX && val[1] == UINT32_MAX &&
|
||||
|
@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/assembler-inl.h"
|
||||
#include "src/compiler/backend/instruction-selector-impl.h"
|
||||
#include "src/compiler/node-matchers.h"
|
||||
@ -3432,7 +3433,7 @@ void InstructionSelector::VisitS128Const(Node* node) {
|
||||
static const int kUint32Immediates = 4;
|
||||
uint32_t val[kUint32Immediates];
|
||||
STATIC_ASSERT(sizeof(val) == kSimd128Size);
|
||||
memcpy(val, S128ImmediateParameterOf(node->op()).data(), kSimd128Size);
|
||||
base::Memcpy(val, S128ImmediateParameterOf(node->op()).data(), kSimd128Size);
|
||||
// If all bytes are zeros, avoid emitting code for generic constants
|
||||
bool all_zeros = !(val[0] || val[1] || val[2] || val[3]);
|
||||
InstructionOperand dst = g.DefineAsRegister(node);
|
||||
|
@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/base/iterator.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/compiler/backend/instruction-selector-impl.h"
|
||||
#include "src/compiler/node-matchers.h"
|
||||
#include "src/compiler/node-properties.h"
|
||||
@ -2178,7 +2179,7 @@ void InstructionSelector::VisitS128Const(Node* node) {
|
||||
IA32OperandGenerator g(this);
|
||||
static const int kUint32Immediates = kSimd128Size / sizeof(uint32_t);
|
||||
uint32_t val[kUint32Immediates];
|
||||
memcpy(val, S128ImmediateParameterOf(node->op()).data(), kSimd128Size);
|
||||
base::Memcpy(val, S128ImmediateParameterOf(node->op()).data(), kSimd128Size);
|
||||
// If all bytes are zeros or ones, avoid emitting code for generic constants
|
||||
bool all_zeros = !(val[0] || val[1] || val[2] || val[3]);
|
||||
bool all_ones = val[0] == UINT32_MAX && val[1] == UINT32_MAX &&
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <limits>
|
||||
|
||||
#include "src/base/iterator.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/assembler-inl.h"
|
||||
#include "src/codegen/tick-counter.h"
|
||||
#include "src/compiler/backend/instruction-selector-impl.h"
|
||||
@ -3316,7 +3317,8 @@ FrameStateDescriptor* InstructionSelector::GetFrameStateDescriptor(
|
||||
void InstructionSelector::CanonicalizeShuffle(Node* node, uint8_t* shuffle,
|
||||
bool* is_swizzle) {
|
||||
// Get raw shuffle indices.
|
||||
memcpy(shuffle, S128ImmediateParameterOf(node->op()).data(), kSimd128Size);
|
||||
base::Memcpy(shuffle, S128ImmediateParameterOf(node->op()).data(),
|
||||
kSimd128Size);
|
||||
bool needs_swap;
|
||||
bool inputs_equal = GetVirtualRegister(node->InputAt(0)) ==
|
||||
GetVirtualRegister(node->InputAt(1));
|
||||
|
@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/compiler/backend/instruction-selector-impl.h"
|
||||
#include "src/compiler/node-matchers.h"
|
||||
#include "src/compiler/node-properties.h"
|
||||
@ -2934,7 +2935,7 @@ void InstructionSelector::VisitS128Const(Node* node) {
|
||||
Mips64OperandGenerator g(this);
|
||||
static const int kUint32Immediates = kSimd128Size / sizeof(uint32_t);
|
||||
uint32_t val[kUint32Immediates];
|
||||
memcpy(val, S128ImmediateParameterOf(node->op()).data(), kSimd128Size);
|
||||
base::Memcpy(val, S128ImmediateParameterOf(node->op()).data(), kSimd128Size);
|
||||
// If all bytes are zeros or ones, avoid emitting code for generic constants
|
||||
bool all_zeros = !(val[0] || val[1] || val[2] || val[3]);
|
||||
bool all_ones = val[0] == UINT32_MAX && val[1] == UINT32_MAX &&
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/compiler/backend/instruction-selector-impl.h"
|
||||
#include "src/compiler/node-matchers.h"
|
||||
#include "src/compiler/node-properties.h"
|
||||
@ -2848,7 +2849,7 @@ void InstructionSelector::VisitI8x16Swizzle(Node* node) {
|
||||
void InstructionSelector::VisitS128Const(Node* node) {
|
||||
S390OperandGenerator g(this);
|
||||
uint32_t val[kSimd128Size / sizeof(uint32_t)];
|
||||
memcpy(val, S128ImmediateParameterOf(node->op()).data(), kSimd128Size);
|
||||
base::Memcpy(val, S128ImmediateParameterOf(node->op()).data(), kSimd128Size);
|
||||
// If all bytes are zeros, avoid emitting code for generic constants.
|
||||
bool all_zeros = !(val[0] || val[1] || val[2] || val[3]);
|
||||
bool all_ones = val[0] == UINT32_MAX && val[1] == UINT32_MAX &&
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "src/base/iterator.h"
|
||||
#include "src/base/logging.h"
|
||||
#include "src/base/overflowing-math.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/machine-type.h"
|
||||
#include "src/compiler/backend/instruction-selector-impl.h"
|
||||
#include "src/compiler/machine-operator.h"
|
||||
@ -2943,7 +2944,7 @@ void InstructionSelector::VisitS128Const(Node* node) {
|
||||
X64OperandGenerator g(this);
|
||||
static const int kUint32Immediates = kSimd128Size / sizeof(uint32_t);
|
||||
uint32_t val[kUint32Immediates];
|
||||
memcpy(val, S128ImmediateParameterOf(node->op()).data(), kSimd128Size);
|
||||
base::Memcpy(val, S128ImmediateParameterOf(node->op()).data(), kSimd128Size);
|
||||
// If all bytes are zeros or ones, avoid emitting code for generic constants
|
||||
bool all_zeros = !(val[0] || val[1] || val[2] || val[3]);
|
||||
bool all_ones = val[0] == UINT32_MAX && val[1] == UINT32_MAX &&
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "src/compiler/bytecode-graph-builder.h"
|
||||
|
||||
#include "src/ast/ast.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/source-position-table.h"
|
||||
#include "src/codegen/tick-counter.h"
|
||||
#include "src/compiler/access-builder.h"
|
||||
@ -4365,7 +4366,8 @@ Node* BytecodeGraphBuilder::MakeNode(const Operator* op, int value_input_count,
|
||||
if (has_effect) ++input_count_with_deps;
|
||||
Node** buffer = EnsureInputBufferSize(input_count_with_deps);
|
||||
if (value_input_count > 0) {
|
||||
memcpy(buffer, value_inputs, kSystemPointerSize * value_input_count);
|
||||
base::Memcpy(buffer, value_inputs,
|
||||
kSystemPointerSize * value_input_count);
|
||||
}
|
||||
Node** current_input = buffer + value_input_count;
|
||||
if (has_context) {
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/optimized-compilation-info.h"
|
||||
#include "src/codegen/source-position.h"
|
||||
#include "src/compiler/all-nodes.h"
|
||||
@ -255,7 +256,7 @@ std::unique_ptr<char[]> GetVisualizerLogFileName(OptimizedCompilationInfo* info,
|
||||
}
|
||||
|
||||
char* buffer = new char[full_filename.length() + 1];
|
||||
memcpy(buffer, full_filename.begin(), full_filename.length());
|
||||
base::Memcpy(buffer, full_filename.begin(), full_filename.length());
|
||||
buffer[full_filename.length()] = '\0';
|
||||
return std::unique_ptr<char[]>(buffer);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "src/compiler/simd-scalar-lowering.h"
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/machine-type.h"
|
||||
#include "src/common/globals.h"
|
||||
#include "src/compiler/diamond.h"
|
||||
@ -1290,7 +1291,7 @@ void SimdScalarLowering::LowerNode(Node* node) {
|
||||
}
|
||||
case SimdType::kInt16x8: {
|
||||
int16_t val[kNumLanes16];
|
||||
memcpy(val, params.data(), kSimd128Size);
|
||||
base::Memcpy(val, params.data(), kSimd128Size);
|
||||
for (int i = 0; i < num_lanes; ++i) {
|
||||
rep_node[i] = mcgraph_->Int32Constant(static_cast<int32_t>(
|
||||
base::ReadLittleEndianValue<int16_t>(&val[i])));
|
||||
@ -1299,7 +1300,7 @@ void SimdScalarLowering::LowerNode(Node* node) {
|
||||
}
|
||||
case SimdType::kInt32x4: {
|
||||
uint32_t val[kNumLanes32];
|
||||
memcpy(val, params.data(), kSimd128Size);
|
||||
base::Memcpy(val, params.data(), kSimd128Size);
|
||||
for (int i = 0; i < num_lanes; ++i) {
|
||||
rep_node[i] = mcgraph_->Int32Constant(
|
||||
base::ReadLittleEndianValue<uint32_t>(&val[i]));
|
||||
@ -1308,7 +1309,7 @@ void SimdScalarLowering::LowerNode(Node* node) {
|
||||
}
|
||||
case SimdType::kInt64x2: {
|
||||
uint64_t val[kNumLanes64];
|
||||
memcpy(val, params.data(), kSimd128Size);
|
||||
base::Memcpy(val, params.data(), kSimd128Size);
|
||||
for (int i = 0; i < num_lanes; ++i) {
|
||||
rep_node[i] = mcgraph_->Int64Constant(
|
||||
base::ReadLittleEndianValue<uint64_t>(&val[i]));
|
||||
@ -1317,7 +1318,7 @@ void SimdScalarLowering::LowerNode(Node* node) {
|
||||
}
|
||||
case SimdType::kFloat32x4: {
|
||||
float val[kNumLanes32];
|
||||
memcpy(val, params.data(), kSimd128Size);
|
||||
base::Memcpy(val, params.data(), kSimd128Size);
|
||||
for (int i = 0; i < num_lanes; ++i) {
|
||||
rep_node[i] = mcgraph_->Float32Constant(
|
||||
base::ReadLittleEndianValue<float>(&val[i]));
|
||||
@ -1326,7 +1327,7 @@ void SimdScalarLowering::LowerNode(Node* node) {
|
||||
}
|
||||
case SimdType::kFloat64x2: {
|
||||
double val[kNumLanes64];
|
||||
memcpy(val, params.data(), kSimd128Size);
|
||||
base::Memcpy(val, params.data(), kSimd128Size);
|
||||
for (int i = 0; i < num_lanes; ++i) {
|
||||
rep_node[i] = mcgraph_->Float64Constant(
|
||||
base::ReadLittleEndianValue<double>(&val[i]));
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "src/base/optional.h"
|
||||
#include "src/base/platform/elapsed-timer.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/base/small-vector.h"
|
||||
#include "src/base/v8-fallthrough.h"
|
||||
#include "src/codegen/assembler-inl.h"
|
||||
@ -1293,7 +1294,7 @@ Node* WasmGraphBuilder::Return(Vector<Node*> vals) {
|
||||
|
||||
buf[0] = mcgraph()->Int32Constant(0);
|
||||
if (count > 0) {
|
||||
memcpy(buf.data() + 1, vals.begin(), sizeof(void*) * count);
|
||||
base::Memcpy(buf.data() + 1, vals.begin(), sizeof(void*) * count);
|
||||
}
|
||||
buf[count + 1] = effect();
|
||||
buf[count + 2] = control();
|
||||
@ -2826,7 +2827,7 @@ Node* WasmGraphBuilder::BuildCallNode(const wasm::FunctionSig* sig,
|
||||
// Make room for the instance_node parameter at index 1, just after code.
|
||||
inputs[0] = args[0]; // code
|
||||
inputs[1] = instance_node;
|
||||
if (params > 0) memcpy(&inputs[2], &args[1], params * sizeof(Node*));
|
||||
if (params > 0) base::Memcpy(&inputs[2], &args[1], params * sizeof(Node*));
|
||||
|
||||
// Add effect and control inputs.
|
||||
inputs[params + 2] = effect();
|
||||
@ -7269,7 +7270,7 @@ std::unique_ptr<OptimizedCompilationJob> NewJSToWasmCompilationJob(
|
||||
constexpr size_t kMaxNameLen = 128;
|
||||
constexpr size_t kNamePrefixLen = 11;
|
||||
auto name_buffer = std::unique_ptr<char[]>(new char[kMaxNameLen]);
|
||||
memcpy(name_buffer.get(), "js-to-wasm:", kNamePrefixLen);
|
||||
base::Memcpy(name_buffer.get(), "js-to-wasm:", kNamePrefixLen);
|
||||
PrintSignature(VectorOf(name_buffer.get(), kMaxNameLen) + kNamePrefixLen,
|
||||
sig);
|
||||
|
||||
@ -7647,7 +7648,7 @@ MaybeHandle<Code> CompileWasmToJSWrapper(Isolate* isolate,
|
||||
constexpr size_t kMaxNameLen = 128;
|
||||
constexpr size_t kNamePrefixLen = 11;
|
||||
auto name_buffer = std::unique_ptr<char[]>(new char[kMaxNameLen]);
|
||||
memcpy(name_buffer.get(), "wasm-to-js:", kNamePrefixLen);
|
||||
base::Memcpy(name_buffer.get(), "wasm-to-js:", kNamePrefixLen);
|
||||
PrintSignature(VectorOf(name_buffer.get(), kMaxNameLen) + kNamePrefixLen,
|
||||
sig);
|
||||
|
||||
@ -7699,7 +7700,7 @@ MaybeHandle<Code> CompileJSToJSWrapper(Isolate* isolate,
|
||||
constexpr size_t kMaxNameLen = 128;
|
||||
constexpr size_t kNamePrefixLen = 9;
|
||||
auto name_buffer = std::unique_ptr<char[]>(new char[kMaxNameLen]);
|
||||
memcpy(name_buffer.get(), "js-to-js:", kNamePrefixLen);
|
||||
base::Memcpy(name_buffer.get(), "js-to-js:", kNamePrefixLen);
|
||||
PrintSignature(VectorOf(name_buffer.get(), kMaxNameLen) + kNamePrefixLen,
|
||||
sig);
|
||||
|
||||
@ -7754,7 +7755,7 @@ Handle<Code> CompileCWasmEntry(Isolate* isolate, const wasm::FunctionSig* sig,
|
||||
constexpr size_t kMaxNameLen = 128;
|
||||
constexpr size_t kNamePrefixLen = 13;
|
||||
auto name_buffer = std::unique_ptr<char[]>(new char[kMaxNameLen]);
|
||||
memcpy(name_buffer.get(), "c-wasm-entry:", kNamePrefixLen);
|
||||
base::Memcpy(name_buffer.get(), "c-wasm-entry:", kNamePrefixLen);
|
||||
PrintSignature(VectorOf(name_buffer.get(), kMaxNameLen) + kNamePrefixLen,
|
||||
sig);
|
||||
|
||||
@ -7856,7 +7857,7 @@ Vector<const char> GetDebugName(Zone* zone, int index) {
|
||||
DCHECK(name_len > 0 && name_len < name_vector.length());
|
||||
|
||||
char* index_name = zone->NewArray<char>(name_len);
|
||||
memcpy(index_name, name_vector.begin(), name_len);
|
||||
base::Memcpy(index_name, name_vector.begin(), name_len);
|
||||
return Vector<const char>(index_name, name_len);
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
|
||||
#define SHM_SIZE 0x100000
|
||||
#define MAX_EDGES ((SHM_SIZE - 4) * 8)
|
||||
|
||||
@ -40,7 +42,7 @@ extern "C" void __sanitizer_cov_trace_pc_guard_init(uint32_t* start,
|
||||
const char* shm_key = getenv("SHM_ID");
|
||||
if (!shm_key) {
|
||||
puts("[COV] no shared memory bitmap available, skipping");
|
||||
shmem = (struct shmem_data*)malloc(SHM_SIZE);
|
||||
shmem = (struct shmem_data*)base::Malloc(SHM_SIZE);
|
||||
} else {
|
||||
int fd = shm_open(shm_key, O_RDWR, S_IREAD | S_IWRITE);
|
||||
if (fd <= -1) {
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/d8/d8.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -316,7 +317,7 @@ static Local<Value> GetStdout(Isolate* isolate, int child_fd,
|
||||
.ToLocalChecked();
|
||||
accumulator = String::Concat(isolate, accumulator, addition);
|
||||
fullness = bytes_read + fullness - length;
|
||||
memcpy(buffer, buffer + length, fullness);
|
||||
base::Memcpy(buffer, buffer + length, fullness);
|
||||
}
|
||||
} while (bytes_read != 0);
|
||||
return accumulator;
|
||||
|
19
src/d8/d8.cc
19
src/d8/d8.cc
@ -30,6 +30,7 @@
|
||||
#include "src/base/logging.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/time.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/base/sys-info.h"
|
||||
#include "src/d8/d8-console.h"
|
||||
#include "src/d8/d8-platforms.h"
|
||||
@ -487,7 +488,7 @@ ScriptCompiler::CachedData* Shell::LookupCodeCache(Isolate* isolate,
|
||||
if (entry != cached_code_map_.end() && entry->second) {
|
||||
int length = entry->second->length;
|
||||
uint8_t* cache = new uint8_t[length];
|
||||
memcpy(cache, entry->second->data, length);
|
||||
base::Memcpy(cache, entry->second->data, length);
|
||||
ScriptCompiler::CachedData* cached_data = new ScriptCompiler::CachedData(
|
||||
cache, length, ScriptCompiler::CachedData::BufferOwned);
|
||||
return cached_data;
|
||||
@ -504,7 +505,7 @@ void Shell::StoreInCodeCache(Isolate* isolate, Local<Value> source,
|
||||
DCHECK(*key);
|
||||
int length = cache_data->length;
|
||||
uint8_t* cache = new uint8_t[length];
|
||||
memcpy(cache, cache_data->data, length);
|
||||
base::Memcpy(cache, cache_data->data, length);
|
||||
cached_code_map_[*key] = std::unique_ptr<ScriptCompiler::CachedData>(
|
||||
new ScriptCompiler::CachedData(cache, length,
|
||||
ScriptCompiler::CachedData::BufferOwned));
|
||||
@ -1544,7 +1545,7 @@ void Shell::LogGetAndStop(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
|
||||
bool exists = false;
|
||||
raw_log = i::ReadFile(log_file, &exists, true);
|
||||
fclose(log_file);
|
||||
base::Fclose(log_file);
|
||||
|
||||
if (!exists) {
|
||||
Throw(isolate, "Unable to read log file.");
|
||||
@ -2603,13 +2604,13 @@ static FILE* FOpen(const char* path, const char* mode) {
|
||||
return nullptr;
|
||||
}
|
||||
#else
|
||||
FILE* file = fopen(path, mode);
|
||||
FILE* file = base::Fopen(path, mode);
|
||||
if (file == nullptr) return nullptr;
|
||||
struct stat file_stat;
|
||||
if (fstat(fileno(file), &file_stat) != 0) return nullptr;
|
||||
bool is_regular_file = ((file_stat.st_mode & S_IFREG) != 0);
|
||||
if (is_regular_file) return file;
|
||||
fclose(file);
|
||||
base::Fclose(file);
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
@ -2631,12 +2632,12 @@ static char* ReadChars(const char* name, int* size_out) {
|
||||
for (size_t i = 0; i < size;) {
|
||||
i += fread(&chars[i], 1, size - i, file);
|
||||
if (ferror(file)) {
|
||||
fclose(file);
|
||||
base::Fclose(file);
|
||||
delete[] chars;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
base::Fclose(file);
|
||||
*size_out = static_cast<int>(size);
|
||||
return chars;
|
||||
}
|
||||
@ -3840,12 +3841,12 @@ class Serializer : public ValueSerializer::Delegate {
|
||||
current_memory_usage_ += size;
|
||||
if (current_memory_usage_ > kMaxSerializerMemoryUsage) return nullptr;
|
||||
|
||||
void* result = realloc(old_buffer, size);
|
||||
void* result = base::Realloc(old_buffer, size);
|
||||
*actual_size = result ? size : 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
void FreeBufferMemory(void* buffer) override { free(buffer); }
|
||||
void FreeBufferMemory(void* buffer) override { base::Free(buffer); }
|
||||
|
||||
private:
|
||||
Maybe<bool> PrepareTransfer(Local<Context> context, Local<Value> transfer) {
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "src/base/once.h"
|
||||
#include "src/base/platform/time.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/d8/async-hooks-wrapper.h"
|
||||
#include "src/strings/string-hasher.h"
|
||||
#include "src/utils/allocation.h"
|
||||
@ -137,7 +138,7 @@ class SerializationData {
|
||||
|
||||
private:
|
||||
struct DataDeleter {
|
||||
void operator()(uint8_t* p) const { free(p); }
|
||||
void operator()(uint8_t* p) const { base::Free(p); }
|
||||
};
|
||||
|
||||
std::unique_ptr<uint8_t, DataDeleter> data_;
|
||||
|
@ -3,8 +3,11 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/debug/wasm/gdb-server/transport.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
|
||||
#ifndef SD_BOTH
|
||||
#define SD_BOTH 2
|
||||
#endif
|
||||
@ -116,7 +119,7 @@ Transport::~Transport() {
|
||||
|
||||
void Transport::CopyFromBuffer(char** dst, int32_t* len) {
|
||||
int32_t copy_bytes = std::min(*len, size_ - pos_);
|
||||
memcpy(*dst, buf_.get() + pos_, copy_bytes);
|
||||
base::Memcpy(*dst, buf_.get() + pos_, copy_bytes);
|
||||
pos_ += copy_bytes;
|
||||
*len -= copy_bytes;
|
||||
*dst += copy_bytes;
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "src/api/api-inl.h"
|
||||
#include "src/api/api.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/execution/frames-inl.h"
|
||||
#include "src/execution/frames.h"
|
||||
#include "src/objects/script.h"
|
||||
@ -293,11 +294,11 @@ uint32_t WasmModuleDebug::GetWasmMemory(Isolate* isolate, uint32_t frame_index,
|
||||
uint8_t* mem_start = instance->memory_start();
|
||||
size_t mem_size = instance->memory_size();
|
||||
if (static_cast<uint64_t>(offset) + size <= mem_size) {
|
||||
memcpy(buffer, mem_start + offset, size);
|
||||
base::Memcpy(buffer, mem_start + offset, size);
|
||||
bytes_read = size;
|
||||
} else if (offset < mem_size) {
|
||||
bytes_read = static_cast<uint32_t>(mem_size) - offset;
|
||||
memcpy(buffer, mem_start + offset, bytes_read);
|
||||
base::Memcpy(buffer, mem_start + offset, bytes_read);
|
||||
}
|
||||
}
|
||||
return bytes_read;
|
||||
@ -317,7 +318,7 @@ uint32_t WasmModuleDebug::GetWasmModuleBytes(wasm_addr_t wasm_addr,
|
||||
if (offset < wire_bytes.length()) {
|
||||
uint32_t module_size = static_cast<uint32_t>(wire_bytes.length());
|
||||
bytes_read = module_size - offset >= size ? size : module_size - offset;
|
||||
memcpy(buffer, wire_bytes.start() + offset, bytes_read);
|
||||
base::Memcpy(buffer, wire_bytes.start() + offset, bytes_read);
|
||||
}
|
||||
}
|
||||
return bytes_read;
|
||||
@ -350,7 +351,7 @@ bool StoreValue(const T& value, uint8_t* buffer, uint32_t buffer_size,
|
||||
uint32_t* size) {
|
||||
*size = sizeof(value);
|
||||
if (*size > buffer_size) return false;
|
||||
memcpy(buffer, &value, *size);
|
||||
base::Memcpy(buffer, &value, *size);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "src/base/macros.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/label.h"
|
||||
#include "src/codegen/register-arch.h"
|
||||
#include "src/codegen/source-position.h"
|
||||
@ -695,12 +696,14 @@ class FrameDescription {
|
||||
void* operator new(size_t size, uint32_t frame_size) {
|
||||
// Subtracts kSystemPointerSize, as the member frame_content_ already
|
||||
// supplies the first element of the area to store the frame.
|
||||
return malloc(size + frame_size - kSystemPointerSize);
|
||||
return base::Malloc(size + frame_size - kSystemPointerSize);
|
||||
}
|
||||
|
||||
void operator delete(void* pointer, uint32_t frame_size) { free(pointer); }
|
||||
void operator delete(void* pointer, uint32_t frame_size) {
|
||||
base::Free(pointer);
|
||||
}
|
||||
|
||||
void operator delete(void* description) { free(description); }
|
||||
void operator delete(void* description) { base::Free(description); }
|
||||
|
||||
uint32_t GetFrameSize() const {
|
||||
USE(frame_content_);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#if V8_TARGET_ARCH_ARM64
|
||||
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/arm64/decoder-arm64-inl.h"
|
||||
#include "src/codegen/arm64/utils-arm64.h"
|
||||
#include "src/diagnostics/arm64/disasm-arm64.h"
|
||||
@ -20,7 +21,7 @@ namespace internal {
|
||||
|
||||
DisassemblingDecoder::DisassemblingDecoder() {
|
||||
buffer_size_ = 256;
|
||||
buffer_ = reinterpret_cast<char*>(malloc(buffer_size_));
|
||||
buffer_ = reinterpret_cast<char*>(base::Malloc(buffer_size_));
|
||||
buffer_pos_ = 0;
|
||||
own_buffer_ = true;
|
||||
}
|
||||
@ -34,7 +35,7 @@ DisassemblingDecoder::DisassemblingDecoder(char* text_buffer, int buffer_size) {
|
||||
|
||||
DisassemblingDecoder::~DisassemblingDecoder() {
|
||||
if (own_buffer_) {
|
||||
free(buffer_);
|
||||
base::Free(buffer_);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define V8_DIAGNOSTICS_CODE_TRACER_H_
|
||||
|
||||
#include "src/base/optional.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/common/globals.h"
|
||||
#include "src/flags/flags.h"
|
||||
#include "src/utils/allocation.h"
|
||||
@ -91,7 +92,7 @@ class CodeTracer final : public Malloced {
|
||||
|
||||
if (--scope_depth_ == 0) {
|
||||
DCHECK_NOT_NULL(file_);
|
||||
fclose(file_);
|
||||
base::Fclose(file_);
|
||||
file_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/execution/frames-inl.h"
|
||||
#include "src/execution/frames.h"
|
||||
#include "src/handles/global-handles.h"
|
||||
@ -47,9 +48,9 @@ class Writer {
|
||||
: debug_object_(debug_object),
|
||||
position_(0),
|
||||
capacity_(1024),
|
||||
buffer_(reinterpret_cast<byte*>(malloc(capacity_))) {}
|
||||
buffer_(reinterpret_cast<byte*>(base::Malloc(capacity_))) {}
|
||||
|
||||
~Writer() { free(buffer_); }
|
||||
~Writer() { base::Free(buffer_); }
|
||||
|
||||
uintptr_t position() const { return position_; }
|
||||
|
||||
@ -98,7 +99,7 @@ class Writer {
|
||||
void Ensure(uintptr_t pos) {
|
||||
if (capacity_ < pos) {
|
||||
while (capacity_ < pos) capacity_ *= 2;
|
||||
buffer_ = reinterpret_cast<byte*>(realloc(buffer_, capacity_));
|
||||
buffer_ = reinterpret_cast<byte*>(base::Realloc(buffer_, capacity_));
|
||||
}
|
||||
}
|
||||
|
||||
@ -628,7 +629,7 @@ class ELF {
|
||||
#else
|
||||
#error Unsupported target architecture.
|
||||
#endif
|
||||
memcpy(header->ident, ident, 16);
|
||||
base::Memcpy(header->ident, ident, 16);
|
||||
header->type = 1;
|
||||
#if V8_TARGET_ARCH_IA32
|
||||
header->machine = 3;
|
||||
@ -1741,8 +1742,8 @@ void __gdb_print_v8_object(Object object) {
|
||||
|
||||
static JITCodeEntry* CreateCodeEntry(Address symfile_addr,
|
||||
uintptr_t symfile_size) {
|
||||
JITCodeEntry* entry =
|
||||
static_cast<JITCodeEntry*>(malloc(sizeof(JITCodeEntry) + symfile_size));
|
||||
JITCodeEntry* entry = static_cast<JITCodeEntry*>(
|
||||
base::Malloc(sizeof(JITCodeEntry) + symfile_size));
|
||||
|
||||
entry->symfile_addr_ = reinterpret_cast<Address>(entry + 1);
|
||||
entry->symfile_size_ = symfile_size;
|
||||
@ -1754,7 +1755,7 @@ static JITCodeEntry* CreateCodeEntry(Address symfile_addr,
|
||||
return entry;
|
||||
}
|
||||
|
||||
static void DestroyCodeEntry(JITCodeEntry* entry) { free(entry); }
|
||||
static void DestroyCodeEntry(JITCodeEntry* entry) { base::Free(entry); }
|
||||
|
||||
static void RegisterCodeEntry(JITCodeEntry* entry) {
|
||||
entry->next_ = __jit_debug_descriptor.first_entry_;
|
||||
|
@ -33,8 +33,10 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/assembler.h"
|
||||
#include "src/codegen/source-position-table.h"
|
||||
#include "src/diagnostics/eh-frame.h"
|
||||
@ -145,7 +147,7 @@ void PerfJitLogger::OpenJitDumpFile() {
|
||||
|
||||
void PerfJitLogger::CloseJitDumpFile() {
|
||||
if (perf_output_handle_ == nullptr) return;
|
||||
fclose(perf_output_handle_);
|
||||
base::Fclose(perf_output_handle_);
|
||||
perf_output_handle_ = nullptr;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#if defined(V8_OS_WIN_X64)
|
||||
#include "src/codegen/x64/assembler-x64.h"
|
||||
#elif defined(V8_OS_WIN_ARM64)
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/arm64/assembler-arm64-inl.h"
|
||||
#include "src/codegen/arm64/macro-assembler-arm64-inl.h"
|
||||
#else
|
||||
@ -170,8 +171,8 @@ void InitUnwindingRecord(Record* record, size_t code_size_in_bytes) {
|
||||
masm.movq(rax, reinterpret_cast<uint64_t>(&CRASH_HANDLER_FUNCTION_NAME));
|
||||
masm.jmp(rax);
|
||||
DCHECK_LE(masm.instruction_size(), sizeof(record->exception_thunk));
|
||||
memcpy(&record->exception_thunk[0], masm.buffer_start(),
|
||||
masm.instruction_size());
|
||||
base::Memcpy(&record->exception_thunk[0], masm.buffer_start(),
|
||||
masm.instruction_size());
|
||||
}
|
||||
|
||||
#elif defined(V8_OS_WIN_ARM64)
|
||||
@ -448,8 +449,8 @@ void InitUnwindingRecord(Record* record, size_t code_size_in_bytes) {
|
||||
Operand(reinterpret_cast<uint64_t>(&CRASH_HANDLER_FUNCTION_NAME)));
|
||||
masm.Br(x16);
|
||||
DCHECK_LE(masm.instruction_size(), sizeof(record->exception_thunk));
|
||||
memcpy(&record->exception_thunk[0], masm.buffer_start(),
|
||||
masm.instruction_size());
|
||||
base::Memcpy(&record->exception_thunk[0], masm.buffer_start(),
|
||||
masm.instruction_size());
|
||||
}
|
||||
|
||||
#endif // V8_OS_WIN_X64
|
||||
|
@ -8,12 +8,15 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/lazy-instance.h"
|
||||
#include "src/base/memory.h"
|
||||
#include "src/base/overflowing-math.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/arm/constants-arm.h"
|
||||
#include "src/codegen/assembler-inl.h"
|
||||
#include "src/codegen/macro-assembler.h"
|
||||
@ -631,7 +634,7 @@ void Simulator::CheckICache(base::CustomMatcherHashMap* i_cache,
|
||||
cache_page->CachedData(offset), kInstrSize));
|
||||
} else {
|
||||
// Cache miss. Load memory into the cache.
|
||||
memcpy(cached_line, line, CachePage::kLineLength);
|
||||
base::Memcpy(cached_line, line, CachePage::kLineLength);
|
||||
*cache_valid_byte = CachePage::LINE_VALID;
|
||||
}
|
||||
}
|
||||
@ -640,7 +643,7 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
|
||||
// Set up simulator support first. Some of this information is needed to
|
||||
// setup the architecture state.
|
||||
size_t stack_size = 1 * 1024 * 1024; // allocate 1MB for stack
|
||||
stack_ = reinterpret_cast<char*>(malloc(stack_size));
|
||||
stack_ = reinterpret_cast<char*>(base::Malloc(stack_size));
|
||||
pc_modified_ = false;
|
||||
icount_ = 0;
|
||||
break_pc_ = nullptr;
|
||||
@ -690,7 +693,7 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
|
||||
|
||||
Simulator::~Simulator() {
|
||||
GlobalMonitor::Get()->RemoveProcessor(&global_monitor_processor_);
|
||||
free(stack_);
|
||||
base::Free(stack_);
|
||||
}
|
||||
|
||||
// Get the active Simulator for the current thread.
|
||||
@ -736,14 +739,14 @@ double Simulator::get_double_from_register_pair(int reg) {
|
||||
// Read the bits from the unsigned integer register_[] array
|
||||
// into the double precision floating point value and return it.
|
||||
char buffer[2 * sizeof(vfp_registers_[0])];
|
||||
memcpy(buffer, ®isters_[reg], 2 * sizeof(registers_[0]));
|
||||
memcpy(&dm_val, buffer, 2 * sizeof(registers_[0]));
|
||||
base::Memcpy(buffer, ®isters_[reg], 2 * sizeof(registers_[0]));
|
||||
base::Memcpy(&dm_val, buffer, 2 * sizeof(registers_[0]));
|
||||
return (dm_val);
|
||||
}
|
||||
|
||||
void Simulator::set_register_pair_from_double(int reg, double* value) {
|
||||
DCHECK((reg >= 0) && (reg < num_registers) && ((reg % 2) == 0));
|
||||
memcpy(registers_ + reg, value, sizeof(*value));
|
||||
base::Memcpy(registers_ + reg, value, sizeof(*value));
|
||||
}
|
||||
|
||||
void Simulator::set_dw_register(int dreg, const int* dbl) {
|
||||
@ -754,22 +757,22 @@ void Simulator::set_dw_register(int dreg, const int* dbl) {
|
||||
|
||||
void Simulator::get_d_register(int dreg, uint64_t* value) {
|
||||
DCHECK((dreg >= 0) && (dreg < DwVfpRegister::SupportedRegisterCount()));
|
||||
memcpy(value, vfp_registers_ + dreg * 2, sizeof(*value));
|
||||
base::Memcpy(value, vfp_registers_ + dreg * 2, sizeof(*value));
|
||||
}
|
||||
|
||||
void Simulator::set_d_register(int dreg, const uint64_t* value) {
|
||||
DCHECK((dreg >= 0) && (dreg < DwVfpRegister::SupportedRegisterCount()));
|
||||
memcpy(vfp_registers_ + dreg * 2, value, sizeof(*value));
|
||||
base::Memcpy(vfp_registers_ + dreg * 2, value, sizeof(*value));
|
||||
}
|
||||
|
||||
void Simulator::get_d_register(int dreg, uint32_t* value) {
|
||||
DCHECK((dreg >= 0) && (dreg < DwVfpRegister::SupportedRegisterCount()));
|
||||
memcpy(value, vfp_registers_ + dreg * 2, sizeof(*value) * 2);
|
||||
base::Memcpy(value, vfp_registers_ + dreg * 2, sizeof(*value) * 2);
|
||||
}
|
||||
|
||||
void Simulator::set_d_register(int dreg, const uint32_t* value) {
|
||||
DCHECK((dreg >= 0) && (dreg < DwVfpRegister::SupportedRegisterCount()));
|
||||
memcpy(vfp_registers_ + dreg * 2, value, sizeof(*value) * 2);
|
||||
base::Memcpy(vfp_registers_ + dreg * 2, value, sizeof(*value) * 2);
|
||||
}
|
||||
|
||||
template <typename T, int SIZE>
|
||||
@ -777,7 +780,7 @@ void Simulator::get_neon_register(int reg, T (&value)[SIZE / sizeof(T)]) {
|
||||
DCHECK(SIZE == kSimd128Size || SIZE == kDoubleSize);
|
||||
DCHECK_LE(0, reg);
|
||||
DCHECK_GT(SIZE == kSimd128Size ? num_q_registers : num_d_registers, reg);
|
||||
memcpy(value, vfp_registers_ + reg * (SIZE / 4), SIZE);
|
||||
base::Memcpy(value, vfp_registers_ + reg * (SIZE / 4), SIZE);
|
||||
}
|
||||
|
||||
template <typename T, int SIZE>
|
||||
@ -785,7 +788,7 @@ void Simulator::set_neon_register(int reg, const T (&value)[SIZE / sizeof(T)]) {
|
||||
DCHECK(SIZE == kSimd128Size || SIZE == kDoubleSize);
|
||||
DCHECK_LE(0, reg);
|
||||
DCHECK_GT(SIZE == kSimd128Size ? num_q_registers : num_d_registers, reg);
|
||||
memcpy(vfp_registers_ + reg * (SIZE / 4), value, SIZE);
|
||||
base::Memcpy(vfp_registers_ + reg * (SIZE / 4), value, SIZE);
|
||||
}
|
||||
|
||||
// Raw access to the PC register.
|
||||
@ -821,7 +824,7 @@ void Simulator::SetVFPRegister(int reg_index, const InputType& value) {
|
||||
if (register_size == 2)
|
||||
DCHECK(reg_index < DwVfpRegister::SupportedRegisterCount());
|
||||
|
||||
memcpy(&vfp_registers_[reg_index * register_size], &value, bytes);
|
||||
base::Memcpy(&vfp_registers_[reg_index * register_size], &value, bytes);
|
||||
}
|
||||
|
||||
template <class ReturnType, int register_size>
|
||||
@ -834,7 +837,7 @@ ReturnType Simulator::GetFromVFPRegister(int reg_index) {
|
||||
DCHECK(reg_index < DwVfpRegister::SupportedRegisterCount());
|
||||
|
||||
ReturnType value;
|
||||
memcpy(&value, &vfp_registers_[register_size * reg_index], bytes);
|
||||
base::Memcpy(&value, &vfp_registers_[register_size * reg_index], bytes);
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -888,14 +891,14 @@ void Simulator::GetFpArgs(double* x, double* y, int32_t* z) {
|
||||
void Simulator::SetFpResult(const double& result) {
|
||||
if (use_eabi_hardfloat()) {
|
||||
char buffer[2 * sizeof(vfp_registers_[0])];
|
||||
memcpy(buffer, &result, sizeof(buffer));
|
||||
base::Memcpy(buffer, &result, sizeof(buffer));
|
||||
// Copy result to d0.
|
||||
memcpy(vfp_registers_, buffer, sizeof(buffer));
|
||||
base::Memcpy(vfp_registers_, buffer, sizeof(buffer));
|
||||
} else {
|
||||
char buffer[2 * sizeof(registers_[0])];
|
||||
memcpy(buffer, &result, sizeof(buffer));
|
||||
base::Memcpy(buffer, &result, sizeof(buffer));
|
||||
// Copy result to r0 and r1.
|
||||
memcpy(registers_, buffer, sizeof(buffer));
|
||||
base::Memcpy(registers_, buffer, sizeof(buffer));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1097,7 +1100,7 @@ int Simulator::WriteExDW(int32_t addr, int32_t value1, int32_t value2) {
|
||||
uintptr_t Simulator::StackLimit(uintptr_t c_limit) const {
|
||||
// The simulator uses a separate JS stack. If we have exhausted the C stack,
|
||||
// we also drop down the JS limit to reflect the exhaustion on the JS stack.
|
||||
if (GetCurrentStackPosition() < c_limit) {
|
||||
if (base::Stack::GetCurrentStackPosition() < c_limit) {
|
||||
return reinterpret_cast<uintptr_t>(get_sp());
|
||||
}
|
||||
|
||||
@ -3414,7 +3417,7 @@ void Simulator::DecodeTypeVFP(Instruction* instr) {
|
||||
if ((opc1_opc2 & 0xB) == 0) {
|
||||
// NeonS32 / NeonU32
|
||||
int32_t int_data[2];
|
||||
memcpy(int_data, &data, sizeof(int_data));
|
||||
base::Memcpy(int_data, &data, sizeof(int_data));
|
||||
set_register(rt, int_data[instr->Bit(21)]);
|
||||
} else {
|
||||
uint64_t data;
|
||||
@ -4080,7 +4083,7 @@ void VmovImmediate(Simulator* simulator, Instruction* instr) {
|
||||
// Set all bytes of register.
|
||||
std::fill_n(imms, kSimd128Size, imm);
|
||||
uint64_t imm64;
|
||||
memcpy(&imm64, imms, 8);
|
||||
base::Memcpy(&imm64, imms, 8);
|
||||
for (int r = 0; r < regs; r++) {
|
||||
simulator->set_d_register(vd + r, &imm64);
|
||||
}
|
||||
@ -4263,9 +4266,9 @@ void MultiplyLong(Simulator* simulator, int Vd, int Vn, int Vm) {
|
||||
// underlying datatype easily.
|
||||
uint64_t tmp;
|
||||
simulator->get_d_register(Vn, &tmp);
|
||||
memcpy(src1, &tmp, sizeof(tmp));
|
||||
base::Memcpy(src1, &tmp, sizeof(tmp));
|
||||
simulator->get_d_register(Vm, &tmp);
|
||||
memcpy(src2, &tmp, sizeof(tmp));
|
||||
base::Memcpy(src2, &tmp, sizeof(tmp));
|
||||
|
||||
for (int i = 0; i < kElems; i++) {
|
||||
dst[i] = WideType{src1[i]} * WideType{src2[i]};
|
||||
@ -6116,8 +6119,9 @@ intptr_t Simulator::CallImpl(Address entry, int argument_count,
|
||||
entry_stack &= -base::OS::ActivationFrameAlignment();
|
||||
}
|
||||
// Store remaining arguments on stack, from low to high memory.
|
||||
memcpy(reinterpret_cast<intptr_t*>(entry_stack), arguments + reg_arg_count,
|
||||
(argument_count - reg_arg_count) * sizeof(*arguments));
|
||||
base::Memcpy(reinterpret_cast<intptr_t*>(entry_stack),
|
||||
arguments + reg_arg_count,
|
||||
(argument_count - reg_arg_count) * sizeof(*arguments));
|
||||
set_register(sp, entry_stack);
|
||||
|
||||
CallInternal(entry);
|
||||
|
@ -7,12 +7,15 @@
|
||||
#if defined(USE_SIMULATOR)
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdarg>
|
||||
#include <type_traits>
|
||||
|
||||
#include "src/base/lazy-instance.h"
|
||||
#include "src/base/overflowing-math.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/arm64/decoder-arm64-inl.h"
|
||||
#include "src/codegen/assembler-inl.h"
|
||||
#include "src/codegen/macro-assembler.h"
|
||||
@ -140,7 +143,7 @@ void Simulator::CallImpl(Address entry, CallArgument* args) {
|
||||
char* stack = reinterpret_cast<char*>(entry_stack);
|
||||
std::vector<int64_t>::const_iterator it;
|
||||
for (it = stack_args.begin(); it != stack_args.end(); it++) {
|
||||
memcpy(stack, &(*it), sizeof(*it));
|
||||
base::Memcpy(stack, &(*it), sizeof(*it));
|
||||
stack += sizeof(*it);
|
||||
}
|
||||
|
||||
@ -263,9 +266,9 @@ uintptr_t Simulator::PushAddress(uintptr_t address) {
|
||||
DCHECK(sizeof(uintptr_t) < 2 * kXRegSize);
|
||||
intptr_t new_sp = sp() - 2 * kXRegSize;
|
||||
uintptr_t* alignment_slot = reinterpret_cast<uintptr_t*>(new_sp + kXRegSize);
|
||||
memcpy(alignment_slot, &kSlotsZapValue, kSystemPointerSize);
|
||||
base::Memcpy(alignment_slot, &kSlotsZapValue, kSystemPointerSize);
|
||||
uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(new_sp);
|
||||
memcpy(stack_slot, &address, kSystemPointerSize);
|
||||
base::Memcpy(stack_slot, &address, kSystemPointerSize);
|
||||
set_sp(new_sp);
|
||||
return new_sp;
|
||||
}
|
||||
@ -283,7 +286,7 @@ uintptr_t Simulator::PopAddress() {
|
||||
uintptr_t Simulator::StackLimit(uintptr_t c_limit) const {
|
||||
// The simulator uses a separate JS stack. If we have exhausted the C stack,
|
||||
// we also drop down the JS limit to reflect the exhaustion on the JS stack.
|
||||
if (GetCurrentStackPosition() < c_limit) {
|
||||
if (base::Stack::GetCurrentStackPosition() < c_limit) {
|
||||
return get_sp();
|
||||
}
|
||||
|
||||
@ -3591,9 +3594,10 @@ void Simulator::VisitException(Instruction* instr) {
|
||||
uint32_t code;
|
||||
uint32_t parameters;
|
||||
|
||||
memcpy(&code, pc_->InstructionAtOffset(kDebugCodeOffset), sizeof(code));
|
||||
memcpy(¶meters, pc_->InstructionAtOffset(kDebugParamsOffset),
|
||||
sizeof(parameters));
|
||||
base::Memcpy(&code, pc_->InstructionAtOffset(kDebugCodeOffset),
|
||||
sizeof(code));
|
||||
base::Memcpy(¶meters, pc_->InstructionAtOffset(kDebugParamsOffset),
|
||||
sizeof(parameters));
|
||||
char const* message = reinterpret_cast<char const*>(
|
||||
pc_->InstructionAtOffset(kDebugMessageOffset));
|
||||
|
||||
@ -5812,9 +5816,9 @@ void Simulator::DoPrintf(Instruction* instr) {
|
||||
uint32_t arg_count;
|
||||
uint32_t arg_pattern_list;
|
||||
STATIC_ASSERT(sizeof(*instr) == 1);
|
||||
memcpy(&arg_count, instr + kPrintfArgCountOffset, sizeof(arg_count));
|
||||
memcpy(&arg_pattern_list, instr + kPrintfArgPatternListOffset,
|
||||
sizeof(arg_pattern_list));
|
||||
base::Memcpy(&arg_count, instr + kPrintfArgCountOffset, sizeof(arg_count));
|
||||
base::Memcpy(&arg_pattern_list, instr + kPrintfArgPatternListOffset,
|
||||
sizeof(arg_pattern_list));
|
||||
|
||||
DCHECK_LE(arg_count, kPrintfMaxArgCount);
|
||||
DCHECK_EQ(arg_pattern_list >> (kPrintfArgPatternBits * arg_count), 0);
|
||||
|
@ -11,9 +11,11 @@
|
||||
#if defined(USE_SIMULATOR)
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "src/base/compiler-specific.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/arm64/assembler-arm64.h"
|
||||
#include "src/codegen/arm64/decoder-arm64.h"
|
||||
#include "src/codegen/assembler.h"
|
||||
@ -249,7 +251,7 @@ class SimMemory {
|
||||
DCHECK((sizeof(value) == 1) || (sizeof(value) == 2) ||
|
||||
(sizeof(value) == 4) || (sizeof(value) == 8) ||
|
||||
(sizeof(value) == 16));
|
||||
memcpy(&value, reinterpret_cast<const char*>(address), sizeof(value));
|
||||
base::Memcpy(&value, reinterpret_cast<const char*>(address), sizeof(value));
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -259,7 +261,7 @@ class SimMemory {
|
||||
DCHECK((sizeof(value) == 1) || (sizeof(value) == 2) ||
|
||||
(sizeof(value) == 4) || (sizeof(value) == 8) ||
|
||||
(sizeof(value) == 16));
|
||||
memcpy(reinterpret_cast<char*>(address), &value, sizeof(value));
|
||||
base::Memcpy(reinterpret_cast<char*>(address), &value, sizeof(value));
|
||||
}
|
||||
};
|
||||
|
||||
@ -325,7 +327,7 @@ class SimRegisterBase {
|
||||
// All AArch64 registers are zero-extending.
|
||||
memset(value_ + sizeof(new_value), 0, kSizeInBytes - sizeof(new_value));
|
||||
}
|
||||
memcpy(&value_, &new_value, sizeof(T));
|
||||
base::Memcpy(&value_, &new_value, sizeof(T));
|
||||
NotifyRegisterWrite();
|
||||
}
|
||||
|
||||
@ -338,7 +340,8 @@ class SimRegisterBase {
|
||||
DCHECK_GE(lane, 0);
|
||||
DCHECK_LE(sizeof(new_value) + (lane * sizeof(new_value)),
|
||||
static_cast<unsigned>(kSizeInBytes));
|
||||
memcpy(&value_[lane * sizeof(new_value)], &new_value, sizeof(new_value));
|
||||
base::Memcpy(&value_[lane * sizeof(new_value)], &new_value,
|
||||
sizeof(new_value));
|
||||
NotifyRegisterWrite();
|
||||
}
|
||||
|
||||
@ -348,7 +351,7 @@ class SimRegisterBase {
|
||||
DCHECK_GE(lane, 0);
|
||||
DCHECK_LE(sizeof(result) + (lane * sizeof(result)),
|
||||
static_cast<unsigned>(kSizeInBytes));
|
||||
memcpy(&result, &value_[lane * sizeof(result)], sizeof(result));
|
||||
base::Memcpy(&result, &value_[lane * sizeof(result)], sizeof(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -436,7 +439,7 @@ class LogicVRegister {
|
||||
int64_t IntLeftJustified(VectorFormat vform, int index) const {
|
||||
uint64_t value = UintLeftJustified(vform, index);
|
||||
int64_t result;
|
||||
memcpy(&result, &value, sizeof(result));
|
||||
base::Memcpy(&result, &value, sizeof(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -672,13 +675,13 @@ class Simulator : public DecoderVisitor, public SimulatorBase {
|
||||
explicit CallArgument(T argument) {
|
||||
bits_ = 0;
|
||||
DCHECK(sizeof(argument) <= sizeof(bits_));
|
||||
memcpy(&bits_, &argument, sizeof(argument));
|
||||
base::Memcpy(&bits_, &argument, sizeof(argument));
|
||||
type_ = X_ARG;
|
||||
}
|
||||
|
||||
explicit CallArgument(double argument) {
|
||||
DCHECK(sizeof(argument) == sizeof(bits_));
|
||||
memcpy(&bits_, &argument, sizeof(argument));
|
||||
base::Memcpy(&bits_, &argument, sizeof(argument));
|
||||
type_ = D_ARG;
|
||||
}
|
||||
|
||||
@ -689,10 +692,10 @@ class Simulator : public DecoderVisitor, public SimulatorBase {
|
||||
// Make the D register a NaN to try to trap errors if the callee expects a
|
||||
// double. If it expects a float, the callee should ignore the top word.
|
||||
DCHECK(sizeof(kFP64SignallingNaN) == sizeof(bits_));
|
||||
memcpy(&bits_, &kFP64SignallingNaN, sizeof(kFP64SignallingNaN));
|
||||
base::Memcpy(&bits_, &kFP64SignallingNaN, sizeof(kFP64SignallingNaN));
|
||||
// Write the float payload to the S register.
|
||||
DCHECK(sizeof(argument) <= sizeof(bits_));
|
||||
memcpy(&bits_, &argument, sizeof(argument));
|
||||
base::Memcpy(&bits_, &argument, sizeof(argument));
|
||||
type_ = D_ARG;
|
||||
}
|
||||
|
||||
@ -755,7 +758,7 @@ class Simulator : public DecoderVisitor, public SimulatorBase {
|
||||
template <typename T>
|
||||
void set_pc(T new_pc) {
|
||||
DCHECK(sizeof(T) == sizeof(pc_));
|
||||
memcpy(&pc_, &new_pc, sizeof(T));
|
||||
base::Memcpy(&pc_, &new_pc, sizeof(T));
|
||||
pc_modified_ = true;
|
||||
}
|
||||
Instruction* pc() { return pc_; }
|
||||
@ -1047,7 +1050,7 @@ class Simulator : public DecoderVisitor, public SimulatorBase {
|
||||
static_assert(sizeof(result) <= sizeof(raw),
|
||||
"Template type must be <= 64 bits.");
|
||||
// Copy the result and truncate to fit. This assumes a little-endian host.
|
||||
memcpy(&result, &raw, sizeof(result));
|
||||
base::Memcpy(&result, &raw, sizeof(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1502,7 +1505,7 @@ class Simulator : public DecoderVisitor, public SimulatorBase {
|
||||
STATIC_ASSERT((sizeof(value) == 1) || (sizeof(value) == 2) ||
|
||||
(sizeof(value) == 4) || (sizeof(value) == 8) ||
|
||||
(sizeof(value) == 16));
|
||||
memcpy(&value, reinterpret_cast<const void*>(address), sizeof(value));
|
||||
base::Memcpy(&value, reinterpret_cast<const void*>(address), sizeof(value));
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -1512,7 +1515,7 @@ class Simulator : public DecoderVisitor, public SimulatorBase {
|
||||
STATIC_ASSERT((sizeof(value) == 1) || (sizeof(value) == 2) ||
|
||||
(sizeof(value) == 4) || (sizeof(value) == 8) ||
|
||||
(sizeof(value) == 16));
|
||||
memcpy(reinterpret_cast<void*>(address), &value, sizeof(value));
|
||||
base::Memcpy(reinterpret_cast<void*>(address), &value, sizeof(value));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "src/execution/external-pointer-table.h"
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
@ -11,7 +13,7 @@ void ExternalPointerTable::GrowTable(ExternalPointerTable* table) {
|
||||
// TODO(v8:10391, saelo): overflow check here and in the multiplication below
|
||||
uint32_t new_capacity = table->capacity_ + table->capacity_ / 2;
|
||||
table->buffer_ = reinterpret_cast<Address*>(
|
||||
realloc(table->buffer_, new_capacity * sizeof(Address)));
|
||||
base::Realloc(table->buffer_, new_capacity * sizeof(Address)));
|
||||
CHECK(table->buffer_);
|
||||
memset(&table->buffer_[table->capacity_], 0,
|
||||
(new_capacity - table->capacity_) * sizeof(Address));
|
||||
|
@ -5,6 +5,7 @@
|
||||
#ifndef V8_EXECUTION_EXTERNAL_POINTER_TABLE_H_
|
||||
#define V8_EXECUTION_EXTERNAL_POINTER_TABLE_H_
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/common/external-pointer.h"
|
||||
#include "src/utils/utils.h"
|
||||
|
||||
@ -16,8 +17,8 @@ class V8_EXPORT_PRIVATE ExternalPointerTable {
|
||||
static const int kExternalPointerTableInitialCapacity = 1024;
|
||||
|
||||
ExternalPointerTable()
|
||||
: buffer_(reinterpret_cast<Address*>(
|
||||
calloc(kExternalPointerTableInitialCapacity, sizeof(Address)))),
|
||||
: buffer_(reinterpret_cast<Address*>(base::Calloc(
|
||||
kExternalPointerTableInitialCapacity, sizeof(Address)))),
|
||||
length_(1),
|
||||
capacity_(kExternalPointerTableInitialCapacity),
|
||||
freelist_head_(0) {
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/interface-descriptors.h"
|
||||
#include "src/codegen/macro-assembler.h"
|
||||
#include "src/codegen/register-configuration.h"
|
||||
@ -1817,7 +1818,7 @@ void WasmFrame::Print(StringStream* accumulator, PrintMode mode,
|
||||
const int kMaxPrintedFunctionName = 64;
|
||||
char func_name[kMaxPrintedFunctionName + 1];
|
||||
int func_name_len = std::min(kMaxPrintedFunctionName, raw_func_name.length());
|
||||
memcpy(func_name, raw_func_name.begin(), func_name_len);
|
||||
base::Memcpy(func_name, raw_func_name.begin(), func_name_len);
|
||||
func_name[func_name_len] = '\0';
|
||||
int pos = position();
|
||||
const wasm::WasmModule* module = wasm_instance().module_object().module();
|
||||
|
@ -103,6 +103,7 @@
|
||||
#endif // V8_OS_WIN64
|
||||
|
||||
#ifdef V8_ENABLE_CONSERVATIVE_STACK_SCANNING
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/heap/conservative-stack-visitor.h"
|
||||
#endif
|
||||
|
||||
@ -3110,7 +3111,7 @@ void Isolate::Deinit() {
|
||||
|
||||
heap_.TearDown();
|
||||
FILE* logfile = logger_->TearDownAndGetLogFile();
|
||||
if (logfile != nullptr) fclose(logfile);
|
||||
if (logfile != nullptr) base::Fclose(logfile);
|
||||
|
||||
if (wasm_engine_) {
|
||||
wasm_engine_->RemoveIsolate(this);
|
||||
|
@ -10,10 +10,13 @@
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/lazy-instance.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/assembler-inl.h"
|
||||
#include "src/codegen/macro-assembler.h"
|
||||
#include "src/codegen/mips/constants-mips.h"
|
||||
@ -847,7 +850,7 @@ void Simulator::CheckICache(base::CustomMatcherHashMap* i_cache,
|
||||
cache_page->CachedData(offset), kInstrSize));
|
||||
} else {
|
||||
// Cache miss. Load memory into the cache.
|
||||
memcpy(cached_line, line, CachePage::kLineLength);
|
||||
base::Memcpy(cached_line, line, CachePage::kLineLength);
|
||||
*cache_valid_byte = CachePage::LINE_VALID;
|
||||
}
|
||||
}
|
||||
@ -856,7 +859,7 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
|
||||
// Set up simulator support first. Some of this information is needed to
|
||||
// setup the architecture state.
|
||||
stack_size_ = FLAG_sim_stack_size * KB;
|
||||
stack_ = reinterpret_cast<char*>(malloc(stack_size_));
|
||||
stack_ = reinterpret_cast<char*>(base::Malloc(stack_size_));
|
||||
pc_modified_ = false;
|
||||
icount_ = 0;
|
||||
break_count_ = 0;
|
||||
@ -893,7 +896,7 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
|
||||
|
||||
Simulator::~Simulator() {
|
||||
GlobalMonitor::Get()->RemoveLinkedAddress(&global_monitor_thread_);
|
||||
free(stack_);
|
||||
base::Free(stack_);
|
||||
}
|
||||
|
||||
// Get the active Simulator for the current thread.
|
||||
@ -987,8 +990,8 @@ double Simulator::get_double_from_register_pair(int reg) {
|
||||
// Read the bits from the unsigned integer register_[] array
|
||||
// into the double precision floating point value and return it.
|
||||
char buffer[2 * sizeof(registers_[0])];
|
||||
memcpy(buffer, ®isters_[reg], 2 * sizeof(registers_[0]));
|
||||
memcpy(&dm_val, buffer, 2 * sizeof(registers_[0]));
|
||||
base::Memcpy(buffer, ®isters_[reg], 2 * sizeof(registers_[0]));
|
||||
base::Memcpy(&dm_val, buffer, 2 * sizeof(registers_[0]));
|
||||
return (dm_val);
|
||||
}
|
||||
|
||||
@ -1041,13 +1044,13 @@ double Simulator::get_fpu_register_double(int fpureg) const {
|
||||
template <typename T>
|
||||
void Simulator::get_msa_register(int wreg, T* value) {
|
||||
DCHECK((wreg >= 0) && (wreg < kNumMSARegisters));
|
||||
memcpy(value, FPUregisters_ + wreg * 2, kSimd128Size);
|
||||
base::Memcpy(value, FPUregisters_ + wreg * 2, kSimd128Size);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Simulator::set_msa_register(int wreg, const T* value) {
|
||||
DCHECK((wreg >= 0) && (wreg < kNumMSARegisters));
|
||||
memcpy(FPUregisters_ + wreg * 2, value, kSimd128Size);
|
||||
base::Memcpy(FPUregisters_ + wreg * 2, value, kSimd128Size);
|
||||
}
|
||||
|
||||
// Runtime FP routines take up to two double arguments and zero
|
||||
@ -1068,14 +1071,14 @@ void Simulator::GetFpArgs(double* x, double* y, int32_t* z) {
|
||||
// Registers a0 and a1 -> x.
|
||||
reg_buffer[0] = get_register(a0);
|
||||
reg_buffer[1] = get_register(a1);
|
||||
memcpy(x, buffer, sizeof(buffer));
|
||||
base::Memcpy(x, buffer, sizeof(buffer));
|
||||
// Registers a2 and a3 -> y.
|
||||
reg_buffer[0] = get_register(a2);
|
||||
reg_buffer[1] = get_register(a3);
|
||||
memcpy(y, buffer, sizeof(buffer));
|
||||
base::Memcpy(y, buffer, sizeof(buffer));
|
||||
// Register 2 -> z.
|
||||
reg_buffer[0] = get_register(a2);
|
||||
memcpy(z, buffer, sizeof(*z));
|
||||
base::Memcpy(z, buffer, sizeof(*z));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1086,7 +1089,7 @@ void Simulator::SetFpResult(const double& result) {
|
||||
} else {
|
||||
char buffer[2 * sizeof(registers_[0])];
|
||||
int32_t* reg_buffer = reinterpret_cast<int32_t*>(buffer);
|
||||
memcpy(buffer, &result, sizeof(buffer));
|
||||
base::Memcpy(buffer, &result, sizeof(buffer));
|
||||
// Copy result to v0 and v1.
|
||||
set_register(v0, reg_buffer[0]);
|
||||
set_register(v1, reg_buffer[1]);
|
||||
@ -1653,7 +1656,7 @@ void Simulator::TraceMSARegWr(T* value, TraceType t) {
|
||||
float f[4];
|
||||
double df[2];
|
||||
} v;
|
||||
memcpy(v.b, value, kSimd128Size);
|
||||
base::Memcpy(v.b, value, kSimd128Size);
|
||||
switch (t) {
|
||||
case BYTE:
|
||||
SNPrintF(trace_buf_,
|
||||
@ -1706,7 +1709,7 @@ void Simulator::TraceMSARegWr(T* value) {
|
||||
float f[kMSALanesWord];
|
||||
double df[kMSALanesDword];
|
||||
} v;
|
||||
memcpy(v.b, value, kMSALanesByte);
|
||||
base::Memcpy(v.b, value, kMSALanesByte);
|
||||
|
||||
if (std::is_same<T, int32_t>::value) {
|
||||
SNPrintF(trace_buf_,
|
||||
@ -2135,7 +2138,7 @@ void Simulator::WriteMem(int32_t addr, T value, Instruction* instr) {
|
||||
uintptr_t Simulator::StackLimit(uintptr_t c_limit) const {
|
||||
// The simulator uses a separate JS stack. If we have exhausted the C stack,
|
||||
// we also drop down the JS limit to reflect the exhaustion on the JS stack.
|
||||
if (GetCurrentStackPosition() < c_limit) {
|
||||
if (base::Stack::GetCurrentStackPosition() < c_limit) {
|
||||
return reinterpret_cast<uintptr_t>(get_sp());
|
||||
}
|
||||
|
||||
@ -7028,8 +7031,8 @@ intptr_t Simulator::CallImpl(Address entry, int argument_count,
|
||||
}
|
||||
// Store remaining arguments on stack, from low to high memory.
|
||||
intptr_t* stack_argument = reinterpret_cast<intptr_t*>(entry_stack);
|
||||
memcpy(stack_argument + kCArgSlotCount, arguments + reg_arg_count,
|
||||
(argument_count - reg_arg_count) * sizeof(*arguments));
|
||||
base::Memcpy(stack_argument + kCArgSlotCount, arguments + reg_arg_count,
|
||||
(argument_count - reg_arg_count) * sizeof(*arguments));
|
||||
set_register(sp, entry_stack);
|
||||
|
||||
CallInternal(entry);
|
||||
@ -7048,9 +7051,9 @@ double Simulator::CallFP(Address entry, double d0, double d1) {
|
||||
} else {
|
||||
int buffer[2];
|
||||
DCHECK(sizeof(buffer[0]) * 2 == sizeof(d0));
|
||||
memcpy(buffer, &d0, sizeof(d0));
|
||||
base::Memcpy(buffer, &d0, sizeof(d0));
|
||||
set_dw_register(a0, buffer);
|
||||
memcpy(buffer, &d1, sizeof(d1));
|
||||
base::Memcpy(buffer, &d1, sizeof(d1));
|
||||
set_dw_register(a2, buffer);
|
||||
}
|
||||
CallInternal(entry);
|
||||
|
@ -10,9 +10,12 @@
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/assembler-inl.h"
|
||||
#include "src/codegen/macro-assembler.h"
|
||||
#include "src/codegen/mips64/constants-mips64.h"
|
||||
@ -788,7 +791,7 @@ void Simulator::CheckICache(base::CustomMatcherHashMap* i_cache,
|
||||
cache_page->CachedData(offset), kInstrSize));
|
||||
} else {
|
||||
// Cache miss. Load memory into the cache.
|
||||
memcpy(cached_line, line, CachePage::kLineLength);
|
||||
base::Memcpy(cached_line, line, CachePage::kLineLength);
|
||||
*cache_valid_byte = CachePage::LINE_VALID;
|
||||
}
|
||||
}
|
||||
@ -797,7 +800,7 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
|
||||
// Set up simulator support first. Some of this information is needed to
|
||||
// setup the architecture state.
|
||||
stack_size_ = FLAG_sim_stack_size * KB;
|
||||
stack_ = reinterpret_cast<char*>(malloc(stack_size_));
|
||||
stack_ = reinterpret_cast<char*>(base::Malloc(stack_size_));
|
||||
pc_modified_ = false;
|
||||
icount_ = 0;
|
||||
break_count_ = 0;
|
||||
@ -835,7 +838,7 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
|
||||
|
||||
Simulator::~Simulator() {
|
||||
GlobalMonitor::Get()->RemoveLinkedAddress(&global_monitor_thread_);
|
||||
free(stack_);
|
||||
base::Free(stack_);
|
||||
}
|
||||
|
||||
// Get the active Simulator for the current thread.
|
||||
@ -929,8 +932,8 @@ double Simulator::get_double_from_register_pair(int reg) {
|
||||
// Read the bits from the unsigned integer register_[] array
|
||||
// into the double precision floating point value and return it.
|
||||
char buffer[sizeof(registers_[0])];
|
||||
memcpy(buffer, ®isters_[reg], sizeof(registers_[0]));
|
||||
memcpy(&dm_val, buffer, sizeof(registers_[0]));
|
||||
base::Memcpy(buffer, ®isters_[reg], sizeof(registers_[0]));
|
||||
base::Memcpy(&dm_val, buffer, sizeof(registers_[0]));
|
||||
return (dm_val);
|
||||
}
|
||||
|
||||
@ -967,13 +970,13 @@ double Simulator::get_fpu_register_double(int fpureg) const {
|
||||
template <typename T>
|
||||
void Simulator::get_msa_register(int wreg, T* value) {
|
||||
DCHECK((wreg >= 0) && (wreg < kNumMSARegisters));
|
||||
memcpy(value, FPUregisters_ + wreg * 2, kSimd128Size);
|
||||
base::Memcpy(value, FPUregisters_ + wreg * 2, kSimd128Size);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Simulator::set_msa_register(int wreg, const T* value) {
|
||||
DCHECK((wreg >= 0) && (wreg < kNumMSARegisters));
|
||||
memcpy(FPUregisters_ + wreg * 2, value, kSimd128Size);
|
||||
base::Memcpy(FPUregisters_ + wreg * 2, value, kSimd128Size);
|
||||
}
|
||||
|
||||
// Runtime FP routines take up to two double arguments and zero
|
||||
@ -995,14 +998,14 @@ void Simulator::GetFpArgs(double* x, double* y, int32_t* z) {
|
||||
// Registers a0 and a1 -> x.
|
||||
reg_buffer[0] = get_register(a0);
|
||||
reg_buffer[1] = get_register(a1);
|
||||
memcpy(x, buffer, sizeof(buffer));
|
||||
base::Memcpy(x, buffer, sizeof(buffer));
|
||||
// Registers a2 and a3 -> y.
|
||||
reg_buffer[0] = get_register(a2);
|
||||
reg_buffer[1] = get_register(a3);
|
||||
memcpy(y, buffer, sizeof(buffer));
|
||||
base::Memcpy(y, buffer, sizeof(buffer));
|
||||
// Register 2 -> z.
|
||||
reg_buffer[0] = get_register(a2);
|
||||
memcpy(z, buffer, sizeof(*z));
|
||||
base::Memcpy(z, buffer, sizeof(*z));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1013,7 +1016,7 @@ void Simulator::SetFpResult(const double& result) {
|
||||
} else {
|
||||
char buffer[2 * sizeof(registers_[0])];
|
||||
int64_t* reg_buffer = reinterpret_cast<int64_t*>(buffer);
|
||||
memcpy(buffer, &result, sizeof(buffer));
|
||||
base::Memcpy(buffer, &result, sizeof(buffer));
|
||||
// Copy result to v0 and v1.
|
||||
set_register(v0, reg_buffer[0]);
|
||||
set_register(v1, reg_buffer[1]);
|
||||
@ -1590,7 +1593,7 @@ void Simulator::TraceMSARegWr(T* value, TraceType t) {
|
||||
float f[4];
|
||||
double df[2];
|
||||
} v;
|
||||
memcpy(v.b, value, kSimd128Size);
|
||||
base::Memcpy(v.b, value, kSimd128Size);
|
||||
switch (t) {
|
||||
case BYTE:
|
||||
SNPrintF(trace_buf_,
|
||||
@ -1643,7 +1646,7 @@ void Simulator::TraceMSARegWr(T* value) {
|
||||
float f[kMSALanesWord];
|
||||
double df[kMSALanesDword];
|
||||
} v;
|
||||
memcpy(v.b, value, kMSALanesByte);
|
||||
base::Memcpy(v.b, value, kMSALanesByte);
|
||||
|
||||
if (std::is_same<T, int32_t>::value) {
|
||||
SNPrintF(trace_buf_,
|
||||
@ -2140,7 +2143,7 @@ void Simulator::WriteMem(int64_t addr, T value, Instruction* instr) {
|
||||
uintptr_t Simulator::StackLimit(uintptr_t c_limit) const {
|
||||
// The simulator uses a separate JS stack. If we have exhausted the C stack,
|
||||
// we also drop down the JS limit to reflect the exhaustion on the JS stack.
|
||||
if (GetCurrentStackPosition() < c_limit) {
|
||||
if (base::Stack::GetCurrentStackPosition() < c_limit) {
|
||||
return reinterpret_cast<uintptr_t>(get_sp());
|
||||
}
|
||||
|
||||
@ -7447,8 +7450,8 @@ intptr_t Simulator::CallImpl(Address entry, int argument_count,
|
||||
}
|
||||
// Store remaining arguments on stack, from low to high memory.
|
||||
intptr_t* stack_argument = reinterpret_cast<intptr_t*>(entry_stack);
|
||||
memcpy(stack_argument + kCArgSlotCount, arguments + reg_arg_count,
|
||||
stack_args_count * sizeof(*arguments));
|
||||
base::Memcpy(stack_argument + kCArgSlotCount, arguments + reg_arg_count,
|
||||
stack_args_count * sizeof(*arguments));
|
||||
set_register(sp, entry_stack);
|
||||
|
||||
CallInternal(entry);
|
||||
@ -7468,9 +7471,9 @@ double Simulator::CallFP(Address entry, double d0, double d1) {
|
||||
} else {
|
||||
int buffer[2];
|
||||
DCHECK(sizeof(buffer[0]) * 2 == sizeof(d0));
|
||||
memcpy(buffer, &d0, sizeof(d0));
|
||||
base::Memcpy(buffer, &d0, sizeof(d0));
|
||||
set_dw_register(a0, buffer);
|
||||
memcpy(buffer, &d1, sizeof(d1));
|
||||
base::Memcpy(buffer, &d1, sizeof(d1));
|
||||
set_dw_register(a2, buffer);
|
||||
}
|
||||
CallInternal(entry);
|
||||
|
@ -8,10 +8,13 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/lazy-instance.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/assembler.h"
|
||||
#include "src/codegen/macro-assembler.h"
|
||||
#include "src/codegen/ppc/constants-ppc.h"
|
||||
@ -712,7 +715,7 @@ void Simulator::CheckICache(base::CustomMatcherHashMap* i_cache,
|
||||
cache_page->CachedData(offset), kInstrSize));
|
||||
} else {
|
||||
// Cache miss. Load memory into the cache.
|
||||
memcpy(cached_line, line, CachePage::kLineLength);
|
||||
base::Memcpy(cached_line, line, CachePage::kLineLength);
|
||||
*cache_valid_byte = CachePage::LINE_VALID;
|
||||
}
|
||||
}
|
||||
@ -726,7 +729,7 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
|
||||
size_t stack_size = MB; // allocate 1MB for stack
|
||||
#endif
|
||||
stack_size += 2 * stack_protection_size_;
|
||||
stack_ = reinterpret_cast<char*>(malloc(stack_size));
|
||||
stack_ = reinterpret_cast<char*>(base::Malloc(stack_size));
|
||||
pc_modified_ = false;
|
||||
icount_ = 0;
|
||||
break_pc_ = nullptr;
|
||||
@ -757,7 +760,7 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
|
||||
last_debugger_input_ = nullptr;
|
||||
}
|
||||
|
||||
Simulator::~Simulator() { free(stack_); }
|
||||
Simulator::~Simulator() { base::Free(stack_); }
|
||||
|
||||
// Get the active Simulator for the current thread.
|
||||
Simulator* Simulator::current(Isolate* isolate) {
|
||||
@ -798,8 +801,8 @@ double Simulator::get_double_from_register_pair(int reg) {
|
||||
// Read the bits from the unsigned integer register_[] array
|
||||
// into the double precision floating point value and return it.
|
||||
char buffer[sizeof(fp_registers_[0])];
|
||||
memcpy(buffer, ®isters_[reg], 2 * sizeof(registers_[0]));
|
||||
memcpy(&dm_val, buffer, 2 * sizeof(registers_[0]));
|
||||
base::Memcpy(buffer, ®isters_[reg], 2 * sizeof(registers_[0]));
|
||||
base::Memcpy(&dm_val, buffer, 2 * sizeof(registers_[0]));
|
||||
#endif
|
||||
return (dm_val);
|
||||
}
|
||||
@ -869,7 +872,7 @@ RW_VAR_LIST(GENERATE_RW_FUNC)
|
||||
uintptr_t Simulator::StackLimit(uintptr_t c_limit) const {
|
||||
// The simulator uses a separate JS stack. If we have exhausted the C stack,
|
||||
// we also drop down the JS limit to reflect the exhaustion on the JS stack.
|
||||
if (GetCurrentStackPosition() < c_limit) {
|
||||
if (base::Stack::GetCurrentStackPosition() < c_limit) {
|
||||
return reinterpret_cast<uintptr_t>(get_sp());
|
||||
}
|
||||
|
||||
@ -1191,8 +1194,8 @@ void Simulator::SoftwareInterrupt(Instruction* instr) {
|
||||
set_register(r3, x);
|
||||
set_register(r4, y);
|
||||
} else {
|
||||
memcpy(reinterpret_cast<void*>(result_buffer), &result,
|
||||
sizeof(ObjectPair));
|
||||
base::Memcpy(reinterpret_cast<void*>(result_buffer), &result,
|
||||
sizeof(ObjectPair));
|
||||
set_register(r3, result_buffer);
|
||||
}
|
||||
} else {
|
||||
@ -3923,8 +3926,8 @@ intptr_t Simulator::CallImpl(Address entry, int argument_count,
|
||||
// +2 is a hack for the LR slot + old SP on PPC
|
||||
intptr_t* stack_argument =
|
||||
reinterpret_cast<intptr_t*>(entry_stack) + kStackFrameExtraParamSlot;
|
||||
memcpy(stack_argument, arguments + reg_arg_count,
|
||||
stack_arg_count * sizeof(*arguments));
|
||||
base::Memcpy(stack_argument, arguments + reg_arg_count,
|
||||
stack_arg_count * sizeof(*arguments));
|
||||
set_register(sp, entry_stack);
|
||||
|
||||
CallInternal(entry);
|
||||
|
@ -18,14 +18,14 @@
|
||||
#if defined(USE_SIMULATOR)
|
||||
// Running with a simulator.
|
||||
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/base/lazy-instance.h"
|
||||
#include "src/base/platform/mutex.h"
|
||||
#include "src/utils/allocation.h"
|
||||
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/assembler.h"
|
||||
#include "src/codegen/ppc/constants-ppc.h"
|
||||
#include "src/execution/simulator-base.h"
|
||||
#include "src/utils/allocation.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -253,7 +253,7 @@ class Simulator : public SimulatorBase {
|
||||
template <typename T>
|
||||
inline void Read(uintptr_t address, T* value) {
|
||||
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
|
||||
memcpy(value, reinterpret_cast<const char*>(address), sizeof(T));
|
||||
base::Memcpy(value, reinterpret_cast<const char*>(address), sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -262,7 +262,7 @@ class Simulator : public SimulatorBase {
|
||||
GlobalMonitor::Get()->NotifyLoadExcl(
|
||||
address, static_cast<TransactionSize>(sizeof(T)),
|
||||
isolate_->thread_id());
|
||||
memcpy(value, reinterpret_cast<const char*>(address), sizeof(T));
|
||||
base::Memcpy(value, reinterpret_cast<const char*>(address), sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -271,7 +271,7 @@ class Simulator : public SimulatorBase {
|
||||
GlobalMonitor::Get()->NotifyStore(address,
|
||||
static_cast<TransactionSize>(sizeof(T)),
|
||||
isolate_->thread_id());
|
||||
memcpy(reinterpret_cast<char*>(address), &value, sizeof(T));
|
||||
base::Memcpy(reinterpret_cast<char*>(address), &value, sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -280,7 +280,7 @@ class Simulator : public SimulatorBase {
|
||||
if (GlobalMonitor::Get()->NotifyStoreExcl(
|
||||
address, static_cast<TransactionSize>(sizeof(T)),
|
||||
isolate_->thread_id())) {
|
||||
memcpy(reinterpret_cast<char*>(address), &value, sizeof(T));
|
||||
base::Memcpy(reinterpret_cast<char*>(address), &value, sizeof(T));
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
|
@ -9,10 +9,13 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/once.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/assembler.h"
|
||||
#include "src/codegen/macro-assembler.h"
|
||||
#include "src/codegen/register-configuration.h"
|
||||
@ -732,7 +735,7 @@ void Simulator::CheckICache(base::CustomMatcherHashMap* i_cache,
|
||||
0);
|
||||
} else {
|
||||
// Cache miss. Load memory into the cache.
|
||||
memcpy(cached_line, line, CachePage::kLineLength);
|
||||
base::Memcpy(cached_line, line, CachePage::kLineLength);
|
||||
*cache_valid_byte = CachePage::LINE_VALID;
|
||||
}
|
||||
}
|
||||
@ -1561,7 +1564,7 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
|
||||
size_t stack_size = MB; // allocate 1MB for stack
|
||||
#endif
|
||||
stack_size += 2 * stack_protection_size_;
|
||||
stack_ = reinterpret_cast<char*>(malloc(stack_size));
|
||||
stack_ = reinterpret_cast<char*>(base::Malloc(stack_size));
|
||||
pc_modified_ = false;
|
||||
icount_ = 0;
|
||||
break_pc_ = nullptr;
|
||||
@ -1596,7 +1599,7 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
|
||||
last_debugger_input_ = nullptr;
|
||||
}
|
||||
|
||||
Simulator::~Simulator() { free(stack_); }
|
||||
Simulator::~Simulator() { base::Free(stack_); }
|
||||
|
||||
// Get the active Simulator for the current thread.
|
||||
Simulator* Simulator::current(Isolate* isolate) {
|
||||
@ -1672,8 +1675,8 @@ double Simulator::get_double_from_register_pair(int reg) {
|
||||
// Read the bits from the unsigned integer register_[] array
|
||||
// into the double precision floating point value and return it.
|
||||
char buffer[sizeof(fp_registers_[0])];
|
||||
memcpy(buffer, ®isters_[reg], 2 * sizeof(registers_[0]));
|
||||
memcpy(&dm_val, buffer, 2 * sizeof(registers_[0]));
|
||||
base::Memcpy(buffer, ®isters_[reg], 2 * sizeof(registers_[0]));
|
||||
base::Memcpy(&dm_val, buffer, 2 * sizeof(registers_[0]));
|
||||
#endif
|
||||
return (dm_val);
|
||||
}
|
||||
@ -1812,7 +1815,7 @@ float Simulator::ReadFloat(intptr_t addr) {
|
||||
uintptr_t Simulator::StackLimit(uintptr_t c_limit) const {
|
||||
// The simulator uses a separate JS stack. If we have exhausted the C stack,
|
||||
// we also drop down the JS limit to reflect the exhaustion on the JS stack.
|
||||
if (GetCurrentStackPosition() < c_limit) {
|
||||
if (base::Stack::GetCurrentStackPosition() < c_limit) {
|
||||
return reinterpret_cast<uintptr_t>(get_sp());
|
||||
}
|
||||
|
||||
@ -2140,8 +2143,8 @@ void Simulator::SoftwareInterrupt(Instruction* instr) {
|
||||
set_register(r2, x);
|
||||
set_register(r3, y);
|
||||
} else {
|
||||
memcpy(reinterpret_cast<void*>(result_buffer), &result,
|
||||
sizeof(ObjectPair));
|
||||
base::Memcpy(reinterpret_cast<void*>(result_buffer), &result,
|
||||
sizeof(ObjectPair));
|
||||
set_register(r2, result_buffer);
|
||||
}
|
||||
} else {
|
||||
@ -2570,8 +2573,8 @@ intptr_t Simulator::CallImpl(Address entry, int argument_count,
|
||||
// Store remaining arguments on stack, from low to high memory.
|
||||
intptr_t* stack_argument =
|
||||
reinterpret_cast<intptr_t*>(entry_stack + kCalleeRegisterSaveAreaSize);
|
||||
memcpy(stack_argument, arguments + reg_arg_count,
|
||||
stack_arg_count * sizeof(*arguments));
|
||||
base::Memcpy(stack_argument, arguments + reg_arg_count,
|
||||
stack_arg_count * sizeof(*arguments));
|
||||
set_register(sp, entry_stack);
|
||||
|
||||
// Prepare to execute the code at entry
|
||||
@ -3031,7 +3034,7 @@ EVALUATE(VLGV) {
|
||||
const int size_by_byte = 1 << m4;
|
||||
int8_t* src = get_simd_register(r3).int8 + index * size_by_byte;
|
||||
set_register(r1, 0);
|
||||
memcpy(&get_register(r1), src, size_by_byte);
|
||||
base::Memcpy(&get_register(r1), src, size_by_byte);
|
||||
return length;
|
||||
}
|
||||
|
||||
@ -3042,7 +3045,7 @@ EVALUATE(VLVG) {
|
||||
int64_t index = b2_val + d2;
|
||||
const int size_by_byte = 1 << m4;
|
||||
int8_t* dst = get_simd_register(r1).int8 + index * size_by_byte;
|
||||
memcpy(dst, &get_register(r3), size_by_byte);
|
||||
base::Memcpy(dst, &get_register(r3), size_by_byte);
|
||||
return length;
|
||||
}
|
||||
|
||||
@ -3062,7 +3065,7 @@ EVALUATE(VREP) {
|
||||
int8_t* src = get_simd_register(r3).int8;
|
||||
int8_t* dst = get_simd_register(r1).int8;
|
||||
for (int i = 0; i < kSimd128Size; i += size_by_byte) {
|
||||
memcpy(dst + i, src + i2 * size_by_byte, size_by_byte);
|
||||
base::Memcpy(dst + i, src + i2 * size_by_byte, size_by_byte);
|
||||
}
|
||||
return length;
|
||||
}
|
||||
@ -3076,7 +3079,7 @@ EVALUATE(VLREP) {
|
||||
int8_t* src = reinterpret_cast<int8_t*>(addr);
|
||||
set_simd_register(r1, fp_zero);
|
||||
for (int i = 0; i < kSimd128Size; i += size_by_byte) {
|
||||
memcpy(dst + i, src, size_by_byte);
|
||||
base::Memcpy(dst + i, src, size_by_byte);
|
||||
}
|
||||
return length;
|
||||
}
|
||||
@ -3089,7 +3092,7 @@ EVALUATE(VREPI) {
|
||||
uint64_t immediate = static_cast<uint64_t>(i2);
|
||||
set_simd_register(r1, fp_zero);
|
||||
for (int i = 0; i < kSimd128Size; i += size_by_byte) {
|
||||
memcpy(dst + i, &immediate, size_by_byte);
|
||||
base::Memcpy(dst + i, &immediate, size_by_byte);
|
||||
}
|
||||
return length;
|
||||
}
|
||||
@ -3133,7 +3136,7 @@ inline static void VectorBinaryOp(void* dst, void* src1, void* src2,
|
||||
T& src1_val = *reinterpret_cast<T*>(src1_ptr + i);
|
||||
T& src2_val = *reinterpret_cast<T*>(src2_ptr + i);
|
||||
dst_val = op(src1_val, src2_val);
|
||||
memcpy(dst_ptr + i, &dst_val, sizeof(T));
|
||||
base::Memcpy(dst_ptr + i, &dst_val, sizeof(T));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3259,8 +3262,8 @@ void VectorSum(void* dst, void* src1, void* src2) {
|
||||
value += *(reinterpret_cast<S*>(src1) + i);
|
||||
if ((i + 1) % (sizeof(D) / sizeof(S)) == 0) {
|
||||
value += *(reinterpret_cast<S*>(src2) + i);
|
||||
memcpy(reinterpret_cast<D*>(dst) + i / (sizeof(D) / sizeof(S)), &value,
|
||||
sizeof(D));
|
||||
base::Memcpy(reinterpret_cast<D*>(dst) + i / (sizeof(D) / sizeof(S)),
|
||||
&value, sizeof(D));
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
@ -3317,14 +3320,14 @@ void VectorPack(void* dst, void* src1, void* src2, bool saturate,
|
||||
src = reinterpret_cast<S*>(src2);
|
||||
count = 0;
|
||||
}
|
||||
memcpy(&value, src + count, sizeof(S));
|
||||
base::Memcpy(&value, src + count, sizeof(S));
|
||||
if (saturate) {
|
||||
if (value > max)
|
||||
value = max;
|
||||
else if (value < min)
|
||||
value = min;
|
||||
}
|
||||
memcpy(reinterpret_cast<D*>(dst) + i, &value, sizeof(D));
|
||||
base::Memcpy(reinterpret_cast<D*>(dst) + i, &value, sizeof(D));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3409,7 +3412,7 @@ void VectorUnpackHigh(void* dst, void* src) {
|
||||
D value = 0;
|
||||
for (size_t i = 0; i < kItemCount; i++) {
|
||||
value = *(reinterpret_cast<S*>(src) + i + kItemCount);
|
||||
memcpy(reinterpret_cast<D*>(dst) + i, &value, sizeof(D));
|
||||
base::Memcpy(reinterpret_cast<D*>(dst) + i, &value, sizeof(D));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3470,7 +3473,7 @@ void VectorUnpackLow(void* dst, void* src) {
|
||||
temps[i] = static_cast<D>(*(reinterpret_cast<S*>(src) + i));
|
||||
}
|
||||
for (size_t i = 0; i < kItemCount; i++) {
|
||||
memcpy(reinterpret_cast<D*>(dst) + i, &temps[i], sizeof(D));
|
||||
base::Memcpy(reinterpret_cast<D*>(dst) + i, &temps[i], sizeof(D));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3707,7 +3710,7 @@ void VectorLoadComplement(void* dst, void* src) {
|
||||
T& src_val = *reinterpret_cast<T*>(src_ptr + i);
|
||||
T& dst_val = *reinterpret_cast<T*>(dst_ptr + i);
|
||||
dst_val = -(uint64_t)src_val;
|
||||
memcpy(dst_ptr + i, &dst_val, sizeof(T));
|
||||
base::Memcpy(dst_ptr + i, &dst_val, sizeof(T));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3812,7 +3815,7 @@ void VectorShift(void* dst, void* src, unsigned int shift, Operation op) {
|
||||
T& dst_val = *reinterpret_cast<T*>(dst_ptr + i);
|
||||
T& src_val = *reinterpret_cast<T*>(src_ptr + i);
|
||||
dst_val = op(src_val, shift);
|
||||
memcpy(dst_ptr + i, &dst_val, sizeof(T));
|
||||
base::Memcpy(dst_ptr + i, &dst_val, sizeof(T));
|
||||
}
|
||||
}
|
||||
|
||||
@ -4070,7 +4073,7 @@ void VectorFPMaxMin(void* dst, void* src1, void* src2, int mode, Operation op) {
|
||||
T src1_val = *(src1_ptr + i);
|
||||
T src2_val = *(src2_ptr + i);
|
||||
T value = op(src1_val, src2_val, mode);
|
||||
memcpy(dst_ptr + i, &value, sizeof(T));
|
||||
base::Memcpy(dst_ptr + i, &value, sizeof(T));
|
||||
}
|
||||
}
|
||||
|
||||
@ -4144,7 +4147,7 @@ void VectorFPCompare(void* dst, void* src1, void* src2, Operation op) {
|
||||
S src1_val = *(src1_ptr + i);
|
||||
S src2_val = *(src2_ptr + i);
|
||||
D value = op(src1_val, src2_val);
|
||||
memcpy(dst_ptr + i, &value, sizeof(D));
|
||||
base::Memcpy(dst_ptr + i, &value, sizeof(D));
|
||||
}
|
||||
}
|
||||
|
||||
@ -4213,33 +4216,33 @@ void VectorSignOp(void* dst, void* src, int m4, int m5) {
|
||||
case 0:
|
||||
if (m4 == 8) {
|
||||
T value = -(*src_ptr);
|
||||
memcpy(dst_ptr, &value, sizeof(T));
|
||||
base::Memcpy(dst_ptr, &value, sizeof(T));
|
||||
} else {
|
||||
for (size_t i = 0; i < kSimd128Size / sizeof(T); i++) {
|
||||
T value = -(*(src_ptr + i));
|
||||
memcpy(dst_ptr + i, &value, sizeof(T));
|
||||
base::Memcpy(dst_ptr + i, &value, sizeof(T));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (m4 == 8) {
|
||||
T value = -abs(*src_ptr);
|
||||
memcpy(dst_ptr, &value, sizeof(T));
|
||||
base::Memcpy(dst_ptr, &value, sizeof(T));
|
||||
} else {
|
||||
for (size_t i = 0; i < kSimd128Size / sizeof(T); i++) {
|
||||
T value = -abs(*(src_ptr + i));
|
||||
memcpy(dst_ptr + i, &value, sizeof(T));
|
||||
base::Memcpy(dst_ptr + i, &value, sizeof(T));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (m4 == 8) {
|
||||
T value = abs(*src_ptr);
|
||||
memcpy(dst_ptr, &value, sizeof(T));
|
||||
base::Memcpy(dst_ptr, &value, sizeof(T));
|
||||
} else {
|
||||
for (size_t i = 0; i < kSimd128Size / sizeof(T); i++) {
|
||||
T value = abs(*(src_ptr + i));
|
||||
memcpy(dst_ptr + i, &value, sizeof(T));
|
||||
base::Memcpy(dst_ptr + i, &value, sizeof(T));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -4276,7 +4279,7 @@ void VectorFPSqrt(void* dst, void* src) {
|
||||
T* src_ptr = reinterpret_cast<T*>(src);
|
||||
for (size_t i = 0; i < kSimd128Size / sizeof(T); i++) {
|
||||
T value = sqrt(*(src_ptr + i));
|
||||
memcpy(dst_ptr + i, &value, sizeof(T));
|
||||
base::Memcpy(dst_ptr + i, &value, sizeof(T));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,6 +96,7 @@
|
||||
#include "src/heap/conservative-stack-visitor.h"
|
||||
#endif
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
// Has to be the last include (doesn't have include guards):
|
||||
#include "src/objects/object-macros.h"
|
||||
|
||||
@ -4667,12 +4668,12 @@ void Heap::ConfigureHeap(const v8::ResourceConstraints& constraints) {
|
||||
void Heap::AddToRingBuffer(const char* string) {
|
||||
size_t first_part =
|
||||
Min(strlen(string), kTraceRingBufferSize - ring_buffer_end_);
|
||||
memcpy(trace_ring_buffer_ + ring_buffer_end_, string, first_part);
|
||||
base::Memcpy(trace_ring_buffer_ + ring_buffer_end_, string, first_part);
|
||||
ring_buffer_end_ += first_part;
|
||||
if (first_part < strlen(string)) {
|
||||
ring_buffer_full_ = true;
|
||||
size_t second_part = strlen(string) - first_part;
|
||||
memcpy(trace_ring_buffer_, string + first_part, second_part);
|
||||
base::Memcpy(trace_ring_buffer_, string + first_part, second_part);
|
||||
ring_buffer_end_ = second_part;
|
||||
}
|
||||
}
|
||||
@ -4682,9 +4683,9 @@ void Heap::GetFromRingBuffer(char* buffer) {
|
||||
size_t copied = 0;
|
||||
if (ring_buffer_full_) {
|
||||
copied = kTraceRingBufferSize - ring_buffer_end_;
|
||||
memcpy(buffer, trace_ring_buffer_ + ring_buffer_end_, copied);
|
||||
base::Memcpy(buffer, trace_ring_buffer_ + ring_buffer_end_, copied);
|
||||
}
|
||||
memcpy(buffer + copied, trace_ring_buffer_, ring_buffer_end_);
|
||||
base::Memcpy(buffer + copied, trace_ring_buffer_, ring_buffer_end_);
|
||||
}
|
||||
|
||||
void Heap::ConfigureHeapDefault() {
|
||||
@ -6690,7 +6691,7 @@ void Heap::IncrementObjectCounters() {
|
||||
// heap as a strong root array, saves that entry in StrongRootsEntry*, and
|
||||
// returns a pointer to Address 1.
|
||||
Address* StrongRootBlockAllocator::allocate(size_t n) {
|
||||
void* block = malloc(sizeof(StrongRootsEntry*) + n * sizeof(Address));
|
||||
void* block = base::Malloc(sizeof(StrongRootsEntry*) + n * sizeof(Address));
|
||||
|
||||
StrongRootsEntry** header = reinterpret_cast<StrongRootsEntry**>(block);
|
||||
Address* ret = reinterpret_cast<Address*>(reinterpret_cast<char*>(block) +
|
||||
@ -6711,7 +6712,7 @@ void StrongRootBlockAllocator::deallocate(Address* p, size_t n) noexcept {
|
||||
|
||||
heap_->UnregisterStrongRoots(*header);
|
||||
|
||||
free(block);
|
||||
base::Free(block);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "src/heap/memory-chunk.h"
|
||||
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/heap/code-object-registry.h"
|
||||
#include "src/heap/memory-allocator.h"
|
||||
#include "src/heap/memory-chunk-inl.h"
|
||||
@ -378,12 +379,13 @@ bool MemoryChunk::RegisteredObjectWithInvalidatedSlots(HeapObject object) {
|
||||
|
||||
void MemoryChunk::AllocateYoungGenerationBitmap() {
|
||||
DCHECK_NULL(young_generation_bitmap_);
|
||||
young_generation_bitmap_ = static_cast<Bitmap*>(calloc(1, Bitmap::kSize));
|
||||
young_generation_bitmap_ =
|
||||
static_cast<Bitmap*>(base::Calloc(1, Bitmap::kSize));
|
||||
}
|
||||
|
||||
void MemoryChunk::ReleaseYoungGenerationBitmap() {
|
||||
DCHECK_NOT_NULL(young_generation_bitmap_);
|
||||
free(young_generation_bitmap_);
|
||||
base::Free(young_generation_bitmap_);
|
||||
young_generation_bitmap_ = nullptr;
|
||||
}
|
||||
|
||||
|
@ -12,11 +12,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "unicode/putil.h"
|
||||
#include "unicode/udata.h"
|
||||
|
||||
#include "src/base/build_config.h"
|
||||
#include "src/base/file-utils.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "unicode/putil.h"
|
||||
#include "unicode/udata.h"
|
||||
|
||||
#define ICU_UTIL_DATA_FILE 0
|
||||
#define ICU_UTIL_DATA_STATIC 1
|
||||
@ -71,7 +71,7 @@ bool InitializeICU(const char* icu_data_file) {
|
||||
|
||||
if (g_icu_data_ptr) return true;
|
||||
|
||||
FILE* inf = fopen(icu_data_file, "rb");
|
||||
FILE* inf = base::Fopen(icu_data_file, "rb");
|
||||
if (!inf) return false;
|
||||
|
||||
fseek(inf, 0, SEEK_END);
|
||||
@ -82,10 +82,10 @@ bool InitializeICU(const char* icu_data_file) {
|
||||
if (fread(g_icu_data_ptr, 1, size, inf) != size) {
|
||||
delete[] g_icu_data_ptr;
|
||||
g_icu_data_ptr = nullptr;
|
||||
fclose(inf);
|
||||
base::Fclose(inf);
|
||||
return false;
|
||||
}
|
||||
fclose(inf);
|
||||
base::Fclose(inf);
|
||||
|
||||
atexit(free_icu_data_ptr);
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "src/base/file-utils.h"
|
||||
#include "src/base/logging.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/flags/flags.h"
|
||||
#include "src/utils/utils.h"
|
||||
|
||||
@ -42,7 +43,7 @@ void Load(const char* blob_file, v8::StartupData* startup_data,
|
||||
|
||||
CHECK(blob_file);
|
||||
|
||||
FILE* file = fopen(blob_file, "rb");
|
||||
FILE* file = base::Fopen(blob_file, "rb");
|
||||
if (!file) {
|
||||
PrintF(stderr, "Failed to open startup resource '%s'.\n", blob_file);
|
||||
return;
|
||||
@ -55,7 +56,7 @@ void Load(const char* blob_file, v8::StartupData* startup_data,
|
||||
startup_data->data = new char[startup_data->raw_size];
|
||||
int read_size = static_cast<int>(fread(const_cast<char*>(startup_data->data),
|
||||
1, startup_data->raw_size, file));
|
||||
fclose(file);
|
||||
base::Fclose(file);
|
||||
|
||||
if (startup_data->raw_size == read_size) {
|
||||
(*setter_fn)(startup_data);
|
||||
|
@ -2,12 +2,12 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "include/libplatform/v8-tracing.h"
|
||||
|
||||
#include "base/trace_event/common/trace_event_common.h"
|
||||
#include "include/libplatform/v8-tracing.h"
|
||||
#include "include/v8-platform.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/time.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace platform {
|
||||
@ -25,7 +25,7 @@ V8_INLINE static void CopyTraceObjectParameter(char** buffer,
|
||||
const char** member) {
|
||||
if (*member == nullptr) return;
|
||||
size_t length = strlen(*member) + 1;
|
||||
memcpy(*buffer, *member, length);
|
||||
base::Memcpy(*buffer, *member, length);
|
||||
*member = *buffer;
|
||||
*buffer += length;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "src/api/api-inl.h"
|
||||
#include "src/base/platform/mutex.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/builtins/profile-data-reader.h"
|
||||
#include "src/codegen/bailout-reason.h"
|
||||
#include "src/codegen/macro-assembler.h"
|
||||
@ -311,7 +312,7 @@ PerfBasicLogger::PerfBasicLogger(Isolate* isolate)
|
||||
}
|
||||
|
||||
PerfBasicLogger::~PerfBasicLogger() {
|
||||
fclose(perf_output_handle_);
|
||||
base::Fclose(perf_output_handle_);
|
||||
perf_output_handle_ = nullptr;
|
||||
}
|
||||
|
||||
@ -575,7 +576,7 @@ LowLevelLogger::LowLevelLogger(Isolate* isolate, const char* name)
|
||||
}
|
||||
|
||||
LowLevelLogger::~LowLevelLogger() {
|
||||
fclose(ll_output_handle_);
|
||||
base::Fclose(ll_output_handle_);
|
||||
ll_output_handle_ = nullptr;
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/numbers/conversions.h"
|
||||
#include "src/numbers/double.h"
|
||||
#include "src/objects/heap-number-inl.h"
|
||||
@ -50,7 +51,7 @@ inline unsigned int FastD2UI(double x) {
|
||||
reinterpret_cast<void*>(reinterpret_cast<Address>(&x) + kInt32Size);
|
||||
#endif
|
||||
// Copy least significant 32 bits of mantissa.
|
||||
memcpy(&result, mantissa_ptr, sizeof(result));
|
||||
base::Memcpy(&result, mantissa_ptr, sizeof(result));
|
||||
return negative ? ~result + 1 : result;
|
||||
}
|
||||
// Large number (outside uint32 range), Infinity or NaN.
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/common/assert-scope.h"
|
||||
#include "src/handles/handles.h"
|
||||
#include "src/heap/factory.h"
|
||||
@ -1347,7 +1348,8 @@ char* DoubleToRadixCString(double value, int radix) {
|
||||
DCHECK_LE(0, integer_cursor);
|
||||
// Allocate new string as return value.
|
||||
char* result = NewArray<char>(fraction_cursor - integer_cursor);
|
||||
memcpy(result, buffer + integer_cursor, fraction_cursor - integer_cursor);
|
||||
base::Memcpy(result, buffer + integer_cursor,
|
||||
fraction_cursor - integer_cursor);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/execution/isolate.h"
|
||||
#include "src/handles/global-handles.h"
|
||||
#include "src/logging/counters.h"
|
||||
@ -464,7 +465,8 @@ std::unique_ptr<BackingStore> BackingStore::CopyWasmMemory(Isolate* isolate,
|
||||
// If the allocation was successful, then the new buffer must be at least
|
||||
// as big as the old one.
|
||||
DCHECK_GE(new_pages * wasm::kWasmPageSize, byte_length_);
|
||||
memcpy(new_backing_store->buffer_start(), buffer_start_, byte_length_);
|
||||
base::Memcpy(new_backing_store->buffer_start(), buffer_start_,
|
||||
byte_length_);
|
||||
}
|
||||
|
||||
return new_backing_store;
|
||||
|
@ -240,6 +240,7 @@ class MutableBigInt : public FreshlyAllocatedBigInt {
|
||||
OBJECT_CONSTRUCTORS_IMPL(MutableBigInt, FreshlyAllocatedBigInt)
|
||||
NEVER_READ_ONLY_SPACE_IMPL(MutableBigInt)
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/objects/object-macros-undef.h"
|
||||
|
||||
template <typename T, typename Isolate>
|
||||
@ -361,9 +362,10 @@ Handle<MutableBigInt> MutableBigInt::Copy(Isolate* isolate,
|
||||
int length = source->length();
|
||||
// Allocating a BigInt of the same length as an existing BigInt cannot throw.
|
||||
Handle<MutableBigInt> result = New(isolate, length).ToHandleChecked();
|
||||
memcpy(reinterpret_cast<void*>(result->address() + BigIntBase::kHeaderSize),
|
||||
reinterpret_cast<void*>(source->address() + BigIntBase::kHeaderSize),
|
||||
BigInt::SizeFor(length) - BigIntBase::kHeaderSize);
|
||||
base::Memcpy(
|
||||
reinterpret_cast<void*>(result->address() + BigIntBase::kHeaderSize),
|
||||
reinterpret_cast<void*>(source->address() + BigIntBase::kHeaderSize),
|
||||
BigInt::SizeFor(length) - BigIntBase::kHeaderSize);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2003,7 +2005,7 @@ void BigInt::SerializeDigits(uint8_t* storage) {
|
||||
reinterpret_cast<void*>(ptr() + kDigitsOffset - kHeapObjectTag);
|
||||
#if defined(V8_TARGET_LITTLE_ENDIAN)
|
||||
int bytelength = length() * kDigitSize;
|
||||
memcpy(storage, digits, bytelength);
|
||||
base::Memcpy(storage, digits, bytelength);
|
||||
#elif defined(V8_TARGET_BIG_ENDIAN)
|
||||
digit_t* digit_storage = reinterpret_cast<digit_t*>(storage);
|
||||
const digit_t* digit = reinterpret_cast<const digit_t*>(digits);
|
||||
@ -2029,7 +2031,7 @@ MaybeHandle<BigInt> BigInt::FromSerializedDigits(
|
||||
void* digits =
|
||||
reinterpret_cast<void*>(result->ptr() + kDigitsOffset - kHeapObjectTag);
|
||||
#if defined(V8_TARGET_LITTLE_ENDIAN)
|
||||
memcpy(digits, digits_storage.begin(), bytelength);
|
||||
base::Memcpy(digits, digits_storage.begin(), bytelength);
|
||||
void* padding_start =
|
||||
reinterpret_cast<void*>(reinterpret_cast<Address>(digits) + bytelength);
|
||||
memset(padding_start, 0, length * kDigitSize - bytelength);
|
||||
|
@ -530,14 +530,14 @@ void ByteArray::copy_in(int index, const byte* buffer, int length) {
|
||||
DCHECK(index >= 0 && length >= 0 && length <= kMaxInt - index &&
|
||||
index + length <= this->length());
|
||||
Address dst_addr = field_address(kHeaderSize + index * kCharSize);
|
||||
memcpy(reinterpret_cast<void*>(dst_addr), buffer, length);
|
||||
base::Memcpy(reinterpret_cast<void*>(dst_addr), buffer, length);
|
||||
}
|
||||
|
||||
void ByteArray::copy_out(int index, byte* buffer, int length) {
|
||||
DCHECK(index >= 0 && length >= 0 && length <= kMaxInt - index &&
|
||||
index + length <= this->length());
|
||||
Address src_addr = field_address(kHeaderSize + index * kCharSize);
|
||||
memcpy(buffer, reinterpret_cast<void*>(src_addr), length);
|
||||
base::Memcpy(buffer, reinterpret_cast<void*>(src_addr), length);
|
||||
}
|
||||
|
||||
int ByteArray::get_int(int index) const {
|
||||
@ -632,6 +632,7 @@ void TemplateList::set(int index, Object value) {
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/objects/object-macros-undef.h"
|
||||
|
||||
#endif // V8_OBJECTS_FIXED_ARRAY_INL_H_
|
||||
|
@ -3,10 +3,11 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/objects/js-array-buffer.h"
|
||||
#include "src/objects/js-array-buffer-inl.h"
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/execution/protectors-inl.h"
|
||||
#include "src/logging/counters.h"
|
||||
#include "src/objects/js-array-buffer-inl.h"
|
||||
#include "src/objects/property-descriptor.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -174,7 +175,7 @@ Handle<JSArrayBuffer> JSTypedArray::GetBuffer() {
|
||||
|
||||
// Copy the elements into the backing store of the array buffer.
|
||||
if (byte_length > 0) {
|
||||
memcpy(backing_store->buffer_start(), self->DataPtr(), byte_length);
|
||||
base::Memcpy(backing_store->buffer_start(), self->DataPtr(), byte_length);
|
||||
}
|
||||
|
||||
// Attach the backing store to the array buffer.
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/handles/handles-inl.h"
|
||||
#include "src/objects/objects-inl.h"
|
||||
|
||||
@ -101,9 +102,9 @@ Handle<LayoutDescriptor> LayoutDescriptor::EnsureCapacity(
|
||||
DCHECK(new_layout_descriptor->IsSlowLayout());
|
||||
|
||||
if (layout_descriptor->IsSlowLayout()) {
|
||||
memcpy(new_layout_descriptor->GetDataStartAddress(),
|
||||
layout_descriptor->GetDataStartAddress(),
|
||||
layout_descriptor->DataSize());
|
||||
base::Memcpy(new_layout_descriptor->GetDataStartAddress(),
|
||||
layout_descriptor->GetDataStartAddress(),
|
||||
layout_descriptor->DataSize());
|
||||
return new_layout_descriptor;
|
||||
} else {
|
||||
// Fast layout.
|
||||
|
@ -60,7 +60,7 @@ void PreparseData::copy_in(int index, const byte* buffer, int length) {
|
||||
DCHECK(index >= 0 && length >= 0 && length <= kMaxInt - index &&
|
||||
index + length <= this->data_length());
|
||||
Address dst_addr = field_address(kDataStartOffset + index * kByteSize);
|
||||
memcpy(reinterpret_cast<void*>(dst_addr), buffer, length);
|
||||
base::Memcpy(reinterpret_cast<void*>(dst_addr), buffer, length);
|
||||
}
|
||||
|
||||
PreparseData PreparseData::get_child(int index) const {
|
||||
@ -791,6 +791,7 @@ bool SharedFunctionInfo::are_properties_final() const {
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/objects/object-macros-undef.h"
|
||||
|
||||
#endif // V8_OBJECTS_SHARED_FUNCTION_INFO_INL_H_
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "include/v8.h"
|
||||
#include "src/api/api-inl.h"
|
||||
#include "src/base/logging.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/execution/isolate.h"
|
||||
#include "src/flags/flags.h"
|
||||
#include "src/handles/handles-inl.h"
|
||||
@ -246,7 +247,7 @@ ValueSerializer::~ValueSerializer() {
|
||||
if (delegate_) {
|
||||
delegate_->FreeBufferMemory(buffer_);
|
||||
} else {
|
||||
free(buffer_);
|
||||
base::Free(buffer_);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -326,7 +327,7 @@ void ValueSerializer::WriteBigIntContents(BigInt bigint) {
|
||||
void ValueSerializer::WriteRawBytes(const void* source, size_t length) {
|
||||
uint8_t* dest;
|
||||
if (ReserveRawBytes(length).To(&dest) && length > 0) {
|
||||
memcpy(dest, source, length);
|
||||
base::Memcpy(dest, source, length);
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,7 +354,7 @@ Maybe<bool> ValueSerializer::ExpandBuffer(size_t required_capacity) {
|
||||
new_buffer = delegate_->ReallocateBufferMemory(buffer_, requested_capacity,
|
||||
&provided_capacity);
|
||||
} else {
|
||||
new_buffer = realloc(buffer_, requested_capacity);
|
||||
new_buffer = base::Realloc(buffer_, requested_capacity);
|
||||
provided_capacity = requested_capacity;
|
||||
}
|
||||
if (new_buffer) {
|
||||
@ -1176,7 +1177,7 @@ Maybe<double> ValueDeserializer::ReadDouble() {
|
||||
// Warning: this uses host endianness.
|
||||
if (position_ > end_ - sizeof(double)) return Nothing<double>();
|
||||
double value;
|
||||
memcpy(&value, position_, sizeof(double));
|
||||
base::Memcpy(&value, position_, sizeof(double));
|
||||
position_ += sizeof(double);
|
||||
if (std::isnan(value)) value = std::numeric_limits<double>::quiet_NaN();
|
||||
return Just(value);
|
||||
@ -1413,7 +1414,7 @@ MaybeHandle<String> ValueDeserializer::ReadTwoByteString() {
|
||||
// Copy the bytes directly into the new string.
|
||||
// Warning: this uses host endianness.
|
||||
DisallowHeapAllocation no_gc;
|
||||
memcpy(string->GetChars(no_gc), bytes.begin(), bytes.length());
|
||||
base::Memcpy(string->GetChars(no_gc), bytes.begin(), bytes.length());
|
||||
return string;
|
||||
}
|
||||
|
||||
@ -1771,7 +1772,7 @@ MaybeHandle<JSArrayBuffer> ValueDeserializer::ReadJSArrayBuffer(
|
||||
if (!result.ToHandle(&array_buffer)) return result;
|
||||
|
||||
if (byte_length > 0) {
|
||||
memcpy(array_buffer->backing_store(), position_, byte_length);
|
||||
base::Memcpy(array_buffer->backing_store(), position_, byte_length);
|
||||
}
|
||||
position_ += byte_length;
|
||||
AddObjectWithID(id, array_buffer);
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "src/ast/scopes.h"
|
||||
#include "src/ast/variables.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/handles/handles.h"
|
||||
#include "src/objects/objects-inl.h"
|
||||
#include "src/objects/shared-function-info.h"
|
||||
@ -133,7 +134,7 @@ struct RawPreparseData {};
|
||||
|
||||
void PreparseDataBuilder::ByteData::Finalize(Zone* zone) {
|
||||
uint8_t* raw_zone_data = zone->NewArray<uint8_t, RawPreparseData>(index_);
|
||||
memcpy(raw_zone_data, byte_data_->data(), index_);
|
||||
base::Memcpy(raw_zone_data, byte_data_->data(), index_);
|
||||
byte_data_->resize(0);
|
||||
zone_byte_data_ = Vector<uint8_t>(raw_zone_data, index_);
|
||||
#ifdef DEBUG
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <cmath>
|
||||
|
||||
#include "src/ast/ast-value-factory.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/numbers/conversions-inl.h"
|
||||
#include "src/objects/bigint.h"
|
||||
#include "src/parsing/parse-info.h"
|
||||
@ -1050,7 +1051,7 @@ const char* Scanner::CurrentLiteralAsCString(Zone* zone) const {
|
||||
Vector<const uint8_t> vector = literal_one_byte_string();
|
||||
int length = vector.length();
|
||||
char* buffer = zone->NewArray<char>(length + 1);
|
||||
memcpy(buffer, vector.begin(), length);
|
||||
base::Memcpy(buffer, vector.begin(), length);
|
||||
buffer[length] = '\0';
|
||||
return buffer;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "src/runtime/runtime.h"
|
||||
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/reloc-info.h"
|
||||
#include "src/execution/isolate.h"
|
||||
#include "src/handles/handles-inl.h"
|
||||
@ -256,8 +257,8 @@ const Runtime::Function* Runtime::RuntimeFunctionTable(Isolate* isolate) {
|
||||
if (!isolate->runtime_state()->redirected_intrinsic_functions()) {
|
||||
size_t function_count = arraysize(kIntrinsicFunctions);
|
||||
Function* redirected_functions = new Function[function_count];
|
||||
memcpy(redirected_functions, kIntrinsicFunctions,
|
||||
sizeof(kIntrinsicFunctions));
|
||||
base::Memcpy(redirected_functions, kIntrinsicFunctions,
|
||||
sizeof(kIntrinsicFunctions));
|
||||
for (size_t i = 0; i < function_count; i++) {
|
||||
ExternalReference redirected_entry =
|
||||
ExternalReference::Create(static_cast<Runtime::FunctionId>(i));
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "src/snapshot/deserializer.h"
|
||||
|
||||
#include "src/base/logging.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/assembler-inl.h"
|
||||
#include "src/common/assert-scope.h"
|
||||
#include "src/common/external-pointer.h"
|
||||
@ -191,7 +192,7 @@ class SlotAccessorForHandle {
|
||||
template <typename TSlot>
|
||||
int Deserializer::WriteAddress(TSlot dest, Address value) {
|
||||
DCHECK(!next_reference_is_weak_);
|
||||
memcpy(dest.ToVoidPtr(), &value, kSystemPointerSize);
|
||||
base::Memcpy(dest.ToVoidPtr(), &value, kSystemPointerSize);
|
||||
STATIC_ASSERT(IsAligned(kSystemPointerSize, TSlot::kSlotDataSize));
|
||||
return (kSystemPointerSize / TSlot::kSlotDataSize);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "src/snapshot/embedded/platform-embedded-file-writer-base.h"
|
||||
|
||||
#if defined(V8_OS_WIN64)
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/diagnostics/unwinding-info-win64.h"
|
||||
#endif // V8_OS_WIN64
|
||||
|
||||
@ -113,7 +114,7 @@ class EmbeddedFileWriter : public EmbeddedFileWriterInterface {
|
||||
WriteCodeSection(writer.get(), blob);
|
||||
WriteFileEpilogue(writer.get(), blob);
|
||||
|
||||
fclose(fp);
|
||||
base::Fclose(fp);
|
||||
}
|
||||
|
||||
static FILE* GetFileDescriptorOrDie(const char* filename) {
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/common/globals.h"
|
||||
#include "src/snapshot/embedded/platform-embedded-file-writer-aix.h"
|
||||
#include "src/snapshot/embedded/platform-embedded-file-writer-generic.h"
|
||||
@ -59,11 +60,11 @@ int PlatformEmbeddedFileWriterBase::WriteByteChunk(const uint8_t* data) {
|
||||
break;
|
||||
case 16:
|
||||
#ifdef V8_TARGET_BIG_ENDIAN
|
||||
memcpy(&high, data, kHalfSize);
|
||||
memcpy(&low, data + kHalfSize, kHalfSize);
|
||||
base::Memcpy(&high, data, kHalfSize);
|
||||
base::Memcpy(&low, data + kHalfSize, kHalfSize);
|
||||
#else
|
||||
memcpy(&high, data + kHalfSize, kHalfSize);
|
||||
memcpy(&low, data, kHalfSize);
|
||||
base::Memcpy(&high, data + kHalfSize, kHalfSize);
|
||||
base::Memcpy(&low, data, kHalfSize);
|
||||
#endif // V8_TARGET_BIG_ENDIAN
|
||||
break;
|
||||
default:
|
||||
|
@ -5,10 +5,12 @@
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
#include "include/libplatform/libplatform.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/assembler-arch.h"
|
||||
#include "src/codegen/source-position-table.h"
|
||||
#include "src/flags/flags.h"
|
||||
@ -47,7 +49,7 @@ class SnapshotFileWriter {
|
||||
|
||||
FILE* fp = GetFileDescriptorOrDie(snapshot_blob_path_);
|
||||
size_t written = fwrite(blob.begin(), 1, blob.length(), fp);
|
||||
fclose(fp);
|
||||
v8::base::Fclose(fp);
|
||||
if (written != static_cast<size_t>(blob.length())) {
|
||||
i::PrintF("Writing snapshot file failed.. Aborting.\n");
|
||||
remove(snapshot_blob_path_);
|
||||
@ -64,7 +66,7 @@ class SnapshotFileWriter {
|
||||
WriteSnapshotFileData(fp, blob);
|
||||
WriteSnapshotFileSuffix(fp);
|
||||
|
||||
fclose(fp);
|
||||
v8::base::Fclose(fp);
|
||||
}
|
||||
|
||||
static void WriteSnapshotFilePrefix(FILE* fp) {
|
||||
@ -139,7 +141,7 @@ char* GetExtraCode(char* filename, const char* description) {
|
||||
}
|
||||
i += read;
|
||||
}
|
||||
fclose(file);
|
||||
v8::base::Fclose(file);
|
||||
return chars;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "src/base/atomicops.h"
|
||||
#include "src/base/logging.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/common/globals.h"
|
||||
#include "src/snapshot/snapshot-utils.h"
|
||||
#include "src/utils/utils.h"
|
||||
@ -51,7 +52,7 @@ class SnapshotByteSource final {
|
||||
void Advance(int by) { position_ += by; }
|
||||
|
||||
void CopyRaw(void* to, int number_of_bytes) {
|
||||
memcpy(to, data_ + position_, number_of_bytes);
|
||||
base::Memcpy(to, data_ + position_, number_of_bytes);
|
||||
position_ += number_of_bytes;
|
||||
}
|
||||
|
||||
@ -61,7 +62,7 @@ class SnapshotByteSource final {
|
||||
for (base::AtomicWord* p = start; p < end;
|
||||
++p, position_ += sizeof(base::AtomicWord)) {
|
||||
base::AtomicWord val;
|
||||
memcpy(&val, data_ + position_, sizeof(base::AtomicWord));
|
||||
base::Memcpy(&val, data_ + position_, sizeof(base::AtomicWord));
|
||||
base::Relaxed_Store(p, val);
|
||||
}
|
||||
}
|
||||
@ -73,7 +74,7 @@ class SnapshotByteSource final {
|
||||
for (AtomicTagged_t* p = start; p < end;
|
||||
++p, position_ += sizeof(AtomicTagged_t)) {
|
||||
AtomicTagged_t val;
|
||||
memcpy(&val, data_ + position_, sizeof(AtomicTagged_t));
|
||||
base::Memcpy(&val, data_ + position_, sizeof(AtomicTagged_t));
|
||||
base::Relaxed_Store(p, val);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "include/v8-platform.h"
|
||||
#include "src/base/atomicops.h"
|
||||
#include "src/base/macros.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
|
||||
// This header file defines implementation details of how the trace macros in
|
||||
// trace_event_common.h collect and store trace events. Anything not
|
||||
@ -434,7 +435,7 @@ SetTraceValue(T arg, unsigned char* type, uint64_t* value) {
|
||||
*type = value_type_id; \
|
||||
*value = 0; \
|
||||
STATIC_ASSERT(sizeof(arg) <= sizeof(*value)); \
|
||||
memcpy(value, &arg, sizeof(arg)); \
|
||||
base::Memcpy(value, &arg, sizeof(arg)); \
|
||||
}
|
||||
INTERNAL_DECLARE_SET_TRACE_VALUE(double, TRACE_VALUE_TYPE_DOUBLE)
|
||||
INTERNAL_DECLARE_SET_TRACE_VALUE(const void*, TRACE_VALUE_TYPE_POINTER)
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#if V8_LIBC_BIONIC
|
||||
#include <malloc.h> // NOLINT
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#endif
|
||||
|
||||
namespace v8 {
|
||||
@ -93,7 +95,7 @@ void* Malloced::operator new(size_t size) {
|
||||
return result;
|
||||
}
|
||||
|
||||
void Malloced::operator delete(void* p) { free(p); }
|
||||
void Malloced::operator delete(void* p) { base::Free(p); }
|
||||
|
||||
char* StrDup(const char* str) {
|
||||
size_t length = strlen(str);
|
||||
@ -115,7 +117,7 @@ char* StrNDup(const char* str, size_t n) {
|
||||
void* AllocWithRetry(size_t size) {
|
||||
void* result = nullptr;
|
||||
for (int i = 0; i < kAllocationTries; ++i) {
|
||||
result = malloc(size);
|
||||
result = base::Malloc(size);
|
||||
if (result != nullptr) break;
|
||||
if (!OnCriticalMemoryPressure(size)) break;
|
||||
}
|
||||
@ -142,9 +144,9 @@ void AlignedFree(void* ptr) {
|
||||
_aligned_free(ptr);
|
||||
#elif V8_LIBC_BIONIC
|
||||
// Using free is not correct in general, but for V8_LIBC_BIONIC it is.
|
||||
free(ptr);
|
||||
base::Free(ptr);
|
||||
#else
|
||||
free(ptr);
|
||||
base::Free(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include "src/base/logging.h"
|
||||
#include "src/base/macros.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
@ -8,10 +8,12 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "src/base/logging.h"
|
||||
#include "src/base/macros.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -43,7 +45,7 @@ using MemCopyUint8Function = void (*)(uint8_t* dest, const uint8_t* src,
|
||||
V8_EXPORT_PRIVATE extern MemCopyUint8Function memcopy_uint8_function;
|
||||
V8_INLINE void MemCopyUint8Wrapper(uint8_t* dest, const uint8_t* src,
|
||||
size_t chars) {
|
||||
memcpy(dest, src, chars);
|
||||
base::Memcpy(dest, src, chars);
|
||||
}
|
||||
// For values < 16, the assembler function is slower than the inlined C code.
|
||||
const size_t kMinComplexMemCopy = 16;
|
||||
@ -64,7 +66,7 @@ using MemCopyUint8Function = void (*)(uint8_t* dest, const uint8_t* src,
|
||||
V8_EXPORT_PRIVATE extern MemCopyUint8Function memcopy_uint8_function;
|
||||
V8_INLINE void MemCopyUint8Wrapper(uint8_t* dest, const uint8_t* src,
|
||||
size_t chars) {
|
||||
memcpy(dest, src, chars);
|
||||
base::Memcpy(dest, src, chars);
|
||||
}
|
||||
// For values < 16, the assembler function is slower than the inlined C code.
|
||||
const size_t kMinComplexMemCopy = 16;
|
||||
@ -83,9 +85,9 @@ inline void MemCopy(void* dest, const void* src, size_t size) {
|
||||
// fixed sizes to a sequence of move instructions. This avoids the overhead of
|
||||
// the general {memcpy} function.
|
||||
switch (size) {
|
||||
#define CASE(N) \
|
||||
case N: \
|
||||
memcpy(dest, src, N); \
|
||||
#define CASE(N) \
|
||||
case N: \
|
||||
base::Memcpy(dest, src, N); \
|
||||
return;
|
||||
CASE(1)
|
||||
CASE(2)
|
||||
@ -105,7 +107,7 @@ inline void MemCopy(void* dest, const void* src, size_t size) {
|
||||
CASE(16)
|
||||
#undef CASE
|
||||
default:
|
||||
memcpy(dest, src, size);
|
||||
base::Memcpy(dest, src, size);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,13 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "src/base/functional.h"
|
||||
#include "src/base/logging.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/utils/memcopy.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -202,7 +204,7 @@ std::vector<char> ReadCharsFromFile(FILE* file, bool* exists, bool verbose,
|
||||
for (ptrdiff_t i = 0; i < size && feof(file) == 0;) {
|
||||
ptrdiff_t read = fread(result.data() + i, 1, size - i, file);
|
||||
if (read != (size - i) && ferror(file) != 0) {
|
||||
fclose(file);
|
||||
base::Fclose(file);
|
||||
*exists = false;
|
||||
return std::vector<char>();
|
||||
}
|
||||
@ -216,7 +218,7 @@ std::vector<char> ReadCharsFromFile(const char* filename, bool* exists,
|
||||
bool verbose) {
|
||||
FILE* file = base::OS::FOpen(filename, "rb");
|
||||
std::vector<char> result = ReadCharsFromFile(file, exists, verbose, filename);
|
||||
if (file != nullptr) fclose(file);
|
||||
if (file != nullptr) base::Fclose(file);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -261,7 +263,7 @@ int WriteChars(const char* filename, const char* str, int size, bool verbose) {
|
||||
return 0;
|
||||
}
|
||||
int written = WriteCharsToFile(str, size, f);
|
||||
fclose(f);
|
||||
base::Fclose(f);
|
||||
return written;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#ifndef V8_WASM_BASELINE_ARM_LIFTOFF_ASSEMBLER_ARM_H_
|
||||
#define V8_WASM_BASELINE_ARM_LIFTOFF_ASSEMBLER_ARM_H_
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/heap/memory-chunk.h"
|
||||
#include "src/wasm/baseline/liftoff-assembler.h"
|
||||
#include "src/wasm/baseline/liftoff-register.h"
|
||||
@ -3530,7 +3531,7 @@ void LiftoffAssembler::emit_f64x2_le(LiftoffRegister dst, LiftoffRegister lhs,
|
||||
void LiftoffAssembler::emit_s128_const(LiftoffRegister dst,
|
||||
const uint8_t imms[16]) {
|
||||
uint64_t vals[2];
|
||||
memcpy(vals, imms, sizeof(vals));
|
||||
base::Memcpy(vals, imms, sizeof(vals));
|
||||
vmov(dst.low_fp(), Double(vals[0]));
|
||||
vmov(dst.high_fp(), Double(vals[1]));
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#ifndef V8_WASM_BASELINE_ARM64_LIFTOFF_ASSEMBLER_ARM64_H_
|
||||
#define V8_WASM_BASELINE_ARM64_LIFTOFF_ASSEMBLER_ARM64_H_
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/heap/memory-chunk.h"
|
||||
#include "src/wasm/baseline/liftoff-assembler.h"
|
||||
|
||||
@ -2532,7 +2533,7 @@ void LiftoffAssembler::emit_f64x2_le(LiftoffRegister dst, LiftoffRegister lhs,
|
||||
void LiftoffAssembler::emit_s128_const(LiftoffRegister dst,
|
||||
const uint8_t imms[16]) {
|
||||
uint64_t vals[2];
|
||||
memcpy(vals, imms, sizeof(vals));
|
||||
base::Memcpy(vals, imms, sizeof(vals));
|
||||
Movi(dst.fp().V16B(), vals[1], vals[0]);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#ifndef V8_WASM_BASELINE_IA32_LIFTOFF_ASSEMBLER_IA32_H_
|
||||
#define V8_WASM_BASELINE_IA32_LIFTOFF_ASSEMBLER_IA32_H_
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/assembler.h"
|
||||
#include "src/heap/memory-chunk.h"
|
||||
#include "src/wasm/baseline/liftoff-assembler.h"
|
||||
@ -3013,7 +3014,7 @@ void LiftoffAssembler::emit_f64x2_le(LiftoffRegister dst, LiftoffRegister lhs,
|
||||
void LiftoffAssembler::emit_s128_const(LiftoffRegister dst,
|
||||
const uint8_t imms[16]) {
|
||||
uint64_t vals[2];
|
||||
memcpy(vals, imms, sizeof(vals));
|
||||
base::Memcpy(vals, imms, sizeof(vals));
|
||||
TurboAssembler::Move(dst.fp(), vals[0]);
|
||||
|
||||
uint64_t high = vals[1];
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "src/base/optional.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/assembler-inl.h"
|
||||
#include "src/codegen/macro-assembler-inl.h"
|
||||
#include "src/compiler/linkage.h"
|
||||
@ -531,7 +532,7 @@ LiftoffAssembler::LiftoffAssembler(std::unique_ptr<AssemblerBuffer> buffer)
|
||||
|
||||
LiftoffAssembler::~LiftoffAssembler() {
|
||||
if (num_locals_ > kInlineLocalTypes) {
|
||||
free(more_local_types_);
|
||||
base::Free(more_local_types_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1116,8 +1117,8 @@ void LiftoffAssembler::set_num_locals(uint32_t num_locals) {
|
||||
DCHECK_EQ(0, num_locals_); // only call this once.
|
||||
num_locals_ = num_locals;
|
||||
if (num_locals > kInlineLocalTypes) {
|
||||
more_local_types_ =
|
||||
reinterpret_cast<ValueType*>(malloc(num_locals * sizeof(ValueType)));
|
||||
more_local_types_ = reinterpret_cast<ValueType*>(
|
||||
base::Malloc(num_locals * sizeof(ValueType)));
|
||||
DCHECK_NOT_NULL(more_local_types_);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "src/wasm/baseline/liftoff-compiler.h"
|
||||
|
||||
#include "src/base/optional.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/assembler-inl.h"
|
||||
// TODO(clemensb): Remove dependences on compiler stuff.
|
||||
#include "src/codegen/external-reference.h"
|
||||
@ -3046,7 +3047,7 @@ class LiftoffCompiler {
|
||||
LiftoffRegister dst = __ GetUnusedRegister(result_rc, {lhs, rhs}, {});
|
||||
|
||||
uint8_t shuffle[kSimd128Size];
|
||||
memcpy(shuffle, imm.value, sizeof(shuffle));
|
||||
base::Memcpy(shuffle, imm.value, sizeof(shuffle));
|
||||
bool is_swizzle;
|
||||
bool needs_swap;
|
||||
wasm::SimdShuffle::CanonicalizeShuffle(lhs == rhs, shuffle, &needs_swap,
|
||||
|
@ -5,6 +5,7 @@
|
||||
#ifndef V8_WASM_BASELINE_MIPS64_LIFTOFF_ASSEMBLER_MIPS64_H_
|
||||
#define V8_WASM_BASELINE_MIPS64_LIFTOFF_ASSEMBLER_MIPS64_H_
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/heap/memory-chunk.h"
|
||||
#include "src/wasm/baseline/liftoff-assembler.h"
|
||||
|
||||
@ -1754,7 +1755,7 @@ void LiftoffAssembler::emit_s128_const(LiftoffRegister dst,
|
||||
const uint8_t imms[16]) {
|
||||
MSARegister dst_msa = dst.fp().toW();
|
||||
uint64_t vals[2];
|
||||
memcpy(vals, imms, sizeof(vals));
|
||||
base::Memcpy(vals, imms, sizeof(vals));
|
||||
li(kScratchReg, vals[0]);
|
||||
insert_d(dst_msa, 0, kScratchReg);
|
||||
li(kScratchReg, vals[1]);
|
||||
|
@ -5,6 +5,7 @@
|
||||
#ifndef V8_WASM_BASELINE_X64_LIFTOFF_ASSEMBLER_X64_H_
|
||||
#define V8_WASM_BASELINE_X64_LIFTOFF_ASSEMBLER_X64_H_
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/assembler.h"
|
||||
#include "src/heap/memory-chunk.h"
|
||||
#include "src/wasm/baseline/liftoff-assembler.h"
|
||||
@ -2636,7 +2637,7 @@ void LiftoffAssembler::emit_f64x2_le(LiftoffRegister dst, LiftoffRegister lhs,
|
||||
void LiftoffAssembler::emit_s128_const(LiftoffRegister dst,
|
||||
const uint8_t imms[16]) {
|
||||
uint64_t vals[2];
|
||||
memcpy(vals, imms, sizeof(vals));
|
||||
base::Memcpy(vals, imms, sizeof(vals));
|
||||
TurboAssembler::Move(dst.fp(), vals[0]);
|
||||
movq(kScratchRegister, vals[1]);
|
||||
Pinsrq(dst.fp(), kScratchRegister, uint8_t{1});
|
||||
|
@ -19,15 +19,14 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/wasm/c-api.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#include "src/wasm/c-api.h"
|
||||
|
||||
#include "third_party/wasm-api/wasm.h"
|
||||
|
||||
#include "include/libplatform/libplatform.h"
|
||||
#include "src/api/api-inl.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/compiler/wasm-compiler.h"
|
||||
#include "src/objects/js-collection-inl.h"
|
||||
#include "src/objects/managed.h"
|
||||
@ -39,6 +38,7 @@
|
||||
#include "src/wasm/wasm-objects.h"
|
||||
#include "src/wasm/wasm-result.h"
|
||||
#include "src/wasm/wasm-serialization.h"
|
||||
#include "third_party/wasm-api/wasm.h"
|
||||
|
||||
#ifdef WASM_API_DEBUG
|
||||
#error "WASM_API_DEBUG is unsupported"
|
||||
@ -2212,22 +2212,22 @@ struct borrowed_vec {
|
||||
}
|
||||
|
||||
// Vectors with no ownership management of elements
|
||||
#define WASM_DEFINE_VEC_PLAIN(name, Name) \
|
||||
WASM_DEFINE_VEC_BASE(name, Name, \
|
||||
wasm::vec, ) /* NOLINT(whitespace/parens) */ \
|
||||
\
|
||||
void wasm_##name##_vec_new(wasm_##name##_vec_t* out, size_t size, \
|
||||
const wasm_##name##_t data[]) { \
|
||||
auto v2 = wasm::vec<Name>::make_uninitialized(size); \
|
||||
if (v2.size() != 0) { \
|
||||
memcpy(v2.get(), data, size * sizeof(wasm_##name##_t)); \
|
||||
} \
|
||||
*out = release_##name##_vec(std::move(v2)); \
|
||||
} \
|
||||
\
|
||||
void wasm_##name##_vec_copy(wasm_##name##_vec_t* out, \
|
||||
wasm_##name##_vec_t* v) { \
|
||||
wasm_##name##_vec_new(out, v->size, v->data); \
|
||||
#define WASM_DEFINE_VEC_PLAIN(name, Name) \
|
||||
WASM_DEFINE_VEC_BASE(name, Name, \
|
||||
wasm::vec, ) /* NOLINT(whitespace/parens) */ \
|
||||
\
|
||||
void wasm_##name##_vec_new(wasm_##name##_vec_t* out, size_t size, \
|
||||
const wasm_##name##_t data[]) { \
|
||||
auto v2 = wasm::vec<Name>::make_uninitialized(size); \
|
||||
if (v2.size() != 0) { \
|
||||
v8::base::Memcpy(v2.get(), data, size * sizeof(wasm_##name##_t)); \
|
||||
} \
|
||||
*out = release_##name##_vec(std::move(v2)); \
|
||||
} \
|
||||
\
|
||||
void wasm_##name##_vec_copy(wasm_##name##_vec_t* out, \
|
||||
wasm_##name##_vec_t* v) { \
|
||||
wasm_##name##_vec_new(out, v->size, v->data); \
|
||||
}
|
||||
|
||||
// Vectors that own their elements
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "src/base/platform/elapsed-timer.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/base/small-vector.h"
|
||||
#include "src/utils/bit-vector.h"
|
||||
#include "src/wasm/decoder.h"
|
||||
@ -399,7 +400,7 @@ struct ImmF32Immediate {
|
||||
// returns a float would potentially flip NaN bits per C++ semantics, so we
|
||||
// have to inline the memcpy call directly.
|
||||
uint32_t tmp = decoder->read_u32<validate>(pc, "immf32");
|
||||
memcpy(&value, &tmp, sizeof(value));
|
||||
base::Memcpy(&value, &tmp, sizeof(value));
|
||||
}
|
||||
};
|
||||
|
||||
@ -410,7 +411,7 @@ struct ImmF64Immediate {
|
||||
inline ImmF64Immediate(Decoder* decoder, const byte* pc) {
|
||||
// Avoid bit_cast because it might not preserve the signalling bit of a NaN.
|
||||
uint64_t tmp = decoder->read_u64<validate>(pc, "immf64");
|
||||
memcpy(&value, &tmp, sizeof(value));
|
||||
base::Memcpy(&value, &tmp, sizeof(value));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "src/wasm/local-decl-encoder.h"
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/codegen/signature.h"
|
||||
#include "src/wasm/leb-helper.h"
|
||||
|
||||
@ -20,7 +21,7 @@ void LocalDeclEncoder::Prepend(Zone* zone, const byte** start,
|
||||
byte* buffer = zone->NewArray<byte, LocalDeclEncoderBuffer>(Size() + size);
|
||||
size_t pos = Emit(buffer);
|
||||
if (size > 0) {
|
||||
memcpy(buffer + pos, *start, size);
|
||||
base::Memcpy(buffer + pos, *start, size);
|
||||
}
|
||||
pos += size;
|
||||
*start = buffer;
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "src/base/functional.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/flags/flags.h"
|
||||
#include "src/init/v8.h"
|
||||
#include "src/logging/counters.h"
|
||||
@ -310,7 +311,7 @@ class ModuleDecoderImpl : public Decoder {
|
||||
size_t rv = 0;
|
||||
if (FILE* file = base::OS::FOpen(path.c_str(), "wb")) {
|
||||
rv = fwrite(module_bytes.begin(), module_bytes.length(), 1, file);
|
||||
fclose(file);
|
||||
base::Fclose(file);
|
||||
}
|
||||
if (rv != 1) {
|
||||
OFStream os(stderr);
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "src/api/api.h"
|
||||
#include "src/asmjs/asm-js.h"
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/logging/counters.h"
|
||||
#include "src/logging/metrics.h"
|
||||
#include "src/numbers/conversions-inl.h"
|
||||
@ -885,7 +886,7 @@ void InstanceBuilder::LoadDataSegments(Handle<WasmInstanceObject> instance) {
|
||||
instance->memory_size()));
|
||||
byte* dest = instance->memory_start() + dest_offset;
|
||||
const byte* src = wire_bytes.begin() + segment.source.offset();
|
||||
memcpy(dest, src, size);
|
||||
base::Memcpy(dest, src, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1675,8 +1676,8 @@ void InstanceBuilder::InitGlobals(Handle<WasmInstanceObject> instance) {
|
||||
size_t size = (global.type == kWasmI64 || global.type == kWasmF64)
|
||||
? sizeof(double)
|
||||
: sizeof(int32_t);
|
||||
memcpy(raw_buffer_ptr(untagged_globals_, new_offset),
|
||||
raw_buffer_ptr(untagged_globals_, old_offset), size);
|
||||
base::Memcpy(raw_buffer_ptr(untagged_globals_, new_offset),
|
||||
raw_buffer_ptr(untagged_globals_, old_offset), size);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "src/wasm/streaming-decoder.h"
|
||||
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/handles/handles.h"
|
||||
#include "src/objects/descriptor-array.h"
|
||||
#include "src/objects/dictionary.h"
|
||||
@ -62,7 +63,8 @@ class V8_EXPORT_PRIVATE AsyncStreamingDecoder : public StreamingDecoder {
|
||||
1 + length_bytes.length() + payload_length)),
|
||||
payload_offset_(1 + length_bytes.length()) {
|
||||
bytes_.start()[0] = id;
|
||||
memcpy(bytes_.start() + 1, &length_bytes.first(), length_bytes.length());
|
||||
base::Memcpy(bytes_.start() + 1, &length_bytes.first(),
|
||||
length_bytes.length());
|
||||
}
|
||||
|
||||
SectionCode section_code() const {
|
||||
@ -252,7 +254,7 @@ size_t AsyncStreamingDecoder::DecodingState::ReadBytes(
|
||||
Vector<uint8_t> remaining_buf = buffer() + offset();
|
||||
size_t num_bytes = std::min(bytes.size(), remaining_buf.size());
|
||||
TRACE_STREAMING("ReadBytes(%zu bytes)\n", num_bytes);
|
||||
memcpy(remaining_buf.begin(), &bytes.first(), num_bytes);
|
||||
base::Memcpy(remaining_buf.begin(), &bytes.first(), num_bytes);
|
||||
set_offset(offset() + num_bytes);
|
||||
return num_bytes;
|
||||
}
|
||||
@ -288,12 +290,12 @@ void AsyncStreamingDecoder::Finish() {
|
||||
#define BYTES(x) (x & 0xFF), (x >> 8) & 0xFF, (x >> 16) & 0xFF, (x >> 24) & 0xFF
|
||||
uint8_t module_header[]{BYTES(kWasmMagic), BYTES(kWasmVersion)};
|
||||
#undef BYTES
|
||||
memcpy(cursor, module_header, arraysize(module_header));
|
||||
base::Memcpy(cursor, module_header, arraysize(module_header));
|
||||
cursor += arraysize(module_header);
|
||||
}
|
||||
for (const auto& buffer : section_buffers_) {
|
||||
DCHECK_LE(cursor - bytes.start() + buffer->length(), total_size_);
|
||||
memcpy(cursor, buffer->bytes().begin(), buffer->length());
|
||||
base::Memcpy(cursor, buffer->bytes().begin(), buffer->length());
|
||||
cursor += buffer->length();
|
||||
}
|
||||
processor_->OnFinishedStream(std::move(bytes));
|
||||
@ -512,7 +514,7 @@ size_t AsyncStreamingDecoder::DecodeVarInt32::ReadBytes(
|
||||
Vector<uint8_t> remaining_buf = buf + offset();
|
||||
size_t new_bytes = std::min(bytes.size(), remaining_buf.size());
|
||||
TRACE_STREAMING("ReadBytes of a VarInt\n");
|
||||
memcpy(remaining_buf.begin(), &bytes.first(), new_bytes);
|
||||
base::Memcpy(remaining_buf.begin(), &bytes.first(), new_bytes);
|
||||
buf.Truncate(offset() + new_bytes);
|
||||
Decoder decoder(buf,
|
||||
streaming->module_offset() - static_cast<uint32_t>(offset()));
|
||||
@ -626,7 +628,7 @@ AsyncStreamingDecoder::DecodeNumberOfFunctions::NextWithValue(
|
||||
if (payload_buf.size() < bytes_consumed_) {
|
||||
return streaming->Error("invalid code section length");
|
||||
}
|
||||
memcpy(payload_buf.begin(), buffer().begin(), bytes_consumed_);
|
||||
base::Memcpy(payload_buf.begin(), buffer().begin(), bytes_consumed_);
|
||||
|
||||
// {value} is the number of functions.
|
||||
if (value_ == 0) {
|
||||
@ -657,7 +659,7 @@ AsyncStreamingDecoder::DecodeFunctionLength::NextWithValue(
|
||||
if (fun_length_buffer.size() < bytes_consumed_) {
|
||||
return streaming->Error("read past code section end");
|
||||
}
|
||||
memcpy(fun_length_buffer.begin(), buffer().begin(), bytes_consumed_);
|
||||
base::Memcpy(fun_length_buffer.begin(), buffer().begin(), bytes_consumed_);
|
||||
|
||||
// {value} is the length of the function.
|
||||
if (value_ == 0) return streaming->Error("invalid function length (0)");
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "src/wasm/wasm-objects.h"
|
||||
|
||||
#if defined(V8_OS_WIN64)
|
||||
#include "src/base/platform/wrappers.h"
|
||||
#include "src/diagnostics/unwinding-info-win64.h"
|
||||
#endif // V8_OS_WIN64
|
||||
|
||||
@ -182,7 +183,7 @@ std::unique_ptr<const byte[]> WasmCode::ConcatenateBytes(
|
||||
byte* ptr = result.get();
|
||||
for (auto& vec : vectors) {
|
||||
if (vec.empty()) continue; // Avoid nullptr in {memcpy}.
|
||||
memcpy(ptr, vec.begin(), vec.size());
|
||||
base::Memcpy(ptr, vec.begin(), vec.size());
|
||||
ptr += vec.size();
|
||||
}
|
||||
return result;
|
||||
@ -836,8 +837,8 @@ void NativeModule::ReserveCodeTableForTesting(uint32_t max_functions) {
|
||||
DCHECK_LE(module_->num_declared_functions, max_functions);
|
||||
auto new_table = std::make_unique<WasmCode*[]>(max_functions);
|
||||
if (module_->num_declared_functions > 0) {
|
||||
memcpy(new_table.get(), code_table_.get(),
|
||||
module_->num_declared_functions * sizeof(WasmCode*));
|
||||
base::Memcpy(new_table.get(), code_table_.get(),
|
||||
module_->num_declared_functions * sizeof(WasmCode*));
|
||||
}
|
||||
code_table_ = std::move(new_table);
|
||||
|
||||
@ -914,7 +915,8 @@ WasmCode* NativeModule::AddCodeForTesting(Handle<Code> code) {
|
||||
|
||||
Vector<uint8_t> dst_code_bytes =
|
||||
code_allocator_.AllocateForCode(this, instructions.size());
|
||||
memcpy(dst_code_bytes.begin(), instructions.begin(), instructions.size());
|
||||
base::Memcpy(dst_code_bytes.begin(), instructions.begin(),
|
||||
instructions.size());
|
||||
|
||||
// Apply the relocation delta by iterating over the RelocInfo.
|
||||
intptr_t delta = reinterpret_cast<Address>(dst_code_bytes.begin()) -
|
||||
@ -1039,8 +1041,8 @@ std::unique_ptr<WasmCode> NativeModule::AddCodeWithCodeSpace(
|
||||
const int instr_size = desc.instr_size;
|
||||
|
||||
CODE_SPACE_WRITE_SCOPE
|
||||
memcpy(dst_code_bytes.begin(), desc.buffer,
|
||||
static_cast<size_t>(desc.instr_size));
|
||||
base::Memcpy(dst_code_bytes.begin(), desc.buffer,
|
||||
static_cast<size_t>(desc.instr_size));
|
||||
|
||||
// Apply the relocation delta by iterating over the RelocInfo.
|
||||
intptr_t delta = dst_code_bytes.begin() - desc.buffer;
|
||||
@ -1186,7 +1188,8 @@ WasmCode* NativeModule::AddDeserializedCode(
|
||||
Vector<uint8_t> dst_code_bytes =
|
||||
code_allocator_.AllocateForCode(this, instructions.size());
|
||||
UpdateCodeSize(dst_code_bytes.size(), tier, kNoDebugging);
|
||||
memcpy(dst_code_bytes.begin(), instructions.begin(), instructions.size());
|
||||
base::Memcpy(dst_code_bytes.begin(), instructions.begin(),
|
||||
instructions.size());
|
||||
|
||||
std::unique_ptr<WasmCode> code{new WasmCode{
|
||||
this, index, dst_code_bytes, stack_slots, tagged_parameter_slots,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user