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

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

Issue 10837303: Make stackmaps store their actual length. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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) 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/bitmap.h" 5 #include "vm/bitmap.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/object.h" 8 #include "vm/object.h"
9 9
10 namespace dart { 10 namespace dart {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 } 55 }
56 56
57 57
58 void BitmapBuilder::SetRange(intptr_t min, intptr_t max, bool value) { 58 void BitmapBuilder::SetRange(intptr_t min, intptr_t max, bool value) {
59 for (intptr_t i = min; i <= max; i++) { 59 for (intptr_t i = min; i <= max; i++) {
60 Set(i, value); 60 Set(i, value);
61 } 61 }
62 } 62 }
63 63
64 64
65 void BitmapBuilder::SetBits(const Stackmap& stackmap) {
66 intptr_t min = stackmap.MinimumBitIndex();
67 intptr_t max = stackmap.MaximumBitIndex();
68 if (min == Stackmap::kNoMinimum || max == Stackmap::kNoMaximum) {
69 return;
70 }
71 for (intptr_t i = 0; i < min; i++) {
72 Set(i, false);
73 }
74 for (intptr_t i = min; i <= max; i++) {
75 Set(i, stackmap.IsObject(i));
76 }
77 intptr_t bound = SizeInBits();
78 for (intptr_t i = (max + 1); i < bound; i++) {
79 Set(i, false);
80 }
81 }
82
83
84 bool BitmapBuilder::GetBit(intptr_t bit_offset) const { 65 bool BitmapBuilder::GetBit(intptr_t bit_offset) const {
85 ASSERT(InRange(bit_offset)); 66 ASSERT(InRange(bit_offset));
86 int byte_offset = bit_offset >> kBitsPerByteLog2; 67 int byte_offset = bit_offset >> kBitsPerByteLog2;
87 int bit_remainder = bit_offset & (kBitsPerByte - 1); 68 int bit_remainder = bit_offset & (kBitsPerByte - 1);
88 uint8_t mask = 1U << bit_remainder; 69 uint8_t mask = 1U << bit_remainder;
89 ASSERT(bit_list_ != NULL); 70 ASSERT(bit_list_ != NULL);
90 return ((bit_list_[byte_offset] & mask) != 0); 71 return ((bit_list_[byte_offset] & mask) != 0);
91 } 72 }
92 73
93 74
94 void BitmapBuilder::SetBit(intptr_t bit_offset, bool value) { 75 void BitmapBuilder::SetBit(intptr_t bit_offset, bool value) {
95 ASSERT(InRange(bit_offset)); 76 ASSERT(InRange(bit_offset));
96 int byte_offset = bit_offset >> kBitsPerByteLog2; 77 int byte_offset = bit_offset >> kBitsPerByteLog2;
97 int bit_remainder = bit_offset & (kBitsPerByte - 1); 78 int bit_remainder = bit_offset & (kBitsPerByte - 1);
98 uint8_t mask = 1U << bit_remainder; 79 uint8_t mask = 1U << bit_remainder;
99 uint8_t* byte_addr; 80 uint8_t* byte_addr;
100 ASSERT(bit_list_ != NULL); 81 ASSERT(bit_list_ != NULL);
101 byte_addr = &(bit_list_[byte_offset]); 82 byte_addr = &(bit_list_[byte_offset]);
102 if (value) { 83 if (value) {
103 *byte_addr |= mask; 84 *byte_addr |= mask;
104 } else { 85 } else {
105 *byte_addr &= ~mask; 86 *byte_addr &= ~mask;
106 } 87 }
107 } 88 }
108 89
109 } // namespace dart 90 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698