| 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 2085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2096 Assembler* assembler) { | 2096 Assembler* assembler) { |
| 2097 const Register left = RAX; | 2097 const Register left = RAX; |
| 2098 const Register right = RDX; | 2098 const Register right = RDX; |
| 2099 | 2099 |
| 2100 __ movq(left, Address(RSP, 2 * kWordSize)); | 2100 __ movq(left, Address(RSP, 2 * kWordSize)); |
| 2101 __ movq(right, Address(RSP, 1 * kWordSize)); | 2101 __ movq(right, Address(RSP, 1 * kWordSize)); |
| 2102 GenerateIdenticalWithNumberCheckStub(assembler, left, right); | 2102 GenerateIdenticalWithNumberCheckStub(assembler, left, right); |
| 2103 __ ret(); | 2103 __ ret(); |
| 2104 } | 2104 } |
| 2105 | 2105 |
| 2106 |
| 2107 void StubCode::EmitMegamorphicLookup( |
| 2108 Assembler* assembler, Register receiver, Register cache, Register target) { |
| 2109 ASSERT((cache != RAX) && (cache != RDI)); |
| 2110 __ LoadTaggedClassIdMayBeSmi(RAX, receiver); |
| 2111 // RAX: class ID of the receiver (smi). |
| 2112 __ movq(RDI, FieldAddress(cache, MegamorphicCache::buckets_offset())); |
| 2113 __ movq(RBX, FieldAddress(cache, MegamorphicCache::mask_offset())); |
| 2114 // RDI: cache buckets array. |
| 2115 // RBX: mask. |
| 2116 __ movq(RCX, RAX); |
| 2117 |
| 2118 Label loop, update, call_target_function; |
| 2119 __ jmp(&loop); |
| 2120 |
| 2121 __ Bind(&update); |
| 2122 __ AddImmediate(RCX, Immediate(Smi::RawValue(1)), PP); |
| 2123 __ Bind(&loop); |
| 2124 __ andq(RCX, RBX); |
| 2125 const intptr_t base = Array::data_offset(); |
| 2126 // RCX is smi tagged, but table entries are two words, so TIMES_8. |
| 2127 __ movq(RDX, FieldAddress(RDI, RCX, TIMES_8, base)); |
| 2128 |
| 2129 ASSERT(kIllegalCid == 0); |
| 2130 __ testq(RDX, RDX); |
| 2131 __ j(ZERO, &call_target_function, Assembler::kNearJump); |
| 2132 __ cmpq(RDX, RAX); |
| 2133 __ j(NOT_EQUAL, &update, Assembler::kNearJump); |
| 2134 |
| 2135 __ Bind(&call_target_function); |
| 2136 // Call the target found in the cache. For a class id match, this is a |
| 2137 // proper target for the given name and arguments descriptor. If the |
| 2138 // illegal class id was found, the target is a cache miss handler that can |
| 2139 // be invoked as a normal Dart function. |
| 2140 __ movq(RAX, FieldAddress(RDI, RCX, TIMES_8, base + kWordSize)); |
| 2141 __ movq(target, FieldAddress(RAX, Function::instructions_offset())); |
| 2142 // TODO(srdjan): Evaluate performance impact of moving the instruction below |
| 2143 // to the call site, instead of having it here. |
| 2144 __ AddImmediate( |
| 2145 target, Immediate(Instructions::HeaderSize() - kHeapObjectTag), PP); |
| 2146 } |
| 2147 |
| 2148 |
| 2149 // Called from megamorphic calls. |
| 2150 // RDI: receiver. |
| 2151 // RBX: lookup cache. |
| 2152 // Result: |
| 2153 // RCX: entry point. |
| 2154 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
| 2155 EmitMegamorphicLookup(assembler, RDI, RBX, RCX); |
| 2156 __ ret(); |
| 2157 } |
| 2158 |
| 2106 } // namespace dart | 2159 } // namespace dart |
| 2107 | 2160 |
| 2108 #endif // defined TARGET_ARCH_X64 | 2161 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |