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 1972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1983 __ ldr(right, Address(SP, 0 * kWordSize)); | 1983 __ ldr(right, Address(SP, 0 * kWordSize)); |
1984 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); | 1984 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); |
1985 __ Ret(); | 1985 __ Ret(); |
1986 } | 1986 } |
1987 | 1987 |
1988 | 1988 |
1989 // Called from megamorphic calls. | 1989 // Called from megamorphic calls. |
1990 // R0: receiver | 1990 // R0: receiver |
1991 // R9: MegamorphicCache (preserved) | 1991 // R9: MegamorphicCache (preserved) |
1992 // Result: | 1992 // Result: |
1993 // R1: target entry point | |
1994 // CODE_REG: target Code | 1993 // CODE_REG: target Code |
1995 // R4: arguments descriptor | 1994 // R4: arguments descriptor |
1996 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { | 1995 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
| 1996 __ NoMonomorphicCheckedEntry(); |
| 1997 |
1997 __ LoadTaggedClassIdMayBeSmi(R0, R0); | 1998 __ LoadTaggedClassIdMayBeSmi(R0, R0); |
1998 // R0: receiver cid as Smi. | 1999 // R0: receiver cid as Smi. |
1999 __ ldr(R2, FieldAddress(R9, MegamorphicCache::buckets_offset())); | 2000 __ ldr(R2, FieldAddress(R9, MegamorphicCache::buckets_offset())); |
2000 __ ldr(R1, FieldAddress(R9, MegamorphicCache::mask_offset())); | 2001 __ ldr(R1, FieldAddress(R9, MegamorphicCache::mask_offset())); |
2001 // R2: cache buckets array. | 2002 // R2: cache buckets array. |
2002 // R1: mask. | 2003 // R1: mask. |
2003 | 2004 |
2004 // Compute the table index. | 2005 // Compute the table index. |
2005 ASSERT(MegamorphicCache::kSpreadFactor == 7); | 2006 ASSERT(MegamorphicCache::kSpreadFactor == 7); |
2006 // Use reverse substract to multiply with 7 == 8 - 1. | 2007 // Use reverse substract to multiply with 7 == 8 - 1. |
(...skipping 14 matching lines...) Expand all Loading... |
2021 Label load_target; | 2022 Label load_target; |
2022 __ Bind(&load_target); | 2023 __ Bind(&load_target); |
2023 // Call the target found in the cache. For a class id match, this is a | 2024 // Call the target found in the cache. For a class id match, this is a |
2024 // proper target for the given name and arguments descriptor. If the | 2025 // proper target for the given name and arguments descriptor. If the |
2025 // illegal class id was found, the target is a cache miss handler that can | 2026 // illegal class id was found, the target is a cache miss handler that can |
2026 // be invoked as a normal Dart function. | 2027 // be invoked as a normal Dart function. |
2027 __ ldr(R0, FieldAddress(IP, base + kWordSize)); | 2028 __ ldr(R0, FieldAddress(IP, base + kWordSize)); |
2028 __ ldr(R4, FieldAddress(R9, MegamorphicCache::arguments_descriptor_offset())); | 2029 __ ldr(R4, FieldAddress(R9, MegamorphicCache::arguments_descriptor_offset())); |
2029 __ ldr(R1, FieldAddress(R0, Function::entry_point_offset())); | 2030 __ ldr(R1, FieldAddress(R0, Function::entry_point_offset())); |
2030 __ ldr(CODE_REG, FieldAddress(R0, Function::code_offset())); | 2031 __ ldr(CODE_REG, FieldAddress(R0, Function::code_offset())); |
2031 __ Ret(); | 2032 __ bx(R1); |
2032 | 2033 |
2033 // Probe failed, check if it is a miss. | 2034 // Probe failed, check if it is a miss. |
2034 __ Bind(&probe_failed); | 2035 __ Bind(&probe_failed); |
2035 ASSERT(kIllegalCid == 0); | 2036 ASSERT(kIllegalCid == 0); |
2036 __ tst(R6, Operand(R6)); | 2037 __ tst(R6, Operand(R6)); |
2037 __ b(&load_target, EQ); // branch if miss. | 2038 __ b(&load_target, EQ); // branch if miss. |
2038 | 2039 |
2039 // Try next extry in the table. | 2040 // Try next extry in the table. |
2040 __ AddImmediate(R3, Smi::RawValue(1)); | 2041 __ AddImmediate(R3, Smi::RawValue(1)); |
2041 __ b(&loop); | 2042 __ b(&loop); |
2042 } | 2043 } |
2043 | 2044 |
2044 | 2045 |
2045 // Called from switchable IC calls. | 2046 // Called from switchable IC calls. |
2046 // R0: receiver | 2047 // R0: receiver |
2047 // R9: ICData (preserved) | 2048 // R9: ICData (preserved) |
2048 // Result: | 2049 // Result: |
2049 // R1: target entry point | |
2050 // CODE_REG: target Code object | 2050 // CODE_REG: target Code object |
2051 // R4: arguments descriptor | 2051 // R4: arguments descriptor |
2052 void StubCode::GenerateICLookupThroughFunctionStub(Assembler* assembler) { | 2052 void StubCode::GenerateICLookupThroughFunctionStub(Assembler* assembler) { |
| 2053 __ NoMonomorphicCheckedEntry(); |
| 2054 |
2053 Label loop, found, miss; | 2055 Label loop, found, miss; |
2054 __ ldr(R4, FieldAddress(R9, ICData::arguments_descriptor_offset())); | 2056 __ ldr(R4, FieldAddress(R9, ICData::arguments_descriptor_offset())); |
2055 __ ldr(R8, FieldAddress(R9, ICData::ic_data_offset())); | 2057 __ ldr(R8, FieldAddress(R9, ICData::ic_data_offset())); |
2056 __ AddImmediate(R8, R8, Array::data_offset() - kHeapObjectTag); | 2058 __ AddImmediate(R8, R8, Array::data_offset() - kHeapObjectTag); |
2057 // R8: first IC entry | 2059 // R8: first IC entry |
2058 __ LoadTaggedClassIdMayBeSmi(R1, R0); | 2060 __ LoadTaggedClassIdMayBeSmi(R1, R0); |
2059 // R1: receiver cid as Smi | 2061 // R1: receiver cid as Smi |
2060 | 2062 |
2061 __ Bind(&loop); | 2063 __ Bind(&loop); |
2062 __ ldr(R2, Address(R8, 0)); | 2064 __ ldr(R2, Address(R8, 0)); |
2063 __ cmp(R1, Operand(R2)); | 2065 __ cmp(R1, Operand(R2)); |
2064 __ b(&found, EQ); | 2066 __ b(&found, EQ); |
2065 __ CompareImmediate(R2, Smi::RawValue(kIllegalCid)); | 2067 __ CompareImmediate(R2, Smi::RawValue(kIllegalCid)); |
2066 __ b(&miss, EQ); | 2068 __ b(&miss, EQ); |
2067 | 2069 |
2068 const intptr_t entry_length = ICData::TestEntryLengthFor(1) * kWordSize; | 2070 const intptr_t entry_length = ICData::TestEntryLengthFor(1) * kWordSize; |
2069 __ AddImmediate(R8, entry_length); // Next entry. | 2071 __ AddImmediate(R8, entry_length); // Next entry. |
2070 __ b(&loop); | 2072 __ b(&loop); |
2071 | 2073 |
2072 __ Bind(&found); | 2074 __ Bind(&found); |
2073 const intptr_t target_offset = ICData::TargetIndexFor(1) * kWordSize; | 2075 const intptr_t target_offset = ICData::TargetIndexFor(1) * kWordSize; |
2074 __ LoadFromOffset(kWord, R0, R8, target_offset); | 2076 __ LoadFromOffset(kWord, R0, R8, target_offset); |
2075 __ ldr(R1, FieldAddress(R0, Function::entry_point_offset())); | 2077 __ ldr(R1, FieldAddress(R0, Function::entry_point_offset())); |
2076 __ ldr(CODE_REG, FieldAddress(R0, Function::code_offset())); | 2078 __ ldr(CODE_REG, FieldAddress(R0, Function::code_offset())); |
2077 __ Ret(); | 2079 __ bx(R1); |
2078 | 2080 |
2079 __ Bind(&miss); | 2081 __ Bind(&miss); |
2080 __ LoadIsolate(R2); | 2082 __ LoadIsolate(R2); |
2081 __ ldr(CODE_REG, Address(R2, Isolate::ic_miss_code_offset())); | 2083 __ ldr(CODE_REG, Address(R2, Isolate::ic_miss_code_offset())); |
2082 __ ldr(R1, FieldAddress(CODE_REG, Code::entry_point_offset())); | 2084 __ ldr(R1, FieldAddress(CODE_REG, Code::entry_point_offset())); |
2083 __ Ret(); | 2085 __ bx(R1); |
2084 } | 2086 } |
2085 | 2087 |
2086 | 2088 |
2087 void StubCode::GenerateICLookupThroughCodeStub(Assembler* assembler) { | 2089 void StubCode::GenerateICLookupThroughCodeStub(Assembler* assembler) { |
| 2090 __ NoMonomorphicCheckedEntry(); |
| 2091 |
2088 Label loop, found, miss; | 2092 Label loop, found, miss; |
2089 __ ldr(R4, FieldAddress(R9, ICData::arguments_descriptor_offset())); | 2093 __ ldr(R4, FieldAddress(R9, ICData::arguments_descriptor_offset())); |
2090 __ ldr(R8, FieldAddress(R9, ICData::ic_data_offset())); | 2094 __ ldr(R8, FieldAddress(R9, ICData::ic_data_offset())); |
2091 __ AddImmediate(R8, R8, Array::data_offset() - kHeapObjectTag); | 2095 __ AddImmediate(R8, R8, Array::data_offset() - kHeapObjectTag); |
2092 // R8: first IC entry | 2096 // R8: first IC entry |
2093 __ LoadTaggedClassIdMayBeSmi(R1, R0); | 2097 __ LoadTaggedClassIdMayBeSmi(R1, R0); |
2094 // R1: receiver cid as Smi | 2098 // R1: receiver cid as Smi |
2095 | 2099 |
2096 __ Bind(&loop); | 2100 __ Bind(&loop); |
2097 __ ldr(R2, Address(R8, 0)); | 2101 __ ldr(R2, Address(R8, 0)); |
2098 __ cmp(R1, Operand(R2)); | 2102 __ cmp(R1, Operand(R2)); |
2099 __ b(&found, EQ); | 2103 __ b(&found, EQ); |
2100 __ CompareImmediate(R2, Smi::RawValue(kIllegalCid)); | 2104 __ CompareImmediate(R2, Smi::RawValue(kIllegalCid)); |
2101 __ b(&miss, EQ); | 2105 __ b(&miss, EQ); |
2102 | 2106 |
2103 const intptr_t entry_length = ICData::TestEntryLengthFor(1) * kWordSize; | 2107 const intptr_t entry_length = ICData::TestEntryLengthFor(1) * kWordSize; |
2104 __ AddImmediate(R8, entry_length); // Next entry. | 2108 __ AddImmediate(R8, entry_length); // Next entry. |
2105 __ b(&loop); | 2109 __ b(&loop); |
2106 | 2110 |
2107 __ Bind(&found); | 2111 __ Bind(&found); |
2108 const intptr_t code_offset = ICData::CodeIndexFor(1) * kWordSize; | 2112 const intptr_t code_offset = ICData::CodeIndexFor(1) * kWordSize; |
2109 const intptr_t entry_offset = ICData::EntryPointIndexFor(1) * kWordSize; | 2113 const intptr_t entry_offset = ICData::EntryPointIndexFor(1) * kWordSize; |
2110 __ ldr(R1, Address(R8, entry_offset)); | 2114 __ ldr(R1, Address(R8, entry_offset)); |
2111 __ ldr(CODE_REG, Address(R8, code_offset)); | 2115 __ ldr(CODE_REG, Address(R8, code_offset)); |
2112 __ Ret(); | 2116 __ bx(R1); |
2113 | 2117 |
2114 __ Bind(&miss); | 2118 __ Bind(&miss); |
2115 __ LoadIsolate(R2); | 2119 __ LoadIsolate(R2); |
2116 __ ldr(CODE_REG, Address(R2, Isolate::ic_miss_code_offset())); | 2120 __ ldr(CODE_REG, Address(R2, Isolate::ic_miss_code_offset())); |
2117 __ ldr(R1, FieldAddress(CODE_REG, Code::entry_point_offset())); | 2121 __ ldr(R1, FieldAddress(CODE_REG, Code::entry_point_offset())); |
2118 __ Ret(); | 2122 __ bx(R1); |
2119 } | 2123 } |
2120 | 2124 |
2121 | 2125 |
| 2126 // Called from the monomorphic checked entry. |
| 2127 // R0: receiver |
| 2128 void StubCode::GenerateMonomorphicMissStub(Assembler* assembler) { |
| 2129 __ EnterStubFrame(); |
| 2130 __ Push(R0); // Preserve receiver. |
| 2131 |
| 2132 __ PushObject(Object::null_object()); // Result. |
| 2133 __ Push(R0); // Arg0: Receiver |
| 2134 __ CallRuntime(kMonomorphicMissRuntimeEntry, 1); |
| 2135 __ Drop(1); |
| 2136 __ Pop(R9); // result = IC |
| 2137 |
| 2138 __ Pop(R0); // Restore receiver. |
| 2139 __ LeaveStubFrame(); |
| 2140 |
| 2141 __ ldr(CODE_REG, Address(THR, Thread::ic_lookup_through_code_stub_offset())); |
| 2142 __ ldr(R1, FieldAddress(CODE_REG, Code::checked_entry_point_offset())); |
| 2143 __ bx(R1); |
| 2144 } |
| 2145 |
| 2146 |
2122 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { | 2147 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { |
2123 __ bkpt(0); | 2148 __ bkpt(0); |
2124 } | 2149 } |
2125 | 2150 |
2126 } // namespace dart | 2151 } // namespace dart |
2127 | 2152 |
2128 #endif // defined TARGET_ARCH_ARM | 2153 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |