Commit 47cea503 authored by jochen@chromium.org's avatar jochen@chromium.org

Replace some calls to MemCopy with small constant sizes with memcpy

MemCopy is only meant for variable size, large (>64bytes) copies,
otherwise, it's probably slower than memcpy due to the call
overhead and the compiler can't optimize it away.

BUG=none
R=jkummerow@chromium.org
LOG=n

Review URL: https://codereview.chromium.org/306453005

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21519 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2097644f
......@@ -2325,7 +2325,7 @@ void Assembler::vstm(BlockAddrMode am,
static void DoubleAsTwoUInt32(double d, uint32_t* lo, uint32_t* hi) {
uint64_t i;
MemCopy(&i, &d, 8);
memcpy(&i, &d, 8);
*lo = i & 0xffffffff;
*hi = i >> 32;
......
......@@ -28,7 +28,7 @@ double Instruction::DoubleImmedVmov() const {
uint64_t imm = high16 << 48;
double d;
MemCopy(&d, &imm, 8);
memcpy(&d, &imm, 8);
return d;
}
......
......@@ -699,7 +699,7 @@ void Simulator::CheckICache(v8::internal::HashMap* i_cache,
cache_page->CachedData(offset), Instruction::kInstrSize));
} else {
// Cache miss. Load memory into the cache.
MemCopy(cached_line, line, CachePage::kLineLength);
memcpy(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])];
MemCopy(buffer, &registers_[reg], 2 * sizeof(registers_[0]));
MemCopy(&dm_val, buffer, 2 * sizeof(registers_[0]));
memcpy(buffer, &registers_[reg], 2 * sizeof(registers_[0]));
memcpy(&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])];
MemCopy(buffer, &value, register_size * sizeof(vfp_registers_[0]));
MemCopy(&vfp_registers_[reg_index * register_size], buffer,
register_size * sizeof(vfp_registers_[0]));
memcpy(buffer, &value, register_size * sizeof(vfp_registers_[0]));
memcpy(&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])];
MemCopy(buffer, &vfp_registers_[register_size * reg_index],
register_size * sizeof(vfp_registers_[0]));
MemCopy(&value, buffer, register_size * sizeof(vfp_registers_[0]));
memcpy(buffer, &vfp_registers_[register_size * reg_index],
register_size * sizeof(vfp_registers_[0]));
memcpy(&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])];
MemCopy(buffer, &result, sizeof(buffer));
memcpy(buffer, &result, sizeof(buffer));
// Copy result to d0.
MemCopy(vfp_registers_, buffer, sizeof(buffer));
memcpy(vfp_registers_, buffer, sizeof(buffer));
} else {
char buffer[2 * sizeof(registers_[0])];
MemCopy(buffer, &result, sizeof(buffer));
memcpy(buffer, &result, sizeof(buffer));
// Copy result to r0 and r1.
MemCopy(registers_, buffer, sizeof(buffer));
memcpy(registers_, buffer, sizeof(buffer));
}
}
......@@ -1635,12 +1635,12 @@ void Simulator::HandleVList(Instruction* instr) {
ReadW(reinterpret_cast<int32_t>(address + 1), instr)
};
double d;
MemCopy(&d, data, 8);
memcpy(&d, data, 8);
set_d_register_from_double(reg, d);
} else {
int32_t data[2];
double d = get_double_from_d_register(reg);
MemCopy(data, &d, 8);
memcpy(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];
MemCopy(data, &dd_value, 8);
memcpy(data, &dd_value, 8);
data[instr->Bit(21)] = get_register(instr->RtValue());
MemCopy(&dd_value, data, 8);
memcpy(&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];
MemCopy(data, &dn_value, 8);
memcpy(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);
MemCopy(data, &d, 8);
memcpy(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;
MemCopy(&d, data, 8);
memcpy(&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;
MemCopy(&val, data, 8);
memcpy(&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);
MemCopy(data, &val, 8);
memcpy(data, &val, 8);
WriteW(address, data[0], instr);
WriteW(address + 4, data[1], instr);
}
......
......@@ -8,7 +8,6 @@
#include <string.h>
#include "atomicops.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 +61,9 @@ void AtomicOps_Internalx86CPUFeaturesInit() {
// Get vendor string (issue CPUID with eax = 0)
cpuid(eax, ebx, ecx, edx, 0);
char vendor[13];
v8::internal::MemCopy(vendor, &ebx, 4);
v8::internal::MemCopy(vendor + 4, &edx, 4);
v8::internal::MemCopy(vendor + 8, &ecx, 4);
memcpy(vendor, &ebx, 4);
memcpy(vendor + 4, &edx, 4);
memcpy(vendor + 8, &ecx, 4);
vendor[12] = 0;
// get feature flags in ecx/edx, and family/model in eax
......
......@@ -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.
MemCopy(&result, mantissa_ptr, sizeof(result));
memcpy(&result, mantissa_ptr, sizeof(result));
return negative ? ~result + 1 : result;
}
// Large number (outside uint32 range), Infinity or NaN.
......
......@@ -658,7 +658,7 @@ class ELF BASE_EMBEDDED {
#else
#error Unsupported target architecture.
#endif
MemCopy(header->ident, ident, 16);
memcpy(header->ident, ident, 16);
header->type = 1;
#if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
header->machine = 3;
......
......@@ -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;
MemCopy(&i, &d, 8);
memcpy(&i, &d, 8);
*lo = i & 0xffffffff;
*hi = i >> 32;
......
......@@ -845,7 +845,7 @@ void Simulator::CheckICache(v8::internal::HashMap* i_cache,
Instruction::kInstrSize));
} else {
// Cache miss. Load memory into the cache.
MemCopy(cached_line, line, CachePage::kLineLength);
memcpy(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])];
MemCopy(buffer, &registers_[reg], 2 * sizeof(registers_[0]));
MemCopy(&dm_val, buffer, 2 * sizeof(registers_[0]));
memcpy(buffer, &registers_[reg], 2 * sizeof(registers_[0]));
memcpy(&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);
MemCopy(x, buffer, sizeof(buffer));
memcpy(x, buffer, sizeof(buffer));
// Registers a2 and a3 -> y.
reg_buffer[0] = get_register(a2);
reg_buffer[1] = get_register(a3);
MemCopy(y, buffer, sizeof(buffer));
memcpy(y, buffer, sizeof(buffer));
// Register 2 -> z.
reg_buffer[0] = get_register(a2);
MemCopy(z, buffer, sizeof(*z));
memcpy(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);
MemCopy(buffer, &result, sizeof(buffer));
memcpy(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));
MemCopy(buffer, &d0, sizeof(d0));
memcpy(buffer, &d0, sizeof(d0));
set_dw_register(a0, buffer);
MemCopy(buffer, &d1, sizeof(d1));
memcpy(buffer, &d1, sizeof(d1));
set_dw_register(a2, buffer);
}
CallInternal(entry);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment