| 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_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 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1091   __ LoadObject(EDX, arguments_descriptor); |  1091   __ LoadObject(EDX, arguments_descriptor); | 
|  1092   GenerateDartCall(deopt_id, |  1092   GenerateDartCall(deopt_id, | 
|  1093                    token_pos, |  1093                    token_pos, | 
|  1094                    target_label, |  1094                    target_label, | 
|  1095                    PcDescriptors::kIcCall, |  1095                    PcDescriptors::kIcCall, | 
|  1096                    locs); |  1096                    locs); | 
|  1097   __ Drop(argument_count); |  1097   __ Drop(argument_count); | 
|  1098 } |  1098 } | 
|  1099  |  1099  | 
|  1100  |  1100  | 
 |  1101 void FlowGraphCompiler::EmitMegamorphicInstanceCall( | 
 |  1102     const ICData& ic_data, | 
 |  1103     const Array& arguments_descriptor, | 
 |  1104     intptr_t argument_count, | 
 |  1105     intptr_t deopt_id, | 
 |  1106     intptr_t token_pos, | 
 |  1107     LocationSummary* locs) { | 
 |  1108   MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table(); | 
 |  1109   const String& name = String::Handle(ic_data.target_name()); | 
 |  1110   const MegamorphicCache& cache = | 
 |  1111       MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor)); | 
 |  1112   Label not_smi, load_cache; | 
 |  1113   __ movl(EAX, Address(ESP, (argument_count - 1) * kWordSize)); | 
 |  1114   __ testl(EAX, Immediate(kSmiTagMask)); | 
 |  1115   __ j(NOT_ZERO, ¬_smi, Assembler::kNearJump); | 
 |  1116   __ movl(EAX, Immediate(Smi::RawValue(kSmiCid))); | 
 |  1117   __ jmp(&load_cache); | 
 |  1118  | 
 |  1119   __ Bind(¬_smi); | 
 |  1120   __ LoadClassId(EAX, EAX); | 
 |  1121   __ SmiTag(EAX); | 
 |  1122  | 
 |  1123   // EAX: class ID of the receiver (smi). | 
 |  1124   __ Bind(&load_cache); | 
 |  1125   __ LoadObject(EBX, cache); | 
 |  1126   __ movl(EDI, FieldAddress(EBX, MegamorphicCache::buckets_offset())); | 
 |  1127   __ movl(EBX, FieldAddress(EBX, MegamorphicCache::mask_offset())); | 
 |  1128   // EDI: cache buckets array. | 
 |  1129   // EBX: mask. | 
 |  1130   __ movl(ECX, EAX); | 
 |  1131  | 
 |  1132   Label loop, update, call_target_function; | 
 |  1133   __ jmp(&loop); | 
 |  1134  | 
 |  1135   __ Bind(&update); | 
 |  1136   __ addl(ECX, Immediate(Smi::RawValue(1))); | 
 |  1137   __ Bind(&loop); | 
 |  1138   __ andl(ECX, EBX); | 
 |  1139   const intptr_t base = Array::data_offset(); | 
 |  1140   // ECX is smi tagged, but table entries are two words, so TIMES_4. | 
 |  1141   __ movl(EDX, FieldAddress(EDI, ECX, TIMES_4, base)); | 
 |  1142  | 
 |  1143   ASSERT(kIllegalCid == 0); | 
 |  1144   __ testl(EDX, EDX); | 
 |  1145   __ j(ZERO, &call_target_function, Assembler::kNearJump); | 
 |  1146   __ cmpl(EDX, EAX); | 
 |  1147   __ j(NOT_EQUAL, &update, Assembler::kNearJump); | 
 |  1148  | 
 |  1149   __ Bind(&call_target_function); | 
 |  1150   // Call the target found in the cache.  For a class id match, this is a | 
 |  1151   // proper target for the given name and arguments descriptor.  If the | 
 |  1152   // illegal class id was found, the target is a cache miss handler that can | 
 |  1153   // be invoked as a normal Dart function. | 
 |  1154   __ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize)); | 
 |  1155   __ movl(EAX, FieldAddress(EAX, Function::code_offset())); | 
 |  1156   __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); | 
 |  1157   __ LoadObject(ECX, ic_data); | 
 |  1158   __ LoadObject(EDX, arguments_descriptor); | 
 |  1159   __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 
 |  1160   __ call(EAX); | 
 |  1161   AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); | 
 |  1162   RecordSafepoint(locs); | 
 |  1163   AddDeoptIndexAtCall(deopt_id, token_pos); | 
 |  1164   __ Drop(argument_count); | 
 |  1165 } | 
 |  1166  | 
 |  1167  | 
|  1101 void FlowGraphCompiler::EmitStaticCall(const Function& function, |  1168 void FlowGraphCompiler::EmitStaticCall(const Function& function, | 
|  1102                                        const Array& arguments_descriptor, |  1169                                        const Array& arguments_descriptor, | 
|  1103                                        intptr_t argument_count, |  1170                                        intptr_t argument_count, | 
|  1104                                        intptr_t deopt_id, |  1171                                        intptr_t deopt_id, | 
|  1105                                        intptr_t token_pos, |  1172                                        intptr_t token_pos, | 
|  1106                                        LocationSummary* locs) { |  1173                                        LocationSummary* locs) { | 
|  1107   __ LoadObject(EDX, arguments_descriptor); |  1174   __ LoadObject(EDX, arguments_descriptor); | 
|  1108   // Do not use the code from the function, but let the code be patched so that |  1175   // Do not use the code from the function, but let the code be patched so that | 
|  1109   // we can record the outgoing edges to other code. |  1176   // we can record the outgoing edges to other code. | 
|  1110   GenerateDartCall(deopt_id, |  1177   GenerateDartCall(deopt_id, | 
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1431   __ popl(ECX); |  1498   __ popl(ECX); | 
|  1432   __ popl(EAX); |  1499   __ popl(EAX); | 
|  1433 } |  1500 } | 
|  1434  |  1501  | 
|  1435  |  1502  | 
|  1436 #undef __ |  1503 #undef __ | 
|  1437  |  1504  | 
|  1438 }  // namespace dart |  1505 }  // namespace dart | 
|  1439  |  1506  | 
|  1440 #endif  // defined TARGET_ARCH_IA32 |  1507 #endif  // defined TARGET_ARCH_IA32 | 
| OLD | NEW |