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

Side by Side Diff: runtime/vm/flow_graph_compiler_ia32.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_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
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 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 __ LoadObject(EDX, arguments_descriptor); 1086 __ LoadObject(EDX, arguments_descriptor);
1087 GenerateDartCall(deopt_id, 1087 GenerateDartCall(deopt_id,
1088 token_pos, 1088 token_pos,
1089 target_label, 1089 target_label,
1090 PcDescriptors::kIcCall, 1090 PcDescriptors::kIcCall,
1091 locs); 1091 locs);
1092 __ Drop(argument_count); 1092 __ Drop(argument_count);
1093 } 1093 }
1094 1094
1095 1095
1096 void FlowGraphCompiler::EmitMegamorphicInstanceCall(
1097 const ICData& ic_data,
1098 const Array& arguments_descriptor,
1099 intptr_t argument_count,
1100 intptr_t deopt_id,
1101 intptr_t token_pos,
1102 LocationSummary* locs) {
1103 MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table();
1104 const String& name = String::Handle(ic_data.target_name());
1105 const MegamorphicCache& cache =
1106 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor));
1107 Label not_smi, load_cache;
1108 __ movl(EAX, Address(ESP, (argument_count - 1) * kWordSize));
1109 __ testl(EAX, Immediate(kSmiTagMask));
1110 __ j(NOT_ZERO, &not_smi, Assembler::kNearJump);
1111 __ movl(EAX, Immediate(Smi::RawValue(kSmiCid)));
1112 __ jmp(&load_cache);
1113
1114 __ Bind(&not_smi);
1115 __ LoadClassId(EAX, EAX);
1116 __ SmiTag(EAX);
1117
1118 // EAX: class ID of the receiver (smi).
1119 __ Bind(&load_cache);
1120 __ LoadObject(EBX, cache);
1121 __ movl(EDI, FieldAddress(EBX, MegamorphicCache::buckets_offset()));
1122 __ movl(EBX, FieldAddress(EBX, MegamorphicCache::mask_offset()));
1123 // EDI: cache buckets array.
1124 // EBX: mask.
1125 __ movl(ECX, EAX);
1126
1127 Label loop, update, found;
1128 __ jmp(&loop);
1129
1130 __ Bind(&update);
1131 __ addl(ECX, Immediate(Smi::RawValue(1)));
1132 __ Bind(&loop);
1133 __ andl(ECX, EBX);
1134 const intptr_t base = Array::data_offset();
1135 // ECX is smi tagged, but table entries are two words, so TIMES_4.
1136 __ movl(EDX, FieldAddress(EDI, ECX, TIMES_4, base));
1137
1138 ASSERT(kIllegalCid == 0);
1139 __ testl(EDX, EDX);
1140 __ j(ZERO, &found, Assembler::kNearJump);
srdjan 2012/12/03 19:10:46 Maybe use a different label e.g., megamorphic_miss
Kevin Millikin (Google) 2012/12/06 14:03:11 Changed to call_target.
1141 __ cmpl(EDX, EAX);
1142 __ j(NOT_EQUAL, &update, Assembler::kNearJump);
1143
1144 __ Bind(&found);
1145 __ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize));
1146 __ movl(EAX, FieldAddress(EAX, Function::code_offset()));
1147 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset()));
1148 __ LoadObject(ECX, ic_data);
1149 __ LoadObject(EDX, arguments_descriptor);
1150 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
1151 __ call(EAX);
1152 AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos);
1153 RecordSafepoint(locs);
1154 AddDeoptIndexAtCall(deopt_id, token_pos);
1155 __ Drop(argument_count);
1156 }
1157
1158
1096 void FlowGraphCompiler::EmitStaticCall(const Function& function, 1159 void FlowGraphCompiler::EmitStaticCall(const Function& function,
1097 const Array& arguments_descriptor, 1160 const Array& arguments_descriptor,
1098 intptr_t argument_count, 1161 intptr_t argument_count,
1099 intptr_t deopt_id, 1162 intptr_t deopt_id,
1100 intptr_t token_pos, 1163 intptr_t token_pos,
1101 LocationSummary* locs) { 1164 LocationSummary* locs) {
1102 __ LoadObject(EDX, arguments_descriptor); 1165 __ LoadObject(EDX, arguments_descriptor);
1103 // Do not use the code from the function, but let the code be patched so that 1166 // Do not use the code from the function, but let the code be patched so that
1104 // we can record the outgoing edges to other code. 1167 // we can record the outgoing edges to other code.
1105 GenerateDartCall(deopt_id, 1168 GenerateDartCall(deopt_id,
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 __ popl(ECX); 1489 __ popl(ECX);
1427 __ popl(EAX); 1490 __ popl(EAX);
1428 } 1491 }
1429 1492
1430 1493
1431 #undef __ 1494 #undef __
1432 1495
1433 } // namespace dart 1496 } // namespace dart
1434 1497
1435 #endif // defined TARGET_ARCH_IA32 1498 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698