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