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

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

Issue 1125623003: Move megamorphic lookup code to stub instead of inlining. Preformance loss < 5%, instruction size r… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph_compiler_arm64.cc ('k') | runtime/vm/flow_graph_compiler_mips.cc » ('j') | 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" // 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 "vm/ast_printer.h" 10 #include "vm/ast_printer.h"
11 #include "vm/code_patcher.h" 11 #include "vm/code_patcher.h"
12 #include "vm/compiler.h" 12 #include "vm/compiler.h"
13 #include "vm/cpu.h" 13 #include "vm/cpu.h"
14 #include "vm/dart_entry.h" 14 #include "vm/dart_entry.h"
15 #include "vm/deopt_instructions.h" 15 #include "vm/deopt_instructions.h"
16 #include "vm/flow_graph_builder.h" 16 #include "vm/flow_graph_builder.h"
17 #include "vm/il_printer.h" 17 #include "vm/il_printer.h"
18 #include "vm/locations.h" 18 #include "vm/locations.h"
19 #include "vm/object_store.h" 19 #include "vm/object_store.h"
20 #include "vm/parser.h" 20 #include "vm/parser.h"
21 #include "vm/stack_frame.h" 21 #include "vm/stack_frame.h"
22 #include "vm/stub_code.h" 22 #include "vm/stub_code.h"
23 #include "vm/symbols.h" 23 #include "vm/symbols.h"
24 #include "vm/verified_memory.h" 24 #include "vm/verified_memory.h"
25 25
26 namespace dart { 26 namespace dart {
27 27
28 DEFINE_FLAG(bool, trap_on_deoptimization, false, "Trap on deoptimization."); 28 DEFINE_FLAG(bool, trap_on_deoptimization, false, "Trap on deoptimization.");
29 DEFINE_FLAG(bool, unbox_mints, true, "Optimize 64-bit integer arithmetic."); 29 DEFINE_FLAG(bool, unbox_mints, true, "Optimize 64-bit integer arithmetic.");
30
30 DECLARE_FLAG(bool, enable_type_checks); 31 DECLARE_FLAG(bool, enable_type_checks);
31 DECLARE_FLAG(bool, enable_simd_inline); 32 DECLARE_FLAG(bool, enable_simd_inline);
33 DECLARE_FLAG(bool, use_megamorphic_stub);
32 34
33 35
34 FlowGraphCompiler::~FlowGraphCompiler() { 36 FlowGraphCompiler::~FlowGraphCompiler() {
35 // BlockInfos are zone-allocated, so their destructors are not called. 37 // BlockInfos are zone-allocated, so their destructors are not called.
36 // Verify the labels explicitly here. 38 // Verify the labels explicitly here.
37 for (int i = 0; i < block_info_.length(); ++i) { 39 for (int i = 0; i < block_info_.length(); ++i) {
38 ASSERT(!block_info_[i]->jump_label()->IsLinked()); 40 ASSERT(!block_info_[i]->jump_label()->IsLinked());
39 ASSERT(!block_info_[i]->jump_label()->HasNear()); 41 ASSERT(!block_info_[i]->jump_label()->HasNear());
40 } 42 }
41 } 43 }
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 __ Drop(argument_count); 1298 __ Drop(argument_count);
1297 } 1299 }
1298 1300
1299 1301
1300 void FlowGraphCompiler::EmitMegamorphicInstanceCall( 1302 void FlowGraphCompiler::EmitMegamorphicInstanceCall(
1301 const ICData& ic_data, 1303 const ICData& ic_data,
1302 intptr_t argument_count, 1304 intptr_t argument_count,
1303 intptr_t deopt_id, 1305 intptr_t deopt_id,
1304 intptr_t token_pos, 1306 intptr_t token_pos,
1305 LocationSummary* locs) { 1307 LocationSummary* locs) {
1306 MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table(); 1308 MegamorphicCacheTable* table = isolate()->megamorphic_cache_table();
1307 const String& name = String::Handle(ic_data.target_name()); 1309 const String& name = String::Handle(ic_data.target_name());
1308 const Array& arguments_descriptor = 1310 const Array& arguments_descriptor =
1309 Array::ZoneHandle(ic_data.arguments_descriptor()); 1311 Array::ZoneHandle(ic_data.arguments_descriptor());
1310 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); 1312 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0));
1311 const MegamorphicCache& cache = 1313 const MegamorphicCache& cache =
1312 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor)); 1314 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor));
1313 Label load_cache; 1315 const Register receiverR = EDI;
1314 __ movl(EBX, Address(ESP, (argument_count - 1) * kWordSize)); 1316 const Register cacheR = EBX;
1315 __ LoadTaggedClassIdMayBeSmi(EAX, EBX); 1317 const Register targetR = EBX;
1318 __ movl(receiverR, Address(ESP, (argument_count - 1) * kWordSize));
1319 __ LoadObject(cacheR, cache);
1316 1320
1317 // EAX: class ID of the receiver (smi). 1321 if (FLAG_use_megamorphic_stub) {
1318 __ Bind(&load_cache); 1322 StubCode* stub_code = isolate()->stub_code();
1319 __ LoadObject(EBX, cache); 1323 __ call(&stub_code->MegamorphicLookupLabel());
1320 __ movl(EDI, FieldAddress(EBX, MegamorphicCache::buckets_offset())); 1324 } else {
1321 __ movl(EBX, FieldAddress(EBX, MegamorphicCache::mask_offset())); 1325 StubCode::EmitMegamorphicLookup(assembler(), receiverR, cacheR, targetR);
1322 // EDI: cache buckets array. 1326 }
1323 // EBX: mask.
1324 __ movl(ECX, EAX);
1325 1327
1326 Label loop, update, call_target_function;
1327 __ jmp(&loop);
1328
1329 __ Bind(&update);
1330 __ addl(ECX, Immediate(Smi::RawValue(1)));
1331 __ Bind(&loop);
1332 __ andl(ECX, EBX);
1333 const intptr_t base = Array::data_offset();
1334 // ECX is smi tagged, but table entries are two words, so TIMES_4.
1335 __ movl(EDX, FieldAddress(EDI, ECX, TIMES_4, base));
1336
1337 ASSERT(kIllegalCid == 0);
1338 __ testl(EDX, EDX);
1339 __ j(ZERO, &call_target_function, Assembler::kNearJump);
1340 __ cmpl(EDX, EAX);
1341 __ j(NOT_EQUAL, &update, Assembler::kNearJump);
1342
1343 __ Bind(&call_target_function);
1344 // Call the target found in the cache. For a class id match, this is a
1345 // proper target for the given name and arguments descriptor. If the
1346 // illegal class id was found, the target is a cache miss handler that can
1347 // be invoked as a normal Dart function.
1348 __ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize));
1349 __ movl(EBX, FieldAddress(EAX, Function::instructions_offset()));
1350 __ LoadObject(ECX, ic_data); 1328 __ LoadObject(ECX, ic_data);
1351 __ LoadObject(EDX, arguments_descriptor); 1329 __ LoadObject(EDX, arguments_descriptor);
1352 __ addl(EBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); 1330 __ call(targetR);
1353 __ call(EBX);
1354 AddCurrentDescriptor(RawPcDescriptors::kOther, 1331 AddCurrentDescriptor(RawPcDescriptors::kOther,
1355 Isolate::kNoDeoptId, token_pos); 1332 Isolate::kNoDeoptId, token_pos);
1356 RecordSafepoint(locs); 1333 RecordSafepoint(locs);
1357 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); 1334 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id);
1358 if (is_optimizing()) { 1335 if (is_optimizing()) {
1359 AddDeoptIndexAtCall(deopt_id_after, token_pos); 1336 AddDeoptIndexAtCall(deopt_id_after, token_pos);
1360 } else { 1337 } else {
1361 // Add deoptimization continuation point after the call and before the 1338 // Add deoptimization continuation point after the call and before the
1362 // arguments are removed. 1339 // arguments are removed.
1363 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); 1340 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos);
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 __ movups(reg, Address(ESP, 0)); 1819 __ movups(reg, Address(ESP, 0));
1843 __ addl(ESP, Immediate(kFpuRegisterSize)); 1820 __ addl(ESP, Immediate(kFpuRegisterSize));
1844 } 1821 }
1845 1822
1846 1823
1847 #undef __ 1824 #undef __
1848 1825
1849 } // namespace dart 1826 } // namespace dart
1850 1827
1851 #endif // defined TARGET_ARCH_IA32 1828 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_arm64.cc ('k') | runtime/vm/flow_graph_compiler_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698