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

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

Issue 442293002: Consolidate all range analysis related code in a separate file. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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_range_analysis.cc ('k') | runtime/vm/il_printer.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) 2014, 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/flow_graph_range_analysis.h"
6 #include "vm/unit_test.h" 6 #include "vm/unit_test.h"
7 7
8 namespace dart { 8 namespace dart {
9 9
10 TEST_CASE(InstructionTests) {
11 TargetEntryInstr* target_instr =
12 new TargetEntryInstr(1, CatchClauseNode::kInvalidTryIndex);
13 EXPECT(target_instr->IsBlockEntry());
14 EXPECT(!target_instr->IsDefinition());
15 CurrentContextInstr* context = new CurrentContextInstr();
16 EXPECT(context->IsDefinition());
17 EXPECT(!context->IsBlockEntry());
18 }
19
20
21 TEST_CASE(OptimizationTests) {
22 JoinEntryInstr* join =
23 new JoinEntryInstr(1, CatchClauseNode::kInvalidTryIndex);
24
25 Definition* def1 = new PhiInstr(join, 0);
26 Definition* def2 = new PhiInstr(join, 0);
27 Value* use1a = new Value(def1);
28 Value* use1b = new Value(def1);
29 EXPECT(use1a->Equals(use1b));
30 Value* use2 = new Value(def2);
31 EXPECT(!use2->Equals(use1a));
32
33 ConstantInstr* c1 = new ConstantInstr(Bool::True());
34 ConstantInstr* c2 = new ConstantInstr(Bool::True());
35 EXPECT(c1->Equals(c2));
36 ConstantInstr* c3 = new ConstantInstr(Object::ZoneHandle());
37 ConstantInstr* c4 = new ConstantInstr(Object::ZoneHandle());
38 EXPECT(c3->Equals(c4));
39 EXPECT(!c3->Equals(c1));
40 }
41
42 10
43 TEST_CASE(RangeTests) { 11 TEST_CASE(RangeTests) {
44 Range* zero = new Range( 12 Range* zero = new Range(
45 RangeBoundary::FromConstant(0), 13 RangeBoundary::FromConstant(0),
46 RangeBoundary::FromConstant(0)); 14 RangeBoundary::FromConstant(0));
47 Range* positive = new Range( 15 Range* positive = new Range(
48 RangeBoundary::FromConstant(0), 16 RangeBoundary::FromConstant(0),
49 RangeBoundary::FromConstant(100)); 17 RangeBoundary::FromConstant(100));
50 Range* negative = new Range( 18 Range* negative = new Range(
51 RangeBoundary::FromConstant(-1), 19 RangeBoundary::FromConstant(-1),
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 RangeBoundary(static_cast<int64_t>(kMaxInt64)), 631 RangeBoundary(static_cast<int64_t>(kMaxInt64)),
664 RangeBoundary(static_cast<int64_t>(kMaxInt32)), 632 RangeBoundary(static_cast<int64_t>(kMaxInt32)),
665 RangeBoundary::kRangeBoundaryInt64).ConstantValue() == kMaxInt32); 633 RangeBoundary::kRangeBoundaryInt64).ConstantValue() == kMaxInt32);
666 634
667 EXPECT(RangeBoundary::Max( 635 EXPECT(RangeBoundary::Max(
668 RangeBoundary(static_cast<int64_t>(kMaxInt64)), 636 RangeBoundary(static_cast<int64_t>(kMaxInt64)),
669 RangeBoundary(static_cast<int64_t>(kMaxInt32)), 637 RangeBoundary(static_cast<int64_t>(kMaxInt32)),
670 RangeBoundary::kRangeBoundaryInt64).ConstantValue() == kMaxInt64); 638 RangeBoundary::kRangeBoundaryInt64).ConstantValue() == kMaxInt64);
671 } 639 }
672 640
641
673 } // namespace dart 642 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_range_analysis.cc ('k') | runtime/vm/il_printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698