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

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

Issue 62133002: Cleanup of branch code generation (no change in functionality). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: rebased Created 7 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 | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_arm.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) 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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flow_graph_allocator.h" 10 #include "vm/flow_graph_allocator.h"
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 void Instruction::RemoveEnvironment() { 480 void Instruction::RemoveEnvironment() {
481 for (Environment::DeepIterator it(env()); !it.Done(); it.Advance()) { 481 for (Environment::DeepIterator it(env()); !it.Done(); it.Advance()) {
482 it.CurrentValue()->RemoveFromUseList(); 482 it.CurrentValue()->RemoveFromUseList();
483 } 483 }
484 env_ = NULL; 484 env_ = NULL;
485 } 485 }
486 486
487 487
488 Instruction* Instruction::RemoveFromGraph(bool return_previous) { 488 Instruction* Instruction::RemoveFromGraph(bool return_previous) {
489 ASSERT(!IsBlockEntry()); 489 ASSERT(!IsBlockEntry());
490 ASSERT(!IsControl()); 490 ASSERT(!IsBranch());
491 ASSERT(!IsThrow()); 491 ASSERT(!IsThrow());
492 ASSERT(!IsReturn()); 492 ASSERT(!IsReturn());
493 ASSERT(!IsReThrow()); 493 ASSERT(!IsReThrow());
494 ASSERT(!IsGoto()); 494 ASSERT(!IsGoto());
495 ASSERT(previous() != NULL); 495 ASSERT(previous() != NULL);
496 // We cannot assert that the instruction, if it is a definition, has no 496 // We cannot assert that the instruction, if it is a definition, has no
497 // uses. This function is used to remove instructions from the graph and 497 // uses. This function is used to remove instructions from the graph and
498 // reinsert them elsewhere (e.g., hoisting). 498 // reinsert them elsewhere (e.g., hoisting).
499 Instruction* prev_instr = previous(); 499 Instruction* prev_instr = previous();
500 Instruction* next_instr = next(); 500 Instruction* next_instr = next();
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 return 1 + catch_entries_.length(); 1082 return 1 + catch_entries_.length();
1083 } 1083 }
1084 1084
1085 1085
1086 BlockEntryInstr* GraphEntryInstr::SuccessorAt(intptr_t index) const { 1086 BlockEntryInstr* GraphEntryInstr::SuccessorAt(intptr_t index) const {
1087 if (index == 0) return normal_entry_; 1087 if (index == 0) return normal_entry_;
1088 return catch_entries_[index - 1]; 1088 return catch_entries_[index - 1];
1089 } 1089 }
1090 1090
1091 1091
1092 intptr_t ControlInstruction::SuccessorCount() const { 1092 intptr_t BranchInstr::SuccessorCount() const {
1093 return 2; 1093 return 2;
1094 } 1094 }
1095 1095
1096 1096
1097 BlockEntryInstr* ControlInstruction::SuccessorAt(intptr_t index) const { 1097 BlockEntryInstr* BranchInstr::SuccessorAt(intptr_t index) const {
1098 if (index == 0) return true_successor_; 1098 if (index == 0) return true_successor_;
1099 if (index == 1) return false_successor_; 1099 if (index == 1) return false_successor_;
1100 UNREACHABLE(); 1100 UNREACHABLE();
1101 return NULL; 1101 return NULL;
1102 } 1102 }
1103 1103
1104 1104
1105 intptr_t GotoInstr::SuccessorCount() const { 1105 intptr_t GotoInstr::SuccessorCount() const {
1106 return 1; 1106 return 1;
1107 } 1107 }
(...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after
2473 2473
2474 2474
2475 void IfThenElseInstr::InferRange() { 2475 void IfThenElseInstr::InferRange() {
2476 const intptr_t min = Utils::Minimum(if_true_, if_false_); 2476 const intptr_t min = Utils::Minimum(if_true_, if_false_);
2477 const intptr_t max = Utils::Maximum(if_true_, if_false_); 2477 const intptr_t max = Utils::Maximum(if_true_, if_false_);
2478 range_ = new Range(RangeBoundary::FromConstant(min), 2478 range_ = new Range(RangeBoundary::FromConstant(min),
2479 RangeBoundary::FromConstant(max)); 2479 RangeBoundary::FromConstant(max));
2480 } 2480 }
2481 2481
2482 2482
2483 static bool BindsToSmiConstant(Value* value) {
2484 return value->BindsToConstant() && value->BoundConstant().IsSmi();
2485 }
2486
2487
2488 bool IfThenElseInstr::Supports(ComparisonInstr* comparison,
2489 Value* v1,
2490 Value* v2) {
2491 if (!(comparison->IsStrictCompare() &&
2492 !comparison->AsStrictCompare()->needs_number_check()) &&
2493 !(comparison->IsEqualityCompare() &&
2494 (comparison->AsEqualityCompare()->operation_cid() == kSmiCid))) {
2495 return false;
2496 }
2497
2498 if (!BindsToSmiConstant(v1) || !BindsToSmiConstant(v2)) {
2499 return false;
2500 }
2501
2502 return true;
2503 }
2504
2505
2483 void PhiInstr::InferRange() { 2506 void PhiInstr::InferRange() {
2484 RangeBoundary new_min; 2507 RangeBoundary new_min;
2485 RangeBoundary new_max; 2508 RangeBoundary new_max;
2486 2509
2487 for (intptr_t i = 0; i < InputCount(); i++) { 2510 for (intptr_t i = 0; i < InputCount(); i++) {
2488 Range* input_range = InputAt(i)->definition()->range(); 2511 Range* input_range = InputAt(i)->definition()->range();
2489 if (input_range == NULL) { 2512 if (input_range == NULL) {
2490 range_ = Range::Unknown(); 2513 range_ = Range::Unknown();
2491 return; 2514 return;
2492 } 2515 }
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
2921 return kCosRuntimeEntry; 2944 return kCosRuntimeEntry;
2922 default: 2945 default:
2923 UNREACHABLE(); 2946 UNREACHABLE();
2924 } 2947 }
2925 return kSinRuntimeEntry; 2948 return kSinRuntimeEntry;
2926 } 2949 }
2927 2950
2928 #undef __ 2951 #undef __
2929 2952
2930 } // namespace dart 2953 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698