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

Side by Side Diff: vm/memory_region.h

Issue 10967044: Fix the types used in bit fields. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 2 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 | « vm/compiler_stats.cc ('k') | vm/object.h » ('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) 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 #ifndef VM_MEMORY_REGION_H_ 5 #ifndef VM_MEMORY_REGION_H_
6 #define VM_MEMORY_REGION_H_ 6 #define VM_MEMORY_REGION_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 size_ = (region.size() + extra); 59 size_ = (region.size() + extra);
60 } 60 }
61 61
62 private: 62 private:
63 template<typename T> T* ComputeInternalPointer(uword offset) const { 63 template<typename T> T* ComputeInternalPointer(uword offset) const {
64 ASSERT(size() >= sizeof(T)); 64 ASSERT(size() >= sizeof(T));
65 ASSERT(offset <= size() - sizeof(T)); 65 ASSERT(offset <= size() - sizeof(T));
66 return reinterpret_cast<T*>(start() + offset); 66 return reinterpret_cast<T*>(start() + offset);
67 } 67 }
68 68
69 // Locate the bit with the given offset. Returns a pointer to the byte
70 // containing the bit, and sets bit_mask to the bit within that byte.
71 uint8_t* ComputeBitPointer(uword bit_offset, uint8_t* bit_mask) const {
72 uword bit_remainder = (bit_offset & (kBitsPerByte - 1));
73 *bit_mask = (1U << bit_remainder);
74 uword byte_offset = (bit_offset >> kBitsPerByteLog2);
75 return ComputeInternalPointer<uint8_t>(byte_offset);
76 }
77
78 void* pointer_; 69 void* pointer_;
79 uword size_; 70 uword size_;
80 71
81 DISALLOW_COPY_AND_ASSIGN(MemoryRegion); 72 DISALLOW_COPY_AND_ASSIGN(MemoryRegion);
82 }; 73 };
83 74
84 } // namespace dart 75 } // namespace dart
85 76
86 #endif // VM_MEMORY_REGION_H_ 77 #endif // VM_MEMORY_REGION_H_
OLDNEW
« no previous file with comments | « vm/compiler_stats.cc ('k') | vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698