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

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

Issue 11299298: Cache lookups at megamorphic call sites in optimized code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/flow_graph_compiler.h" 8 #include "vm/flow_graph_compiler.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 __ LoadObject(R10, arguments_descriptor); 1090 __ LoadObject(R10, arguments_descriptor);
1091 GenerateDartCall(deopt_id, 1091 GenerateDartCall(deopt_id,
1092 token_pos, 1092 token_pos,
1093 target_label, 1093 target_label,
1094 PcDescriptors::kIcCall, 1094 PcDescriptors::kIcCall,
1095 locs); 1095 locs);
1096 __ Drop(argument_count); 1096 __ Drop(argument_count);
1097 } 1097 }
1098 1098
1099 1099
1100 void FlowGraphCompiler::EmitMegamorphicInstanceCall(
1101 const ICData& ic_data,
1102 const Array& arguments_descriptor,
1103 intptr_t argument_count,
1104 intptr_t deopt_id,
1105 intptr_t token_pos,
1106 LocationSummary* locs) {
1107 MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table();
1108 const String& name = String::Handle(ic_data.target_name());
1109 const MegamorphicCache& cache =
1110 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor));
1111 Label not_smi, load_cache;
1112 __ movq(RAX, Address(RSP, (argument_count - 1) * kWordSize));
1113 __ testq(RAX, Immediate(kSmiTagMask));
1114 __ j(NOT_ZERO, &not_smi, Assembler::kNearJump);
1115 __ movq(RAX, Immediate(Smi::RawValue(kSmiCid)));
1116 __ jmp(&load_cache);
1117
1118 __ Bind(&not_smi);
1119 __ LoadClassId(RAX, RAX);
1120 __ SmiTag(RAX);
1121
1122 // RAX: class ID of the receiver (smi).
1123 __ Bind(&load_cache);
1124 __ LoadObject(RBX, cache);
1125 __ movq(RDI, FieldAddress(RBX, MegamorphicCache::buckets_offset()));
1126 __ movq(RBX, FieldAddress(RBX, MegamorphicCache::mask_offset()));
1127 // RDI: cache buckets array.
1128 // RBX: mask.
1129 __ movq(RCX, RAX);
1130
1131 Label loop, update, found;
1132 __ jmp(&loop);
1133
1134 __ Bind(&update);
1135 __ addq(RCX, Immediate(Smi::RawValue(1)));
1136 __ Bind(&loop);
1137 __ andq(RCX, RBX);
1138 const intptr_t base = Array::data_offset();
1139 // RCX is smi tagged, but table entries are two words, so TIMES_8.
1140 __ movq(RDX, FieldAddress(RDI, RCX, TIMES_8, base));
1141
1142 ASSERT(kIllegalCid == 0);
1143 __ testq(RDX, RDX);
1144 __ j(ZERO, &found, Assembler::kNearJump);
1145 __ cmpq(RDX, RAX);
1146 __ j(NOT_EQUAL, &update, Assembler::kNearJump);
1147
1148 __ Bind(&found);
1149 __ movq(RAX, FieldAddress(RDI, RCX, TIMES_8, base + kWordSize));
1150 __ movq(RAX, FieldAddress(RAX, Function::code_offset()));
1151 __ movq(RAX, FieldAddress(RAX, Code::instructions_offset()));
1152 __ LoadObject(RBX, ic_data);
1153 __ LoadObject(R10, arguments_descriptor);
1154 __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
1155 __ call(RAX);
1156 AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos);
1157 RecordSafepoint(locs);
1158 AddDeoptIndexAtCall(deopt_id, token_pos);
1159 __ Drop(argument_count);
1160 }
1161
1162
1100 void FlowGraphCompiler::EmitStaticCall(const Function& function, 1163 void FlowGraphCompiler::EmitStaticCall(const Function& function,
1101 const Array& arguments_descriptor, 1164 const Array& arguments_descriptor,
1102 intptr_t argument_count, 1165 intptr_t argument_count,
1103 intptr_t deopt_id, 1166 intptr_t deopt_id,
1104 intptr_t token_pos, 1167 intptr_t token_pos,
1105 LocationSummary* locs) { 1168 LocationSummary* locs) {
1106 __ LoadObject(R10, arguments_descriptor); 1169 __ LoadObject(R10, arguments_descriptor);
1107 // Do not use the code from the function, but let the code be patched so that 1170 // Do not use the code from the function, but let the code be patched so that
1108 // we can record the outgoing edges to other code. 1171 // we can record the outgoing edges to other code.
1109 GenerateDartCall(deopt_id, 1172 GenerateDartCall(deopt_id,
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) { 1467 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) {
1405 __ Exchange(mem1, mem2); 1468 __ Exchange(mem1, mem2);
1406 } 1469 }
1407 1470
1408 1471
1409 #undef __ 1472 #undef __
1410 1473
1411 } // namespace dart 1474 } // namespace dart
1412 1475
1413 #endif // defined TARGET_ARCH_X64 1476 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698