From 84e078e561d68861f0dc50abe849b9080d8276a2 Mon Sep 17 00:00:00 2001 From: "jochen@chromium.org" Date: Tue, 27 May 2014 07:57:22 +0000 Subject: [PATCH] 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 --- src/allocation.cc | 4 +- src/api.cc | 8 +- src/arm/assembler-arm.cc | 8 +- src/arm/codegen-arm.cc | 11 ++- src/arm/constants-arm.cc | 2 +- src/arm/simulator-arm.cc | 50 +++++------ src/atomicops_internals_x86_gcc.cc | 8 +- src/builtins.cc | 12 +-- src/conversions-inl.h | 2 +- src/debug.cc | 5 +- src/deoptimizer.cc | 3 +- src/execution.cc | 5 +- src/flags.cc | 4 +- src/gdb-jit.cc | 4 +- src/heap-inl.h | 10 +-- src/heap-snapshot-generator.cc | 6 +- src/heap.cc | 10 +-- src/hydrogen-check-elimination.cc | 6 +- src/hydrogen-gvn.cc | 15 ++-- src/ia32/assembler-ia32.cc | 6 +- src/ia32/codegen-ia32.cc | 4 +- src/ia32/deoptimizer-ia32.cc | 8 +- src/isolate.cc | 12 +-- src/jsregexp.cc | 3 +- src/list-inl.h | 2 +- src/lithium-codegen.cc | 2 +- src/liveedit.cc | 12 +-- src/log.cc | 6 +- src/mips/assembler-mips.cc | 8 +- src/mips/codegen-mips.cc | 5 +- src/mips/simulator-mips.cc | 18 ++-- src/objects.cc | 2 +- src/platform-posix.cc | 66 -------------- src/platform-win32.cc | 35 +------- src/platform.h | 84 ----------------- src/preparse-data.cc | 2 +- src/prettyprinter.cc | 2 +- src/regexp-macro-assembler-irregexp.cc | 4 +- src/regexp-stack.cc | 13 ++- src/scanner.h | 2 +- src/serialize.cc | 2 +- src/serialize.h | 2 +- src/string-stream.cc | 4 +- src/unicode-inl.h | 6 +- src/utils.cc | 67 +++++++++++++- src/utils.h | 119 ++++++++++++++++++++----- src/v8.cc | 2 +- src/x64/assembler-x64.cc | 6 +- src/x87/assembler-x87.cc | 6 +- src/x87/codegen-x87.cc | 4 +- src/x87/deoptimizer-x87.cc | 8 +- test/cctest/test-api.cc | 6 +- test/cctest/test-compiler.cc | 2 +- test/cctest/test-heap-profiler.cc | 2 +- test/cctest/test-parsing.cc | 4 +- test/cctest/test-utils.cc | 8 +- 56 files changed, 328 insertions(+), 389 deletions(-) diff --git a/src/allocation.cc b/src/allocation.cc index 0549a199ff..7b7cca1973 100644 --- a/src/allocation.cc +++ b/src/allocation.cc @@ -66,7 +66,7 @@ void AllStatic::operator delete(void* p) { char* StrDup(const char* str) { int length = StrLength(str); char* result = NewArray(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(length + 1); - OS::MemCopy(result, str, length); + MemCopy(result, str, length); result[length] = '\0'; return result; } diff --git a/src/api.cc b/src/api.cc index a8ab53723b..81cba85f6d 100644 --- a/src/api.cc +++ b/src/api.cc @@ -3275,7 +3275,7 @@ Local 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 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 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(); } diff --git a/src/arm/assembler-arm.cc b/src/arm/assembler-arm.cc index 8465d22066..46712d5e17 100644 --- a/src/arm/assembler-arm.cc +++ b/src/arm/assembler-arm.cc @@ -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_); diff --git a/src/arm/codegen-arm.cc b/src/arm/codegen-arm.cc index 8a46006eb9..67abb3f608 100644 --- a/src/arm/codegen-arm.cc +++ b/src/arm/codegen-arm.cc @@ -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(buffer); + return FUNCTION_CAST(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(buffer); + return FUNCTION_CAST(buffer); #endif } #endif diff --git a/src/arm/constants-arm.cc b/src/arm/constants-arm.cc index 676239f829..696e2e3d08 100644 --- a/src/arm/constants-arm.cc +++ b/src/arm/constants-arm.cc @@ -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; } diff --git a/src/arm/simulator-arm.cc b/src/arm/simulator-arm.cc index 23e4b3de2e..0dc50a2444 100644 --- a/src/arm/simulator-arm.cc +++ b/src/arm/simulator-arm.cc @@ -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(instr), - cache_page->CachedData(offset), - Instruction::kInstrSize)); + CHECK_EQ(0, + memcmp(reinterpret_cast(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(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(address), data[0], instr); WriteW(reinterpret_cast(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); } diff --git a/src/atomicops_internals_x86_gcc.cc b/src/atomicops_internals_x86_gcc.cc index 0b0e04c815..45a598822a 100644 --- a/src/atomicops_internals_x86_gcc.cc +++ b/src/atomicops_internals_x86_gcc.cc @@ -8,7 +8,7 @@ #include #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 diff --git a/src/builtins.cc b/src/builtins.cc index 6cdd4a9530..e8d3e71379 100644 --- a/src/builtins.cc +++ b/src/builtins.cc @@ -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); } diff --git a/src/conversions-inl.h b/src/conversions-inl.h index 43363f3738..63f84f4ecc 100644 --- a/src/conversions-inl.h +++ b/src/conversions-inl.h @@ -58,7 +58,7 @@ inline unsigned int FastD2UI(double x) { Address mantissa_ptr = reinterpret_cast
(&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. diff --git a/src/debug.cc b/src/debug.cc index 80f993b82b..058ec35873 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -515,7 +515,7 @@ void Debug::ThreadInit() { char* Debug::ArchiveDebug(char* storage) { char* to = storage; - OS::MemCopy(to, reinterpret_cast(&thread_local_), sizeof(ThreadLocal)); + MemCopy(to, reinterpret_cast(&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(&thread_local_), from, sizeof(ThreadLocal)); + MemCopy(reinterpret_cast(&thread_local_), from, sizeof(ThreadLocal)); return storage + ArchiveSpacePerThread(); } diff --git a/src/deoptimizer.cc b/src/deoptimizer.cc index 6e9ead7e20..17bf8fbf5a 100644 --- a/src/deoptimizer.cc +++ b/src/deoptimizer.cc @@ -2906,8 +2906,7 @@ int32_t TranslationIterator::Next() { Handle TranslationBuffer::CreateByteArray(Factory* factory) { int length = contents_.length(); Handle result = factory->NewByteArray(length, TENURED); - OS::MemCopy( - result->GetDataStartAddress(), contents_.ToVector().start(), length); + MemCopy(result->GetDataStartAddress(), contents_.ToVector().start(), length); return result; } diff --git a/src/execution.cc b/src/execution.cc index fc5198069d..4c6bd93d06 100644 --- a/src/execution.cc +++ b/src/execution.cc @@ -380,7 +380,7 @@ bool StackGuard::CheckAndClearInterrupt(InterruptFlag flag, char* StackGuard::ArchiveStackGuard(char* to) { ExecutionAccess access(isolate_); - OS::MemCopy(to, reinterpret_cast(&thread_local_), sizeof(ThreadLocal)); + MemCopy(to, reinterpret_cast(&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(&thread_local_), from, sizeof(ThreadLocal)); + MemCopy(reinterpret_cast(&thread_local_), from, sizeof(ThreadLocal)); isolate_->heap()->SetStackLimits(); return from + sizeof(ThreadLocal); } diff --git a/src/flags.cc b/src/flags.cc index 467f4a9e0a..59dc440257 100644 --- a/src/flags.cc +++ b/src/flags.cc @@ -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(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 copy0(len + 1); - OS::MemCopy(copy0.start(), str, len); + MemCopy(copy0.start(), str, len); copy0[len] = '\0'; // strip leading white space diff --git a/src/gdb-jit.cc b/src/gdb-jit.cc index 1924ab8b83..4fb8d8217e 100644 --- a/src/gdb-jit.cc +++ b/src/gdb-jit.cc @@ -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
(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; diff --git a/src/heap-inl.h b/src/heap-inl.h index 3cddcb91dc..6c59790ec1 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -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 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(byte_size)); + MemMove(dst, src, static_cast(byte_size)); } } diff --git a/src/heap-snapshot-generator.cc b/src/heap-snapshot-generator.cc index a0bb4a82f3..d1f268be65 100644 --- a/src/heap-snapshot-generator.cc +++ b/src/heap-snapshot-generator.cc @@ -2683,10 +2683,10 @@ class OutputStreamWriter { ASSERT(static_cast(n) <= strlen(s)); const char* s_end = s + n; while (s < s_end) { - int s_chunk_size = Min( - chunk_size_ - chunk_pos_, static_cast(s_end - s)); + int s_chunk_size = + Min(chunk_size_ - chunk_pos_, static_cast(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(); diff --git a/src/heap.cc b/src/heap.cc index 741d33e271..b7a59189e4 100644 --- a/src/heap.cc +++ b/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 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 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(); } diff --git a/src/hydrogen-check-elimination.cc b/src/hydrogen-check-elimination.cc index f3c5cbe151..506a045889 100644 --- a/src/hydrogen-check-elimination.cc +++ b/src/hydrogen-check-elimination.cc @@ -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. diff --git a/src/hydrogen-gvn.cc b/src/hydrogen-gvn.cc index b32b90951a..398897b12a 100644 --- a/src/hydrogen-gvn.cc +++ b/src/hydrogen-gvn.cc @@ -140,10 +140,10 @@ HInstructionMap::HInstructionMap(Zone* zone, const HInstructionMap* other) lists_(zone->NewArray(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; } diff --git a/src/ia32/assembler-ia32.cc b/src/ia32/assembler-ia32.cc index 49ff5e3fcc..6d57446e82 100644 --- a/src/ia32/assembler-ia32.cc +++ b/src/ia32/assembler-ia32.cc @@ -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 && diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc index 04d00648cb..003da616f1 100644 --- a/src/ia32/codegen-ia32.cc +++ b/src/ia32/codegen-ia32.cc @@ -186,7 +186,7 @@ class LabelConverter { }; -OS::MemMoveFunction CreateMemMoveFunction() { +MemMoveFunction CreateMemMoveFunction() { size_t actual_size; // Allocate buffer in executable space. byte* buffer = static_cast(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(buffer); + return FUNCTION_CAST(buffer); } diff --git a/src/ia32/deoptimizer-ia32.cc b/src/ia32/deoptimizer-ia32.cc index 05b2ce8a74..87c04836f2 100644 --- a/src/ia32/deoptimizer-ia32.cc +++ b/src/ia32/deoptimizer-ia32.cc @@ -67,9 +67,8 @@ void Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(Handle code) { Factory* factory = isolate->factory(); Handle 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); diff --git a/src/isolate.cc b/src/isolate.cc index d204726f8b..3a8bfa637c 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -1343,8 +1343,8 @@ Handle Isolate::GetCallingNativeContext() { char* Isolate::ArchiveThread(char* to) { - OS::MemCopy(to, reinterpret_cast(thread_local_top()), - sizeof(ThreadLocalTop)); + MemCopy(to, reinterpret_cast(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(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(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 diff --git a/src/jsregexp.cc b/src/jsregexp.cc index ae338d0c0e..01140e830a 100644 --- a/src/jsregexp.cc +++ b/src/jsregexp.cc @@ -604,8 +604,7 @@ int RegExpImpl::IrregexpExecRaw(Handle 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()); diff --git a/src/list-inl.h b/src/list-inl.h index 4a18d98205..c8b7410bbc 100644 --- a/src/list-inl.h +++ b/src/list-inl.h @@ -65,7 +65,7 @@ template void List::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::DeleteData(data_); data_ = new_data; capacity_ = new_capacity; diff --git a/src/lithium-codegen.cc b/src/lithium-codegen.cc index eebe1dfde5..ea04f35871 100644 --- a/src/lithium-codegen.cc +++ b/src/lithium-codegen.cc @@ -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 copy = Vector::New(static_cast(length) + 1); - OS::MemCopy(copy.start(), builder.Finalize(), copy.length()); + MemCopy(copy.start(), builder.Finalize(), copy.length()); masm()->RecordComment(copy.start()); } diff --git a/src/liveedit.cc b/src/liveedit.cc index f43f38a3b5..5494817847 100644 --- a/src/liveedit.cc +++ b/src/liveedit.cc @@ -1313,8 +1313,8 @@ class RelocInfoBuffer { // Copy the data. int curently_used_size = static_cast(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 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 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()); diff --git a/src/log.cc b/src/log.cc index 3cbe3866f6..22f19140a5 100644 --- a/src/log.cc +++ b/src/log.cc @@ -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 ll_name(static_cast(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); diff --git a/src/mips/assembler-mips.cc b/src/mips/assembler-mips.cc index 621a20a439..f539504a7f 100644 --- a/src/mips/assembler-mips.cc +++ b/src/mips/assembler-mips.cc @@ -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_); diff --git a/src/mips/codegen-mips.cc b/src/mips/codegen-mips.cc index adf6d37d89..d7e0a5110d 100644 --- a/src/mips/codegen-mips.cc +++ b/src/mips/codegen-mips.cc @@ -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(buffer); + return FUNCTION_CAST(buffer); #endif } #endif diff --git a/src/mips/simulator-mips.cc b/src/mips/simulator-mips.cc index 278344fd88..e0b074905e 100644 --- a/src/mips/simulator-mips.cc +++ b/src/mips/simulator-mips.cc @@ -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(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); diff --git a/src/objects.cc b/src/objects.cc index b09e1a0530..277d320588 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -16724,7 +16724,7 @@ Handle 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(array) % sizeof(uintptr_t) == 0); diff --git a/src/platform-posix.cc b/src/platform-posix.cc index 1972505565..2b5f40c9ab 100644 --- a/src/platform-posix.cc +++ b/src/platform-posix.cc @@ -447,72 +447,6 @@ int OS::VSNPrintF(Vector 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(*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. // diff --git a/src/platform-win32.cc b/src/platform-win32.cc index 9c7f5a9b4f..6f6fe9262a 100644 --- a/src/platform-win32.cc +++ b/src/platform-win32.cc @@ -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); } diff --git a/src/platform.h b/src/platform.h index 7d857cc0df..4c7dc3f34b 100644 --- a/src/platform.h +++ b/src/platform.h @@ -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(dest), - reinterpret_cast(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(dest), - reinterpret_cast(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: diff --git a/src/preparse-data.cc b/src/preparse-data.cc index 5ddf72137f..9a95a45e4b 100644 --- a/src/preparse-data.cc +++ b/src/preparse-data.cc @@ -66,7 +66,7 @@ Vector CompleteParserRecorder::ExtractData() { int total_size = PreparseDataConstants::kHeaderSize + function_size; Vector data = Vector::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)); diff --git a/src/prettyprinter.cc b/src/prettyprinter.cc index 233d7c2fab..2bb7c94658 100644 --- a/src/prettyprinter.cc +++ b/src/prettyprinter.cc @@ -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(new_size); - OS::MemCopy(new_output, output_, pos_); + MemCopy(new_output, output_, pos_); DeleteArray(output_); output_ = new_output; size_ = new_size; diff --git a/src/regexp-macro-assembler-irregexp.cc b/src/regexp-macro-assembler-irregexp.cc index 368fb3006c..d51fc1edf9 100644 --- a/src/regexp-macro-assembler-irregexp.cc +++ b/src/regexp-macro-assembler-irregexp.cc @@ -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 old_buffer = buffer_; buffer_ = Vector::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(); } diff --git a/src/regexp-stack.cc b/src/regexp-stack.cc index 5e250dd85e..9122446d1d 100644 --- a/src/regexp-stack.cc +++ b/src/regexp-stack.cc @@ -33,7 +33,7 @@ RegExpStack::~RegExpStack() { char* RegExpStack::ArchiveStack(char* to) { size_t size = sizeof(thread_local_); - OS::MemCopy(reinterpret_cast(to), &thread_local_, size); + MemCopy(reinterpret_cast(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(from), size); + MemCopy(&thread_local_, reinterpret_cast(from), size); return from + size; } @@ -69,11 +69,10 @@ Address RegExpStack::EnsureCapacity(size_t size) { Address new_memory = NewArray(static_cast(size)); if (thread_local_.memory_size_ > 0) { // Copy original memory into top of new memory. - OS::MemCopy( - reinterpret_cast( - new_memory + size - thread_local_.memory_size_), - reinterpret_cast(thread_local_.memory_), - thread_local_.memory_size_); + MemCopy(reinterpret_cast(new_memory + size - + thread_local_.memory_size_), + reinterpret_cast(thread_local_.memory_), + thread_local_.memory_size_); DeleteArray(thread_local_.memory_); } thread_local_.memory_ = new_memory; diff --git a/src/scanner.h b/src/scanner.h index 037da5b173..eeed183cdf 100644 --- a/src/scanner.h +++ b/src/scanner.h @@ -258,7 +258,7 @@ class LiteralBuffer { void ExpandBuffer() { Vector new_store = Vector::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; } diff --git a/src/serialize.cc b/src/serialize.cc index e179880d09..c2706f62ff 100644 --- a/src/serialize.cc +++ b/src/serialize.cc @@ -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)); } diff --git a/src/serialize.h b/src/serialize.h index aaf97e32d2..3f3c679b02 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -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; } diff --git a/src/string-stream.cc b/src/string-stream.cc index 25e340b4a5..2db084b2ff 100644 --- a/src/string-stream.cc +++ b/src/string-stream.cc @@ -237,7 +237,7 @@ void StringStream::Add(const char* format, FmtElm arg0, FmtElm arg1, SmartArrayPointer StringStream::ToCString() const { char* str = NewArray(length_ + 1); - OS::MemCopy(str, buffer_, length_); + MemCopy(str, buffer_, length_); str[length_] = '\0'; return SmartArrayPointer(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; diff --git a/src/unicode-inl.h b/src/unicode-inl.h index a0142d2259..faa9862c48 100644 --- a/src/unicode-inl.h +++ b/src/unicode-inl.h @@ -7,7 +7,7 @@ #include "unicode.h" #include "checks.h" -#include "platform.h" +#include "utils.h" namespace unibrow { @@ -189,8 +189,8 @@ unsigned Utf8Decoder::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. diff --git a/src/utils.cc b/src/utils.cc index 7af30f27b7..c159fc13ea 100644 --- a/src/utils.cc +++ b/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(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(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(*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 diff --git a/src/utils.h b/src/utils.h index 115f784758..eeb0987521 100644 --- a/src/utils.h +++ b/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(dest), + reinterpret_cast(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(dest), + reinterpret_cast(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 { // When copying, make underlying Vector to reference our buffer. EmbeddedVector(const EmbeddedVector& rhs) : Vector(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::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(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(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(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(OS::kMinComplexMemCopy / sizeof(*dest))) { - OS::MemCopy(dest, src, chars * sizeof(*dest)); + if (chars >= static_cast(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 diff --git a/src/v8.cc b/src/v8.cc index 0048340d46..4a546dcef9 100644 --- a/src/v8.cc +++ b/src/v8.cc @@ -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(); diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc index 64a5cc3ae6..71df6a9bfc 100644 --- a/src/x64/assembler-x64.cc +++ b/src/x64/assembler-x64.cc @@ -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 && diff --git a/src/x87/assembler-x87.cc b/src/x87/assembler-x87.cc index 0d2c0a3821..d40e8c5356 100644 --- a/src/x87/assembler-x87.cc +++ b/src/x87/assembler-x87.cc @@ -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 && diff --git a/src/x87/codegen-x87.cc b/src/x87/codegen-x87.cc index 01e346f145..711aff2765 100644 --- a/src/x87/codegen-x87.cc +++ b/src/x87/codegen-x87.cc @@ -76,7 +76,7 @@ class LabelConverter { }; -OS::MemMoveFunction CreateMemMoveFunction() { +MemMoveFunction CreateMemMoveFunction() { size_t actual_size; // Allocate buffer in executable space. byte* buffer = static_cast(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(buffer); + return FUNCTION_CAST(buffer); } diff --git a/src/x87/deoptimizer-x87.cc b/src/x87/deoptimizer-x87.cc index fb0e8f2686..0d717264fc 100644 --- a/src/x87/deoptimizer-x87.cc +++ b/src/x87/deoptimizer-x87.cc @@ -67,9 +67,8 @@ void Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(Handle code) { Factory* factory = isolate->factory(); Handle 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); diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index dc091f3a9c..775e2529d8 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -14912,7 +14912,7 @@ TEST(PreCompileSerialization) { // Serialize. const v8::ScriptCompiler::CachedData* cd = source.GetCachedData(); char* serialized_data = i::NewArray(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; } diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc index 9974ff5702..accd429bdb 100644 --- a/test/cctest/test-compiler.cc +++ b/test/cctest/test-compiler.cc @@ -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 script_body = v8::String::NewFromUtf8(CcTest::isolate(), buffer.start()); v8::Script::Compile(script_body, &origin)->Run(); diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc index a515a22bdf..7e05e4fb15 100644 --- a/test/cctest/test-heap-profiler.cc +++ b/test/cctest/test-heap-profiler.cc @@ -777,7 +777,7 @@ class TestJSONStream : public v8::OutputStream { if (abort_countdown_ == 0) return kAbort; CHECK_GT(chars_written, 0); i::Vector 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) { diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc index b95944bf0f..43f9d827ac 100644 --- a/test/cctest/test-parsing.cc +++ b/test/cctest/test-parsing.cc @@ -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(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); diff --git a/test/cctest/test-utils.cc b/test/cctest/test-utils.cc index 86d52fa82b..4eb256becb 100644 --- a/test/cctest/test-utils.cc +++ b/test/cctest/test-utils.cc @@ -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(area1 + i), area1[i], area2[i]); + printf("diff at offset %d (%p): is %d, should be %d\n", i, + reinterpret_cast(area1 + i), area1[i], area2[i]); } CHECK(false); }