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