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

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

Issue 10887009: Refactor branch instructions to enable further optimizations. (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 | « no previous file | runtime/vm/flow_graph_optimizer.h » ('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/flow_graph_builder.h" 5 #include "vm/flow_graph_builder.h"
6 6
7 #include "vm/ast_printer.h" 7 #include "vm/ast_printer.h"
8 #include "vm/code_descriptors.h" 8 #include "vm/code_descriptors.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flags.h" 10 #include "vm/flags.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 269
270 270
271 void TestGraphVisitor::ReturnValue(Value* value) { 271 void TestGraphVisitor::ReturnValue(Value* value) {
272 if (FLAG_enable_type_checks) { 272 if (FLAG_enable_type_checks) {
273 value = Bind(new AssertBooleanComp(condition_token_pos(), 273 value = Bind(new AssertBooleanComp(condition_token_pos(),
274 owner()->try_index(), 274 owner()->try_index(),
275 value)); 275 value));
276 } 276 }
277 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); 277 const Bool& bool_true = Bool::ZoneHandle(Bool::True());
278 Value* constant_true = Bind(Constant(bool_true)); 278 Value* constant_true = Bind(Constant(bool_true));
279 StrictCompareAndBranchInstr* branch = 279 StrictCompareComp* comp =
280 new StrictCompareAndBranchInstr(value, constant_true, Token::kEQ_STRICT); 280 new StrictCompareComp(Token::kEQ_STRICT, value, constant_true);
281 BranchInstr* branch = new BranchInstr(comp);
281 AddInstruction(branch); 282 AddInstruction(branch);
282 CloseFragment(); 283 CloseFragment();
283 true_successor_address_ = branch->true_successor_address(); 284 true_successor_address_ = branch->true_successor_address();
284 false_successor_address_ = branch->false_successor_address(); 285 false_successor_address_ = branch->false_successor_address();
285 } 286 }
286 287
287 288
288 void TestGraphVisitor::MergeBranchWithComparison(ComparisonComp* comp) { 289 void TestGraphVisitor::MergeBranchWithComparison(ComparisonComp* comp) {
289 ASSERT(!FLAG_enable_type_checks); 290 ASSERT(!FLAG_enable_type_checks);
290 ControlInstruction* branch; 291 ControlInstruction* branch;
291 if (Token::IsStrictEqualityOperator(comp->kind())) { 292 if (Token::IsStrictEqualityOperator(comp->kind())) {
292 branch = new StrictCompareAndBranchInstr(comp->left(), 293 branch = new BranchInstr(new StrictCompareComp(comp->kind(),
293 comp->right(), 294 comp->left(),
294 comp->kind()); 295 comp->right()));
295 } else if (Token::IsEqualityOperator(comp->kind()) && 296 } else if (Token::IsEqualityOperator(comp->kind()) &&
296 (comp->left()->BindsToConstantNull() || 297 (comp->left()->BindsToConstantNull() ||
297 comp->right()->BindsToConstantNull())) { 298 comp->right()->BindsToConstantNull())) {
298 branch = new StrictCompareAndBranchInstr( 299 branch = new BranchInstr(new StrictCompareComp(
300 (comp->kind() == Token::kEQ) ? Token::kEQ_STRICT : Token::kNE_STRICT,
299 comp->left(), 301 comp->left(),
300 comp->right(), 302 comp->right()));
301 (comp->kind() == Token::kEQ) ? Token::kEQ_STRICT : Token::kNE_STRICT);
302 } else { 303 } else {
303 branch = new BranchInstr(condition_token_pos(), 304 branch = new BranchInstr(comp);
304 owner()->try_index(),
305 comp->left(),
306 comp->right(),
307 comp->kind());
308 } 305 }
309 AddInstruction(branch); 306 AddInstruction(branch);
310 CloseFragment(); 307 CloseFragment();
311 true_successor_address_ = branch->true_successor_address(); 308 true_successor_address_ = branch->true_successor_address();
312 false_successor_address_ = branch->false_successor_address(); 309 false_successor_address_ = branch->false_successor_address();
313 } 310 }
314 311
315 312
316 void TestGraphVisitor::MergeBranchWithNegate(BooleanNegateComp* comp) { 313 void TestGraphVisitor::MergeBranchWithNegate(BooleanNegateComp* comp) {
317 ASSERT(!FLAG_enable_type_checks); 314 ASSERT(!FLAG_enable_type_checks);
318 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); 315 const Bool& bool_true = Bool::ZoneHandle(Bool::True());
319 Value* constant_true = Bind(Constant(bool_true)); 316 Value* constant_true = Bind(Constant(bool_true));
320 StrictCompareAndBranchInstr* branch = 317 BranchInstr* branch = new BranchInstr(
321 new StrictCompareAndBranchInstr(comp->value(), 318 new StrictCompareComp(Token::kNE_STRICT,
322 constant_true, 319 comp->value(),
323 Token::kNE_STRICT); 320 constant_true));
324 AddInstruction(branch); 321 AddInstruction(branch);
325 CloseFragment(); 322 CloseFragment();
326 true_successor_address_ = branch->true_successor_address(); 323 true_successor_address_ = branch->true_successor_address();
327 false_successor_address_ = branch->false_successor_address(); 324 false_successor_address_ = branch->false_successor_address();
328 } 325 }
329 326
330 327
331 void TestGraphVisitor::ReturnComputation(Computation* computation) { 328 void TestGraphVisitor::ReturnComputation(Computation* computation) {
332 if (!FLAG_enable_type_checks) { 329 if (!FLAG_enable_type_checks) {
333 if (computation->AsComparison() != NULL) { 330 if (computation->AsComparison() != NULL) {
(...skipping 2092 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 2423 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
2427 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 2424 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
2428 OS::SNPrint(chars, len, kFormat, function_name, reason); 2425 OS::SNPrint(chars, len, kFormat, function_name, reason);
2429 const Error& error = Error::Handle( 2426 const Error& error = Error::Handle(
2430 LanguageError::New(String::Handle(String::New(chars)))); 2427 LanguageError::New(String::Handle(String::New(chars))));
2431 Isolate::Current()->long_jump_base()->Jump(1, error); 2428 Isolate::Current()->long_jump_base()->Jump(1, error);
2432 } 2429 }
2433 2430
2434 2431
2435 } // namespace dart 2432 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_optimizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698