summaryrefslogtreecommitdiffstats
path: root/runtime/utils.h
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2014-06-16 18:39:09 -0700
committerAndreas Gampe <agampe@google.com>2014-07-01 11:06:24 -0700
commitc200a4abeca91e19969f5b35543f17f812ba32b9 (patch)
tree5912a08310e7ddb4b3907c0dc687006669c0cedd /runtime/utils.h
parent73904fed884bf216b51acdc64402c427cc34725b (diff)
downloadart-c200a4abeca91e19969f5b35543f17f812ba32b9.tar.gz
art-c200a4abeca91e19969f5b35543f17f812ba32b9.tar.bz2
art-c200a4abeca91e19969f5b35543f17f812ba32b9.zip
ART: Rework Generic JNI, add ARM version
Refactors and optimizes Generic JNI. This version uses TwoWordReturn to avoid writing to / loading from the bottom of the alloca. Change-Id: I3287007c976f79c9fd32d3b3a43f2d1371bf4cd3
Diffstat (limited to 'runtime/utils.h')
-rw-r--r--runtime/utils.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/runtime/utils.h b/runtime/utils.h
index 68ea47541b..eb79968e21 100644
--- a/runtime/utils.h
+++ b/runtime/utils.h
@@ -203,6 +203,19 @@ static inline bool NeedsEscaping(uint16_t ch) {
return (ch < ' ' || ch > '~');
}
+// Interpret the bit pattern of input (type U) as type V. Requires the size
+// of V >= size of U (compile-time checked).
+template<typename U, typename V>
+static inline V bit_cast(U in) {
+ COMPILE_ASSERT(sizeof(U) <= sizeof(V), size_of_u_not_le_size_of_v);
+ union {
+ U u;
+ V v;
+ } tmp;
+ tmp.u = in;
+ return tmp.v;
+}
+
std::string PrintableChar(uint16_t ch);
// Returns an ASCII string corresponding to the given UTF-8 string.