Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(744)

Unified Diff: runtime/vm/simulator_dbc.cc

Issue 1904153003: DBC: Adds simdbc64 target, adds arm64 arithmetic overflow logic (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/boringssl/boringssl_configurations.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/simulator_dbc.cc
diff --git a/runtime/vm/simulator_dbc.cc b/runtime/vm/simulator_dbc.cc
index 8623a643e1db258ea960f2d3abdb5679f76cd1d7..fab3a10e2d3ae5ae43612ddd6575b38db2752c58 100644
--- a/runtime/vm/simulator_dbc.cc
+++ b/runtime/vm/simulator_dbc.cc
@@ -106,11 +106,13 @@ DART_FORCE_INLINE static RawObject** FrameArguments(RawObject** FP,
class SimulatorHelpers {
public:
DART_FORCE_INLINE static RawSmi* GetClassIdAsSmi(RawObject* obj) {
- return Smi::New(obj->IsHeapObject() ? obj->GetClassId() : kSmiCid);
+ return Smi::New(obj->IsHeapObject() ? obj->GetClassId()
+ : static_cast<intptr_t>(kSmiCid));
}
DART_FORCE_INLINE static intptr_t GetClassId(RawObject* obj) {
- return obj->IsHeapObject() ? obj->GetClassId() : kSmiCid;
+ return obj->IsHeapObject() ? obj->GetClassId()
+ : static_cast<intptr_t>(kSmiCid);
}
DART_FORCE_INLINE static void IncrementUsageCounter(RawICData* icdata) {
@@ -338,27 +340,11 @@ void Simulator::Exit(Thread* thread,
}
-#if defined(__has_builtin)
Vyacheslav Egorov (Google) 2016/04/22 06:22:04 Where did this go? Inline assembly is just a fall
zra 2016/04/22 19:40:49 I found the problem with the intrinsics. Their use
Vyacheslav Egorov (Google) 2016/04/23 18:58:35 Good catch! Alternative would be to just rewrite S
zra 2016/04/25 15:42:56 Assuming the intrinsic does a branch to decide the
-#if __has_builtin(__builtin_smul_overflow)
-#define HAS_MUL_OVERFLOW
-#endif
-#if __has_builtin(__builtin_sadd_overflow)
-#define HAS_ADD_OVERFLOW
-#endif
-#if __has_builtin(__builtin_ssub_overflow)
-#define HAS_SUB_OVERFLOW
-#endif
-#endif
-
-
-DART_FORCE_INLINE static bool SignedAddWithOverflow(int32_t lhs,
- int32_t rhs,
+DART_FORCE_INLINE static bool SignedAddWithOverflow(intptr_t lhs,
+ intptr_t rhs,
intptr_t* out) {
int32_t res = 1;
Vyacheslav Egorov (Google) 2016/04/22 06:22:04 if you make this intptr_t then both ARM and ARM64
zra 2016/04/22 19:40:49 Done.
-#if defined(HAS_ADD_OVERFLOW)
- res = static_cast<int32_t>(__builtin_sadd_overflow(
- lhs, rhs, reinterpret_cast<int32_t*>(out)));
-#elif defined(__i386__)
+#if defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64)
asm volatile(
"add %2, %1\n"
Ivan Posva 2016/04/21 23:35:15 Shouldn't this be at least an addq for HOST_ARCH_X
zra 2016/04/22 19:40:49 The correct ops for the types of the provided oper
"jo 1f;\n"
@@ -368,7 +354,7 @@ DART_FORCE_INLINE static bool SignedAddWithOverflow(int32_t lhs,
: "+r"(res), "+r"(lhs)
: "r"(rhs), "r"(out)
: "cc");
-#elif defined(__arm__)
+#elif defined(HOST_ARCH_ARM)
asm volatile(
"adds %1, %1, %2;\n"
"bvs 1f;\n"
@@ -378,6 +364,16 @@ DART_FORCE_INLINE static bool SignedAddWithOverflow(int32_t lhs,
: "+r"(res), "+r"(lhs)
: "r"(rhs), "r"(out)
: "cc", "r12");
+#elif defined(HOST_ARCH_ARM64)
+ asm volatile(
+ "adds %1, %1, %2;\n"
+ "bvs 1f;\n"
+ "mov %w0, #0;\n"
+ "str %1, [%3, #0]\n"
+ "1:"
+ : "+r"(res), "+r"(lhs)
+ : "r"(rhs), "r"(out)
+ : "cc");
#else
#error "Unsupported platform"
#endif
@@ -385,14 +381,11 @@ DART_FORCE_INLINE static bool SignedAddWithOverflow(int32_t lhs,
}
-DART_FORCE_INLINE static bool SignedSubWithOverflow(int32_t lhs,
- int32_t rhs,
+DART_FORCE_INLINE static bool SignedSubWithOverflow(intptr_t lhs,
+ intptr_t rhs,
intptr_t* out) {
int32_t res = 1;
-#if defined(HAS_SUB_OVERFLOW)
- res = static_cast<int32_t>(__builtin_ssub_overflow(
- lhs, rhs, reinterpret_cast<int32_t*>(out)));
-#elif defined(__i386__)
+#if defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64)
Ivan Posva 2016/04/21 23:35:15 dittoq
zra 2016/04/22 19:40:49 Acknowledged.
asm volatile(
"sub %2, %1\n"
"jo 1f;\n"
@@ -402,7 +395,7 @@ DART_FORCE_INLINE static bool SignedSubWithOverflow(int32_t lhs,
: "+r"(res), "+r"(lhs)
: "r"(rhs), "r"(out)
: "cc");
-#elif defined(__arm__)
+#elif defined(HOST_ARCH_ARM)
asm volatile(
"subs %1, %1, %2;\n"
"bvs 1f;\n"
@@ -412,6 +405,16 @@ DART_FORCE_INLINE static bool SignedSubWithOverflow(int32_t lhs,
: "+r"(res), "+r"(lhs)
: "r"(rhs), "r"(out)
: "cc", "r12");
+#elif defined(HOST_ARCH_ARM64)
+ asm volatile(
+ "subs %1, %1, %2;\n"
+ "bvs 1f;\n"
+ "mov %w0, #0;\n"
+ "str %1, [%3, #0]\n"
+ "1:"
+ : "+r"(res), "+r"(lhs)
+ : "r"(rhs), "r"(out)
+ : "cc");
#else
#error "Unsupported platform"
#endif
@@ -419,14 +422,11 @@ DART_FORCE_INLINE static bool SignedSubWithOverflow(int32_t lhs,
}
-DART_FORCE_INLINE static bool SignedMulWithOverflow(int32_t lhs,
- int32_t rhs,
+DART_FORCE_INLINE static bool SignedMulWithOverflow(intptr_t lhs,
+ intptr_t rhs,
intptr_t* out) {
int32_t res = 1;
-#if defined(HAS_MUL_OVERFLOW)
- res = static_cast<int32_t>(__builtin_smul_overflow(
- lhs, rhs, reinterpret_cast<int32_t*>(out)));
-#elif defined(__i386__)
+#if defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64)
Ivan Posva 2016/04/21 23:35:15 dittoq
zra 2016/04/22 19:40:49 Acknowledged.
asm volatile(
"imul %2, %1\n"
"jo 1f;\n"
@@ -436,7 +436,7 @@ DART_FORCE_INLINE static bool SignedMulWithOverflow(int32_t lhs,
: "+r"(res), "+r"(lhs)
: "r"(rhs), "r"(out)
: "cc");
-#elif defined(__arm__)
+#elif defined(HOST_ARCH_ARM)
asm volatile(
"smull %1, ip, %1, %2;\n"
"cmp ip, %1, ASR #31;\n"
@@ -447,6 +447,19 @@ DART_FORCE_INLINE static bool SignedMulWithOverflow(int32_t lhs,
: "+r"(res), "+r"(lhs)
: "r"(rhs), "r"(out)
: "cc", "r12");
+#elif defined(HOST_ARCH_ARM64)
+ int64_t prod_lo;
+ asm volatile(
+ "mul %1, %2, %3\n"
+ "smulh %2, %2, %3\n"
+ "cmp %2, %1, ASR #63;\n"
+ "bne 1f;\n"
+ "mov %w0, #0;\n"
+ "str %1, [%4, #0]\n"
+ "1:"
+ : "+r"(res), "+r"(prod_lo), "+r"(lhs)
+ : "r"(rhs), "r"(out)
+ : "cc");
#else
#error "Unsupported platform"
#endif
« no previous file with comments | « no previous file | third_party/boringssl/boringssl_configurations.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698