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/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 { |
11 | 11 |
12 bool BitmapBuilder::Get(intptr_t bit_offset) const { | 12 bool BitmapBuilder::Get(intptr_t bit_offset) const { |
13 if (!InRange(bit_offset)) { | 13 if (!InRange(bit_offset)) { |
14 return false; | 14 return false; |
15 } | 15 } |
16 return GetBit(bit_offset); | 16 return GetBit(bit_offset); |
17 } | 17 } |
18 | 18 |
19 | 19 |
20 void BitmapBuilder::Set(intptr_t bit_offset, bool value) { | 20 void BitmapBuilder::Set(intptr_t bit_offset, bool value) { |
21 while (!InRange(bit_offset)) { | 21 while (!InRange(bit_offset)) { |
22 intptr_t new_size = size_in_bytes_ + kIncrementSizeInBytes; | 22 intptr_t new_size = size_in_bytes_ + kIncrementSizeInBytes; |
23 ASSERT(new_size > 0); | 23 ASSERT(new_size > 0); |
24 uint8_t* new_bit_list = reinterpret_cast<uint8_t*>( | 24 uint8_t* new_bit_list = |
25 Isolate::Current()->current_zone()->Allocate(new_size)); | 25 Isolate::Current()->current_zone()->Alloc<uint8_t>(new_size); |
26 ASSERT(new_bit_list != NULL); | 26 ASSERT(new_bit_list != NULL); |
27 ASSERT(bit_list_ != NULL); | 27 ASSERT(bit_list_ != NULL); |
28 uint8_t* old_bit_list = bit_list_; | 28 uint8_t* old_bit_list = bit_list_; |
29 memmove(new_bit_list, old_bit_list, size_in_bytes_); | 29 memmove(new_bit_list, old_bit_list, size_in_bytes_); |
30 memset((new_bit_list + size_in_bytes_), 0, kIncrementSizeInBytes); | 30 memset((new_bit_list + size_in_bytes_), 0, kIncrementSizeInBytes); |
31 size_in_bytes_ = new_size; | 31 size_in_bytes_ = new_size; |
32 bit_list_ = new_bit_list; | 32 bit_list_ = new_bit_list; |
33 } | 33 } |
34 SetBit(bit_offset, value); | 34 SetBit(bit_offset, value); |
35 } | 35 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 ASSERT(bit_list_ != NULL); | 100 ASSERT(bit_list_ != NULL); |
101 byte_addr = &(bit_list_[byte_offset]); | 101 byte_addr = &(bit_list_[byte_offset]); |
102 if (value) { | 102 if (value) { |
103 *byte_addr |= mask; | 103 *byte_addr |= mask; |
104 } else { | 104 } else { |
105 *byte_addr &= ~mask; | 105 *byte_addr &= ~mask; |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 } // namespace dart | 109 } // namespace dart |
OLD | NEW |