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

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

Issue 1921893002: Faster code for megamorphic calls fo get:hashCode for Smi and OneByteString (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: sync Created 4 years, 8 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
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_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 "vm/ast_printer.h" 10 #include "vm/ast_printer.h"
(...skipping 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 TokenPosition token_pos, 1321 TokenPosition token_pos,
1322 LocationSummary* locs, 1322 LocationSummary* locs,
1323 intptr_t try_index, 1323 intptr_t try_index,
1324 intptr_t slow_path_argument_count) { 1324 intptr_t slow_path_argument_count) {
1325 const String& name = String::Handle(zone(), ic_data.target_name()); 1325 const String& name = String::Handle(zone(), ic_data.target_name());
1326 const Array& arguments_descriptor = 1326 const Array& arguments_descriptor =
1327 Array::ZoneHandle(zone(), ic_data.arguments_descriptor()); 1327 Array::ZoneHandle(zone(), ic_data.arguments_descriptor());
1328 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); 1328 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0));
1329 const MegamorphicCache& cache = MegamorphicCache::ZoneHandle(zone(), 1329 const MegamorphicCache& cache = MegamorphicCache::ZoneHandle(zone(),
1330 MegamorphicCacheTable::Lookup(isolate(), name, arguments_descriptor)); 1330 MegamorphicCacheTable::Lookup(isolate(), name, arguments_descriptor));
1331 __ Comment("MegamorphicCall");
1332 // Load receiver into RDI.
1333 __ movq(RDI, Address(RSP, (argument_count - 1) * kWordSize));
1334 Label done;
1335 if (name.raw() == Symbols::hashCode().raw()) {
1336 Label try_onebytestring, megamorphic_call;
1337 __ Comment("Inlined get:hashCode for Smi and OneByteString");
1338 __ testq(RDI, Immediate(kSmiTagMask));
1339 __ j(NOT_ZERO, &try_onebytestring, Assembler::kNearJump); // Non-smi value.
1340 __ movq(RAX, RDI);
1341 __ jmp(&done, Assembler::kNearJump);
1331 1342
1332 __ Comment("MegamorphicCall"); 1343 __ Bind(&try_onebytestring);
1333 __ movq(RDI, Address(RSP, (argument_count - 1) * kWordSize)); 1344 __ CompareClassId(RDI, kOneByteStringCid);
1345 __ j(NOT_EQUAL, &megamorphic_call, Assembler::kNearJump);
1346 __ movq(RAX, FieldAddress(RDI, String::hash_offset()));
1347 __ cmpq(RAX, Immediate(0));
1348 __ j(NOT_EQUAL, &done, Assembler::kNearJump);
1349
1350 __ Bind(&megamorphic_call);
1351 __ Comment("Slow case: megamorphic call");
1352 }
1334 __ LoadObject(RBX, cache); 1353 __ LoadObject(RBX, cache);
1335 if (FLAG_use_megamorphic_stub) { 1354 if (FLAG_use_megamorphic_stub) {
1336 __ Call(*StubCode::MegamorphicLookup_entry()); 1355 __ Call(*StubCode::MegamorphicLookup_entry());
1337 } else { 1356 } else {
1338 StubCode::EmitMegamorphicLookup(assembler()); 1357 StubCode::EmitMegamorphicLookup(assembler());
1339 } 1358 }
1340 __ call(RCX); 1359 __ call(RCX);
1341 1360
1361 __ Bind(&done);
1342 RecordSafepoint(locs, slow_path_argument_count); 1362 RecordSafepoint(locs, slow_path_argument_count);
1343 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); 1363 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id);
1344 if (FLAG_precompiled_mode) { 1364 if (FLAG_precompiled_mode) {
1345 // Megamorphic calls may occur in slow path stubs. 1365 // Megamorphic calls may occur in slow path stubs.
1346 // If valid use try_index argument. 1366 // If valid use try_index argument.
1347 if (try_index == CatchClauseNode::kInvalidTryIndex) { 1367 if (try_index == CatchClauseNode::kInvalidTryIndex) {
1348 try_index = CurrentTryIndex(); 1368 try_index = CurrentTryIndex();
1349 } 1369 }
1350 pc_descriptors_list()->AddDescriptor(RawPcDescriptors::kOther, 1370 pc_descriptors_list()->AddDescriptor(RawPcDescriptors::kOther,
1351 assembler()->CodeSize(), 1371 assembler()->CodeSize(),
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 __ movups(reg, Address(RSP, 0)); 1870 __ movups(reg, Address(RSP, 0));
1851 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); 1871 __ AddImmediate(RSP, Immediate(kFpuRegisterSize));
1852 } 1872 }
1853 1873
1854 1874
1855 #undef __ 1875 #undef __
1856 1876
1857 } // namespace dart 1877 } // namespace dart
1858 1878
1859 #endif // defined TARGET_ARCH_X64 1879 #endif // defined TARGET_ARCH_X64
OLDNEW
« runtime/vm/flow_graph_compiler_arm.cc ('K') | « runtime/vm/flow_graph_compiler_mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698