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/code_generator.h" | 9 #include "vm/code_generator.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 2199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2210 __ mov(V0, A3); // Exception object. | 2210 __ mov(V0, A3); // Exception object. |
2211 // MIPS ABI reserves stack space for all arguments. The StackTrace object is | 2211 // MIPS ABI reserves stack space for all arguments. The StackTrace object is |
2212 // the last of five arguments, so it is first pushed on the stack. | 2212 // the last of five arguments, so it is first pushed on the stack. |
2213 __ lw(V1, Address(SP, 4 * kWordSize)); // StackTrace object. | 2213 __ lw(V1, Address(SP, 4 * kWordSize)); // StackTrace object. |
2214 __ mov(FP, A2); // Frame_pointer. | 2214 __ mov(FP, A2); // Frame_pointer. |
2215 __ jr(A0); // Jump to the exception handler code. | 2215 __ jr(A0); // Jump to the exception handler code. |
2216 __ delay_slot()->mov(SP, A1); // Stack pointer. | 2216 __ delay_slot()->mov(SP, A1); // Stack pointer. |
2217 } | 2217 } |
2218 | 2218 |
2219 | 2219 |
2220 // Implements equality operator when one of the arguments is null | |
2221 // (identity check) and updates ICData if necessary. | |
2222 // RA: return address. | |
2223 // A1: left argument. | |
2224 // A0: right argument. | |
2225 // T0: ICData. | |
2226 // V0: result. | |
2227 // TODO(srdjan): Move to VM stubs once Boolean objects become VM objects. | |
2228 void StubCode::GenerateEqualityWithNullArgStub(Assembler* assembler) { | |
2229 __ TraceSimMsg("EqualityWithNullArgStub"); | |
2230 __ Comment("EqualityWithNullArgStub"); | |
2231 __ EnterStubFrame(); | |
2232 static const intptr_t kNumArgsTested = 2; | |
2233 #if defined(DEBUG) | |
2234 { Label ok; | |
2235 __ lw(CMPRES1, FieldAddress(T0, ICData::num_args_tested_offset())); | |
2236 __ BranchEqual(CMPRES1, kNumArgsTested, &ok); | |
2237 __ Stop("Incorrect ICData for equality"); | |
2238 __ Bind(&ok); | |
2239 } | |
2240 #endif // DEBUG | |
2241 // Check IC data, update if needed. | |
2242 // T0: IC data object (preserved). | |
2243 __ lw(T6, FieldAddress(T0, ICData::ic_data_offset())); | |
2244 // T6: ic_data_array with check entries: classes and target functions. | |
2245 __ AddImmediate(T6, Array::data_offset() - kHeapObjectTag); | |
2246 // T6: points directly to the first ic data array element. | |
2247 | |
2248 Label get_class_id_as_smi, no_match, loop, found; | |
2249 __ Bind(&loop); | |
2250 // Check left. | |
2251 __ bal(&get_class_id_as_smi); | |
2252 __ delay_slot()->mov(T2, A1); | |
2253 __ lw(T3, Address(T6, 0 * kWordSize)); | |
2254 __ bne(T2, T3, &no_match); // Class id match? | |
2255 | |
2256 // Check right. | |
2257 __ bal(&get_class_id_as_smi); | |
2258 __ delay_slot()->mov(T2, A0); | |
2259 __ lw(T3, Address(T6, 1 * kWordSize)); | |
2260 __ beq(T2, T3, &found); // Class id match? | |
2261 __ Bind(&no_match); | |
2262 // Next check group. | |
2263 intptr_t entry_bytes = kWordSize * ICData::TestEntryLengthFor(kNumArgsTested); | |
2264 if (Utils::IsInt(kImmBits, entry_bytes)) { | |
2265 __ BranchNotEqual(T3, Smi::RawValue(kIllegalCid), &loop); // Done? | |
2266 __ delay_slot()->addiu(T6, T6, Immediate(entry_bytes)); | |
2267 } else { | |
2268 __ AddImmediate(T6, entry_bytes); | |
2269 __ BranchNotEqual(T3, Smi::RawValue(kIllegalCid), &loop); // Done? | |
2270 } | |
2271 | |
2272 Label update_ic_data; | |
2273 __ b(&update_ic_data); | |
2274 | |
2275 __ Bind(&found); | |
2276 const intptr_t count_offset = | |
2277 ICData::CountIndexFor(kNumArgsTested) * kWordSize; | |
2278 Label no_overflow; | |
2279 __ lw(T1, Address(T6, count_offset)); | |
2280 __ AddImmediateDetectOverflow(T1, T1, Smi::RawValue(1), CMPRES, T5); | |
2281 __ bgez(CMPRES, &no_overflow); | |
2282 __ delay_slot()->sw(T1, Address(T6, count_offset)); | |
2283 __ LoadImmediate(TMP1, Smi::RawValue(Smi::kMaxValue)); | |
2284 __ sw(TMP1, Address(T6, count_offset)); // If overflow. | |
2285 __ Bind(&no_overflow); | |
2286 | |
2287 Label compute_result; | |
2288 __ Bind(&compute_result); | |
2289 __ LoadObject(T4, Bool::True()); | |
2290 __ LoadObject(T5, Bool::False()); | |
2291 __ subu(CMPRES, A0, A1); | |
2292 __ movz(V0, T4, CMPRES); | |
2293 __ movn(V0, T5, CMPRES); | |
2294 __ LeaveStubFrameAndReturn(); | |
2295 | |
2296 __ Bind(&get_class_id_as_smi); | |
2297 // Test if Smi -> load Smi class for comparison. | |
2298 Label not_smi; | |
2299 __ andi(CMPRES, T2, Immediate(kSmiTagMask)); | |
2300 __ bne(CMPRES, ZR, ¬_smi); | |
2301 __ jr(RA); | |
2302 __ delay_slot()->addiu(T2, ZR, Immediate(Smi::RawValue(kSmiCid))); | |
2303 __ Bind(¬_smi); | |
2304 __ LoadClassId(T2, T2); | |
2305 __ jr(RA); | |
2306 __ delay_slot()->SmiTag(T2); | |
2307 | |
2308 __ Bind(&update_ic_data); | |
2309 // T0: ICData | |
2310 __ addiu(SP, SP, Immediate(-4 * kWordSize)); | |
2311 __ sw(A1, Address(SP, 3 * kWordSize)); | |
2312 __ sw(A0, Address(SP, 2 * kWordSize)); | |
2313 __ LoadObject(TMP1, Symbols::EqualOperator()); // Target's name. | |
2314 __ sw(TMP1, Address(SP, 1 * kWordSize)); | |
2315 __ sw(T0, Address(SP, 0 * kWordSize)); // ICData. | |
2316 __ CallRuntime(kUpdateICDataTwoArgsRuntimeEntry, 4); | |
2317 __ lw(A0, Address(SP, 2 * kWordSize)); | |
2318 __ lw(A1, Address(SP, 3 * kWordSize)); | |
2319 __ b(&compute_result); | |
2320 __ delay_slot()->addiu(SP, SP, Immediate(4 * kWordSize)); | |
2321 } | |
2322 | |
2323 | |
2324 // Calls to the runtime to optimize the given function. | 2220 // Calls to the runtime to optimize the given function. |
2325 // T0: function to be reoptimized. | 2221 // T0: function to be reoptimized. |
2326 // S4: argument descriptor (preserved). | 2222 // S4: argument descriptor (preserved). |
2327 void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) { | 2223 void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) { |
2328 __ TraceSimMsg("OptimizeFunctionStub"); | 2224 __ TraceSimMsg("OptimizeFunctionStub"); |
2329 __ EnterStubFrame(); | 2225 __ EnterStubFrame(); |
2330 __ addiu(SP, SP, Immediate(-3 * kWordSize)); | 2226 __ addiu(SP, SP, Immediate(-3 * kWordSize)); |
2331 __ sw(S4, Address(SP, 2 * kWordSize)); | 2227 __ sw(S4, Address(SP, 2 * kWordSize)); |
2332 // Setup space on stack for return value. | 2228 // Setup space on stack for return value. |
2333 __ LoadImmediate(TMP, reinterpret_cast<intptr_t>(Object::null())); | 2229 __ LoadImmediate(TMP, reinterpret_cast<intptr_t>(Object::null())); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2491 __ lw(left, Address(SP, 1 * kWordSize)); | 2387 __ lw(left, Address(SP, 1 * kWordSize)); |
2492 __ lw(temp2, Address(SP, 2 * kWordSize)); | 2388 __ lw(temp2, Address(SP, 2 * kWordSize)); |
2493 __ lw(temp1, Address(SP, 3 * kWordSize)); | 2389 __ lw(temp1, Address(SP, 3 * kWordSize)); |
2494 __ Ret(); | 2390 __ Ret(); |
2495 __ delay_slot()->addiu(SP, SP, Immediate(4 * kWordSize)); | 2391 __ delay_slot()->addiu(SP, SP, Immediate(4 * kWordSize)); |
2496 } | 2392 } |
2497 | 2393 |
2498 } // namespace dart | 2394 } // namespace dart |
2499 | 2395 |
2500 #endif // defined TARGET_ARCH_MIPS | 2396 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |