Reviewers: Michael Starzinger,

Message:
PTAL.

Description:
OS::MemMove/OS::MemCopy: Don't call through to generated code when size == 0 to
avoid prefetching invalid memory

BUG=chromium:233500

Please review this at https://codereview.chromium.org/14365011/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/ia32/codegen-ia32.cc
  M src/platform-posix.cc
  M src/platform-win32.cc


Index: src/ia32/codegen-ia32.cc
diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc
index caf808b953731c2a3adbfd56fe3cbf4ca9386526..7663c6a7fd37bd58b466a68db8b4eb86cc436cbc 100644
--- a/src/ia32/codegen-ia32.cc
+++ b/src/ia32/codegen-ia32.cc
@@ -635,6 +635,8 @@ OS::MemMoveFunction CreateMemMoveFunction() {
   ASSERT(!RelocInfo::RequiresRelocation(desc));
   CPU::FlushICache(buffer, actual_size);
   OS::ProtectCode(buffer, actual_size);
+  // TODO(jkummerow): It would be nice to register this code creation event
+  // with the PROFILE / GDBJIT system.
   return FUNCTION_CAST<OS::MemMoveFunction>(buffer);
 }

Index: src/platform-posix.cc
diff --git a/src/platform-posix.cc b/src/platform-posix.cc
index 48898ed9aad0acdb4cc06ccba4b01c9818f26de4..9f650d1e5b5c3b7bcad6ee53fc2b8921cad7580a 100644
--- a/src/platform-posix.cc
+++ b/src/platform-posix.cc
@@ -334,6 +334,7 @@ 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);
Index: src/platform-win32.cc
diff --git a/src/platform-win32.cc b/src/platform-win32.cc
index 272678fe649294017e9758000823da0706ab376c..94b78e45bed144d0a17b1aa904d48acf95e35f77 100644
--- a/src/platform-win32.cc
+++ b/src/platform-win32.cc
@@ -160,6 +160,7 @@ 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);


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to