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

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

Issue 10872096: Simplify EmitTestAndCall and eliminated excessive code generation (two Smi tests emitted). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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_x64.h ('k') | runtime/vm/intermediate_language_x64.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) 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/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 __ movl(EDI, Immediate(kSmiCid)); 711 __ movl(EDI, Immediate(kSmiCid));
712 __ testl(left, Immediate(kSmiTagMask)); 712 __ testl(left, Immediate(kSmiTagMask));
713 __ j(ZERO, &done); 713 __ j(ZERO, &done);
714 __ LoadClassId(EDI, left); 714 __ LoadClassId(EDI, left);
715 __ Bind(&done); 715 __ Bind(&done);
716 compiler->EmitTestAndCall(ICData::Handle(ic_data()->AsUnaryClassChecks()), 716 compiler->EmitTestAndCall(ICData::Handle(ic_data()->AsUnaryClassChecks()),
717 EDI, // Class id register. 717 EDI, // Class id register.
718 kNumArguments, 718 kNumArguments,
719 Array::Handle(), // No named arguments. 719 Array::Handle(), // No named arguments.
720 deopt, // Deoptimize target. 720 deopt, // Deoptimize target.
721 NULL, // Fallthrough when done.
722 deopt_id(), 721 deopt_id(),
723 token_pos(), 722 token_pos(),
724 try_index(), 723 try_index(),
725 locs()); 724 locs());
726 ASSERT(locs()->out().reg() == EAX); 725 ASSERT(locs()->out().reg() == EAX);
727 return; 726 return;
728 } 727 }
729 const String& function_name = 728 const String& function_name =
730 String::ZoneHandle(Symbols::New(Token::Str(kind()))); 729 String::ZoneHandle(Symbols::New(Token::Str(kind())));
731 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, 730 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
(...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after
2127 const Function& target = Function::ZoneHandle(ic_data()->GetTargetAt(0)); 2126 const Function& target = Function::ZoneHandle(ic_data()->GetTargetAt(0));
2128 compiler->GenerateStaticCall(instance_call()->deopt_id(), 2127 compiler->GenerateStaticCall(instance_call()->deopt_id(),
2129 instance_call()->token_pos(), 2128 instance_call()->token_pos(),
2130 instance_call()->try_index(), 2129 instance_call()->try_index(),
2131 target, 2130 target,
2132 instance_call()->ArgumentCount(), 2131 instance_call()->ArgumentCount(),
2133 instance_call()->argument_names(), 2132 instance_call()->argument_names(),
2134 locs()); 2133 locs());
2135 return; 2134 return;
2136 } 2135 }
2137 Label handle_smi;
2138 Label* is_smi_label =
2139 ic_data()->GetReceiverClassIdAt(0) == kSmiCid ? &handle_smi : deopt;
2140 2136
2141 // Load receiver into EAX. 2137 // Load receiver into EAX.
2142 __ movl(EAX, 2138 __ movl(EAX,
2143 Address(ESP, (instance_call()->ArgumentCount() - 1) * kWordSize)); 2139 Address(ESP, (instance_call()->ArgumentCount() - 1) * kWordSize));
2140
2141 Label done;
2142 __ movl(EDI, Immediate(kSmiCid));
2144 __ testl(EAX, Immediate(kSmiTagMask)); 2143 __ testl(EAX, Immediate(kSmiTagMask));
2145 __ j(ZERO, is_smi_label); 2144 __ j(ZERO, &done);
2146 Label done;
2147 __ LoadClassId(EDI, EAX); 2145 __ LoadClassId(EDI, EAX);
2146 __ Bind(&done);
2147
2148 compiler->EmitTestAndCall(*ic_data(), 2148 compiler->EmitTestAndCall(*ic_data(),
2149 EDI, // Class id register. 2149 EDI, // Class id register.
2150 instance_call()->ArgumentCount(), 2150 instance_call()->ArgumentCount(),
2151 instance_call()->argument_names(), 2151 instance_call()->argument_names(),
2152 deopt, 2152 deopt,
2153 (is_smi_label == &handle_smi) ? &done : NULL,
2154 instance_call()->deopt_id(), 2153 instance_call()->deopt_id(),
2155 instance_call()->token_pos(), 2154 instance_call()->token_pos(),
2156 instance_call()->try_index(), 2155 instance_call()->try_index(),
2157 locs()); 2156 locs());
2158 if (is_smi_label == &handle_smi) {
2159 __ Bind(&handle_smi);
2160 ASSERT(ic_data()->GetReceiverClassIdAt(0) == kSmiCid);
2161 const Function& target = Function::ZoneHandle(ic_data()->GetTargetAt(0));
2162 compiler->GenerateStaticCall(instance_call()->deopt_id(),
2163 instance_call()->token_pos(),
2164 instance_call()->try_index(),
2165 target,
2166 instance_call()->ArgumentCount(),
2167 instance_call()->argument_names(),
2168 locs());
2169 }
2170 __ Bind(&done);
2171 } 2157 }
2172 2158
2173 2159
2174 // TODO(srdjan): Move to shared. 2160 // TODO(srdjan): Move to shared.
2175 static bool ICDataWithBothClassIds(const ICData& ic_data, intptr_t class_id) { 2161 static bool ICDataWithBothClassIds(const ICData& ic_data, intptr_t class_id) {
2176 if (ic_data.num_args_tested() != 2) return false; 2162 if (ic_data.num_args_tested() != 2) return false;
2177 if (ic_data.NumberOfChecks() != 1) return false; 2163 if (ic_data.NumberOfChecks() != 1) return false;
2178 Function& target = Function::Handle(); 2164 Function& target = Function::Handle();
2179 GrowableArray<intptr_t> class_ids; 2165 GrowableArray<intptr_t> class_ids;
2180 ic_data.GetCheckAt(0, &class_ids, &target); 2166 ic_data.GetCheckAt(0, &class_ids, &target);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2367 __ testl(value, Immediate(kSmiTagMask)); 2353 __ testl(value, Immediate(kSmiTagMask));
2368 __ j(NOT_ZERO, deopt); 2354 __ j(NOT_ZERO, deopt);
2369 } 2355 }
2370 2356
2371 2357
2372 } // namespace dart 2358 } // namespace dart
2373 2359
2374 #undef __ 2360 #undef __
2375 2361
2376 #endif // defined TARGET_ARCH_X64 2362 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.h ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698