Commit b93e4d2c authored by jochen's avatar jochen Committed by Commit bot

Initialize fast memmove methods in the Isolate's ctor

BUG=v8:2487
R=yangguo@chromium.org
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#32344}
parent a9bdee1f
...@@ -79,7 +79,8 @@ UnaryMathFunctionWithIsolate CreateExpFunction(Isolate* isolate) { ...@@ -79,7 +79,8 @@ UnaryMathFunctionWithIsolate CreateExpFunction(Isolate* isolate) {
} }
#if defined(V8_HOST_ARCH_ARM) #if defined(V8_HOST_ARCH_ARM)
MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { MemCopyUint8Function CreateMemCopyUint8Function(Isolate* isolate,
MemCopyUint8Function stub) {
#if defined(USE_SIMULATOR) #if defined(USE_SIMULATOR)
return stub; return stub;
#else #else
...@@ -87,9 +88,9 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { ...@@ -87,9 +88,9 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) {
size_t actual_size; size_t actual_size;
byte* buffer = byte* buffer =
static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true));
if (buffer == NULL) return stub; if (buffer == nullptr) return stub;
MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size), MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size),
CodeObjectRequired::kNo); CodeObjectRequired::kNo);
Register dest = r0; Register dest = r0;
...@@ -228,7 +229,7 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { ...@@ -228,7 +229,7 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) {
masm.GetCode(&desc); masm.GetCode(&desc);
DCHECK(!RelocInfo::RequiresRelocation(desc)); DCHECK(!RelocInfo::RequiresRelocation(desc));
Assembler::FlushICacheWithoutIsolate(buffer, actual_size); Assembler::FlushICache(isolate, buffer, actual_size);
base::OS::ProtectCode(buffer, actual_size); base::OS::ProtectCode(buffer, actual_size);
return FUNCTION_CAST<MemCopyUint8Function>(buffer); return FUNCTION_CAST<MemCopyUint8Function>(buffer);
#endif #endif
...@@ -237,7 +238,7 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { ...@@ -237,7 +238,7 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) {
// Convert 8 to 16. The number of character to copy must be at least 8. // Convert 8 to 16. The number of character to copy must be at least 8.
MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function( MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function(
MemCopyUint16Uint8Function stub) { Isolate* isolate, MemCopyUint16Uint8Function stub) {
#if defined(USE_SIMULATOR) #if defined(USE_SIMULATOR)
return stub; return stub;
#else #else
...@@ -245,9 +246,9 @@ MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function( ...@@ -245,9 +246,9 @@ MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function(
size_t actual_size; size_t actual_size;
byte* buffer = byte* buffer =
static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true));
if (buffer == NULL) return stub; if (buffer == nullptr) return stub;
MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size), MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size),
CodeObjectRequired::kNo); CodeObjectRequired::kNo);
Register dest = r0; Register dest = r0;
...@@ -316,7 +317,7 @@ MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function( ...@@ -316,7 +317,7 @@ MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function(
CodeDesc desc; CodeDesc desc;
masm.GetCode(&desc); masm.GetCode(&desc);
Assembler::FlushICacheWithoutIsolate(buffer, actual_size); Assembler::FlushICache(isolate, buffer, actual_size);
base::OS::ProtectCode(buffer, actual_size); base::OS::ProtectCode(buffer, actual_size);
return FUNCTION_CAST<MemCopyUint16Uint8Function>(buffer); return FUNCTION_CAST<MemCopyUint16Uint8Function>(buffer);
......
...@@ -187,13 +187,13 @@ class LabelConverter { ...@@ -187,13 +187,13 @@ class LabelConverter {
}; };
MemMoveFunction CreateMemMoveFunction() { MemMoveFunction CreateMemMoveFunction(Isolate* isolate) {
size_t actual_size; size_t actual_size;
// Allocate buffer in executable space. // Allocate buffer in executable space.
byte* buffer = byte* buffer =
static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true));
if (buffer == NULL) return NULL; if (buffer == nullptr) return nullptr;
MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size), MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size),
CodeObjectRequired::kNo); CodeObjectRequired::kNo);
LabelConverter conv(buffer); LabelConverter conv(buffer);
...@@ -507,7 +507,7 @@ MemMoveFunction CreateMemMoveFunction() { ...@@ -507,7 +507,7 @@ MemMoveFunction CreateMemMoveFunction() {
CodeDesc desc; CodeDesc desc;
masm.GetCode(&desc); masm.GetCode(&desc);
DCHECK(!RelocInfo::RequiresRelocation(desc)); DCHECK(!RelocInfo::RequiresRelocation(desc));
Assembler::FlushICacheWithoutIsolate(buffer, actual_size); Assembler::FlushICache(isolate, buffer, actual_size);
base::OS::ProtectCode(buffer, actual_size); base::OS::ProtectCode(buffer, actual_size);
// TODO(jkummerow): It would be nice to register this code creation event // TODO(jkummerow): It would be nice to register this code creation event
// with the PROFILE / GDBJIT system. // with the PROFILE / GDBJIT system.
......
...@@ -1836,6 +1836,8 @@ Isolate::Isolate(bool enable_serializer) ...@@ -1836,6 +1836,8 @@ Isolate::Isolate(bool enable_serializer)
InitializeLoggingAndCounters(); InitializeLoggingAndCounters();
debug_ = new Debug(this); debug_ = new Debug(this);
init_memcopy_functions(this);
} }
......
...@@ -71,7 +71,8 @@ UnaryMathFunctionWithIsolate CreateExpFunction(Isolate* isolate) { ...@@ -71,7 +71,8 @@ UnaryMathFunctionWithIsolate CreateExpFunction(Isolate* isolate) {
#if defined(V8_HOST_ARCH_MIPS) #if defined(V8_HOST_ARCH_MIPS)
MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { MemCopyUint8Function CreateMemCopyUint8Function(Isolate* isolate,
MemCopyUint8Function stub) {
#if defined(USE_SIMULATOR) || defined(_MIPS_ARCH_MIPS32R6) || \ #if defined(USE_SIMULATOR) || defined(_MIPS_ARCH_MIPS32R6) || \
defined(_MIPS_ARCH_MIPS32RX) defined(_MIPS_ARCH_MIPS32RX)
return stub; return stub;
...@@ -79,11 +80,11 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { ...@@ -79,11 +80,11 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) {
size_t actual_size; size_t actual_size;
byte* buffer = byte* buffer =
static_cast<byte*>(base::OS::Allocate(3 * KB, &actual_size, true)); static_cast<byte*>(base::OS::Allocate(3 * KB, &actual_size, true));
if (buffer == NULL) return stub; if (buffer == nullptr) return stub;
// This code assumes that cache lines are 32 bytes and if the cache line is // This code assumes that cache lines are 32 bytes and if the cache line is
// larger it will not work correctly. // larger it will not work correctly.
MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size), MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size),
CodeObjectRequired::kNo); CodeObjectRequired::kNo);
{ {
...@@ -597,7 +598,7 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { ...@@ -597,7 +598,7 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) {
masm.GetCode(&desc); masm.GetCode(&desc);
DCHECK(!RelocInfo::RequiresRelocation(desc)); DCHECK(!RelocInfo::RequiresRelocation(desc));
Assembler::FlushICacheWithoutIsolate(buffer, actual_size); Assembler::FlushICache(isolate, buffer, actual_size);
base::OS::ProtectCode(buffer, actual_size); base::OS::ProtectCode(buffer, actual_size);
return FUNCTION_CAST<MemCopyUint8Function>(buffer); return FUNCTION_CAST<MemCopyUint8Function>(buffer);
#endif #endif
......
...@@ -71,7 +71,8 @@ UnaryMathFunctionWithIsolate CreateExpFunction(Isolate* isolate) { ...@@ -71,7 +71,8 @@ UnaryMathFunctionWithIsolate CreateExpFunction(Isolate* isolate) {
#if defined(V8_HOST_ARCH_MIPS) #if defined(V8_HOST_ARCH_MIPS)
MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { MemCopyUint8Function CreateMemCopyUint8Function(Isolate* isolate,
MemCopyUint8Function stub) {
#if defined(USE_SIMULATOR) #if defined(USE_SIMULATOR)
return stub; return stub;
#else #else
...@@ -79,11 +80,11 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { ...@@ -79,11 +80,11 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) {
size_t actual_size; size_t actual_size;
byte* buffer = byte* buffer =
static_cast<byte*>(base::OS::Allocate(3 * KB, &actual_size, true)); static_cast<byte*>(base::OS::Allocate(3 * KB, &actual_size, true));
if (buffer == NULL) return stub; if (buffer == nullptr) return stub;
// This code assumes that cache lines are 32 bytes and if the cache line is // This code assumes that cache lines are 32 bytes and if the cache line is
// larger it will not work correctly. // larger it will not work correctly.
MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size), MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size),
CodeObjectRequired::kNo); CodeObjectRequired::kNo);
{ {
...@@ -598,7 +599,7 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { ...@@ -598,7 +599,7 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) {
masm.GetCode(&desc); masm.GetCode(&desc);
DCHECK(!RelocInfo::RequiresRelocation(desc)); DCHECK(!RelocInfo::RequiresRelocation(desc));
Assembler::FlushICacheWithoutIsolate(buffer, actual_size); Assembler::FlushICache(isolate, buffer, actual_size);
base::OS::ProtectCode(buffer, actual_size); base::OS::ProtectCode(buffer, actual_size);
return FUNCTION_CAST<MemCopyUint8Function>(buffer); return FUNCTION_CAST<MemCopyUint8Function>(buffer);
#endif #endif
......
...@@ -368,7 +368,7 @@ static void MemMoveWrapper(void* dest, const void* src, size_t size) { ...@@ -368,7 +368,7 @@ static void MemMoveWrapper(void* dest, const void* src, size_t size) {
static MemMoveFunction memmove_function = &MemMoveWrapper; static MemMoveFunction memmove_function = &MemMoveWrapper;
// Defined in codegen-ia32.cc. // Defined in codegen-ia32.cc.
MemMoveFunction CreateMemMoveFunction(); MemMoveFunction CreateMemMoveFunction(Isolate* isolate);
// Copy memory area to disjoint memory area. // Copy memory area to disjoint memory area.
void MemMove(void* dest, const void* src, size_t size) { void MemMove(void* dest, const void* src, size_t size) {
...@@ -392,29 +392,38 @@ MemCopyUint8Function memcopy_uint8_function = &MemCopyUint8Wrapper; ...@@ -392,29 +392,38 @@ MemCopyUint8Function memcopy_uint8_function = &MemCopyUint8Wrapper;
MemCopyUint16Uint8Function memcopy_uint16_uint8_function = MemCopyUint16Uint8Function memcopy_uint16_uint8_function =
&MemCopyUint16Uint8Wrapper; &MemCopyUint16Uint8Wrapper;
// Defined in codegen-arm.cc. // Defined in codegen-arm.cc.
MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub); MemCopyUint8Function CreateMemCopyUint8Function(Isolate* isolate,
MemCopyUint8Function stub);
MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function( MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function(
MemCopyUint16Uint8Function stub); Isolate* isolate, MemCopyUint16Uint8Function stub);
#elif V8_OS_POSIX && V8_HOST_ARCH_MIPS #elif V8_OS_POSIX && V8_HOST_ARCH_MIPS
MemCopyUint8Function memcopy_uint8_function = &MemCopyUint8Wrapper; MemCopyUint8Function memcopy_uint8_function = &MemCopyUint8Wrapper;
// Defined in codegen-mips.cc. // Defined in codegen-mips.cc.
MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub); MemCopyUint8Function CreateMemCopyUint8Function(Isolate* isolate,
MemCopyUint8Function stub);
#endif #endif
void init_memcopy_functions() { static bool g_memcopy_functions_initialized = false;
void init_memcopy_functions(Isolate* isolate) {
if (g_memcopy_functions_initialized) return;
g_memcopy_functions_initialized = true;
#if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
MemMoveFunction generated_memmove = CreateMemMoveFunction(); MemMoveFunction generated_memmove = CreateMemMoveFunction(isolate);
if (generated_memmove != NULL) { if (generated_memmove != NULL) {
memmove_function = generated_memmove; memmove_function = generated_memmove;
} }
#elif V8_OS_POSIX && V8_HOST_ARCH_ARM #elif V8_OS_POSIX && V8_HOST_ARCH_ARM
memcopy_uint8_function = CreateMemCopyUint8Function(&MemCopyUint8Wrapper); memcopy_uint8_function =
CreateMemCopyUint8Function(isolate, &MemCopyUint8Wrapper);
memcopy_uint16_uint8_function = memcopy_uint16_uint8_function =
CreateMemCopyUint16Uint8Function(&MemCopyUint16Uint8Wrapper); CreateMemCopyUint16Uint8Function(isolate, &MemCopyUint16Uint8Wrapper);
#elif V8_OS_POSIX && V8_HOST_ARCH_MIPS #elif V8_OS_POSIX && V8_HOST_ARCH_MIPS
memcopy_uint8_function = CreateMemCopyUint8Function(&MemCopyUint8Wrapper); memcopy_uint8_function =
CreateMemCopyUint8Function(isolate, &MemCopyUint8Wrapper);
#endif #endif
} }
......
...@@ -366,9 +366,8 @@ inline uint32_t ComputePointerHash(void* ptr) { ...@@ -366,9 +366,8 @@ inline uint32_t ComputePointerHash(void* ptr) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Generated memcpy/memmove // Generated memcpy/memmove
// Initializes the codegen support that depends on CPU features. This is // Initializes the codegen support that depends on CPU features.
// called after CPU initialization. void init_memcopy_functions(Isolate* isolate);
void init_memcopy_functions();
#if defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_X87) #if defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_X87)
// Limit below which the extra overhead of the MemCopy function is likely // Limit below which the extra overhead of the MemCopy function is likely
......
...@@ -79,7 +79,6 @@ void V8::InitializeOncePerProcessImpl() { ...@@ -79,7 +79,6 @@ void V8::InitializeOncePerProcessImpl() {
Sampler::SetUp(); Sampler::SetUp();
CpuFeatures::Probe(false); CpuFeatures::Probe(false);
init_memcopy_functions();
ElementsAccessor::InitializeOncePerProcess(); ElementsAccessor::InitializeOncePerProcess();
LOperand::SetUpCaches(); LOperand::SetUpCaches();
SetUpJSCallerSavedCodeData(); SetUpJSCallerSavedCodeData();
......
...@@ -94,13 +94,13 @@ class LabelConverter { ...@@ -94,13 +94,13 @@ class LabelConverter {
}; };
MemMoveFunction CreateMemMoveFunction() { MemMoveFunction CreateMemMoveFunction(Isolate* isolate) {
size_t actual_size; size_t actual_size;
// Allocate buffer in executable space. // Allocate buffer in executable space.
byte* buffer = byte* buffer =
static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true));
if (buffer == NULL) return NULL; if (buffer == nullptr) return nullptr;
MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size), MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size),
CodeObjectRequired::kNo); CodeObjectRequired::kNo);
LabelConverter conv(buffer); LabelConverter conv(buffer);
...@@ -201,7 +201,7 @@ MemMoveFunction CreateMemMoveFunction() { ...@@ -201,7 +201,7 @@ MemMoveFunction CreateMemMoveFunction() {
CodeDesc desc; CodeDesc desc;
masm.GetCode(&desc); masm.GetCode(&desc);
DCHECK(!RelocInfo::RequiresRelocation(desc)); DCHECK(!RelocInfo::RequiresRelocation(desc));
Assembler::FlushICacheWithoutIsolate(buffer, actual_size); Assembler::FlushICache(isolate, buffer, actual_size);
base::OS::ProtectCode(buffer, actual_size); base::OS::ProtectCode(buffer, actual_size);
// TODO(jkummerow): It would be nice to register this code creation event // TODO(jkummerow): It would be nice to register this code creation event
// with the PROFILE / GDBJIT system. // with the PROFILE / GDBJIT system.
......
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