summaryrefslogtreecommitdiffstats
path: root/runtime/entrypoints
diff options
context:
space:
mode:
authorRoland Levillain <rpl@google.com>2015-03-24 14:36:11 +0000
committerRoland Levillain <rpl@google.com>2015-03-24 16:02:21 +0000
commitda4d79bc9a4aeb9da7c6259ce4c9c1c3bf545eb8 (patch)
tree151dd61c4b6a8fd512ea4c2c862af28b02f4ed9c /runtime/entrypoints
parentaf87659f462ac650009fce295097cae3dabce171 (diff)
downloadart-da4d79bc9a4aeb9da7c6259ce4c9c1c3bf545eb8.zip
art-da4d79bc9a4aeb9da7c6259ce4c9c1c3bf545eb8.tar.gz
art-da4d79bc9a4aeb9da7c6259ce4c9c1c3bf545eb8.tar.bz2
Unify ART's various implementations of bit_cast.
ART had several implementations of art::bit_cast: 1. one in runtime/base/casts.h, declared as: template <class Dest, class Source> inline Dest bit_cast(const Source& source); 2. another one in runtime/utils.h, declared as: template<typename U, typename V> static inline V bit_cast(U in); 3. and a third local version, in runtime/memory_region.h, similar to the previous one: template<typename Source, typename Destination> static Destination MemoryRegion::local_bit_cast(Source in); This CL removes versions 2. and 3. and changes their callers to use 1. instead. That version was chosen over the others as: - it was the oldest one in the code base; and - its syntax was closer to the standard C++ cast operators, as it supports the following use: bit_cast<Destination>(source) since `Source' can be deduced from `source'. Change-Id: I7334fd5d55bf0b8a0c52cb33cfbae6894ff83633
Diffstat (limited to 'runtime/entrypoints')
-rw-r--r--runtime/entrypoints/quick/quick_trampoline_entrypoints.cc18
1 files changed, 9 insertions, 9 deletions
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 5eb97d8..8351e22 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -1184,7 +1184,7 @@ template<class T> class BuildNativeCallFrameStateMachine {
gpr_index_--;
if (kMultiGPRegistersWidened) {
DCHECK_EQ(sizeof(uintptr_t), sizeof(int64_t));
- PushGpr(static_cast<int64_t>(bit_cast<uint32_t, int32_t>(val)));
+ PushGpr(static_cast<int64_t>(bit_cast<int32_t, uint32_t>(val)));
} else {
PushGpr(val);
}
@@ -1192,7 +1192,7 @@ template<class T> class BuildNativeCallFrameStateMachine {
stack_entries_++;
if (kMultiGPRegistersWidened) {
DCHECK_EQ(sizeof(uintptr_t), sizeof(int64_t));
- PushStack(static_cast<int64_t>(bit_cast<uint32_t, int32_t>(val)));
+ PushStack(static_cast<int64_t>(bit_cast<int32_t, uint32_t>(val)));
} else {
PushStack(val);
}
@@ -1252,16 +1252,16 @@ template<class T> class BuildNativeCallFrameStateMachine {
void AdvanceFloat(float val) {
if (kNativeSoftFloatAbi) {
- AdvanceInt(bit_cast<float, uint32_t>(val));
+ AdvanceInt(bit_cast<uint32_t, float>(val));
} else {
if (HaveFloatFpr()) {
fpr_index_--;
if (kRegistersNeededForDouble == 1) {
if (kMultiFPRegistersWidened) {
- PushFpr8(bit_cast<double, uint64_t>(val));
+ PushFpr8(bit_cast<uint64_t, double>(val));
} else {
// No widening, just use the bits.
- PushFpr8(bit_cast<float, uint64_t>(val));
+ PushFpr8(static_cast<uint64_t>(bit_cast<uint32_t, float>(val)));
}
} else {
PushFpr4(val);
@@ -1272,9 +1272,9 @@ template<class T> class BuildNativeCallFrameStateMachine {
// Need to widen before storing: Note the "double" in the template instantiation.
// Note: We need to jump through those hoops to make the compiler happy.
DCHECK_EQ(sizeof(uintptr_t), sizeof(uint64_t));
- PushStack(static_cast<uintptr_t>(bit_cast<double, uint64_t>(val)));
+ PushStack(static_cast<uintptr_t>(bit_cast<uint64_t, double>(val)));
} else {
- PushStack(bit_cast<float, uintptr_t>(val));
+ PushStack(static_cast<uintptr_t>(bit_cast<uint32_t, float>(val)));
}
fpr_index_ = 0;
}
@@ -1908,8 +1908,8 @@ extern "C" uint64_t artQuickGenericJniEndTrampoline(Thread* self, jvalue result,
case 'F': {
if (kRuntimeISA == kX86) {
// Convert back the result to float.
- double d = bit_cast<uint64_t, double>(result_f);
- return bit_cast<float, uint32_t>(static_cast<float>(d));
+ double d = bit_cast<double, uint64_t>(result_f);
+ return bit_cast<uint32_t, float>(static_cast<float>(d));
} else {
return result_f;
}