From 586f64e1f3c9d46bf57105beaaef4ffedad6ef8f Mon Sep 17 00:00:00 2001 From: "svenpanne@chromium.org" Date: Fri, 21 Mar 2014 08:03:26 +0000 Subject: [PATCH] Revert "Use constant length for memcpy on A64 simulator." This reverts commit r20141 which broke the build with some GCC versions. The reason behind that is GCC emits a warning about code which can never be reached, but GCC can't figure that out. The right approach would be using template specialization instead of these runtime if/then/else cascades, which would be nicer from a SW engineering perspective, too. TBR=yangguo@chromium.org Review URL: https://codereview.chromium.org/207703003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20142 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/a64/simulator-a64.h | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/a64/simulator-a64.h b/src/a64/simulator-a64.h index db58534..1ef891a 100644 --- a/src/a64/simulator-a64.h +++ b/src/a64/simulator-a64.h @@ -166,18 +166,10 @@ class SimRegisterBase { void Set(T new_value, unsigned size = sizeof(T)) { ASSERT(size <= kSizeInBytes); ASSERT(size <= sizeof(new_value)); - STATIC_ASSERT(kXRegSize == kDRegSize); - STATIC_ASSERT(kWRegSize == kSRegSize); // All AArch64 registers are zero-extending; Writing a W register clears the // top bits of the corresponding X register. - if (size == kXRegSize) { - memcpy(value_, &new_value, kXRegSize); - } else if (size == kWRegSize) { - memset(value_, 0, kSizeInBytes); - memcpy(value_, &new_value, kWRegSize); - } else { - UNREACHABLE(); - } + memset(value_, 0, kSizeInBytes); + memcpy(value_, &new_value, size); } // Copy 'size' bytes of the register to the result, and zero-extend to fill @@ -186,14 +178,8 @@ class SimRegisterBase { T Get(unsigned size = sizeof(T)) const { ASSERT(size <= kSizeInBytes); T result; - if (size == kXRegSize) { - memcpy(&result, value_, kXRegSize); - } else if (size == kWRegSize) { - memset(&result, 0, sizeof(result)); - memcpy(&result, value_, kWRegSize); - } else { - UNREACHABLE(); - } + memset(&result, 0, sizeof(result)); + memcpy(&result, value_, size); return result; } -- 2.7.4