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

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

Issue 11232063: Enable merging of comparisons into branches in checked mode. (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
« no previous file with comments | « no previous file | runtime/vm/flow_graph_optimizer.cc » ('j') | runtime/vm/intermediate_language.h » ('J')
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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 BranchInstr* branch = new BranchInstr(comp); 359 BranchInstr* branch = new BranchInstr(comp);
360 AddInstruction(branch); 360 AddInstruction(branch);
361 CloseFragment(); 361 CloseFragment();
362 362
363 true_successor_addresses_.Add(branch->true_successor_address()); 363 true_successor_addresses_.Add(branch->true_successor_address());
364 false_successor_addresses_.Add(branch->false_successor_address()); 364 false_successor_addresses_.Add(branch->false_successor_address());
365 } 365 }
366 366
367 367
368 void TestGraphVisitor::MergeBranchWithComparison(ComparisonInstr* comp) { 368 void TestGraphVisitor::MergeBranchWithComparison(ComparisonInstr* comp) {
369 ASSERT(!FLAG_enable_type_checks);
370 ControlInstruction* branch; 369 ControlInstruction* branch;
371 if (Token::IsStrictEqualityOperator(comp->kind())) { 370 if (Token::IsStrictEqualityOperator(comp->kind())) {
372 branch = new BranchInstr(new StrictCompareInstr(comp->kind(), 371 branch = new BranchInstr(new StrictCompareInstr(comp->kind(),
373 comp->left(), 372 comp->left(),
374 comp->right())); 373 comp->right()));
375 } else if (Token::IsEqualityOperator(comp->kind()) && 374 } else if (Token::IsEqualityOperator(comp->kind()) &&
376 (comp->left()->BindsToConstantNull() || 375 (comp->left()->BindsToConstantNull() ||
377 comp->right()->BindsToConstantNull())) { 376 comp->right()->BindsToConstantNull())) {
378 branch = new BranchInstr(new StrictCompareInstr( 377 branch = new BranchInstr(new StrictCompareInstr(
379 (comp->kind() == Token::kEQ) ? Token::kEQ_STRICT : Token::kNE_STRICT, 378 (comp->kind() == Token::kEQ) ? Token::kEQ_STRICT : Token::kNE_STRICT,
380 comp->left(), 379 comp->left(),
381 comp->right())); 380 comp->right()));
382 } else { 381 } else {
383 branch = new BranchInstr(comp); 382 branch = new BranchInstr(comp, FLAG_enable_type_checks);
384 } 383 }
385 AddInstruction(branch); 384 AddInstruction(branch);
386 CloseFragment(); 385 CloseFragment();
387 true_successor_addresses_.Add(branch->true_successor_address()); 386 true_successor_addresses_.Add(branch->true_successor_address());
388 false_successor_addresses_.Add(branch->false_successor_address()); 387 false_successor_addresses_.Add(branch->false_successor_address());
389 } 388 }
390 389
391 390
392 void TestGraphVisitor::MergeBranchWithNegate(BooleanNegateInstr* neg) { 391 void TestGraphVisitor::MergeBranchWithNegate(BooleanNegateInstr* neg) {
393 ASSERT(!FLAG_enable_type_checks); 392 ASSERT(!FLAG_enable_type_checks);
394 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); 393 const Bool& bool_true = Bool::ZoneHandle(Bool::True());
395 Value* constant_true = Bind(new ConstantInstr(bool_true)); 394 Value* constant_true = Bind(new ConstantInstr(bool_true));
396 BranchInstr* branch = new BranchInstr( 395 BranchInstr* branch = new BranchInstr(
397 new StrictCompareInstr(Token::kNE_STRICT, neg->value(), constant_true)); 396 new StrictCompareInstr(Token::kNE_STRICT, neg->value(), constant_true));
398 AddInstruction(branch); 397 AddInstruction(branch);
399 CloseFragment(); 398 CloseFragment();
400 true_successor_addresses_.Add(branch->true_successor_address()); 399 true_successor_addresses_.Add(branch->true_successor_address());
401 false_successor_addresses_.Add(branch->false_successor_address()); 400 false_successor_addresses_.Add(branch->false_successor_address());
402 } 401 }
403 402
404 403
405 void TestGraphVisitor::ReturnDefinition(Definition* definition) { 404 void TestGraphVisitor::ReturnDefinition(Definition* definition) {
405 ComparisonInstr* comp = definition->AsComparison();
406 if (comp != NULL) {
407 MergeBranchWithComparison(comp);
408 return;
409 }
406 if (!FLAG_enable_type_checks) { 410 if (!FLAG_enable_type_checks) {
407 ComparisonInstr* comp = definition->AsComparison();
408 if (comp != NULL) {
409 MergeBranchWithComparison(comp);
410 return;
411 }
412 BooleanNegateInstr* neg = definition->AsBooleanNegate(); 411 BooleanNegateInstr* neg = definition->AsBooleanNegate();
413 if (neg != NULL) { 412 if (neg != NULL) {
414 MergeBranchWithNegate(neg); 413 MergeBranchWithNegate(neg);
415 return; 414 return;
416 } 415 }
417 } 416 }
418 ReturnValue(Bind(definition)); 417 ReturnValue(Bind(definition));
419 } 418 }
420 419
421 420
(...skipping 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after
2671 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 2670 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
2672 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 2671 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
2673 OS::SNPrint(chars, len, kFormat, function_name, reason); 2672 OS::SNPrint(chars, len, kFormat, function_name, reason);
2674 const Error& error = Error::Handle( 2673 const Error& error = Error::Handle(
2675 LanguageError::New(String::Handle(String::New(chars)))); 2674 LanguageError::New(String::Handle(String::New(chars))));
2676 Isolate::Current()->long_jump_base()->Jump(1, error); 2675 Isolate::Current()->long_jump_base()->Jump(1, error);
2677 } 2676 }
2678 2677
2679 2678
2680 } // namespace dart 2679 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_optimizer.cc » ('j') | runtime/vm/intermediate_language.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698