Reland 21502 - "Move OS::MemCopy and OS::MemMove out of platform to utils"
Verified that arm builds locally. BUG=none TBR=jkummerow@chromium.org LOG=n Review URL: https://codereview.chromium.org/306473004 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21512 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
b3c067ff03
commit
84e078e561
@ -66,7 +66,7 @@ void AllStatic::operator delete(void* p) {
|
||||
char* StrDup(const char* str) {
|
||||
int length = StrLength(str);
|
||||
char* result = NewArray<char>(length + 1);
|
||||
OS::MemCopy(result, str, length);
|
||||
MemCopy(result, str, length);
|
||||
result[length] = '\0';
|
||||
return result;
|
||||
}
|
||||
@ -76,7 +76,7 @@ char* StrNDup(const char* str, int n) {
|
||||
int length = StrLength(str);
|
||||
if (n < length) length = n;
|
||||
char* result = NewArray<char>(length + 1);
|
||||
OS::MemCopy(result, str, length);
|
||||
MemCopy(result, str, length);
|
||||
result[length] = '\0';
|
||||
return result;
|
||||
}
|
||||
|
@ -3275,7 +3275,7 @@ Local<String> v8::Object::ObjectProtoToString() {
|
||||
|
||||
// Write prefix.
|
||||
char* ptr = buf.start();
|
||||
i::OS::MemCopy(ptr, prefix, prefix_len * v8::internal::kCharSize);
|
||||
i::MemCopy(ptr, prefix, prefix_len * v8::internal::kCharSize);
|
||||
ptr += prefix_len;
|
||||
|
||||
// Write real content.
|
||||
@ -3283,7 +3283,7 @@ Local<String> v8::Object::ObjectProtoToString() {
|
||||
ptr += str_len;
|
||||
|
||||
// Write postfix.
|
||||
i::OS::MemCopy(ptr, postfix, postfix_len * v8::internal::kCharSize);
|
||||
i::MemCopy(ptr, postfix, postfix_len * v8::internal::kCharSize);
|
||||
|
||||
// Copy the buffer into a heap-allocated string and return it.
|
||||
Local<String> result = v8::String::NewFromUtf8(
|
||||
@ -7414,7 +7414,7 @@ void HandleScopeImplementer::FreeThreadResources() {
|
||||
char* HandleScopeImplementer::ArchiveThread(char* storage) {
|
||||
HandleScopeData* current = isolate_->handle_scope_data();
|
||||
handle_scope_data_ = *current;
|
||||
OS::MemCopy(storage, this, sizeof(*this));
|
||||
MemCopy(storage, this, sizeof(*this));
|
||||
|
||||
ResetAfterArchive();
|
||||
current->Initialize();
|
||||
@ -7429,7 +7429,7 @@ int HandleScopeImplementer::ArchiveSpacePerThread() {
|
||||
|
||||
|
||||
char* HandleScopeImplementer::RestoreThread(char* storage) {
|
||||
OS::MemCopy(this, storage, sizeof(*this));
|
||||
MemCopy(this, storage, sizeof(*this));
|
||||
*isolate_->handle_scope_data() = handle_scope_data_;
|
||||
return storage + ArchiveSpacePerThread();
|
||||
}
|
||||
|
@ -2325,7 +2325,7 @@ void Assembler::vstm(BlockAddrMode am,
|
||||
|
||||
static void DoubleAsTwoUInt32(double d, uint32_t* lo, uint32_t* hi) {
|
||||
uint64_t i;
|
||||
OS::MemCopy(&i, &d, 8);
|
||||
MemCopy(&i, &d, 8);
|
||||
|
||||
*lo = i & 0xffffffff;
|
||||
*hi = i >> 32;
|
||||
@ -3114,9 +3114,9 @@ void Assembler::GrowBuffer() {
|
||||
// Copy the data.
|
||||
int pc_delta = desc.buffer - buffer_;
|
||||
int rc_delta = (desc.buffer + desc.buffer_size) - (buffer_ + buffer_size_);
|
||||
OS::MemMove(desc.buffer, buffer_, desc.instr_size);
|
||||
OS::MemMove(reloc_info_writer.pos() + rc_delta,
|
||||
reloc_info_writer.pos(), desc.reloc_size);
|
||||
MemMove(desc.buffer, buffer_, desc.instr_size);
|
||||
MemMove(reloc_info_writer.pos() + rc_delta, reloc_info_writer.pos(),
|
||||
desc.reloc_size);
|
||||
|
||||
// Switch buffers.
|
||||
DeleteArray(buffer_);
|
||||
|
@ -78,8 +78,7 @@ UnaryMathFunction CreateExpFunction() {
|
||||
}
|
||||
|
||||
#if defined(V8_HOST_ARCH_ARM)
|
||||
OS::MemCopyUint8Function CreateMemCopyUint8Function(
|
||||
OS::MemCopyUint8Function stub) {
|
||||
MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) {
|
||||
#if defined(USE_SIMULATOR)
|
||||
return stub;
|
||||
#else
|
||||
@ -228,14 +227,14 @@ OS::MemCopyUint8Function CreateMemCopyUint8Function(
|
||||
|
||||
CPU::FlushICache(buffer, actual_size);
|
||||
OS::ProtectCode(buffer, actual_size);
|
||||
return FUNCTION_CAST<OS::MemCopyUint8Function>(buffer);
|
||||
return FUNCTION_CAST<MemCopyUint8Function>(buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Convert 8 to 16. The number of character to copy must be at least 8.
|
||||
OS::MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function(
|
||||
OS::MemCopyUint16Uint8Function stub) {
|
||||
MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function(
|
||||
MemCopyUint16Uint8Function stub) {
|
||||
#if defined(USE_SIMULATOR)
|
||||
return stub;
|
||||
#else
|
||||
@ -315,7 +314,7 @@ OS::MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function(
|
||||
CPU::FlushICache(buffer, actual_size);
|
||||
OS::ProtectCode(buffer, actual_size);
|
||||
|
||||
return FUNCTION_CAST<OS::MemCopyUint16Uint8Function>(buffer);
|
||||
return FUNCTION_CAST<MemCopyUint16Uint8Function>(buffer);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@ -28,7 +28,7 @@ double Instruction::DoubleImmedVmov() const {
|
||||
|
||||
uint64_t imm = high16 << 48;
|
||||
double d;
|
||||
OS::MemCopy(&d, &imm, 8);
|
||||
MemCopy(&d, &imm, 8);
|
||||
return d;
|
||||
}
|
||||
|
||||
|
@ -694,12 +694,12 @@ void Simulator::CheckICache(v8::internal::HashMap* i_cache,
|
||||
char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask);
|
||||
if (cache_hit) {
|
||||
// Check that the data in memory matches the contents of the I-cache.
|
||||
CHECK_EQ(0, memcmp(reinterpret_cast<void*>(instr),
|
||||
cache_page->CachedData(offset),
|
||||
Instruction::kInstrSize));
|
||||
CHECK_EQ(0,
|
||||
memcmp(reinterpret_cast<void*>(instr),
|
||||
cache_page->CachedData(offset), Instruction::kInstrSize));
|
||||
} else {
|
||||
// Cache miss. Load memory into the cache.
|
||||
OS::MemCopy(cached_line, line, CachePage::kLineLength);
|
||||
MemCopy(cached_line, line, CachePage::kLineLength);
|
||||
*cache_valid_byte = CachePage::LINE_VALID;
|
||||
}
|
||||
}
|
||||
@ -894,8 +894,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(vfp_registers_[0])];
|
||||
OS::MemCopy(buffer, ®isters_[reg], 2 * sizeof(registers_[0]));
|
||||
OS::MemCopy(&dm_val, buffer, 2 * sizeof(registers_[0]));
|
||||
MemCopy(buffer, ®isters_[reg], 2 * sizeof(registers_[0]));
|
||||
MemCopy(&dm_val, buffer, 2 * sizeof(registers_[0]));
|
||||
return(dm_val);
|
||||
}
|
||||
|
||||
@ -999,9 +999,9 @@ void Simulator::SetVFPRegister(int reg_index, const InputType& value) {
|
||||
if (register_size == 2) ASSERT(reg_index < DwVfpRegister::NumRegisters());
|
||||
|
||||
char buffer[register_size * sizeof(vfp_registers_[0])];
|
||||
OS::MemCopy(buffer, &value, register_size * sizeof(vfp_registers_[0]));
|
||||
OS::MemCopy(&vfp_registers_[reg_index * register_size], buffer,
|
||||
register_size * sizeof(vfp_registers_[0]));
|
||||
MemCopy(buffer, &value, register_size * sizeof(vfp_registers_[0]));
|
||||
MemCopy(&vfp_registers_[reg_index * register_size], buffer,
|
||||
register_size * sizeof(vfp_registers_[0]));
|
||||
}
|
||||
|
||||
|
||||
@ -1013,9 +1013,9 @@ ReturnType Simulator::GetFromVFPRegister(int reg_index) {
|
||||
|
||||
ReturnType value = 0;
|
||||
char buffer[register_size * sizeof(vfp_registers_[0])];
|
||||
OS::MemCopy(buffer, &vfp_registers_[register_size * reg_index],
|
||||
register_size * sizeof(vfp_registers_[0]));
|
||||
OS::MemCopy(&value, buffer, register_size * sizeof(vfp_registers_[0]));
|
||||
MemCopy(buffer, &vfp_registers_[register_size * reg_index],
|
||||
register_size * sizeof(vfp_registers_[0]));
|
||||
MemCopy(&value, buffer, register_size * sizeof(vfp_registers_[0]));
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -1044,14 +1044,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])];
|
||||
OS::MemCopy(buffer, &result, sizeof(buffer));
|
||||
MemCopy(buffer, &result, sizeof(buffer));
|
||||
// Copy result to d0.
|
||||
OS::MemCopy(vfp_registers_, buffer, sizeof(buffer));
|
||||
MemCopy(vfp_registers_, buffer, sizeof(buffer));
|
||||
} else {
|
||||
char buffer[2 * sizeof(registers_[0])];
|
||||
OS::MemCopy(buffer, &result, sizeof(buffer));
|
||||
MemCopy(buffer, &result, sizeof(buffer));
|
||||
// Copy result to r0 and r1.
|
||||
OS::MemCopy(registers_, buffer, sizeof(buffer));
|
||||
MemCopy(registers_, buffer, sizeof(buffer));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1635,12 +1635,12 @@ void Simulator::HandleVList(Instruction* instr) {
|
||||
ReadW(reinterpret_cast<int32_t>(address + 1), instr)
|
||||
};
|
||||
double d;
|
||||
OS::MemCopy(&d, data, 8);
|
||||
MemCopy(&d, data, 8);
|
||||
set_d_register_from_double(reg, d);
|
||||
} else {
|
||||
int32_t data[2];
|
||||
double d = get_double_from_d_register(reg);
|
||||
OS::MemCopy(data, &d, 8);
|
||||
MemCopy(data, &d, 8);
|
||||
WriteW(reinterpret_cast<int32_t>(address), data[0], instr);
|
||||
WriteW(reinterpret_cast<int32_t>(address + 1), data[1], instr);
|
||||
}
|
||||
@ -3020,9 +3020,9 @@ void Simulator::DecodeTypeVFP(Instruction* instr) {
|
||||
int vd = instr->Bits(19, 16) | (instr->Bit(7) << 4);
|
||||
double dd_value = get_double_from_d_register(vd);
|
||||
int32_t data[2];
|
||||
OS::MemCopy(data, &dd_value, 8);
|
||||
MemCopy(data, &dd_value, 8);
|
||||
data[instr->Bit(21)] = get_register(instr->RtValue());
|
||||
OS::MemCopy(&dd_value, data, 8);
|
||||
MemCopy(&dd_value, data, 8);
|
||||
set_d_register_from_double(vd, dd_value);
|
||||
} else if ((instr->VLValue() == 0x1) &&
|
||||
(instr->VCValue() == 0x1) &&
|
||||
@ -3031,7 +3031,7 @@ void Simulator::DecodeTypeVFP(Instruction* instr) {
|
||||
int vn = instr->Bits(19, 16) | (instr->Bit(7) << 4);
|
||||
double dn_value = get_double_from_d_register(vn);
|
||||
int32_t data[2];
|
||||
OS::MemCopy(data, &dn_value, 8);
|
||||
MemCopy(data, &dn_value, 8);
|
||||
set_register(instr->RtValue(), data[instr->Bit(21)]);
|
||||
} else if ((instr->VLValue() == 0x1) &&
|
||||
(instr->VCValue() == 0x0) &&
|
||||
@ -3382,13 +3382,13 @@ void Simulator::DecodeType6CoprocessorIns(Instruction* instr) {
|
||||
if (instr->HasL()) {
|
||||
int32_t data[2];
|
||||
double d = get_double_from_d_register(vm);
|
||||
OS::MemCopy(data, &d, 8);
|
||||
MemCopy(data, &d, 8);
|
||||
set_register(rt, data[0]);
|
||||
set_register(rn, data[1]);
|
||||
} else {
|
||||
int32_t data[] = { get_register(rt), get_register(rn) };
|
||||
double d;
|
||||
OS::MemCopy(&d, data, 8);
|
||||
MemCopy(&d, data, 8);
|
||||
set_d_register_from_double(vm, d);
|
||||
}
|
||||
}
|
||||
@ -3411,13 +3411,13 @@ void Simulator::DecodeType6CoprocessorIns(Instruction* instr) {
|
||||
ReadW(address + 4, instr)
|
||||
};
|
||||
double val;
|
||||
OS::MemCopy(&val, data, 8);
|
||||
MemCopy(&val, data, 8);
|
||||
set_d_register_from_double(vd, val);
|
||||
} else {
|
||||
// Store double to memory: vstr.
|
||||
int32_t data[2];
|
||||
double val = get_double_from_d_register(vd);
|
||||
OS::MemCopy(data, &val, 8);
|
||||
MemCopy(data, &val, 8);
|
||||
WriteW(address, data[0], instr);
|
||||
WriteW(address + 4, data[1], instr);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "atomicops.h"
|
||||
#include "platform.h"
|
||||
#include "utils.h"
|
||||
|
||||
// This file only makes sense with atomicops_internals_x86_gcc.h -- it
|
||||
// depends on structs that are defined in that file. If atomicops.h
|
||||
@ -62,9 +62,9 @@ void AtomicOps_Internalx86CPUFeaturesInit() {
|
||||
// Get vendor string (issue CPUID with eax = 0)
|
||||
cpuid(eax, ebx, ecx, edx, 0);
|
||||
char vendor[13];
|
||||
v8::internal::OS::MemCopy(vendor, &ebx, 4);
|
||||
v8::internal::OS::MemCopy(vendor + 4, &edx, 4);
|
||||
v8::internal::OS::MemCopy(vendor + 8, &ecx, 4);
|
||||
v8::internal::MemCopy(vendor, &ebx, 4);
|
||||
v8::internal::MemCopy(vendor + 4, &edx, 4);
|
||||
v8::internal::MemCopy(vendor + 8, &ecx, 4);
|
||||
vendor[12] = 0;
|
||||
|
||||
// get feature flags in ecx/edx, and family/model in eax
|
||||
|
@ -172,15 +172,11 @@ BUILTIN(EmptyFunction) {
|
||||
}
|
||||
|
||||
|
||||
static void MoveDoubleElements(FixedDoubleArray* dst,
|
||||
int dst_index,
|
||||
FixedDoubleArray* src,
|
||||
int src_index,
|
||||
int len) {
|
||||
static void MoveDoubleElements(FixedDoubleArray* dst, int dst_index,
|
||||
FixedDoubleArray* src, int src_index, int len) {
|
||||
if (len == 0) return;
|
||||
OS::MemMove(dst->data_start() + dst_index,
|
||||
src->data_start() + src_index,
|
||||
len * kDoubleSize);
|
||||
MemMove(dst->data_start() + dst_index, src->data_start() + src_index,
|
||||
len * kDoubleSize);
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,7 +58,7 @@ inline unsigned int FastD2UI(double x) {
|
||||
Address mantissa_ptr = reinterpret_cast<Address>(&x) + kIntSize;
|
||||
#endif
|
||||
// Copy least significant 32 bits of mantissa.
|
||||
OS::MemCopy(&result, mantissa_ptr, sizeof(result));
|
||||
MemCopy(&result, mantissa_ptr, sizeof(result));
|
||||
return negative ? ~result + 1 : result;
|
||||
}
|
||||
// Large number (outside uint32 range), Infinity or NaN.
|
||||
|
@ -515,7 +515,7 @@ void Debug::ThreadInit() {
|
||||
|
||||
char* Debug::ArchiveDebug(char* storage) {
|
||||
char* to = storage;
|
||||
OS::MemCopy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal));
|
||||
MemCopy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal));
|
||||
ThreadInit();
|
||||
return storage + ArchiveSpacePerThread();
|
||||
}
|
||||
@ -523,8 +523,7 @@ char* Debug::ArchiveDebug(char* storage) {
|
||||
|
||||
char* Debug::RestoreDebug(char* storage) {
|
||||
char* from = storage;
|
||||
OS::MemCopy(
|
||||
reinterpret_cast<char*>(&thread_local_), from, sizeof(ThreadLocal));
|
||||
MemCopy(reinterpret_cast<char*>(&thread_local_), from, sizeof(ThreadLocal));
|
||||
return storage + ArchiveSpacePerThread();
|
||||
}
|
||||
|
||||
|
@ -2906,8 +2906,7 @@ int32_t TranslationIterator::Next() {
|
||||
Handle<ByteArray> TranslationBuffer::CreateByteArray(Factory* factory) {
|
||||
int length = contents_.length();
|
||||
Handle<ByteArray> result = factory->NewByteArray(length, TENURED);
|
||||
OS::MemCopy(
|
||||
result->GetDataStartAddress(), contents_.ToVector().start(), length);
|
||||
MemCopy(result->GetDataStartAddress(), contents_.ToVector().start(), length);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -380,7 +380,7 @@ bool StackGuard::CheckAndClearInterrupt(InterruptFlag flag,
|
||||
|
||||
char* StackGuard::ArchiveStackGuard(char* to) {
|
||||
ExecutionAccess access(isolate_);
|
||||
OS::MemCopy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal));
|
||||
MemCopy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal));
|
||||
ThreadLocal blank;
|
||||
|
||||
// Set the stack limits using the old thread_local_.
|
||||
@ -397,8 +397,7 @@ char* StackGuard::ArchiveStackGuard(char* to) {
|
||||
|
||||
char* StackGuard::RestoreStackGuard(char* from) {
|
||||
ExecutionAccess access(isolate_);
|
||||
OS::MemCopy(
|
||||
reinterpret_cast<char*>(&thread_local_), from, sizeof(ThreadLocal));
|
||||
MemCopy(reinterpret_cast<char*>(&thread_local_), from, sizeof(ThreadLocal));
|
||||
isolate_->heap()->SetStackLimits();
|
||||
return from + sizeof(ThreadLocal);
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ static void SplitArgument(const char* arg,
|
||||
// make a copy so we can NUL-terminate flag name
|
||||
size_t n = arg - *name;
|
||||
CHECK(n < static_cast<size_t>(buffer_size)); // buffer is too small
|
||||
OS::MemCopy(buffer, *name, n);
|
||||
MemCopy(buffer, *name, n);
|
||||
buffer[n] = '\0';
|
||||
*name = buffer;
|
||||
// get the value
|
||||
@ -475,7 +475,7 @@ static char* SkipBlackSpace(char* p) {
|
||||
int FlagList::SetFlagsFromString(const char* str, int len) {
|
||||
// make a 0-terminated copy of str
|
||||
ScopedVector<char> copy0(len + 1);
|
||||
OS::MemCopy(copy0.start(), str, len);
|
||||
MemCopy(copy0.start(), str, len);
|
||||
copy0[len] = '\0';
|
||||
|
||||
// strip leading white space
|
||||
|
@ -658,7 +658,7 @@ class ELF BASE_EMBEDDED {
|
||||
#else
|
||||
#error Unsupported target architecture.
|
||||
#endif
|
||||
OS::MemCopy(header->ident, ident, 16);
|
||||
MemCopy(header->ident, ident, 16);
|
||||
header->type = 1;
|
||||
#if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
|
||||
header->machine = 3;
|
||||
@ -1833,7 +1833,7 @@ static JITCodeEntry* CreateCodeEntry(Address symfile_addr,
|
||||
|
||||
entry->symfile_addr_ = reinterpret_cast<Address>(entry + 1);
|
||||
entry->symfile_size_ = symfile_size;
|
||||
OS::MemCopy(entry->symfile_addr_, symfile_addr, symfile_size);
|
||||
MemCopy(entry->symfile_addr_, symfile_addr, symfile_size);
|
||||
|
||||
entry->prev_ = entry->next_ = NULL;
|
||||
|
||||
|
@ -122,8 +122,8 @@ AllocationResult Heap::AllocateOneByteInternalizedString(
|
||||
ASSERT_EQ(size, answer->Size());
|
||||
|
||||
// Fill in the characters.
|
||||
OS::MemCopy(answer->address() + SeqOneByteString::kHeaderSize,
|
||||
str.start(), str.length());
|
||||
MemCopy(answer->address() + SeqOneByteString::kHeaderSize, str.start(),
|
||||
str.length());
|
||||
|
||||
return answer;
|
||||
}
|
||||
@ -154,8 +154,8 @@ AllocationResult Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str,
|
||||
ASSERT_EQ(size, answer->Size());
|
||||
|
||||
// Fill in the characters.
|
||||
OS::MemCopy(answer->address() + SeqTwoByteString::kHeaderSize,
|
||||
str.start(), str.length() * kUC16Size);
|
||||
MemCopy(answer->address() + SeqTwoByteString::kHeaderSize, str.start(),
|
||||
str.length() * kUC16Size);
|
||||
|
||||
return answer;
|
||||
}
|
||||
@ -429,7 +429,7 @@ void Heap::MoveBlock(Address dst, Address src, int byte_size) {
|
||||
*dst_slot++ = *src_slot++;
|
||||
}
|
||||
} else {
|
||||
OS::MemMove(dst, src, static_cast<size_t>(byte_size));
|
||||
MemMove(dst, src, static_cast<size_t>(byte_size));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2683,10 +2683,10 @@ class OutputStreamWriter {
|
||||
ASSERT(static_cast<size_t>(n) <= strlen(s));
|
||||
const char* s_end = s + n;
|
||||
while (s < s_end) {
|
||||
int s_chunk_size = Min(
|
||||
chunk_size_ - chunk_pos_, static_cast<int>(s_end - s));
|
||||
int s_chunk_size =
|
||||
Min(chunk_size_ - chunk_pos_, static_cast<int>(s_end - s));
|
||||
ASSERT(s_chunk_size > 0);
|
||||
OS::MemCopy(chunk_.start() + chunk_pos_, s, s_chunk_size);
|
||||
MemCopy(chunk_.start() + chunk_pos_, s, s_chunk_size);
|
||||
s += s_chunk_size;
|
||||
chunk_pos_ += s_chunk_size;
|
||||
MaybeWriteChunk();
|
||||
|
10
src/heap.cc
10
src/heap.cc
@ -861,9 +861,7 @@ void Heap::MoveElements(FixedArray* array,
|
||||
|
||||
ASSERT(array->map() != fixed_cow_array_map());
|
||||
Object** dst_objects = array->data_start() + dst_index;
|
||||
OS::MemMove(dst_objects,
|
||||
array->data_start() + src_index,
|
||||
len * kPointerSize);
|
||||
MemMove(dst_objects, array->data_start() + src_index, len * kPointerSize);
|
||||
if (!InNewSpace(array)) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
// TODO(hpayer): check store buffer for entries
|
||||
@ -3788,7 +3786,7 @@ static inline void WriteOneByteData(Vector<const char> vector,
|
||||
int len) {
|
||||
// Only works for ascii.
|
||||
ASSERT(vector.length() == len);
|
||||
OS::MemCopy(chars, vector.start(), len);
|
||||
MemCopy(chars, vector.start(), len);
|
||||
}
|
||||
|
||||
static inline void WriteTwoByteData(Vector<const char> vector,
|
||||
@ -6424,8 +6422,8 @@ void Heap::CheckpointObjectStats() {
|
||||
CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
|
||||
#undef ADJUST_LAST_TIME_OBJECT_COUNT
|
||||
|
||||
OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
|
||||
OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
|
||||
MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
|
||||
MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
|
||||
ClearObjectStats();
|
||||
}
|
||||
|
||||
|
@ -622,9 +622,9 @@ class HCheckTable : public ZoneObject {
|
||||
int L = cursor_;
|
||||
int R = size_ - cursor_;
|
||||
|
||||
OS::MemMove(&tmp_entries[0], &entries_[0], L * sizeof(HCheckTableEntry));
|
||||
OS::MemMove(&entries_[0], &entries_[L], R * sizeof(HCheckTableEntry));
|
||||
OS::MemMove(&entries_[R], &tmp_entries[0], L * sizeof(HCheckTableEntry));
|
||||
MemMove(&tmp_entries[0], &entries_[0], L * sizeof(HCheckTableEntry));
|
||||
MemMove(&entries_[0], &entries_[L], R * sizeof(HCheckTableEntry));
|
||||
MemMove(&entries_[R], &tmp_entries[0], L * sizeof(HCheckTableEntry));
|
||||
}
|
||||
|
||||
cursor_ = size_; // Move cursor to end.
|
||||
|
@ -140,10 +140,10 @@ HInstructionMap::HInstructionMap(Zone* zone, const HInstructionMap* other)
|
||||
lists_(zone->NewArray<HInstructionMapListElement>(other->lists_size_)),
|
||||
free_list_head_(other->free_list_head_),
|
||||
side_effects_tracker_(other->side_effects_tracker_) {
|
||||
OS::MemCopy(
|
||||
array_, other->array_, array_size_ * sizeof(HInstructionMapListElement));
|
||||
OS::MemCopy(
|
||||
lists_, other->lists_, lists_size_ * sizeof(HInstructionMapListElement));
|
||||
MemCopy(array_, other->array_,
|
||||
array_size_ * sizeof(HInstructionMapListElement));
|
||||
MemCopy(lists_, other->lists_,
|
||||
lists_size_ * sizeof(HInstructionMapListElement));
|
||||
}
|
||||
|
||||
|
||||
@ -270,8 +270,7 @@ void HInstructionMap::ResizeLists(int new_size, Zone* zone) {
|
||||
lists_ = new_lists;
|
||||
|
||||
if (old_lists != NULL) {
|
||||
OS::MemCopy(
|
||||
lists_, old_lists, old_size * sizeof(HInstructionMapListElement));
|
||||
MemCopy(lists_, old_lists, old_size * sizeof(HInstructionMapListElement));
|
||||
}
|
||||
for (int i = old_size; i < lists_size_; ++i) {
|
||||
lists_[i].next = free_list_head_;
|
||||
@ -315,9 +314,9 @@ HSideEffectMap::HSideEffectMap(HSideEffectMap* other) : count_(other->count_) {
|
||||
}
|
||||
|
||||
|
||||
HSideEffectMap& HSideEffectMap::operator= (const HSideEffectMap& other) {
|
||||
HSideEffectMap& HSideEffectMap::operator=(const HSideEffectMap& other) {
|
||||
if (this != &other) {
|
||||
OS::MemCopy(data_, other.data_, kNumberOfTrackedSideEffects * kPointerSize);
|
||||
MemCopy(data_, other.data_, kNumberOfTrackedSideEffects * kPointerSize);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
@ -2490,9 +2490,9 @@ void Assembler::GrowBuffer() {
|
||||
// Copy the data.
|
||||
int pc_delta = desc.buffer - buffer_;
|
||||
int rc_delta = (desc.buffer + desc.buffer_size) - (buffer_ + buffer_size_);
|
||||
OS::MemMove(desc.buffer, buffer_, desc.instr_size);
|
||||
OS::MemMove(rc_delta + reloc_info_writer.pos(),
|
||||
reloc_info_writer.pos(), desc.reloc_size);
|
||||
MemMove(desc.buffer, buffer_, desc.instr_size);
|
||||
MemMove(rc_delta + reloc_info_writer.pos(), reloc_info_writer.pos(),
|
||||
desc.reloc_size);
|
||||
|
||||
// Switch buffers.
|
||||
if (isolate()->assembler_spare_buffer() == NULL &&
|
||||
|
@ -186,7 +186,7 @@ class LabelConverter {
|
||||
};
|
||||
|
||||
|
||||
OS::MemMoveFunction CreateMemMoveFunction() {
|
||||
MemMoveFunction CreateMemMoveFunction() {
|
||||
size_t actual_size;
|
||||
// Allocate buffer in executable space.
|
||||
byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true));
|
||||
@ -508,7 +508,7 @@ OS::MemMoveFunction CreateMemMoveFunction() {
|
||||
OS::ProtectCode(buffer, actual_size);
|
||||
// TODO(jkummerow): It would be nice to register this code creation event
|
||||
// with the PROFILE / GDBJIT system.
|
||||
return FUNCTION_CAST<OS::MemMoveFunction>(buffer);
|
||||
return FUNCTION_CAST<MemMoveFunction>(buffer);
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,9 +67,8 @@ void Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(Handle<Code> code) {
|
||||
Factory* factory = isolate->factory();
|
||||
Handle<ByteArray> new_reloc =
|
||||
factory->NewByteArray(reloc_length + padding, TENURED);
|
||||
OS::MemCopy(new_reloc->GetDataStartAddress() + padding,
|
||||
code->relocation_info()->GetDataStartAddress(),
|
||||
reloc_length);
|
||||
MemCopy(new_reloc->GetDataStartAddress() + padding,
|
||||
code->relocation_info()->GetDataStartAddress(), reloc_length);
|
||||
// Create a relocation writer to write the comments in the padding
|
||||
// space. Use position 0 for everything to ensure short encoding.
|
||||
RelocInfoWriter reloc_info_writer(
|
||||
@ -162,8 +161,7 @@ void Deoptimizer::PatchCodeForDeoptimization(Isolate* isolate, Code* code) {
|
||||
|
||||
// Move the relocation info to the beginning of the byte array.
|
||||
int new_reloc_size = reloc_end_address - reloc_info_writer.pos();
|
||||
OS::MemMove(
|
||||
code->relocation_start(), reloc_info_writer.pos(), new_reloc_size);
|
||||
MemMove(code->relocation_start(), reloc_info_writer.pos(), new_reloc_size);
|
||||
|
||||
// The relocation info is in place, update the size.
|
||||
reloc_info->set_length(new_reloc_size);
|
||||
|
@ -1343,8 +1343,8 @@ Handle<Context> Isolate::GetCallingNativeContext() {
|
||||
|
||||
|
||||
char* Isolate::ArchiveThread(char* to) {
|
||||
OS::MemCopy(to, reinterpret_cast<char*>(thread_local_top()),
|
||||
sizeof(ThreadLocalTop));
|
||||
MemCopy(to, reinterpret_cast<char*>(thread_local_top()),
|
||||
sizeof(ThreadLocalTop));
|
||||
InitializeThreadLocal();
|
||||
clear_pending_exception();
|
||||
clear_pending_message();
|
||||
@ -1354,10 +1354,10 @@ char* Isolate::ArchiveThread(char* to) {
|
||||
|
||||
|
||||
char* Isolate::RestoreThread(char* from) {
|
||||
OS::MemCopy(reinterpret_cast<char*>(thread_local_top()), from,
|
||||
sizeof(ThreadLocalTop));
|
||||
// This might be just paranoia, but it seems to be needed in case a
|
||||
// thread_local_top_ is restored on a separate OS thread.
|
||||
MemCopy(reinterpret_cast<char*>(thread_local_top()), from,
|
||||
sizeof(ThreadLocalTop));
|
||||
// This might be just paranoia, but it seems to be needed in case a
|
||||
// thread_local_top_ is restored on a separate OS thread.
|
||||
#ifdef USE_SIMULATOR
|
||||
thread_local_top()->simulator_ = Simulator::current(this);
|
||||
#endif
|
||||
|
@ -604,8 +604,7 @@ int RegExpImpl::IrregexpExecRaw(Handle<JSRegExp> regexp,
|
||||
index);
|
||||
if (result == RE_SUCCESS) {
|
||||
// Copy capture results to the start of the registers array.
|
||||
OS::MemCopy(
|
||||
output, raw_output, number_of_capture_registers * sizeof(int32_t));
|
||||
MemCopy(output, raw_output, number_of_capture_registers * sizeof(int32_t));
|
||||
}
|
||||
if (result == RE_EXCEPTION) {
|
||||
ASSERT(!isolate->has_pending_exception());
|
||||
|
@ -65,7 +65,7 @@ template<typename T, class P>
|
||||
void List<T, P>::Resize(int new_capacity, P alloc) {
|
||||
ASSERT_LE(length_, new_capacity);
|
||||
T* new_data = NewData(new_capacity, alloc);
|
||||
OS::MemCopy(new_data, data_, length_ * sizeof(T));
|
||||
MemCopy(new_data, data_, length_ * sizeof(T));
|
||||
List<T, P>::DeleteData(data_);
|
||||
data_ = new_data;
|
||||
capacity_ = new_capacity;
|
||||
|
@ -139,7 +139,7 @@ void LCodeGenBase::Comment(const char* format, ...) {
|
||||
// issues when the stack allocated buffer goes out of scope.
|
||||
size_t length = builder.position();
|
||||
Vector<char> copy = Vector<char>::New(static_cast<int>(length) + 1);
|
||||
OS::MemCopy(copy.start(), builder.Finalize(), copy.length());
|
||||
MemCopy(copy.start(), builder.Finalize(), copy.length());
|
||||
masm()->RecordComment(copy.start());
|
||||
}
|
||||
|
||||
|
@ -1313,8 +1313,8 @@ class RelocInfoBuffer {
|
||||
// Copy the data.
|
||||
int curently_used_size =
|
||||
static_cast<int>(buffer_ + buffer_size_ - reloc_info_writer_.pos());
|
||||
OS::MemMove(new_buffer + new_buffer_size - curently_used_size,
|
||||
reloc_info_writer_.pos(), curently_used_size);
|
||||
MemMove(new_buffer + new_buffer_size - curently_used_size,
|
||||
reloc_info_writer_.pos(), curently_used_size);
|
||||
|
||||
reloc_info_writer_.Reposition(
|
||||
new_buffer + new_buffer_size - curently_used_size,
|
||||
@ -1367,7 +1367,7 @@ static Handle<Code> PatchPositionsInCode(
|
||||
|
||||
if (buffer.length() == code->relocation_size()) {
|
||||
// Simply patch relocation area of code.
|
||||
OS::MemCopy(code->relocation_start(), buffer.start(), buffer.length());
|
||||
MemCopy(code->relocation_start(), buffer.start(), buffer.length());
|
||||
return code;
|
||||
} else {
|
||||
// Relocation info section now has different size. We cannot simply
|
||||
@ -1636,9 +1636,9 @@ static const char* DropFrames(Vector<StackFrame*> frames,
|
||||
|
||||
StackFrame* pre_pre_frame = frames[top_frame_index - 2];
|
||||
|
||||
OS::MemMove(padding_start + kPointerSize - shortage_bytes,
|
||||
padding_start + kPointerSize,
|
||||
Debug::FramePaddingLayout::kFrameBaseSize * kPointerSize);
|
||||
MemMove(padding_start + kPointerSize - shortage_bytes,
|
||||
padding_start + kPointerSize,
|
||||
Debug::FramePaddingLayout::kFrameBaseSize * kPointerSize);
|
||||
|
||||
pre_top_frame->UpdateFp(pre_top_frame->fp() - shortage_bytes);
|
||||
pre_pre_frame->SetCallerFp(pre_top_frame->fp());
|
||||
|
@ -106,7 +106,7 @@ class CodeEventLogger::NameBuffer {
|
||||
|
||||
void AppendBytes(const char* bytes, int size) {
|
||||
size = Min(size, kUtf8BufferSize - utf8_pos_);
|
||||
OS::MemCopy(utf8_buffer_ + utf8_pos_, bytes, size);
|
||||
MemCopy(utf8_buffer_ + utf8_pos_, bytes, size);
|
||||
utf8_pos_ += size;
|
||||
}
|
||||
|
||||
@ -536,8 +536,8 @@ LowLevelLogger::LowLevelLogger(const char* name)
|
||||
// Open the low-level log file.
|
||||
size_t len = strlen(name);
|
||||
ScopedVector<char> ll_name(static_cast<int>(len + sizeof(kLogExt)));
|
||||
OS::MemCopy(ll_name.start(), name, len);
|
||||
OS::MemCopy(ll_name.start() + len, kLogExt, sizeof(kLogExt));
|
||||
MemCopy(ll_name.start(), name, len);
|
||||
MemCopy(ll_name.start() + len, kLogExt, sizeof(kLogExt));
|
||||
ll_output_handle_ = OS::FOpen(ll_name.start(), OS::LogFileOpenMode);
|
||||
setvbuf(ll_output_handle_, NULL, _IOFBF, kLogBufferSize);
|
||||
|
||||
|
@ -1675,7 +1675,7 @@ void Assembler::cfc1(Register rt, FPUControlRegister fs) {
|
||||
|
||||
void Assembler::DoubleAsTwoUInt32(double d, uint32_t* lo, uint32_t* hi) {
|
||||
uint64_t i;
|
||||
OS::MemCopy(&i, &d, 8);
|
||||
MemCopy(&i, &d, 8);
|
||||
|
||||
*lo = i & 0xffffffff;
|
||||
*hi = i >> 32;
|
||||
@ -1990,9 +1990,9 @@ void Assembler::GrowBuffer() {
|
||||
// Copy the data.
|
||||
int pc_delta = desc.buffer - buffer_;
|
||||
int rc_delta = (desc.buffer + desc.buffer_size) - (buffer_ + buffer_size_);
|
||||
OS::MemMove(desc.buffer, buffer_, desc.instr_size);
|
||||
OS::MemMove(reloc_info_writer.pos() + rc_delta,
|
||||
reloc_info_writer.pos(), desc.reloc_size);
|
||||
MemMove(desc.buffer, buffer_, desc.instr_size);
|
||||
MemMove(reloc_info_writer.pos() + rc_delta, reloc_info_writer.pos(),
|
||||
desc.reloc_size);
|
||||
|
||||
// Switch buffers.
|
||||
DeleteArray(buffer_);
|
||||
|
@ -71,8 +71,7 @@ UnaryMathFunction CreateExpFunction() {
|
||||
|
||||
|
||||
#if defined(V8_HOST_ARCH_MIPS)
|
||||
OS::MemCopyUint8Function CreateMemCopyUint8Function(
|
||||
OS::MemCopyUint8Function stub) {
|
||||
MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) {
|
||||
#if defined(USE_SIMULATOR)
|
||||
return stub;
|
||||
#else
|
||||
@ -597,7 +596,7 @@ OS::MemCopyUint8Function CreateMemCopyUint8Function(
|
||||
|
||||
CPU::FlushICache(buffer, actual_size);
|
||||
OS::ProtectCode(buffer, actual_size);
|
||||
return FUNCTION_CAST<OS::MemCopyUint8Function>(buffer);
|
||||
return FUNCTION_CAST<MemCopyUint8Function>(buffer);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@ -845,7 +845,7 @@ void Simulator::CheckICache(v8::internal::HashMap* i_cache,
|
||||
Instruction::kInstrSize));
|
||||
} else {
|
||||
// Cache miss. Load memory into the cache.
|
||||
OS::MemCopy(cached_line, line, CachePage::kLineLength);
|
||||
MemCopy(cached_line, line, CachePage::kLineLength);
|
||||
*cache_valid_byte = CachePage::LINE_VALID;
|
||||
}
|
||||
}
|
||||
@ -1047,8 +1047,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])];
|
||||
OS::MemCopy(buffer, ®isters_[reg], 2 * sizeof(registers_[0]));
|
||||
OS::MemCopy(&dm_val, buffer, 2 * sizeof(registers_[0]));
|
||||
MemCopy(buffer, ®isters_[reg], 2 * sizeof(registers_[0]));
|
||||
MemCopy(&dm_val, buffer, 2 * sizeof(registers_[0]));
|
||||
return(dm_val);
|
||||
}
|
||||
|
||||
@ -1096,14 +1096,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);
|
||||
OS::MemCopy(x, buffer, sizeof(buffer));
|
||||
MemCopy(x, buffer, sizeof(buffer));
|
||||
// Registers a2 and a3 -> y.
|
||||
reg_buffer[0] = get_register(a2);
|
||||
reg_buffer[1] = get_register(a3);
|
||||
OS::MemCopy(y, buffer, sizeof(buffer));
|
||||
MemCopy(y, buffer, sizeof(buffer));
|
||||
// Register 2 -> z.
|
||||
reg_buffer[0] = get_register(a2);
|
||||
OS::MemCopy(z, buffer, sizeof(*z));
|
||||
MemCopy(z, buffer, sizeof(*z));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1115,7 +1115,7 @@ void Simulator::SetFpResult(const double& result) {
|
||||
} else {
|
||||
char buffer[2 * sizeof(registers_[0])];
|
||||
int32_t* reg_buffer = reinterpret_cast<int32_t*>(buffer);
|
||||
OS::MemCopy(buffer, &result, sizeof(buffer));
|
||||
MemCopy(buffer, &result, sizeof(buffer));
|
||||
// Copy result to v0 and v1.
|
||||
set_register(v0, reg_buffer[0]);
|
||||
set_register(v1, reg_buffer[1]);
|
||||
@ -2887,9 +2887,9 @@ double Simulator::CallFP(byte* entry, double d0, double d1) {
|
||||
} else {
|
||||
int buffer[2];
|
||||
ASSERT(sizeof(buffer[0]) * 2 == sizeof(d0));
|
||||
OS::MemCopy(buffer, &d0, sizeof(d0));
|
||||
MemCopy(buffer, &d0, sizeof(d0));
|
||||
set_dw_register(a0, buffer);
|
||||
OS::MemCopy(buffer, &d1, sizeof(d1));
|
||||
MemCopy(buffer, &d1, sizeof(d1));
|
||||
set_dw_register(a2, buffer);
|
||||
}
|
||||
CallInternal(entry);
|
||||
|
@ -16724,7 +16724,7 @@ Handle<DeclaredAccessorDescriptor> DeclaredAccessorDescriptor::Create(
|
||||
if (previous_length != 0) {
|
||||
uint8_t* previous_array =
|
||||
previous->serialized_data()->GetDataStartAddress();
|
||||
OS::MemCopy(array, previous_array, previous_length);
|
||||
MemCopy(array, previous_array, previous_length);
|
||||
array += previous_length;
|
||||
}
|
||||
ASSERT(reinterpret_cast<uintptr_t>(array) % sizeof(uintptr_t) == 0);
|
||||
|
@ -447,72 +447,6 @@ int OS::VSNPrintF(Vector<char> str,
|
||||
}
|
||||
|
||||
|
||||
#if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
|
||||
static void MemMoveWrapper(void* dest, const void* src, size_t size) {
|
||||
memmove(dest, src, size);
|
||||
}
|
||||
|
||||
|
||||
// Initialize to library version so we can call this at any time during startup.
|
||||
static OS::MemMoveFunction memmove_function = &MemMoveWrapper;
|
||||
|
||||
// Defined in codegen-ia32.cc.
|
||||
OS::MemMoveFunction CreateMemMoveFunction();
|
||||
|
||||
// Copy memory area. No restrictions.
|
||||
void OS::MemMove(void* dest, const void* src, size_t size) {
|
||||
if (size == 0) return;
|
||||
// Note: here we rely on dependent reads being ordered. This is true
|
||||
// on all architectures we currently support.
|
||||
(*memmove_function)(dest, src, size);
|
||||
}
|
||||
|
||||
#elif defined(V8_HOST_ARCH_ARM)
|
||||
void OS::MemCopyUint16Uint8Wrapper(uint16_t* dest,
|
||||
const uint8_t* src,
|
||||
size_t chars) {
|
||||
uint16_t *limit = dest + chars;
|
||||
while (dest < limit) {
|
||||
*dest++ = static_cast<uint16_t>(*src++);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
OS::MemCopyUint8Function OS::memcopy_uint8_function = &OS::MemCopyUint8Wrapper;
|
||||
OS::MemCopyUint16Uint8Function OS::memcopy_uint16_uint8_function =
|
||||
&OS::MemCopyUint16Uint8Wrapper;
|
||||
// Defined in codegen-arm.cc.
|
||||
OS::MemCopyUint8Function CreateMemCopyUint8Function(
|
||||
OS::MemCopyUint8Function stub);
|
||||
OS::MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function(
|
||||
OS::MemCopyUint16Uint8Function stub);
|
||||
|
||||
#elif defined(V8_HOST_ARCH_MIPS)
|
||||
OS::MemCopyUint8Function OS::memcopy_uint8_function = &OS::MemCopyUint8Wrapper;
|
||||
// Defined in codegen-mips.cc.
|
||||
OS::MemCopyUint8Function CreateMemCopyUint8Function(
|
||||
OS::MemCopyUint8Function stub);
|
||||
#endif
|
||||
|
||||
|
||||
void OS::PostSetUp() {
|
||||
#if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
|
||||
OS::MemMoveFunction generated_memmove = CreateMemMoveFunction();
|
||||
if (generated_memmove != NULL) {
|
||||
memmove_function = generated_memmove;
|
||||
}
|
||||
#elif defined(V8_HOST_ARCH_ARM)
|
||||
OS::memcopy_uint8_function =
|
||||
CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper);
|
||||
OS::memcopy_uint16_uint8_function =
|
||||
CreateMemCopyUint16Uint8Function(&OS::MemCopyUint16Uint8Wrapper);
|
||||
#elif defined(V8_HOST_ARCH_MIPS)
|
||||
OS::memcopy_uint8_function =
|
||||
CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// POSIX string support.
|
||||
//
|
||||
|
@ -107,29 +107,6 @@ intptr_t OS::MaxVirtualMemory() {
|
||||
}
|
||||
|
||||
|
||||
#if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
|
||||
static void MemMoveWrapper(void* dest, const void* src, size_t size) {
|
||||
memmove(dest, src, size);
|
||||
}
|
||||
|
||||
|
||||
// Initialize to library version so we can call this at any time during startup.
|
||||
static OS::MemMoveFunction memmove_function = &MemMoveWrapper;
|
||||
|
||||
// Defined in codegen-ia32.cc.
|
||||
OS::MemMoveFunction CreateMemMoveFunction();
|
||||
|
||||
// Copy memory area to disjoint memory area.
|
||||
void OS::MemMove(void* dest, const void* src, size_t size) {
|
||||
if (size == 0) return;
|
||||
// Note: here we rely on dependent reads being ordered. This is true
|
||||
// on all architectures we currently support.
|
||||
(*memmove_function)(dest, src, size);
|
||||
}
|
||||
|
||||
#endif // V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
|
||||
|
||||
|
||||
class TimezoneCache {
|
||||
public:
|
||||
TimezoneCache() : initialized_(false) { }
|
||||
@ -452,16 +429,6 @@ char* Win32Time::LocalTimezone(TimezoneCache* cache) {
|
||||
}
|
||||
|
||||
|
||||
void OS::PostSetUp() {
|
||||
#if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
|
||||
OS::MemMoveFunction generated_memmove = CreateMemMoveFunction();
|
||||
if (generated_memmove != NULL) {
|
||||
memmove_function = generated_memmove;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Returns the accumulated user time for thread.
|
||||
int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) {
|
||||
FILETIME dummy;
|
||||
@ -913,7 +880,7 @@ OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, int size,
|
||||
if (file_mapping == NULL) return NULL;
|
||||
// Map a view of the file into memory
|
||||
void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size);
|
||||
if (memory) OS::MemMove(memory, initial, size);
|
||||
if (memory) MemMove(memory, initial, size);
|
||||
return new Win32MemoryMappedFile(file, file_mapping, memory, size);
|
||||
}
|
||||
|
||||
|
@ -139,10 +139,6 @@ class TimezoneCache;
|
||||
|
||||
class OS {
|
||||
public:
|
||||
// Initializes the platform OS support that depend on CPU features. This is
|
||||
// called after CPU initialization.
|
||||
static void PostSetUp();
|
||||
|
||||
// Returns the accumulated user time for thread. This routine
|
||||
// can be used for profiling. The implementation should
|
||||
// strive for high-precision timer resolution, preferable
|
||||
@ -295,86 +291,6 @@ class OS {
|
||||
// the platform doesn't care. Guaranteed to be a power of two.
|
||||
static int ActivationFrameAlignment();
|
||||
|
||||
#if defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_X87)
|
||||
// Limit below which the extra overhead of the MemCopy function is likely
|
||||
// to outweigh the benefits of faster copying.
|
||||
static const int kMinComplexMemCopy = 64;
|
||||
|
||||
// Copy memory area. No restrictions.
|
||||
static void MemMove(void* dest, const void* src, size_t size);
|
||||
typedef void (*MemMoveFunction)(void* dest, const void* src, size_t size);
|
||||
|
||||
// Keep the distinction of "move" vs. "copy" for the benefit of other
|
||||
// architectures.
|
||||
static void MemCopy(void* dest, const void* src, size_t size) {
|
||||
MemMove(dest, src, size);
|
||||
}
|
||||
#elif defined(V8_HOST_ARCH_ARM)
|
||||
typedef void (*MemCopyUint8Function)(uint8_t* dest,
|
||||
const uint8_t* src,
|
||||
size_t size);
|
||||
static MemCopyUint8Function memcopy_uint8_function;
|
||||
static void MemCopyUint8Wrapper(uint8_t* dest,
|
||||
const uint8_t* src,
|
||||
size_t chars) {
|
||||
memcpy(dest, src, chars);
|
||||
}
|
||||
// For values < 16, the assembler function is slower than the inlined C code.
|
||||
static const int kMinComplexMemCopy = 16;
|
||||
static void MemCopy(void* dest, const void* src, size_t size) {
|
||||
(*memcopy_uint8_function)(reinterpret_cast<uint8_t*>(dest),
|
||||
reinterpret_cast<const uint8_t*>(src),
|
||||
size);
|
||||
}
|
||||
static void MemMove(void* dest, const void* src, size_t size) {
|
||||
memmove(dest, src, size);
|
||||
}
|
||||
|
||||
typedef void (*MemCopyUint16Uint8Function)(uint16_t* dest,
|
||||
const uint8_t* src,
|
||||
size_t size);
|
||||
static MemCopyUint16Uint8Function memcopy_uint16_uint8_function;
|
||||
static void MemCopyUint16Uint8Wrapper(uint16_t* dest,
|
||||
const uint8_t* src,
|
||||
size_t chars);
|
||||
// For values < 12, the assembler function is slower than the inlined C code.
|
||||
static const int kMinComplexConvertMemCopy = 12;
|
||||
static void MemCopyUint16Uint8(uint16_t* dest,
|
||||
const uint8_t* src,
|
||||
size_t size) {
|
||||
(*memcopy_uint16_uint8_function)(dest, src, size);
|
||||
}
|
||||
#elif defined(V8_HOST_ARCH_MIPS)
|
||||
typedef void (*MemCopyUint8Function)(uint8_t* dest,
|
||||
const uint8_t* src,
|
||||
size_t size);
|
||||
static MemCopyUint8Function memcopy_uint8_function;
|
||||
static void MemCopyUint8Wrapper(uint8_t* dest,
|
||||
const uint8_t* src,
|
||||
size_t chars) {
|
||||
memcpy(dest, src, chars);
|
||||
}
|
||||
// For values < 16, the assembler function is slower than the inlined C code.
|
||||
static const int kMinComplexMemCopy = 16;
|
||||
static void MemCopy(void* dest, const void* src, size_t size) {
|
||||
(*memcopy_uint8_function)(reinterpret_cast<uint8_t*>(dest),
|
||||
reinterpret_cast<const uint8_t*>(src),
|
||||
size);
|
||||
}
|
||||
static void MemMove(void* dest, const void* src, size_t size) {
|
||||
memmove(dest, src, size);
|
||||
}
|
||||
#else
|
||||
// Copy memory area to disjoint memory area.
|
||||
static void MemCopy(void* dest, const void* src, size_t size) {
|
||||
memcpy(dest, src, size);
|
||||
}
|
||||
static void MemMove(void* dest, const void* src, size_t size) {
|
||||
memmove(dest, src, size);
|
||||
}
|
||||
static const int kMinComplexMemCopy = 16 * kPointerSize;
|
||||
#endif // V8_TARGET_ARCH_IA32
|
||||
|
||||
static int GetCurrentProcessId();
|
||||
|
||||
private:
|
||||
|
@ -66,7 +66,7 @@ Vector<unsigned> CompleteParserRecorder::ExtractData() {
|
||||
int total_size = PreparseDataConstants::kHeaderSize + function_size;
|
||||
Vector<unsigned> data = Vector<unsigned>::New(total_size);
|
||||
preamble_[PreparseDataConstants::kFunctionsSizeOffset] = function_size;
|
||||
OS::MemCopy(data.start(), preamble_, sizeof(preamble_));
|
||||
MemCopy(data.start(), preamble_, sizeof(preamble_));
|
||||
if (function_size > 0) {
|
||||
function_store_.WriteTo(data.SubVector(PreparseDataConstants::kHeaderSize,
|
||||
total_size));
|
||||
|
@ -506,7 +506,7 @@ void PrettyPrinter::Print(const char* format, ...) {
|
||||
const int slack = 32;
|
||||
int new_size = size_ + (size_ >> 1) + slack;
|
||||
char* new_output = NewArray<char>(new_size);
|
||||
OS::MemCopy(new_output, output_, pos_);
|
||||
MemCopy(new_output, output_, pos_);
|
||||
DeleteArray(output_);
|
||||
output_ = new_output;
|
||||
size_ = new_size;
|
||||
|
@ -434,7 +434,7 @@ int RegExpMacroAssemblerIrregexp::length() {
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::Copy(Address a) {
|
||||
OS::MemCopy(a, buffer_.start(), length());
|
||||
MemCopy(a, buffer_.start(), length());
|
||||
}
|
||||
|
||||
|
||||
@ -443,7 +443,7 @@ void RegExpMacroAssemblerIrregexp::Expand() {
|
||||
Vector<byte> old_buffer = buffer_;
|
||||
buffer_ = Vector<byte>::New(old_buffer.length() * 2);
|
||||
own_buffer_ = true;
|
||||
OS::MemCopy(buffer_.start(), old_buffer.start(), old_buffer.length());
|
||||
MemCopy(buffer_.start(), old_buffer.start(), old_buffer.length());
|
||||
if (old_buffer_was_our_own) {
|
||||
old_buffer.Dispose();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ RegExpStack::~RegExpStack() {
|
||||
|
||||
char* RegExpStack::ArchiveStack(char* to) {
|
||||
size_t size = sizeof(thread_local_);
|
||||
OS::MemCopy(reinterpret_cast<void*>(to), &thread_local_, size);
|
||||
MemCopy(reinterpret_cast<void*>(to), &thread_local_, size);
|
||||
thread_local_ = ThreadLocal();
|
||||
return to + size;
|
||||
}
|
||||
@ -41,7 +41,7 @@ char* RegExpStack::ArchiveStack(char* to) {
|
||||
|
||||
char* RegExpStack::RestoreStack(char* from) {
|
||||
size_t size = sizeof(thread_local_);
|
||||
OS::MemCopy(&thread_local_, reinterpret_cast<void*>(from), size);
|
||||
MemCopy(&thread_local_, reinterpret_cast<void*>(from), size);
|
||||
return from + size;
|
||||
}
|
||||
|
||||
@ -69,11 +69,10 @@ Address RegExpStack::EnsureCapacity(size_t size) {
|
||||
Address new_memory = NewArray<byte>(static_cast<int>(size));
|
||||
if (thread_local_.memory_size_ > 0) {
|
||||
// Copy original memory into top of new memory.
|
||||
OS::MemCopy(
|
||||
reinterpret_cast<void*>(
|
||||
new_memory + size - thread_local_.memory_size_),
|
||||
reinterpret_cast<void*>(thread_local_.memory_),
|
||||
thread_local_.memory_size_);
|
||||
MemCopy(reinterpret_cast<void*>(new_memory + size -
|
||||
thread_local_.memory_size_),
|
||||
reinterpret_cast<void*>(thread_local_.memory_),
|
||||
thread_local_.memory_size_);
|
||||
DeleteArray(thread_local_.memory_);
|
||||
}
|
||||
thread_local_.memory_ = new_memory;
|
||||
|
@ -258,7 +258,7 @@ class LiteralBuffer {
|
||||
|
||||
void ExpandBuffer() {
|
||||
Vector<byte> new_store = Vector<byte>::New(NewCapacity(kInitialCapacity));
|
||||
OS::MemCopy(new_store.start(), backing_store_.start(), position_);
|
||||
MemCopy(new_store.start(), backing_store_.start(), position_);
|
||||
backing_store_.Dispose();
|
||||
backing_store_ = new_store;
|
||||
}
|
||||
|
@ -1707,7 +1707,7 @@ void Serializer::ObjectSerializer::VisitExternalAsciiString(
|
||||
|
||||
static Code* CloneCodeObject(HeapObject* code) {
|
||||
Address copy = new byte[code->Size()];
|
||||
OS::MemCopy(copy, code->address(), code->Size());
|
||||
MemCopy(copy, code->address(), code->Size());
|
||||
return Code::cast(HeapObject::FromAddress(copy));
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ int SnapshotByteSource::GetInt() {
|
||||
|
||||
|
||||
void SnapshotByteSource::CopyRaw(byte* to, int number_of_bytes) {
|
||||
OS::MemCopy(to, data_ + position_, number_of_bytes);
|
||||
MemCopy(to, data_ + position_, number_of_bytes);
|
||||
position_ += number_of_bytes;
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ void StringStream::Add(const char* format, FmtElm arg0, FmtElm arg1,
|
||||
|
||||
SmartArrayPointer<const char> StringStream::ToCString() const {
|
||||
char* str = NewArray<char>(length_ + 1);
|
||||
OS::MemCopy(str, buffer_, length_);
|
||||
MemCopy(str, buffer_, length_);
|
||||
str[length_] = '\0';
|
||||
return SmartArrayPointer<const char>(str);
|
||||
}
|
||||
@ -546,7 +546,7 @@ char* HeapStringAllocator::grow(unsigned* bytes) {
|
||||
if (new_space == NULL) {
|
||||
return space_;
|
||||
}
|
||||
OS::MemCopy(new_space, space_, *bytes);
|
||||
MemCopy(new_space, space_, *bytes);
|
||||
*bytes = new_bytes;
|
||||
DeleteArray(space_);
|
||||
space_ = new_space;
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "unicode.h"
|
||||
#include "checks.h"
|
||||
#include "platform.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace unibrow {
|
||||
|
||||
@ -189,8 +189,8 @@ unsigned Utf8Decoder<kBufferSize>::WriteUtf16(uint16_t* data,
|
||||
// memcpy everything in buffer.
|
||||
unsigned buffer_length =
|
||||
last_byte_of_buffer_unused_ ? kBufferSize - 1 : kBufferSize;
|
||||
unsigned memcpy_length = length <= buffer_length ? length : buffer_length;
|
||||
v8::internal::OS::MemCopy(data, buffer_, memcpy_length*sizeof(uint16_t));
|
||||
unsigned memcpy_length = length <= buffer_length ? length : buffer_length;
|
||||
v8::internal::MemCopy(data, buffer_, memcpy_length * sizeof(uint16_t));
|
||||
if (length <= buffer_length) return length;
|
||||
ASSERT(unbuffered_start_ != NULL);
|
||||
// Copy the rest the slow way.
|
||||
|
67
src/utils.cc
67
src/utils.cc
@ -29,7 +29,7 @@ void SimpleStringBuilder::AddString(const char* s) {
|
||||
void SimpleStringBuilder::AddSubstring(const char* s, int n) {
|
||||
ASSERT(!is_finalized() && position_ + n <= buffer_.length());
|
||||
ASSERT(static_cast<size_t>(n) <= strlen(s));
|
||||
OS::MemCopy(&buffer_[position_], s, n * kCharSize);
|
||||
MemCopy(&buffer_[position_], s, n * kCharSize);
|
||||
position_ += n;
|
||||
}
|
||||
|
||||
@ -145,12 +145,12 @@ char* ReadLine(const char* prompt) {
|
||||
char* new_result = NewArray<char>(new_len);
|
||||
// Copy the existing input into the new array and set the new
|
||||
// array as the result.
|
||||
OS::MemCopy(new_result, result, offset * kCharSize);
|
||||
MemCopy(new_result, result, offset * kCharSize);
|
||||
DeleteArray(result);
|
||||
result = new_result;
|
||||
}
|
||||
// Copy the newly read line into the result.
|
||||
OS::MemCopy(result + offset, line_buf, len * kCharSize);
|
||||
MemCopy(result + offset, line_buf, len * kCharSize);
|
||||
offset += len;
|
||||
}
|
||||
ASSERT(result != NULL);
|
||||
@ -314,4 +314,65 @@ void StringBuilder::AddFormattedList(const char* format, va_list list) {
|
||||
}
|
||||
|
||||
|
||||
#if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
|
||||
static void MemMoveWrapper(void* dest, const void* src, size_t size) {
|
||||
memmove(dest, src, size);
|
||||
}
|
||||
|
||||
|
||||
// Initialize to library version so we can call this at any time during startup.
|
||||
static MemMoveFunction memmove_function = &MemMoveWrapper;
|
||||
|
||||
// Defined in codegen-ia32.cc.
|
||||
MemMoveFunction CreateMemMoveFunction();
|
||||
|
||||
// Copy memory area to disjoint memory area.
|
||||
void MemMove(void* dest, const void* src, size_t size) {
|
||||
if (size == 0) return;
|
||||
// Note: here we rely on dependent reads being ordered. This is true
|
||||
// on all architectures we currently support.
|
||||
(*memmove_function)(dest, src, size);
|
||||
}
|
||||
|
||||
#elif V8_OS_POSIX && V8_HOST_ARCH_ARM
|
||||
void MemCopyUint16Uint8Wrapper(uint16_t* dest, const uint8_t* src,
|
||||
size_t chars) {
|
||||
uint16_t* limit = dest + chars;
|
||||
while (dest < limit) {
|
||||
*dest++ = static_cast<uint16_t>(*src++);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MemCopyUint8Function memcopy_uint8_function = &MemCopyUint8Wrapper;
|
||||
MemCopyUint16Uint8Function memcopy_uint16_uint8_function =
|
||||
&MemCopyUint16Uint8Wrapper;
|
||||
// Defined in codegen-arm.cc.
|
||||
MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub);
|
||||
MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function(
|
||||
MemCopyUint16Uint8Function stub);
|
||||
|
||||
#elif V8_OS_POSIX && V8_HOST_ARCH_MIPS
|
||||
MemCopyUint8Function memcopy_uint8_function = &MemCopyUint8Wrapper;
|
||||
// Defined in codegen-mips.cc.
|
||||
MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub);
|
||||
#endif
|
||||
|
||||
|
||||
void init_memcopy_functions() {
|
||||
#if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
|
||||
MemMoveFunction generated_memmove = CreateMemMoveFunction();
|
||||
if (generated_memmove != NULL) {
|
||||
memmove_function = generated_memmove;
|
||||
}
|
||||
#elif V8_OS_POSIX && V8_HOST_ARCH_ARM
|
||||
memcopy_uint8_function = CreateMemCopyUint8Function(&MemCopyUint8Wrapper);
|
||||
memcopy_uint16_uint8_function =
|
||||
CreateMemCopyUint16Uint8Function(&MemCopyUint16Uint8Wrapper);
|
||||
#elif V8_OS_POSIX && V8_HOST_ARCH_MIPS
|
||||
memcopy_uint8_function = CreateMemCopyUint8Function(&MemCopyUint8Wrapper);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
} } // namespace v8::internal
|
||||
|
119
src/utils.h
119
src/utils.h
@ -321,6 +321,85 @@ inline uint32_t ComputePointerHash(void* ptr) {
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Generated memcpy/memmove
|
||||
|
||||
// Initializes the codegen support that depends on CPU features. This is
|
||||
// called after CPU initialization.
|
||||
void init_memcopy_functions();
|
||||
|
||||
#if defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_X87)
|
||||
// Limit below which the extra overhead of the MemCopy function is likely
|
||||
// to outweigh the benefits of faster copying.
|
||||
const int kMinComplexMemCopy = 64;
|
||||
|
||||
// Copy memory area. No restrictions.
|
||||
void MemMove(void* dest, const void* src, size_t size);
|
||||
typedef void (*MemMoveFunction)(void* dest, const void* src, size_t size);
|
||||
|
||||
// Keep the distinction of "move" vs. "copy" for the benefit of other
|
||||
// architectures.
|
||||
V8_INLINE void MemCopy(void* dest, const void* src, size_t size) {
|
||||
MemMove(dest, src, size);
|
||||
}
|
||||
#elif defined(V8_HOST_ARCH_ARM)
|
||||
typedef void (*MemCopyUint8Function)(uint8_t* dest, const uint8_t* src,
|
||||
size_t size);
|
||||
extern MemCopyUint8Function memcopy_uint8_function;
|
||||
V8_INLINE void MemCopyUint8Wrapper(uint8_t* dest, const uint8_t* src,
|
||||
size_t chars) {
|
||||
memcpy(dest, src, chars);
|
||||
}
|
||||
// For values < 16, the assembler function is slower than the inlined C code.
|
||||
const int kMinComplexMemCopy = 16;
|
||||
V8_INLINE void MemCopy(void* dest, const void* src, size_t size) {
|
||||
(*memcopy_uint8_function)(reinterpret_cast<uint8_t*>(dest),
|
||||
reinterpret_cast<const uint8_t*>(src), size);
|
||||
}
|
||||
V8_INLINE void MemMove(void* dest, const void* src, size_t size) {
|
||||
memmove(dest, src, size);
|
||||
}
|
||||
|
||||
typedef void (*MemCopyUint16Uint8Function)(uint16_t* dest, const uint8_t* src,
|
||||
size_t size);
|
||||
extern MemCopyUint16Uint8Function memcopy_uint16_uint8_function;
|
||||
void MemCopyUint16Uint8Wrapper(uint16_t* dest, const uint8_t* src,
|
||||
size_t chars);
|
||||
// For values < 12, the assembler function is slower than the inlined C code.
|
||||
const int kMinComplexConvertMemCopy = 12;
|
||||
V8_INLINE void MemCopyUint16Uint8(uint16_t* dest, const uint8_t* src,
|
||||
size_t size) {
|
||||
(*memcopy_uint16_uint8_function)(dest, src, size);
|
||||
}
|
||||
#elif defined(V8_HOST_ARCH_MIPS)
|
||||
typedef void (*MemCopyUint8Function)(uint8_t* dest, const uint8_t* src,
|
||||
size_t size);
|
||||
extern MemCopyUint8Function memcopy_uint8_function;
|
||||
V8_INLINE void MemCopyUint8Wrapper(uint8_t* dest, const uint8_t* src,
|
||||
size_t chars) {
|
||||
memcpy(dest, src, chars);
|
||||
}
|
||||
// For values < 16, the assembler function is slower than the inlined C code.
|
||||
const int kMinComplexMemCopy = 16;
|
||||
V8_INLINE void MemCopy(void* dest, const void* src, size_t size) {
|
||||
(*memcopy_uint8_function)(reinterpret_cast<uint8_t*>(dest),
|
||||
reinterpret_cast<const uint8_t*>(src), size);
|
||||
}
|
||||
V8_INLINE void MemMove(void* dest, const void* src, size_t size) {
|
||||
memmove(dest, src, size);
|
||||
}
|
||||
#else
|
||||
// Copy memory area to disjoint memory area.
|
||||
V8_INLINE void MemCopy(void* dest, const void* src, size_t size) {
|
||||
memcpy(dest, src, size);
|
||||
}
|
||||
V8_INLINE void MemMove(void* dest, const void* src, size_t size) {
|
||||
memmove(dest, src, size);
|
||||
}
|
||||
const int kMinComplexMemCopy = 16 * kPointerSize;
|
||||
#endif // V8_TARGET_ARCH_IA32
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Miscellaneous
|
||||
|
||||
@ -402,14 +481,14 @@ class EmbeddedVector : public Vector<T> {
|
||||
// When copying, make underlying Vector to reference our buffer.
|
||||
EmbeddedVector(const EmbeddedVector& rhs)
|
||||
: Vector<T>(rhs) {
|
||||
OS::MemCopy(buffer_, rhs.buffer_, sizeof(T) * kSize);
|
||||
MemCopy(buffer_, rhs.buffer_, sizeof(T) * kSize);
|
||||
set_start(buffer_);
|
||||
}
|
||||
|
||||
EmbeddedVector& operator=(const EmbeddedVector& rhs) {
|
||||
if (this == &rhs) return *this;
|
||||
Vector<T>::operator=(rhs);
|
||||
OS::MemCopy(buffer_, rhs.buffer_, sizeof(T) * kSize);
|
||||
MemCopy(buffer_, rhs.buffer_, sizeof(T) * kSize);
|
||||
this->set_start(buffer_);
|
||||
return *this;
|
||||
}
|
||||
@ -1140,7 +1219,7 @@ inline void CopyWords(T* dst, const T* src, size_t num_words) {
|
||||
// Max(dst, const_cast<T*>(src)));
|
||||
ASSERT(num_words > 0);
|
||||
|
||||
// Use block copying OS::MemCopy if the segment we're copying is
|
||||
// Use block copying MemCopy if the segment we're copying is
|
||||
// enough to justify the extra call/setup overhead.
|
||||
static const size_t kBlockCopyLimit = 16;
|
||||
|
||||
@ -1150,7 +1229,7 @@ inline void CopyWords(T* dst, const T* src, size_t num_words) {
|
||||
*dst++ = *src++;
|
||||
} while (num_words > 0);
|
||||
} else {
|
||||
OS::MemCopy(dst, src, num_words * kPointerSize);
|
||||
MemCopy(dst, src, num_words * kPointerSize);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1161,7 +1240,7 @@ inline void MoveWords(T* dst, const T* src, size_t num_words) {
|
||||
STATIC_ASSERT(sizeof(T) == kPointerSize);
|
||||
ASSERT(num_words > 0);
|
||||
|
||||
// Use block copying OS::MemCopy if the segment we're copying is
|
||||
// Use block copying MemCopy if the segment we're copying is
|
||||
// enough to justify the extra call/setup overhead.
|
||||
static const size_t kBlockCopyLimit = 16;
|
||||
|
||||
@ -1173,7 +1252,7 @@ inline void MoveWords(T* dst, const T* src, size_t num_words) {
|
||||
*dst++ = *src++;
|
||||
} while (num_words > 0);
|
||||
} else {
|
||||
OS::MemMove(dst, src, num_words * kPointerSize);
|
||||
MemMove(dst, src, num_words * kPointerSize);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1186,9 +1265,9 @@ inline void CopyBytes(T* dst, const T* src, size_t num_bytes) {
|
||||
Max(dst, const_cast<T*>(src)));
|
||||
if (num_bytes == 0) return;
|
||||
|
||||
// Use block copying OS::MemCopy if the segment we're copying is
|
||||
// Use block copying MemCopy if the segment we're copying is
|
||||
// enough to justify the extra call/setup overhead.
|
||||
static const int kBlockCopyLimit = OS::kMinComplexMemCopy;
|
||||
static const int kBlockCopyLimit = kMinComplexMemCopy;
|
||||
|
||||
if (num_bytes < static_cast<size_t>(kBlockCopyLimit)) {
|
||||
do {
|
||||
@ -1196,7 +1275,7 @@ inline void CopyBytes(T* dst, const T* src, size_t num_bytes) {
|
||||
*dst++ = *src++;
|
||||
} while (num_bytes > 0);
|
||||
} else {
|
||||
OS::MemCopy(dst, src, num_bytes);
|
||||
MemCopy(dst, src, num_bytes);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1319,8 +1398,8 @@ void CopyCharsUnsigned(sinkchar* dest, const sourcechar* src, int chars) {
|
||||
sinkchar* limit = dest + chars;
|
||||
#ifdef V8_HOST_CAN_READ_UNALIGNED
|
||||
if (sizeof(*dest) == sizeof(*src)) {
|
||||
if (chars >= static_cast<int>(OS::kMinComplexMemCopy / sizeof(*dest))) {
|
||||
OS::MemCopy(dest, src, chars * sizeof(*dest));
|
||||
if (chars >= static_cast<int>(kMinComplexMemCopy / sizeof(*dest))) {
|
||||
MemCopy(dest, src, chars * sizeof(*dest));
|
||||
return;
|
||||
}
|
||||
// Number of characters in a uintptr_t.
|
||||
@ -1391,17 +1470,17 @@ void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, int chars) {
|
||||
memcpy(dest, src, 15);
|
||||
break;
|
||||
default:
|
||||
OS::MemCopy(dest, src, chars);
|
||||
MemCopy(dest, src, chars);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CopyCharsUnsigned(uint16_t* dest, const uint8_t* src, int chars) {
|
||||
if (chars >= OS::kMinComplexConvertMemCopy) {
|
||||
OS::MemCopyUint16Uint8(dest, src, chars);
|
||||
if (chars >= kMinComplexConvertMemCopy) {
|
||||
MemCopyUint16Uint8(dest, src, chars);
|
||||
} else {
|
||||
OS::MemCopyUint16Uint8Wrapper(dest, src, chars);
|
||||
MemCopyUint16Uint8Wrapper(dest, src, chars);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1432,7 +1511,7 @@ void CopyCharsUnsigned(uint16_t* dest, const uint16_t* src, int chars) {
|
||||
memcpy(dest, src, 14);
|
||||
break;
|
||||
default:
|
||||
OS::MemCopy(dest, src, chars * sizeof(*dest));
|
||||
MemCopy(dest, src, chars * sizeof(*dest));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1440,18 +1519,18 @@ void CopyCharsUnsigned(uint16_t* dest, const uint16_t* src, int chars) {
|
||||
|
||||
#elif defined(V8_HOST_ARCH_MIPS)
|
||||
void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, int chars) {
|
||||
if (chars < OS::kMinComplexMemCopy) {
|
||||
if (chars < kMinComplexMemCopy) {
|
||||
memcpy(dest, src, chars);
|
||||
} else {
|
||||
OS::MemCopy(dest, src, chars);
|
||||
MemCopy(dest, src, chars);
|
||||
}
|
||||
}
|
||||
|
||||
void CopyCharsUnsigned(uint16_t* dest, const uint16_t* src, int chars) {
|
||||
if (chars < OS::kMinComplexMemCopy) {
|
||||
if (chars < kMinComplexMemCopy) {
|
||||
memcpy(dest, src, chars * sizeof(*dest));
|
||||
} else {
|
||||
OS::MemCopy(dest, src, chars * sizeof(*dest));
|
||||
MemCopy(dest, src, chars * sizeof(*dest));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -95,7 +95,7 @@ void V8::InitializeOncePerProcessImpl() {
|
||||
#endif
|
||||
Sampler::SetUp();
|
||||
CpuFeatures::Probe(false);
|
||||
OS::PostSetUp();
|
||||
init_memcopy_functions();
|
||||
// The custom exp implementation needs 16KB of lookup data; initialize it
|
||||
// on demand.
|
||||
init_fast_sqrt_function();
|
||||
|
@ -361,9 +361,9 @@ void Assembler::GrowBuffer() {
|
||||
intptr_t pc_delta = desc.buffer - buffer_;
|
||||
intptr_t rc_delta = (desc.buffer + desc.buffer_size) -
|
||||
(buffer_ + buffer_size_);
|
||||
OS::MemMove(desc.buffer, buffer_, desc.instr_size);
|
||||
OS::MemMove(rc_delta + reloc_info_writer.pos(),
|
||||
reloc_info_writer.pos(), desc.reloc_size);
|
||||
MemMove(desc.buffer, buffer_, desc.instr_size);
|
||||
MemMove(rc_delta + reloc_info_writer.pos(), reloc_info_writer.pos(),
|
||||
desc.reloc_size);
|
||||
|
||||
// Switch buffers.
|
||||
if (isolate() != NULL &&
|
||||
|
@ -1876,9 +1876,9 @@ void Assembler::GrowBuffer() {
|
||||
// Copy the data.
|
||||
int pc_delta = desc.buffer - buffer_;
|
||||
int rc_delta = (desc.buffer + desc.buffer_size) - (buffer_ + buffer_size_);
|
||||
OS::MemMove(desc.buffer, buffer_, desc.instr_size);
|
||||
OS::MemMove(rc_delta + reloc_info_writer.pos(),
|
||||
reloc_info_writer.pos(), desc.reloc_size);
|
||||
MemMove(desc.buffer, buffer_, desc.instr_size);
|
||||
MemMove(rc_delta + reloc_info_writer.pos(), reloc_info_writer.pos(),
|
||||
desc.reloc_size);
|
||||
|
||||
// Switch buffers.
|
||||
if (isolate()->assembler_spare_buffer() == NULL &&
|
||||
|
@ -76,7 +76,7 @@ class LabelConverter {
|
||||
};
|
||||
|
||||
|
||||
OS::MemMoveFunction CreateMemMoveFunction() {
|
||||
MemMoveFunction CreateMemMoveFunction() {
|
||||
size_t actual_size;
|
||||
// Allocate buffer in executable space.
|
||||
byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true));
|
||||
@ -185,7 +185,7 @@ OS::MemMoveFunction CreateMemMoveFunction() {
|
||||
OS::ProtectCode(buffer, actual_size);
|
||||
// TODO(jkummerow): It would be nice to register this code creation event
|
||||
// with the PROFILE / GDBJIT system.
|
||||
return FUNCTION_CAST<OS::MemMoveFunction>(buffer);
|
||||
return FUNCTION_CAST<MemMoveFunction>(buffer);
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,9 +67,8 @@ void Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(Handle<Code> code) {
|
||||
Factory* factory = isolate->factory();
|
||||
Handle<ByteArray> new_reloc =
|
||||
factory->NewByteArray(reloc_length + padding, TENURED);
|
||||
OS::MemCopy(new_reloc->GetDataStartAddress() + padding,
|
||||
code->relocation_info()->GetDataStartAddress(),
|
||||
reloc_length);
|
||||
MemCopy(new_reloc->GetDataStartAddress() + padding,
|
||||
code->relocation_info()->GetDataStartAddress(), reloc_length);
|
||||
// Create a relocation writer to write the comments in the padding
|
||||
// space. Use position 0 for everything to ensure short encoding.
|
||||
RelocInfoWriter reloc_info_writer(
|
||||
@ -162,8 +161,7 @@ void Deoptimizer::PatchCodeForDeoptimization(Isolate* isolate, Code* code) {
|
||||
|
||||
// Move the relocation info to the beginning of the byte array.
|
||||
int new_reloc_size = reloc_end_address - reloc_info_writer.pos();
|
||||
OS::MemMove(
|
||||
code->relocation_start(), reloc_info_writer.pos(), new_reloc_size);
|
||||
MemMove(code->relocation_start(), reloc_info_writer.pos(), new_reloc_size);
|
||||
|
||||
// The relocation info is in place, update the size.
|
||||
reloc_info->set_length(new_reloc_size);
|
||||
|
@ -14912,7 +14912,7 @@ TEST(PreCompileSerialization) {
|
||||
// Serialize.
|
||||
const v8::ScriptCompiler::CachedData* cd = source.GetCachedData();
|
||||
char* serialized_data = i::NewArray<char>(cd->length);
|
||||
i::OS::MemCopy(serialized_data, cd->data, cd->length);
|
||||
i::MemCopy(serialized_data, cd->data, cd->length);
|
||||
|
||||
// Deserialize.
|
||||
i::ScriptData* deserialized = i::ScriptData::New(serialized_data, cd->length);
|
||||
@ -18092,14 +18092,14 @@ TEST(ExternalInternalizedStringCollectedAtGC) {
|
||||
|
||||
static double DoubleFromBits(uint64_t value) {
|
||||
double target;
|
||||
i::OS::MemCopy(&target, &value, sizeof(target));
|
||||
i::MemCopy(&target, &value, sizeof(target));
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
static uint64_t DoubleToBits(double value) {
|
||||
uint64_t target;
|
||||
i::OS::MemCopy(&target, &value, sizeof(target));
|
||||
i::MemCopy(&target, &value, sizeof(target));
|
||||
return target;
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ TEST(GetScriptLineNumber) {
|
||||
for (int i = 0; i < max_rows; ++i) {
|
||||
if (i > 0)
|
||||
buffer[i - 1] = '\n';
|
||||
OS::MemCopy(&buffer[i], function_f, sizeof(function_f) - 1);
|
||||
MemCopy(&buffer[i], function_f, sizeof(function_f) - 1);
|
||||
v8::Handle<v8::String> script_body =
|
||||
v8::String::NewFromUtf8(CcTest::isolate(), buffer.start());
|
||||
v8::Script::Compile(script_body, &origin)->Run();
|
||||
|
@ -777,7 +777,7 @@ class TestJSONStream : public v8::OutputStream {
|
||||
if (abort_countdown_ == 0) return kAbort;
|
||||
CHECK_GT(chars_written, 0);
|
||||
i::Vector<char> chunk = buffer_.AddBlock(chars_written, '\0');
|
||||
i::OS::MemCopy(chunk.start(), buffer, chars_written);
|
||||
i::MemCopy(chunk.start(), buffer, chars_written);
|
||||
return kContinue;
|
||||
}
|
||||
virtual WriteResult WriteUint32Chunk(uint32_t* buffer, int chars_written) {
|
||||
|
@ -84,7 +84,7 @@ TEST(ScanKeywords) {
|
||||
// Adding characters will make keyword matching fail.
|
||||
static const char chars_to_append[] = { 'z', '0', '_' };
|
||||
for (int j = 0; j < static_cast<int>(ARRAY_SIZE(chars_to_append)); ++j) {
|
||||
i::OS::MemMove(buffer, keyword, length);
|
||||
i::MemMove(buffer, keyword, length);
|
||||
buffer[length] = chars_to_append[j];
|
||||
i::Utf8ToUtf16CharacterStream stream(buffer, length + 1);
|
||||
i::Scanner scanner(&unicode_cache);
|
||||
@ -94,7 +94,7 @@ TEST(ScanKeywords) {
|
||||
}
|
||||
// Replacing characters will make keyword matching fail.
|
||||
{
|
||||
i::OS::MemMove(buffer, keyword, length);
|
||||
i::MemMove(buffer, keyword, length);
|
||||
buffer[length - 1] = '_';
|
||||
i::Utf8ToUtf16CharacterStream stream(buffer, length);
|
||||
i::Scanner scanner(&unicode_cache);
|
||||
|
@ -110,15 +110,15 @@ void TestMemMove(byte* area1,
|
||||
area1[i] = i & 0xFF;
|
||||
area2[i] = i & 0xFF;
|
||||
}
|
||||
OS::MemMove(area1 + dest_offset, area1 + src_offset, length);
|
||||
MemMove(area1 + dest_offset, area1 + src_offset, length);
|
||||
memmove(area2 + dest_offset, area2 + src_offset, length);
|
||||
if (memcmp(area1, area2, kAreaSize) != 0) {
|
||||
printf("OS::MemMove(): src_offset: %d, dest_offset: %d, length: %d\n",
|
||||
printf("MemMove(): src_offset: %d, dest_offset: %d, length: %d\n",
|
||||
src_offset, dest_offset, length);
|
||||
for (int i = 0; i < kAreaSize; i++) {
|
||||
if (area1[i] == area2[i]) continue;
|
||||
printf("diff at offset %d (%p): is %d, should be %d\n",
|
||||
i, reinterpret_cast<void*>(area1 + i), area1[i], area2[i]);
|
||||
printf("diff at offset %d (%p): is %d, should be %d\n", i,
|
||||
reinterpret_cast<void*>(area1 + i), area1[i], area2[i]);
|
||||
}
|
||||
CHECK(false);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user