Chromium Code Reviews| 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_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 776 __ movq(RBX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); | 776 __ movq(RBX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); |
| 777 __ SmiUntag(RBX); | 777 __ SmiUntag(RBX); |
| 778 | 778 |
| 779 // Compute address of 'arguments array' data area into RDX. | 779 // Compute address of 'arguments array' data area into RDX. |
| 780 __ movq(RDX, Address(kArgsReg, VMHandles::kOffsetOfRawPtrInHandle)); | 780 __ movq(RDX, Address(kArgsReg, VMHandles::kOffsetOfRawPtrInHandle)); |
| 781 __ leaq(RDX, FieldAddress(RDX, Array::data_offset())); | 781 __ leaq(RDX, FieldAddress(RDX, Array::data_offset())); |
| 782 | 782 |
| 783 // Set up arguments for the Dart call. | 783 // Set up arguments for the Dart call. |
| 784 Label push_arguments; | 784 Label push_arguments; |
| 785 Label done_push_arguments; | 785 Label done_push_arguments; |
| 786 __ testq(RBX, RBX); // check if there are arguments. | 786 |
|
Florian Schneider
2016/07/07 17:13:36
Accidental edit?
bakster
2016/07/07 18:00:03
Done.
| |
| 787 __ j(ZERO, &done_push_arguments, Assembler::kNearJump); | 787 __ j(ZERO, &done_push_arguments, Assembler::kNearJump); |
| 788 __ movq(RAX, Immediate(0)); | 788 __ movq(RAX, Immediate(0)); |
| 789 __ Bind(&push_arguments); | 789 __ Bind(&push_arguments); |
| 790 __ pushq(Address(RDX, RAX, TIMES_8, 0)); | 790 __ pushq(Address(RDX, RAX, TIMES_8, 0)); |
| 791 __ incq(RAX); | 791 __ incq(RAX); |
| 792 __ cmpq(RAX, RBX); | 792 __ cmpq(RAX, RBX); |
| 793 __ j(LESS, &push_arguments, Assembler::kNearJump); | 793 __ j(LESS, &push_arguments, Assembler::kNearJump); |
| 794 __ Bind(&done_push_arguments); | 794 __ Bind(&done_push_arguments); |
| 795 | 795 |
| 796 // Call the Dart code entrypoint. | 796 // Call the Dart code entrypoint. |
| (...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2086 void StubCode::EmitMegamorphicLookup(Assembler* assembler) { | 2086 void StubCode::EmitMegamorphicLookup(Assembler* assembler) { |
| 2087 __ LoadTaggedClassIdMayBeSmi(RAX, RDI); | 2087 __ LoadTaggedClassIdMayBeSmi(RAX, RDI); |
| 2088 // RAX: class ID of the receiver (smi). | 2088 // RAX: class ID of the receiver (smi). |
| 2089 __ movq(R10, | 2089 __ movq(R10, |
| 2090 FieldAddress(RBX, MegamorphicCache::arguments_descriptor_offset())); | 2090 FieldAddress(RBX, MegamorphicCache::arguments_descriptor_offset())); |
| 2091 __ movq(RDI, FieldAddress(RBX, MegamorphicCache::buckets_offset())); | 2091 __ movq(RDI, FieldAddress(RBX, MegamorphicCache::buckets_offset())); |
| 2092 __ movq(R9, FieldAddress(RBX, MegamorphicCache::mask_offset())); | 2092 __ movq(R9, FieldAddress(RBX, MegamorphicCache::mask_offset())); |
| 2093 // R10: arguments descriptor (result). | 2093 // R10: arguments descriptor (result). |
| 2094 // RDI: cache buckets array. | 2094 // RDI: cache buckets array. |
| 2095 // RBX: mask. | 2095 // RBX: mask. |
| 2096 __ movq(RCX, RAX); | 2096 |
| 2097 __ imulq(RCX, Immediate(MegamorphicCache::kSpreadFactor)); | 2097 // Compute the table index. |
| 2098 ASSERT(MegamorphicCache::kSpreadFactor == 7); | |
| 2099 // Use leaq and subq multiply with 7 == 8 - 1. | |
| 2100 __ leaq(RCX, Address(RAX, TIMES_8, 0)); | |
| 2101 __ subq(RCX, RAX); | |
| 2098 | 2102 |
| 2099 Label loop, update, load_target_function; | 2103 Label loop, update, load_target_function; |
| 2100 __ jmp(&loop); | 2104 __ jmp(&loop); |
| 2101 | 2105 |
| 2102 __ Bind(&update); | 2106 __ Bind(&update); |
| 2103 __ AddImmediate(RCX, Immediate(Smi::RawValue(1))); | 2107 __ AddImmediate(RCX, Immediate(Smi::RawValue(1))); |
| 2104 __ Bind(&loop); | 2108 __ Bind(&loop); |
| 2105 __ andq(RCX, R9); | 2109 __ andq(RCX, R9); |
| 2106 const intptr_t base = Array::data_offset(); | 2110 const intptr_t base = Array::data_offset(); |
| 2107 // RCX is smi tagged, but table entries are two words, so TIMES_8. | 2111 // RCX is smi tagged, but table entries are two words, so TIMES_8. |
| 2108 __ movq(RDX, FieldAddress(RDI, RCX, TIMES_8, base)); | 2112 __ movq(RDX, FieldAddress(RDI, RCX, TIMES_8, base)); |
| 2109 | 2113 |
| 2110 ASSERT(kIllegalCid == 0); | 2114 ASSERT(kIllegalCid == 0); |
| 2115 // Check for the uncommon case, a miss in the cache. | |
| 2111 __ testq(RDX, RDX); | 2116 __ testq(RDX, RDX); |
| 2112 __ j(ZERO, &load_target_function, Assembler::kNearJump); | 2117 __ j(ZERO, &load_target_function, Assembler::kNearJump); |
| 2118 | |
| 2113 __ cmpq(RDX, RAX); | 2119 __ cmpq(RDX, RAX); |
| 2114 __ j(NOT_EQUAL, &update, Assembler::kNearJump); | 2120 __ j(NOT_EQUAL, &update, Assembler::kNearJump); |
| 2115 | 2121 |
| 2116 __ Bind(&load_target_function); | 2122 __ Bind(&load_target_function); |
| 2117 // Call the target found in the cache. For a class id match, this is a | 2123 // Call the target found in the cache. For a class id match, this is a |
| 2118 // proper target for the given name and arguments descriptor. If the | 2124 // proper target for the given name and arguments descriptor. If the |
| 2119 // illegal class id was found, the target is a cache miss handler that can | 2125 // illegal class id was found, the target is a cache miss handler that can |
| 2120 // be invoked as a normal Dart function. | 2126 // be invoked as a normal Dart function. |
| 2121 __ movq(RAX, FieldAddress(RDI, RCX, TIMES_8, base + kWordSize)); | 2127 __ movq(RAX, FieldAddress(RDI, RCX, TIMES_8, base + kWordSize)); |
| 2122 __ movq(RCX, FieldAddress(RAX, Function::entry_point_offset())); | 2128 __ movq(RCX, FieldAddress(RAX, Function::entry_point_offset())); |
| 2123 __ movq(CODE_REG, FieldAddress(RAX, Function::code_offset())); | 2129 __ movq(CODE_REG, FieldAddress(RAX, Function::code_offset())); |
| 2124 } | 2130 } |
| 2125 | 2131 |
| 2126 | 2132 |
| 2127 // Called from megamorphic calls. | 2133 // Called from megamorphic calls. |
| 2128 // RDI: receiver | 2134 // RDI: receiver |
| 2129 // RBX: MegamorphicCache (preserved) | 2135 // RBX: MegamorphicCache (preserved) |
| 2130 // Result: | 2136 // Result: |
| 2131 // RCX: target entry point | 2137 // RCX: target entry point |
| 2132 // CODE_REG: target Code | 2138 // CODE_REG: target Code |
| 2133 // R10: arguments descriptor | 2139 // R10: arguments descriptor |
| 2134 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { | 2140 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
| 2135 EmitMegamorphicLookup(assembler); | 2141 // Jump if receiver is a smi. |
|
Florian Schneider
2016/07/07 17:13:36
Can you move this into StubCode::EmitMegamorphicLo
bakster
2016/07/07 18:00:03
I'll remove this code in my next CL.
| |
| 2142 Label smi_case; | |
| 2143 __ testq(RDI, Immediate(kSmiTagMask)); | |
| 2144 // Jump out of line for smi case. | |
| 2145 __ j(ZERO, &smi_case, Assembler::kNearJump); | |
| 2146 | |
| 2147 // Loads the cid of the object. | |
| 2148 __ LoadClassId(RAX, RDI); | |
| 2149 | |
| 2150 Label cid_loaded; | |
| 2151 __ Bind(&cid_loaded); | |
| 2152 __ movq(R9, FieldAddress(RBX, MegamorphicCache::mask_offset())); | |
| 2153 __ movq(RDI, FieldAddress(RBX, MegamorphicCache::buckets_offset())); | |
| 2154 // R10: arguments descriptor (result). | |
| 2155 // RDI: cache buckets array. | |
| 2156 // RBX: mask. | |
| 2157 | |
| 2158 // Tag cid as a smi. | |
| 2159 __ addq(RAX, RAX); | |
| 2160 | |
| 2161 // Compute the table index. | |
| 2162 ASSERT(MegamorphicCache::kSpreadFactor == 7); | |
| 2163 // Use leaq and subq multiply with 7 == 8 - 1. | |
| 2164 __ leaq(RCX, Address(RAX, TIMES_8, 0)); | |
| 2165 __ subq(RCX, RAX); | |
| 2166 | |
| 2167 // __ movq(RCX, RAX); | |
|
Florian Schneider
2016/07/07 17:13:36
Remove commented code.
bakster
2016/07/07 18:00:03
Done.
| |
| 2168 // __ imulq(RCX, Immediate(MegamorphicCache::kSpreadFactor)); | |
| 2169 | |
| 2170 Label loop; | |
| 2171 __ Bind(&loop); | |
| 2172 __ andq(RCX, R9); | |
| 2173 | |
| 2174 const intptr_t base = Array::data_offset(); | |
| 2175 // RCX is smi tagged, but table entries are two words, so TIMES_8. | |
| 2176 Label probe_failed; | |
| 2177 __ cmpq(RAX, FieldAddress(RDI, RCX, TIMES_8, base)); | |
| 2178 __ j(NOT_EQUAL, &probe_failed, Assembler::kNearJump); | |
| 2179 | |
| 2180 Label load_target; | |
| 2181 __ Bind(&load_target); | |
| 2182 // Call the target found in the cache. For a class id match, this is a | |
| 2183 // proper target for the given name and arguments descriptor. If the | |
| 2184 // illegal class id was found, the target is a cache miss handler that can | |
| 2185 // be invoked as a normal Dart function. | |
| 2186 __ movq(RAX, FieldAddress(RDI, RCX, TIMES_8, base + kWordSize)); | |
| 2187 __ movq(R10, | |
| 2188 FieldAddress(RBX, MegamorphicCache::arguments_descriptor_offset())); | |
| 2189 __ movq(RCX, FieldAddress(RAX, Function::entry_point_offset())); | |
| 2190 __ movq(CODE_REG, FieldAddress(RAX, Function::code_offset())); | |
| 2191 | |
| 2136 __ ret(); | 2192 __ ret(); |
| 2193 | |
| 2194 // Probe failed, check if it is a miss. | |
| 2195 __ Bind(&probe_failed); | |
| 2196 __ cmpq(FieldAddress(RDI, RCX, TIMES_8, base), Immediate(kIllegalCid)); | |
| 2197 __ j(ZERO, &load_target, Assembler::kNearJump); | |
| 2198 | |
| 2199 // Try next extry in the table. | |
| 2200 __ AddImmediate(RCX, Immediate(Smi::RawValue(1))); | |
| 2201 __ jmp(&loop); | |
| 2202 | |
| 2203 // Load cid for the Smi case. | |
| 2204 __ Bind(&smi_case); | |
| 2205 __ movq(RAX, Immediate(kSmiCid)); | |
| 2206 __ jmp(&cid_loaded); | |
| 2137 } | 2207 } |
| 2138 | 2208 |
| 2139 | 2209 |
| 2140 // Called from switchable IC calls. | 2210 // Called from switchable IC calls. |
| 2141 // RDI: receiver | 2211 // RDI: receiver |
| 2142 // RBX: ICData (preserved) | 2212 // RBX: ICData (preserved) |
| 2143 // Result: | 2213 // Result: |
| 2144 // RCX: target entry point | 2214 // RCX: target entry point |
| 2145 // CODE_REG: target Code object | 2215 // CODE_REG: target Code object |
| 2146 // R10: arguments descriptor | 2216 // R10: arguments descriptor |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2220 } | 2290 } |
| 2221 | 2291 |
| 2222 | 2292 |
| 2223 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { | 2293 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { |
| 2224 __ int3(); | 2294 __ int3(); |
| 2225 } | 2295 } |
| 2226 | 2296 |
| 2227 } // namespace dart | 2297 } // namespace dart |
| 2228 | 2298 |
| 2229 #endif // defined TARGET_ARCH_X64 | 2299 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |