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

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

Issue 22580005: Implement IsNullCheck for CheckClassInstr. If input is nullable expected type, then check for null … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 80
81 bool Value::Equals(Value* other) const { 81 bool Value::Equals(Value* other) const {
82 return definition() == other->definition(); 82 return definition() == other->definition();
83 } 83 }
84 84
85 85
86 CheckClassInstr::CheckClassInstr(Value* value, 86 CheckClassInstr::CheckClassInstr(Value* value,
87 intptr_t deopt_id, 87 intptr_t deopt_id,
88 const ICData& unary_checks) 88 const ICData& unary_checks)
89 : unary_checks_(unary_checks), 89 : unary_checks_(unary_checks) {
90 null_check_(false) {
91 ASSERT(unary_checks.IsZoneHandle()); 90 ASSERT(unary_checks.IsZoneHandle());
92 // Expected useful check data. 91 // Expected useful check data.
93 ASSERT(!unary_checks_.IsNull()); 92 ASSERT(!unary_checks_.IsNull());
94 ASSERT(unary_checks_.NumberOfChecks() > 0); 93 ASSERT(unary_checks_.NumberOfChecks() > 0);
95 ASSERT(unary_checks_.num_args_tested() == 1); 94 ASSERT(unary_checks_.num_args_tested() == 1);
96 SetInputAt(0, value); 95 SetInputAt(0, value);
97 deopt_id_ = deopt_id; 96 deopt_id_ = deopt_id;
98 // Otherwise use CheckSmiInstr. 97 // Otherwise use CheckSmiInstr.
99 ASSERT((unary_checks_.NumberOfChecks() != 1) || 98 ASSERT((unary_checks_.NumberOfChecks() != 1) ||
100 (unary_checks_.GetReceiverClassIdAt(0) != kSmiCid)); 99 (unary_checks_.GetReceiverClassIdAt(0) != kSmiCid));
(...skipping 20 matching lines...) Expand all
121 120
122 EffectSet CheckClassInstr::Dependencies() const { 121 EffectSet CheckClassInstr::Dependencies() const {
123 // Externalization of strings via the API can change the class-id. 122 // Externalization of strings via the API can change the class-id.
124 const bool externalizable = 123 const bool externalizable =
125 unary_checks().HasReceiverClassId(kOneByteStringCid) || 124 unary_checks().HasReceiverClassId(kOneByteStringCid) ||
126 unary_checks().HasReceiverClassId(kTwoByteStringCid); 125 unary_checks().HasReceiverClassId(kTwoByteStringCid);
127 return externalizable ? EffectSet::Externalization() : EffectSet::None(); 126 return externalizable ? EffectSet::Externalization() : EffectSet::None();
128 } 127 }
129 128
130 129
130 bool CheckClassInstr::IsNullCheck() const {
131 if (unary_checks().NumberOfChecks() != 1) {
132 return false;
133 }
134 CompileType* in_type = value()->Type();
135 const intptr_t cid = unary_checks().GetCidAt(0);
136 return in_type->is_nullable() && (in_type->ToNullableCid() == cid);
137 }
138
139
131 bool GuardFieldInstr::AttributesEqual(Instruction* other) const { 140 bool GuardFieldInstr::AttributesEqual(Instruction* other) const {
132 return field().raw() == other->AsGuardField()->field().raw(); 141 return field().raw() == other->AsGuardField()->field().raw();
133 } 142 }
134 143
135 144
136 bool AssertAssignableInstr::AttributesEqual(Instruction* other) const { 145 bool AssertAssignableInstr::AttributesEqual(Instruction* other) const {
137 AssertAssignableInstr* other_assert = other->AsAssertAssignable(); 146 AssertAssignableInstr* other_assert = other->AsAssertAssignable();
138 ASSERT(other_assert != NULL); 147 ASSERT(other_assert != NULL);
139 // This predicate has to be commutative for DominatorBasedCSE to work. 148 // This predicate has to be commutative for DominatorBasedCSE to work.
140 // TODO(fschneider): Eliminate more asserts with subtype relation. 149 // TODO(fschneider): Eliminate more asserts with subtype relation.
(...skipping 2467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2608 default: 2617 default:
2609 UNREACHABLE(); 2618 UNREACHABLE();
2610 } 2619 }
2611 return kPowRuntimeEntry; 2620 return kPowRuntimeEntry;
2612 } 2621 }
2613 2622
2614 2623
2615 #undef __ 2624 #undef __
2616 2625
2617 } // namespace dart 2626 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698