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

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

Issue 2132803002: Megamorphic code cleanup. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « runtime/vm/stub_code_mips.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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 2064 matching lines...) Expand 10 before | Expand all | Expand 10 after
2075 const Register left = RAX; 2075 const Register left = RAX;
2076 const Register right = RDX; 2076 const Register right = RDX;
2077 2077
2078 __ movq(left, Address(RSP, 2 * kWordSize)); 2078 __ movq(left, Address(RSP, 2 * kWordSize));
2079 __ movq(right, Address(RSP, 1 * kWordSize)); 2079 __ movq(right, Address(RSP, 1 * kWordSize));
2080 GenerateIdenticalWithNumberCheckStub(assembler, left, right); 2080 GenerateIdenticalWithNumberCheckStub(assembler, left, right);
2081 __ ret(); 2081 __ ret();
2082 } 2082 }
2083 2083
2084 2084
2085 void StubCode::EmitMegamorphicLookup(Assembler* assembler) {
2086 __ LoadTaggedClassIdMayBeSmi(RAX, RDI);
2087 // RAX: class ID of the receiver (smi).
2088 __ movq(R10,
2089 FieldAddress(RBX, MegamorphicCache::arguments_descriptor_offset()));
2090 __ movq(RDI, FieldAddress(RBX, MegamorphicCache::buckets_offset()));
2091 __ movq(R9, FieldAddress(RBX, MegamorphicCache::mask_offset()));
2092 // R10: arguments descriptor (result).
2093 // RDI: cache buckets array.
2094 // RBX: mask.
2095
2096 // Compute the table index.
2097 ASSERT(MegamorphicCache::kSpreadFactor == 7);
2098 // Use leaq and subq multiply with 7 == 8 - 1.
2099 __ leaq(RCX, Address(RAX, TIMES_8, 0));
2100 __ subq(RCX, RAX);
2101
2102 Label loop, update, load_target_function;
2103 __ jmp(&loop);
2104
2105 __ Bind(&update);
2106 __ AddImmediate(RCX, Immediate(Smi::RawValue(1)));
2107 __ Bind(&loop);
2108 __ andq(RCX, R9);
2109 const intptr_t base = Array::data_offset();
2110 // RCX is smi tagged, but table entries are two words, so TIMES_8.
2111 __ movq(RDX, FieldAddress(RDI, RCX, TIMES_8, base));
2112
2113 ASSERT(kIllegalCid == 0);
2114 // Check for the uncommon case, a miss in the cache.
2115 __ testq(RDX, RDX);
2116 __ j(ZERO, &load_target_function, Assembler::kNearJump);
2117
2118 __ cmpq(RDX, RAX);
2119 __ j(NOT_EQUAL, &update, Assembler::kNearJump);
2120
2121 __ Bind(&load_target_function);
2122 // Call the target found in the cache. For a class id match, this is a
2123 // proper target for the given name and arguments descriptor. If the
2124 // illegal class id was found, the target is a cache miss handler that can
2125 // be invoked as a normal Dart function.
2126 __ movq(RAX, FieldAddress(RDI, RCX, TIMES_8, base + kWordSize));
2127 __ movq(RCX, FieldAddress(RAX, Function::entry_point_offset()));
2128 __ movq(CODE_REG, FieldAddress(RAX, Function::code_offset()));
2129 }
2130
2131
2132 // Called from megamorphic calls. 2085 // Called from megamorphic calls.
2133 // RDI: receiver 2086 // RDI: receiver
2134 // RBX: MegamorphicCache (preserved) 2087 // RBX: MegamorphicCache (preserved)
2135 // Result: 2088 // Result:
2136 // RCX: target entry point 2089 // RCX: target entry point
2137 // CODE_REG: target Code 2090 // CODE_REG: target Code
2138 // R10: arguments descriptor 2091 // R10: arguments descriptor
2139 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { 2092 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
2140 // Jump if receiver is a smi. 2093 // Jump if receiver is a smi.
2141 Label smi_case; 2094 Label smi_case;
2142 __ testq(RDI, Immediate(kSmiTagMask)); 2095 __ testq(RDI, Immediate(kSmiTagMask));
2143 // Jump out of line for smi case. 2096 // Jump out of line for smi case.
2144 __ j(ZERO, &smi_case, Assembler::kNearJump); 2097 __ j(ZERO, &smi_case, Assembler::kNearJump);
2145 2098
2146 // Loads the cid of the object. 2099 // Loads the cid of the object.
2147 __ LoadClassId(RAX, RDI); 2100 __ LoadClassId(RAX, RDI);
2148 2101
2149 Label cid_loaded; 2102 Label cid_loaded;
2150 __ Bind(&cid_loaded); 2103 __ Bind(&cid_loaded);
2151 __ movq(R9, FieldAddress(RBX, MegamorphicCache::mask_offset())); 2104 __ movq(R9, FieldAddress(RBX, MegamorphicCache::mask_offset()));
2152 __ movq(RDI, FieldAddress(RBX, MegamorphicCache::buckets_offset())); 2105 __ movq(RDI, FieldAddress(RBX, MegamorphicCache::buckets_offset()));
2153 // R10: arguments descriptor (result). 2106 // R9: mask.
2154 // RDI: cache buckets array. 2107 // RDI: cache buckets array.
2155 // RBX: mask.
2156 2108
2157 // Tag cid as a smi. 2109 // Tag cid as a smi.
2158 __ addq(RAX, RAX); 2110 __ addq(RAX, RAX);
2159 2111
2160 // Compute the table index. 2112 // Compute the table index.
2161 ASSERT(MegamorphicCache::kSpreadFactor == 7); 2113 ASSERT(MegamorphicCache::kSpreadFactor == 7);
2162 // Use leaq and subq multiply with 7 == 8 - 1. 2114 // Use leaq and subq multiply with 7 == 8 - 1.
2163 __ leaq(RCX, Address(RAX, TIMES_8, 0)); 2115 __ leaq(RCX, Address(RAX, TIMES_8, 0));
2164 __ subq(RCX, RAX); 2116 __ subq(RCX, RAX);
2165 2117
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2286 } 2238 }
2287 2239
2288 2240
2289 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { 2241 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) {
2290 __ int3(); 2242 __ int3();
2291 } 2243 }
2292 2244
2293 } // namespace dart 2245 } // namespace dart
2294 2246
2295 #endif // defined TARGET_ARCH_X64 2247 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/stub_code_mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698