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

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

Issue 11361225: In optimized code use IC calls for instance calls that have no IC data instead of deoptimizing. The… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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_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/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 25 matching lines...) Expand all
36 const intptr_t kNumTemps = 1; 36 const intptr_t kNumTemps = 1;
37 LocationSummary* locs = 37 LocationSummary* locs =
38 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); 38 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
39 locs->set_in(0, Location::RegisterLocation(RAX)); 39 locs->set_in(0, Location::RegisterLocation(RAX));
40 locs->set_temp(0, Location::RegisterLocation(RDX)); 40 locs->set_temp(0, Location::RegisterLocation(RDX));
41 return locs; 41 return locs;
42 } 42 }
43 43
44 44
45 void ReturnInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 45 void ReturnInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
46 const Function& function =
47 Function::ZoneHandle(compiler->parsed_function().function().raw());
46 Register result = locs()->in(0).reg(); 48 Register result = locs()->in(0).reg();
47 Register func_reg = locs()->temp(0).reg(); 49 Register func_reg = locs()->temp(0).reg();
48 ASSERT(result == RAX); 50 ASSERT(result == RAX);
49 if (!compiler->is_optimizing()) { 51 if (compiler->is_optimizing()) {
52 if (compiler->may_reoptimize()) {
53 // Increment of counter occurs only in optimized IC calls, as they
54 // can cause reoptimization.
55 Label done;
56 __ LoadObject(func_reg, function);
57 __ cmpq(FieldAddress(func_reg, Function::usage_counter_offset()),
58 Immediate(FLAG_optimization_counter_threshold));
59 __ j(LESS, &done, Assembler::kNearJump);
60 // Equal (or greater), optimize. Note that counter can reach equality
61 // only at return instruction.
62 // The stub call preserves result register (EAX).
63 ASSERT(func_reg == RDX);
64 compiler->GenerateCall(0, // no token position.
65 &StubCode::OptimizeFunctionLabel(),
66 PcDescriptors::kOther,
67 locs());
68 __ Bind(&done);
69 }
70 } else {
50 __ Comment("Check function counter"); 71 __ Comment("Check function counter");
51 // Count only in unoptimized code. 72 // Count only in unoptimized code.
52 // TODO(srdjan): Replace the counting code with a type feedback 73 // TODO(srdjan): Replace the counting code with a type feedback
53 // collection and counting stub. 74 // collection and counting stub.
54 const Function& function =
55 Function::ZoneHandle(compiler->parsed_function().function().raw());
56 __ LoadObject(func_reg, function); 75 __ LoadObject(func_reg, function);
57 __ incq(FieldAddress(func_reg, Function::usage_counter_offset())); 76 __ incq(FieldAddress(func_reg, Function::usage_counter_offset()));
58 if (FlowGraphCompiler::CanOptimize() && 77 if (FlowGraphCompiler::CanOptimize() &&
59 compiler->parsed_function().function().is_optimizable()) { 78 compiler->parsed_function().function().is_optimizable()) {
60 // Do not optimize if usage count must be reported. 79 // Do not optimize if usage count must be reported.
61 __ cmpq(FieldAddress(func_reg, Function::usage_counter_offset()), 80 __ cmpq(FieldAddress(func_reg, Function::usage_counter_offset()),
62 Immediate(FLAG_optimization_counter_threshold)); 81 Immediate(FLAG_optimization_counter_threshold));
63 Label not_yet_hot; 82 Label not_yet_hot;
64 __ j(LESS, &not_yet_hot, Assembler::kNearJump); 83 __ j(LESS, &not_yet_hot, Assembler::kNearJump);
65 // Equal (or greater), optimize. 84 // Equal (or greater), optimize.
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 Immediate(reinterpret_cast<intptr_t>(Object::null())); 356 Immediate(reinterpret_cast<intptr_t>(Object::null()));
338 Label check_identity; 357 Label check_identity;
339 __ cmpq(Address(RSP, 0 * kWordSize), raw_null); 358 __ cmpq(Address(RSP, 0 * kWordSize), raw_null);
340 __ j(EQUAL, &check_identity, Assembler::kNearJump); 359 __ j(EQUAL, &check_identity, Assembler::kNearJump);
341 __ cmpq(Address(RSP, 1 * kWordSize), raw_null); 360 __ cmpq(Address(RSP, 1 * kWordSize), raw_null);
342 __ j(EQUAL, &check_identity, Assembler::kNearJump); 361 __ j(EQUAL, &check_identity, Assembler::kNearJump);
343 362
344 ICData& equality_ic_data = ICData::ZoneHandle(original_ic_data.raw()); 363 ICData& equality_ic_data = ICData::ZoneHandle(original_ic_data.raw());
345 if (compiler->is_optimizing() && FLAG_propagate_ic_data) { 364 if (compiler->is_optimizing() && FLAG_propagate_ic_data) {
346 ASSERT(!original_ic_data.IsNull()); 365 ASSERT(!original_ic_data.IsNull());
347 equality_ic_data = original_ic_data.AsUnaryClassChecks(); 366 if (original_ic_data.NumberOfChecks() == 0) {
367 // IC call for reoptimization populates original ICData.
368 equality_ic_data = original_ic_data.raw();
369 } else {
370 // Megamorphic call.
371 equality_ic_data = original_ic_data.AsUnaryClassChecks();
372 }
348 } else { 373 } else {
349 equality_ic_data = ICData::New(compiler->parsed_function().function(), 374 equality_ic_data = ICData::New(compiler->parsed_function().function(),
350 operator_name, 375 operator_name,
351 deopt_id, 376 deopt_id,
352 kNumArgumentsChecked); 377 kNumArgumentsChecked);
353 } 378 }
354 compiler->GenerateInstanceCall(deopt_id, 379 compiler->GenerateInstanceCall(deopt_id,
355 token_pos, 380 token_pos,
356 kNumberOfArguments, 381 kNumberOfArguments,
357 kNoArgumentNames, 382 kNoArgumentNames,
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 if (!compiler->is_optimizing()) { 875 if (!compiler->is_optimizing()) {
851 compiler->AddCurrentDescriptor(PcDescriptors::kDeoptBefore, 876 compiler->AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
852 deopt_id(), 877 deopt_id(),
853 token_pos()); 878 token_pos());
854 } 879 }
855 const intptr_t kNumArguments = 2; 880 const intptr_t kNumArguments = 2;
856 const intptr_t kNumArgsChecked = 2; // Type-feedback. 881 const intptr_t kNumArgsChecked = 2; // Type-feedback.
857 ICData& relational_ic_data = ICData::ZoneHandle(ic_data()->raw()); 882 ICData& relational_ic_data = ICData::ZoneHandle(ic_data()->raw());
858 if (compiler->is_optimizing() && FLAG_propagate_ic_data) { 883 if (compiler->is_optimizing() && FLAG_propagate_ic_data) {
859 ASSERT(!ic_data()->IsNull()); 884 ASSERT(!ic_data()->IsNull());
860 relational_ic_data = ic_data()->AsUnaryClassChecks(); 885 if (ic_data()->NumberOfChecks() == 0) {
886 // IC call for reoptimization populates original ICData.
887 relational_ic_data = ic_data()->raw();
888 } else {
889 // Megamorphic call.
890 relational_ic_data = ic_data()->AsUnaryClassChecks();
891 }
861 } else { 892 } else {
862 relational_ic_data = ICData::New(compiler->parsed_function().function(), 893 relational_ic_data = ICData::New(compiler->parsed_function().function(),
863 function_name, 894 function_name,
864 deopt_id(), 895 deopt_id(),
865 kNumArgsChecked); 896 kNumArgsChecked);
866 } 897 }
867 compiler->GenerateInstanceCall(deopt_id(), 898 compiler->GenerateInstanceCall(deopt_id(),
868 token_pos(), 899 token_pos(),
869 kNumArguments, 900 kNumArguments,
870 Array::ZoneHandle(), // No optional arguments. 901 Array::ZoneHandle(), // No optional arguments.
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after
2344 2375
2345 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2376 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2346 UNIMPLEMENTED(); 2377 UNIMPLEMENTED();
2347 } 2378 }
2348 2379
2349 } // namespace dart 2380 } // namespace dart
2350 2381
2351 #undef __ 2382 #undef __
2352 2383
2353 #endif // defined TARGET_ARCH_X64 2384 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698