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/cpu.h" | 9 #include "vm/cpu.h" |
10 #include "vm/os.h" | 10 #include "vm/os.h" |
(...skipping 2123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2134 FieldAddress(A1, GrowableObjectArray::data_offset()), | 2134 FieldAddress(A1, GrowableObjectArray::data_offset()), |
2135 A0); | 2135 A0); |
2136 __ lw(RA, Address(SP, 0 * kWordSize)); | 2136 __ lw(RA, Address(SP, 0 * kWordSize)); |
2137 __ lw(THR, Address(SP, 1 * kWordSize)); | 2137 __ lw(THR, Address(SP, 1 * kWordSize)); |
2138 __ lw(CODE_REG, Address(SP, 2 * kWordSize)); | 2138 __ lw(CODE_REG, Address(SP, 2 * kWordSize)); |
2139 __ addiu(SP, SP, Immediate(3 * kWordSize)); | 2139 __ addiu(SP, SP, Immediate(3 * kWordSize)); |
2140 __ Ret(); | 2140 __ Ret(); |
2141 } | 2141 } |
2142 | 2142 |
2143 | 2143 |
2144 ASSEMBLER_TEST_GENERATE(ComputeRange, assembler) { | |
2145 Label miss, done; | |
2146 __ ComputeRange(V0, A0, &miss); | |
2147 __ b(&done); | |
2148 | |
2149 __ Bind(&miss); | |
2150 __ LoadImmediate(V0, -1); | |
2151 | |
2152 __ Bind(&done); | |
2153 __ Ret(); | |
2154 } | |
2155 | |
2156 | |
2157 ASSEMBLER_TEST_RUN(ComputeRange, test) { | |
2158 typedef intptr_t (*ComputeRange)(intptr_t value) DART_UNUSED; | |
2159 | |
2160 #define RANGE_OF(v) \ | |
2161 (EXECUTE_TEST_CODE_INTPTR_INTPTR( \ | |
2162 ComputeRange, test->entry(), reinterpret_cast<intptr_t>(v))) | |
2163 | |
2164 EXPECT_EQ(0, RANGE_OF(Smi::New(0))); | |
2165 EXPECT_EQ(0, RANGE_OF(Smi::New(1))); | |
2166 EXPECT_EQ(ICData::kSignedRangeBit, RANGE_OF(Smi::New(-1))); | |
2167 EXPECT_EQ(0, RANGE_OF(Smi::New(Smi::kMaxValue))); | |
2168 EXPECT_EQ(ICData::kSignedRangeBit, RANGE_OF(Smi::New(Smi::kMinValue))); | |
2169 | |
2170 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(Integer::New(Smi::kMaxValue + 1))); | |
2171 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, | |
2172 RANGE_OF(Integer::New(Smi::kMinValue - 1))); | |
2173 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(Integer::New(kMaxInt32))); | |
2174 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, | |
2175 RANGE_OF(Integer::New(kMinInt32))); | |
2176 | |
2177 EXPECT_EQ(ICData::kUint32RangeBit, | |
2178 RANGE_OF(Integer::New(static_cast<int64_t>(kMaxInt32) + 1))); | |
2179 EXPECT_EQ(ICData::kUint32RangeBit, | |
2180 RANGE_OF(Integer::New(kMaxUint32))); | |
2181 | |
2182 EXPECT_EQ(ICData::kInt64RangeBit, | |
2183 RANGE_OF(Integer::New(static_cast<int64_t>(kMaxUint32) + 1))); | |
2184 EXPECT_EQ(ICData::kInt64RangeBit, | |
2185 RANGE_OF(Integer::New(static_cast<int64_t>(kMinInt32) - 1))); | |
2186 EXPECT_EQ(ICData::kInt64RangeBit, RANGE_OF(Integer::New(kMaxInt64))); | |
2187 EXPECT_EQ(ICData::kInt64RangeBit, RANGE_OF(Integer::New(kMinInt64))); | |
2188 | |
2189 EXPECT_EQ(-1, RANGE_OF(Bool::True().raw())); | |
2190 | |
2191 #undef RANGE_OF | |
2192 } | |
2193 | |
2194 | |
2195 ASSEMBLER_TEST_GENERATE(Semaphore, assembler) { | 2144 ASSEMBLER_TEST_GENERATE(Semaphore, assembler) { |
2196 __ EnterFrame(); | 2145 __ EnterFrame(); |
2197 __ LoadImmediate(T0, 40); | 2146 __ LoadImmediate(T0, 40); |
2198 __ LoadImmediate(T1, 42); | 2147 __ LoadImmediate(T1, 42); |
2199 __ Push(T0); | 2148 __ Push(T0); |
2200 Label retry; | 2149 Label retry; |
2201 __ Bind(&retry); | 2150 __ Bind(&retry); |
2202 __ ll(T0, Address(SP)); | 2151 __ ll(T0, Address(SP)); |
2203 __ mov(T2, T1); | 2152 __ mov(T2, T1); |
2204 __ sc(T2, Address(SP)); // T1 == 1, success | 2153 __ sc(T2, Address(SP)); // T1 == 1, success |
2205 __ LoadImmediate(T3, 1); | 2154 __ LoadImmediate(T3, 1); |
2206 __ bne(T2, T3, &retry); // NE if context switch occurred between ll and sc | 2155 __ bne(T2, T3, &retry); // NE if context switch occurred between ll and sc |
2207 __ Pop(V0); // 42 | 2156 __ Pop(V0); // 42 |
2208 __ LeaveFrameAndReturn(); | 2157 __ LeaveFrameAndReturn(); |
2209 } | 2158 } |
2210 | 2159 |
2211 | 2160 |
2212 ASSEMBLER_TEST_RUN(Semaphore, test) { | 2161 ASSEMBLER_TEST_RUN(Semaphore, test) { |
2213 EXPECT(test != NULL); | 2162 EXPECT(test != NULL); |
2214 typedef int (*Semaphore)() DART_UNUSED; | 2163 typedef int (*Semaphore)() DART_UNUSED; |
2215 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(Semaphore, test->entry())); | 2164 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(Semaphore, test->entry())); |
2216 } | 2165 } |
2217 | 2166 |
2218 | 2167 |
2219 } // namespace dart | 2168 } // namespace dart |
2220 | 2169 |
2221 #endif // defined TARGET_ARCH_MIPS | 2170 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |