OLD | NEW |
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/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/become.h" | 10 #include "vm/become.h" |
(...skipping 13447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13458 index * TestEntryLength() + CountIndexFor(NumArgsTested()); | 13458 index * TestEntryLength() + CountIndexFor(NumArgsTested()); |
13459 data.SetAt(data_pos, Smi::Handle(Smi::New(value))); | 13459 data.SetAt(data_pos, Smi::Handle(Smi::New(value))); |
13460 } | 13460 } |
13461 | 13461 |
13462 | 13462 |
13463 intptr_t ICData::GetCountAt(intptr_t index) const { | 13463 intptr_t ICData::GetCountAt(intptr_t index) const { |
13464 ASSERT(Isolate::Current()->compilation_allowed()); | 13464 ASSERT(Isolate::Current()->compilation_allowed()); |
13465 const Array& data = Array::Handle(ic_data()); | 13465 const Array& data = Array::Handle(ic_data()); |
13466 const intptr_t data_pos = | 13466 const intptr_t data_pos = |
13467 index * TestEntryLength() + CountIndexFor(NumArgsTested()); | 13467 index * TestEntryLength() + CountIndexFor(NumArgsTested()); |
13468 return Smi::Value(Smi::RawCast(data.At(data_pos))); | 13468 intptr_t value = Smi::Value(Smi::RawCast(data.At(data_pos))); |
| 13469 if (value >= 0) return value; |
| 13470 |
| 13471 // The counter very rarely overflows to a negative value, but if it does, we |
| 13472 // would rather just reset it to zero. |
| 13473 SetCountAt(index, 0); |
| 13474 return 0; |
13469 } | 13475 } |
13470 | 13476 |
13471 | 13477 |
13472 intptr_t ICData::AggregateCount() const { | 13478 intptr_t ICData::AggregateCount() const { |
13473 if (IsNull()) return 0; | 13479 if (IsNull()) return 0; |
13474 const intptr_t len = NumberOfChecks(); | 13480 const intptr_t len = NumberOfChecks(); |
13475 intptr_t count = 0; | 13481 intptr_t count = 0; |
13476 for (intptr_t i = 0; i < len; i++) { | 13482 for (intptr_t i = 0; i < len; i++) { |
13477 count += GetCountAt(i); | 13483 count += GetCountAt(i); |
13478 } | 13484 } |
(...skipping 9538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
23017 return UserTag::null(); | 23023 return UserTag::null(); |
23018 } | 23024 } |
23019 | 23025 |
23020 | 23026 |
23021 const char* UserTag::ToCString() const { | 23027 const char* UserTag::ToCString() const { |
23022 const String& tag_label = String::Handle(label()); | 23028 const String& tag_label = String::Handle(label()); |
23023 return tag_label.ToCString(); | 23029 return tag_label.ToCString(); |
23024 } | 23030 } |
23025 | 23031 |
23026 } // namespace dart | 23032 } // namespace dart |
OLD | NEW |