| OLD | NEW |
| 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 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 __ LoadObject(R10, arguments_descriptor); | 1095 __ LoadObject(R10, arguments_descriptor); |
| 1096 GenerateDartCall(deopt_id, | 1096 GenerateDartCall(deopt_id, |
| 1097 token_pos, | 1097 token_pos, |
| 1098 target_label, | 1098 target_label, |
| 1099 PcDescriptors::kIcCall, | 1099 PcDescriptors::kIcCall, |
| 1100 locs); | 1100 locs); |
| 1101 __ Drop(argument_count); | 1101 __ Drop(argument_count); |
| 1102 } | 1102 } |
| 1103 | 1103 |
| 1104 | 1104 |
| 1105 void FlowGraphCompiler::EmitMegamorphicInstanceCall( |
| 1106 const ICData& ic_data, |
| 1107 const Array& arguments_descriptor, |
| 1108 intptr_t argument_count, |
| 1109 intptr_t deopt_id, |
| 1110 intptr_t token_pos, |
| 1111 LocationSummary* locs) { |
| 1112 MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table(); |
| 1113 const String& name = String::Handle(ic_data.target_name()); |
| 1114 const MegamorphicCache& cache = |
| 1115 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor)); |
| 1116 Label not_smi, load_cache; |
| 1117 __ movq(RAX, Address(RSP, (argument_count - 1) * kWordSize)); |
| 1118 __ testq(RAX, Immediate(kSmiTagMask)); |
| 1119 __ j(NOT_ZERO, ¬_smi, Assembler::kNearJump); |
| 1120 __ movq(RAX, Immediate(Smi::RawValue(kSmiCid))); |
| 1121 __ jmp(&load_cache); |
| 1122 |
| 1123 __ Bind(¬_smi); |
| 1124 __ LoadClassId(RAX, RAX); |
| 1125 __ SmiTag(RAX); |
| 1126 |
| 1127 // RAX: class ID of the receiver (smi). |
| 1128 __ Bind(&load_cache); |
| 1129 __ LoadObject(RBX, cache); |
| 1130 __ movq(RDI, FieldAddress(RBX, MegamorphicCache::buckets_offset())); |
| 1131 __ movq(RBX, FieldAddress(RBX, MegamorphicCache::mask_offset())); |
| 1132 // RDI: cache buckets array. |
| 1133 // RBX: mask. |
| 1134 __ movq(RCX, RAX); |
| 1135 |
| 1136 Label loop, update, call_target_function; |
| 1137 __ jmp(&loop); |
| 1138 |
| 1139 __ Bind(&update); |
| 1140 __ addq(RCX, Immediate(Smi::RawValue(1))); |
| 1141 __ Bind(&loop); |
| 1142 __ andq(RCX, RBX); |
| 1143 const intptr_t base = Array::data_offset(); |
| 1144 // RCX is smi tagged, but table entries are two words, so TIMES_8. |
| 1145 __ movq(RDX, FieldAddress(RDI, RCX, TIMES_8, base)); |
| 1146 |
| 1147 ASSERT(kIllegalCid == 0); |
| 1148 __ testq(RDX, RDX); |
| 1149 __ j(ZERO, &call_target_function, Assembler::kNearJump); |
| 1150 __ cmpq(RDX, RAX); |
| 1151 __ j(NOT_EQUAL, &update, Assembler::kNearJump); |
| 1152 |
| 1153 __ Bind(&call_target_function); |
| 1154 // Call the target found in the cache. For a class id match, this is a |
| 1155 // proper target for the given name and arguments descriptor. If the |
| 1156 // illegal class id was found, the target is a cache miss handler that can |
| 1157 // be invoked as a normal Dart function. |
| 1158 __ movq(RAX, FieldAddress(RDI, RCX, TIMES_8, base + kWordSize)); |
| 1159 __ movq(RAX, FieldAddress(RAX, Function::code_offset())); |
| 1160 __ movq(RAX, FieldAddress(RAX, Code::instructions_offset())); |
| 1161 __ LoadObject(RBX, ic_data); |
| 1162 __ LoadObject(R10, arguments_descriptor); |
| 1163 __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 1164 __ call(RAX); |
| 1165 AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); |
| 1166 RecordSafepoint(locs); |
| 1167 AddDeoptIndexAtCall(deopt_id, token_pos); |
| 1168 __ Drop(argument_count); |
| 1169 } |
| 1170 |
| 1171 |
| 1105 void FlowGraphCompiler::EmitStaticCall(const Function& function, | 1172 void FlowGraphCompiler::EmitStaticCall(const Function& function, |
| 1106 const Array& arguments_descriptor, | 1173 const Array& arguments_descriptor, |
| 1107 intptr_t argument_count, | 1174 intptr_t argument_count, |
| 1108 intptr_t deopt_id, | 1175 intptr_t deopt_id, |
| 1109 intptr_t token_pos, | 1176 intptr_t token_pos, |
| 1110 LocationSummary* locs) { | 1177 LocationSummary* locs) { |
| 1111 __ LoadObject(R10, arguments_descriptor); | 1178 __ LoadObject(R10, arguments_descriptor); |
| 1112 // Do not use the code from the function, but let the code be patched so that | 1179 // Do not use the code from the function, but let the code be patched so that |
| 1113 // we can record the outgoing edges to other code. | 1180 // we can record the outgoing edges to other code. |
| 1114 GenerateDartCall(deopt_id, | 1181 GenerateDartCall(deopt_id, |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) { | 1476 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) { |
| 1410 __ Exchange(mem1, mem2); | 1477 __ Exchange(mem1, mem2); |
| 1411 } | 1478 } |
| 1412 | 1479 |
| 1413 | 1480 |
| 1414 #undef __ | 1481 #undef __ |
| 1415 | 1482 |
| 1416 } // namespace dart | 1483 } // namespace dart |
| 1417 | 1484 |
| 1418 #endif // defined TARGET_ARCH_X64 | 1485 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |