| 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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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 2036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2047 Assembler* assembler) { | 2047 Assembler* assembler) { |
| 2048 const Register left = EAX; | 2048 const Register left = EAX; |
| 2049 const Register right = EDX; | 2049 const Register right = EDX; |
| 2050 const Register temp = ECX; | 2050 const Register temp = ECX; |
| 2051 __ movl(left, Address(ESP, 2 * kWordSize)); | 2051 __ movl(left, Address(ESP, 2 * kWordSize)); |
| 2052 __ movl(right, Address(ESP, 1 * kWordSize)); | 2052 __ movl(right, Address(ESP, 1 * kWordSize)); |
| 2053 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); | 2053 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); |
| 2054 __ ret(); | 2054 __ ret(); |
| 2055 } | 2055 } |
| 2056 | 2056 |
| 2057 |
| 2058 void StubCode::EmitMegamorphicLookup( |
| 2059 Assembler* assembler, Register receiver, Register cache, Register target) { |
| 2060 ASSERT((cache != EAX) && (cache != EDI)); |
| 2061 __ LoadTaggedClassIdMayBeSmi(EAX, receiver); |
| 2062 |
| 2063 // EAX: class ID of the receiver (smi). |
| 2064 __ movl(EDI, FieldAddress(cache, MegamorphicCache::buckets_offset())); |
| 2065 __ movl(EBX, FieldAddress(cache, MegamorphicCache::mask_offset())); |
| 2066 // EDI: cache buckets array. |
| 2067 // EBX: mask. |
| 2068 __ movl(ECX, EAX); |
| 2069 |
| 2070 Label loop, update, call_target_function; |
| 2071 __ jmp(&loop); |
| 2072 |
| 2073 __ Bind(&update); |
| 2074 __ addl(ECX, Immediate(Smi::RawValue(1))); |
| 2075 __ Bind(&loop); |
| 2076 __ andl(ECX, EBX); |
| 2077 const intptr_t base = Array::data_offset(); |
| 2078 // ECX is smi tagged, but table entries are two words, so TIMES_4. |
| 2079 __ movl(EDX, FieldAddress(EDI, ECX, TIMES_4, base)); |
| 2080 |
| 2081 ASSERT(kIllegalCid == 0); |
| 2082 __ testl(EDX, EDX); |
| 2083 __ j(ZERO, &call_target_function, Assembler::kNearJump); |
| 2084 __ cmpl(EDX, EAX); |
| 2085 __ j(NOT_EQUAL, &update, Assembler::kNearJump); |
| 2086 |
| 2087 __ Bind(&call_target_function); |
| 2088 // Call the target found in the cache. For a class id match, this is a |
| 2089 // proper target for the given name and arguments descriptor. If the |
| 2090 // illegal class id was found, the target is a cache miss handler that can |
| 2091 // be invoked as a normal Dart function. |
| 2092 __ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize)); |
| 2093 __ movl(target, FieldAddress(EAX, Function::instructions_offset())); |
| 2094 // TODO(srdjan): Evaluate performance impact of moving the instruction below |
| 2095 // to the call site, instead of having it here. |
| 2096 __ addl(target, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 2097 } |
| 2098 |
| 2099 |
| 2100 // Called from megamorphic calls. |
| 2101 // EDI: receiver. |
| 2102 // EBX: lookup cache. |
| 2103 // Result: |
| 2104 // EBX: entry point. |
| 2105 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
| 2106 EmitMegamorphicLookup(assembler, EDI, EBX, EBX); |
| 2107 __ ret(); |
| 2108 } |
| 2109 |
| 2110 |
| 2057 } // namespace dart | 2111 } // namespace dart |
| 2058 | 2112 |
| 2059 #endif // defined TARGET_ARCH_IA32 | 2113 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |