| 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_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
| 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/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 2033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2044 __ ldr(left, Address(SP, 1 * kWordSize)); | 2044 __ ldr(left, Address(SP, 1 * kWordSize)); |
| 2045 __ ldr(right, Address(SP, 0 * kWordSize)); | 2045 __ ldr(right, Address(SP, 0 * kWordSize)); |
| 2046 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); | 2046 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); |
| 2047 __ Ret(); | 2047 __ Ret(); |
| 2048 } | 2048 } |
| 2049 | 2049 |
| 2050 | 2050 |
| 2051 void StubCode::EmitMegamorphicLookup(Assembler* assembler) { | 2051 void StubCode::EmitMegamorphicLookup(Assembler* assembler) { |
| 2052 __ LoadTaggedClassIdMayBeSmi(R0, R0); | 2052 __ LoadTaggedClassIdMayBeSmi(R0, R0); |
| 2053 // R0: receiver cid as Smi. | 2053 // R0: receiver cid as Smi. |
| 2054 __ ldr(R4, FieldAddress(R9, MegamorphicCache::arguments_descriptor_offset())); | |
| 2055 __ ldr(R2, FieldAddress(R9, MegamorphicCache::buckets_offset())); | 2054 __ ldr(R2, FieldAddress(R9, MegamorphicCache::buckets_offset())); |
| 2056 __ ldr(R1, FieldAddress(R9, MegamorphicCache::mask_offset())); | 2055 __ ldr(R1, FieldAddress(R9, MegamorphicCache::mask_offset())); |
| 2057 // R2: cache buckets array. | 2056 // R2: cache buckets array. |
| 2058 // R1: mask. | 2057 // R1: mask. |
| 2059 __ LoadImmediate(IP, MegamorphicCache::kSpreadFactor); | 2058 |
| 2060 __ mul(R3, R0, IP); | 2059 // Compute the table index. |
| 2060 ASSERT(MegamorphicCache::kSpreadFactor == 7); |
| 2061 // Use reverse substract to multiply with 7 == 8 - 1. |
| 2062 __ rsb(R3, R0, Operand(R0, LSL, 3)); |
| 2061 // R3: probe. | 2063 // R3: probe. |
| 2062 | 2064 |
| 2063 Label loop, update, load_target_function; | 2065 Label loop, update, load_target_function; |
| 2064 __ b(&loop); | 2066 __ b(&loop); |
| 2065 | 2067 |
| 2066 __ Bind(&update); | 2068 __ Bind(&update); |
| 2067 __ add(R3, R3, Operand(Smi::RawValue(1))); | 2069 __ add(R3, R3, Operand(Smi::RawValue(1))); |
| 2068 __ Bind(&loop); | 2070 __ Bind(&loop); |
| 2069 __ and_(R3, R3, Operand(R1)); | 2071 __ and_(R3, R3, Operand(R1)); |
| 2070 const intptr_t base = Array::data_offset(); | 2072 const intptr_t base = Array::data_offset(); |
| 2071 // R3 is smi tagged, but table entries are two words, so LSL 2. | 2073 // R3 is smi tagged, but table entries are two words, so LSL 2. |
| 2072 __ add(IP, R2, Operand(R3, LSL, 2)); | 2074 __ add(IP, R2, Operand(R3, LSL, 2)); |
| 2073 __ ldr(R6, FieldAddress(IP, base)); | 2075 __ ldr(R6, FieldAddress(IP, base)); |
| 2074 | 2076 |
| 2075 ASSERT(kIllegalCid == 0); | 2077 ASSERT(kIllegalCid == 0); |
| 2076 __ tst(R6, Operand(R6)); | 2078 __ tst(R6, Operand(R6)); |
| 2077 __ b(&load_target_function, EQ); | 2079 __ b(&load_target_function, EQ); |
| 2078 __ cmp(R6, Operand(R0)); | 2080 __ cmp(R6, Operand(R0)); |
| 2079 __ b(&update, NE); | 2081 __ b(&update, NE); |
| 2080 | 2082 |
| 2081 __ Bind(&load_target_function); | 2083 __ Bind(&load_target_function); |
| 2082 // Call the target found in the cache. For a class id match, this is a | 2084 // Call the target found in the cache. For a class id match, this is a |
| 2083 // proper target for the given name and arguments descriptor. If the | 2085 // proper target for the given name and arguments descriptor. If the |
| 2084 // illegal class id was found, the target is a cache miss handler that can | 2086 // illegal class id was found, the target is a cache miss handler that can |
| 2085 // be invoked as a normal Dart function. | 2087 // be invoked as a normal Dart function. |
| 2086 __ add(IP, R2, Operand(R3, LSL, 2)); | 2088 __ add(IP, R2, Operand(R3, LSL, 2)); |
| 2087 __ ldr(R0, FieldAddress(IP, base + kWordSize)); | 2089 __ ldr(R0, FieldAddress(IP, base + kWordSize)); |
| 2090 __ ldr(R4, FieldAddress(R9, MegamorphicCache::arguments_descriptor_offset())); |
| 2088 __ ldr(R1, FieldAddress(R0, Function::entry_point_offset())); | 2091 __ ldr(R1, FieldAddress(R0, Function::entry_point_offset())); |
| 2089 __ ldr(CODE_REG, FieldAddress(R0, Function::code_offset())); | 2092 __ ldr(CODE_REG, FieldAddress(R0, Function::code_offset())); |
| 2090 } | 2093 } |
| 2091 | 2094 |
| 2092 | 2095 |
| 2093 // Called from megamorphic calls. | 2096 // Called from megamorphic calls. |
| 2094 // R0: receiver | 2097 // R0: receiver |
| 2095 // R9: MegamorphicCache (preserved) | 2098 // R9: MegamorphicCache (preserved) |
| 2096 // Result: | 2099 // Result: |
| 2097 // R1: target entry point | 2100 // R1: target entry point |
| 2098 // CODE_REG: target Code | 2101 // CODE_REG: target Code |
| 2099 // R4: arguments descriptor | 2102 // R4: arguments descriptor |
| 2100 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { | 2103 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
| 2101 EmitMegamorphicLookup(assembler); | 2104 __ LoadTaggedClassIdMayBeSmi(R0, R0); |
| 2105 // R0: receiver cid as Smi. |
| 2106 __ ldr(R2, FieldAddress(R9, MegamorphicCache::buckets_offset())); |
| 2107 __ ldr(R1, FieldAddress(R9, MegamorphicCache::mask_offset())); |
| 2108 // R2: cache buckets array. |
| 2109 // R1: mask. |
| 2110 |
| 2111 // Compute the table index. |
| 2112 ASSERT(MegamorphicCache::kSpreadFactor == 7); |
| 2113 // Use reverse substract to multiply with 7 == 8 - 1. |
| 2114 __ rsb(R3, R0, Operand(R0, LSL, 3)); |
| 2115 // R3: probe. |
| 2116 Label loop; |
| 2117 __ Bind(&loop); |
| 2118 __ and_(R3, R3, Operand(R1)); |
| 2119 |
| 2120 const intptr_t base = Array::data_offset(); |
| 2121 // R3 is smi tagged, but table entries are two words, so LSL 2. |
| 2122 Label probe_failed; |
| 2123 __ add(IP, R2, Operand(R3, LSL, 2)); |
| 2124 __ ldr(R6, FieldAddress(IP, base)); |
| 2125 __ cmp(R6, Operand(R0)); |
| 2126 __ b(&probe_failed, NE); |
| 2127 |
| 2128 Label load_target; |
| 2129 __ Bind(&load_target); |
| 2130 // Call the target found in the cache. For a class id match, this is a |
| 2131 // proper target for the given name and arguments descriptor. If the |
| 2132 // illegal class id was found, the target is a cache miss handler that can |
| 2133 // be invoked as a normal Dart function. |
| 2134 __ ldr(R0, FieldAddress(IP, base + kWordSize)); |
| 2135 __ ldr(R4, FieldAddress(R9, MegamorphicCache::arguments_descriptor_offset())); |
| 2136 __ ldr(R1, FieldAddress(R0, Function::entry_point_offset())); |
| 2137 __ ldr(CODE_REG, FieldAddress(R0, Function::code_offset())); |
| 2102 __ Ret(); | 2138 __ Ret(); |
| 2139 |
| 2140 // Probe failed, check if it is a miss. |
| 2141 __ Bind(&probe_failed); |
| 2142 ASSERT(kIllegalCid == 0); |
| 2143 __ tst(R6, Operand(R6)); |
| 2144 __ b(&load_target, EQ); // branch if miss. |
| 2145 |
| 2146 // Try next extry in the table. |
| 2147 __ AddImmediate(R3, Smi::RawValue(1)); |
| 2148 __ b(&loop); |
| 2103 } | 2149 } |
| 2104 | 2150 |
| 2105 | 2151 |
| 2106 // Called from switchable IC calls. | 2152 // Called from switchable IC calls. |
| 2107 // R0: receiver | 2153 // R0: receiver |
| 2108 // R9: ICData (preserved) | 2154 // R9: ICData (preserved) |
| 2109 // Result: | 2155 // Result: |
| 2110 // R1: target entry point | 2156 // R1: target entry point |
| 2111 // CODE_REG: target Code object | 2157 // CODE_REG: target Code object |
| 2112 // R4: arguments descriptor | 2158 // R4: arguments descriptor |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2180 } | 2226 } |
| 2181 | 2227 |
| 2182 | 2228 |
| 2183 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { | 2229 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { |
| 2184 __ bkpt(0); | 2230 __ bkpt(0); |
| 2185 } | 2231 } |
| 2186 | 2232 |
| 2187 } // namespace dart | 2233 } // namespace dart |
| 2188 | 2234 |
| 2189 #endif // defined TARGET_ARCH_ARM | 2235 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |