Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: runtime/vm/stub_code_arm.cc

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

Powered by Google App Engine
This is Rietveld 408576698