Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/os.h" | 9 #include "vm/os.h" |
| 10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1034 __ jalr(R2, RA); | 1034 __ jalr(R2, RA); |
| 1035 __ delay_slot()->ori(V0, ZR, Immediate(42)); | 1035 __ delay_slot()->ori(V0, ZR, Immediate(42)); |
| 1036 } | 1036 } |
| 1037 | 1037 |
| 1038 | 1038 |
| 1039 ASSEMBLER_TEST_RUN(Jalr_delay, test) { | 1039 ASSEMBLER_TEST_RUN(Jalr_delay, test) { |
| 1040 typedef int (*SimpleCode)(); | 1040 typedef int (*SimpleCode)(); |
| 1041 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry())); | 1041 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry())); |
| 1042 } | 1042 } |
| 1043 | 1043 |
| 1044 | |
| 1045 ASSEMBLER_TEST_GENERATE(AddOverflow_detect, assembler) { | |
| 1046 Label error, success; | |
|
regis
2013/04/05 23:23:45
"success" is actually "done".
zra
2013/04/06 00:04:19
Done.
| |
| 1047 __ LoadImmediate(V0, 1); // Success value. | |
| 1048 | |
| 1049 __ LoadImmediate(T0, 0x7fffffff); | |
| 1050 __ LoadImmediate(T1, 1); | |
| 1051 __ AdduDetectOverflow(T2, T1, T0, T3); | |
| 1052 __ bgez(T3, &error); // INT_MAX + 1 overflows. | |
| 1053 | |
| 1054 __ LoadImmediate(T0, 0x7fffffff); | |
| 1055 __ LoadImmediate(T1, 0x7fffffff); | |
| 1056 __ AdduDetectOverflow(T2, T1, T0, T3); | |
| 1057 __ bgez(T3, &error); // INT_MAX + INT_MAX overflows. | |
| 1058 | |
| 1059 __ LoadImmediate(T0, 0x7fffffff); | |
| 1060 __ LoadImmediate(T1, -1); | |
| 1061 __ AdduDetectOverflow(T2, T1, T0, T3); | |
| 1062 __ bltz(T3, &error); // INT_MAX - 1 does not overflow. | |
| 1063 | |
| 1064 __ LoadImmediate(T0, -1); | |
| 1065 __ LoadImmediate(T1, 1); | |
| 1066 __ AdduDetectOverflow(T2, T1, T0, T3); | |
| 1067 __ bltz(T3, &error); // -1 + 1 does not overflow. | |
| 1068 | |
| 1069 __ LoadImmediate(T0, 123456); | |
| 1070 __ LoadImmediate(T1, 654321); | |
| 1071 __ AdduDetectOverflow(T2, T1, T0, T3); | |
| 1072 __ bltz(T3, &error); // 123456 + 654321 does not overflow. | |
| 1073 | |
| 1074 __ LoadImmediate(T0, 0x80000000); | |
| 1075 __ LoadImmediate(T1, -1); | |
| 1076 __ AdduDetectOverflow(T2, T1, T0, T3); | |
| 1077 __ bgez(T3, &error); // INT_MIN - 1 overflows. | |
| 1078 | |
| 1079 __ LoadImmediate(T0, 0x80000000); | |
| 1080 __ LoadImmediate(T1, 0x80000000); | |
| 1081 __ AdduDetectOverflow(T2, T1, T0, T3); | |
| 1082 __ bgez(T3, &error); // INT_MIN + INT_MIN overflows. | |
| 1083 | |
| 1084 __ LoadImmediate(T0, -123456); | |
| 1085 __ LoadImmediate(T1, -654321); | |
| 1086 __ AdduDetectOverflow(T2, T1, T0, T3); | |
| 1087 __ bltz(T3, &error); // -123456 + -654321 does not overflow. | |
| 1088 | |
| 1089 __ b(&success); | |
| 1090 __ Bind(&error); | |
| 1091 __ mov(V0, ZR); | |
| 1092 __ Bind(&success); | |
| 1093 __ Ret(); | |
| 1094 } | |
| 1095 | |
| 1096 | |
| 1097 ASSEMBLER_TEST_RUN(AddOverflow_detect, test) { | |
| 1098 typedef int (*SimpleCode)(); | |
| 1099 EXPECT_EQ(1, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry())); | |
| 1100 } | |
| 1101 | |
| 1044 } // namespace dart | 1102 } // namespace dart |
| 1045 | 1103 |
| 1046 #endif // defined TARGET_ARCH_MIPS | 1104 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |