| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
| 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 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2101 Assembler* assembler) { | 2101 Assembler* assembler) { |
| 2102 const Register temp = R2; | 2102 const Register temp = R2; |
| 2103 const Register left = R1; | 2103 const Register left = R1; |
| 2104 const Register right = R0; | 2104 const Register right = R0; |
| 2105 __ LoadFromOffset(left, SP, 1 * kWordSize, kNoPP); | 2105 __ LoadFromOffset(left, SP, 1 * kWordSize, kNoPP); |
| 2106 __ LoadFromOffset(right, SP, 0 * kWordSize, kNoPP); | 2106 __ LoadFromOffset(right, SP, 0 * kWordSize, kNoPP); |
| 2107 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); | 2107 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); |
| 2108 __ ret(); | 2108 __ ret(); |
| 2109 } | 2109 } |
| 2110 | 2110 |
| 2111 |
| 2112 void StubCode::EmitMegamorphicLookup( |
| 2113 Assembler* assembler, Register receiver, Register cache, Register target) { |
| 2114 ASSERT((cache != R0) && (cache != R2)); |
| 2115 __ LoadTaggedClassIdMayBeSmi(R0, receiver); |
| 2116 // R0: class ID of the receiver (smi). |
| 2117 __ LoadFieldFromOffset(R2, cache, MegamorphicCache::buckets_offset(), PP); |
| 2118 __ LoadFieldFromOffset(R1, cache, MegamorphicCache::mask_offset(), PP); |
| 2119 // R2: cache buckets array. |
| 2120 // R1: mask. |
| 2121 __ mov(R3, R0); |
| 2122 |
| 2123 Label loop, update, call_target_function; |
| 2124 __ b(&loop); |
| 2125 |
| 2126 __ Bind(&update); |
| 2127 __ add(R3, R3, Operand(Smi::RawValue(1))); |
| 2128 __ Bind(&loop); |
| 2129 __ and_(R3, R3, Operand(R1)); |
| 2130 const intptr_t base = Array::data_offset(); |
| 2131 // R3 is smi tagged, but table entries are 16 bytes, so LSL 3. |
| 2132 __ add(TMP, R2, Operand(R3, LSL, 3)); |
| 2133 __ LoadFieldFromOffset(R4, TMP, base, PP); |
| 2134 |
| 2135 ASSERT(kIllegalCid == 0); |
| 2136 __ tst(R4, Operand(R4)); |
| 2137 __ b(&call_target_function, EQ); |
| 2138 __ CompareRegisters(R4, R0); |
| 2139 __ b(&update, NE); |
| 2140 |
| 2141 __ Bind(&call_target_function); |
| 2142 // Call the target found in the cache. For a class id match, this is a |
| 2143 // proper target for the given name and arguments descriptor. If the |
| 2144 // illegal class id was found, the target is a cache miss handler that can |
| 2145 // be invoked as a normal Dart function. |
| 2146 __ add(TMP, R2, Operand(R3, LSL, 3)); |
| 2147 __ LoadFieldFromOffset(R0, TMP, base + kWordSize, PP); |
| 2148 __ LoadFieldFromOffset(R1, R0, Function::instructions_offset(), PP); |
| 2149 // TODO(srdjan): Evaluate performance impact of moving the instruction below |
| 2150 // to the call site, instead of having it here. |
| 2151 __ AddImmediate(target, R1, Instructions::HeaderSize() - kHeapObjectTag, PP); |
| 2152 } |
| 2153 |
| 2154 |
| 2155 // Called from megamorphic calls. |
| 2156 // R0: receiver. |
| 2157 // R1: lookup cache. |
| 2158 // Result: |
| 2159 // R1: entry point. |
| 2160 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
| 2161 EmitMegamorphicLookup(assembler, R0, R1, R1); |
| 2162 __ ret(); |
| 2163 } |
| 2164 |
| 2111 } // namespace dart | 2165 } // namespace dart |
| 2112 | 2166 |
| 2113 #endif // defined TARGET_ARCH_ARM64 | 2167 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |