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: src/IceMemoryRegion.h

Issue 643903006: Subzero: Do class definition cleanups for assembler files too. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: stuff Created 6 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
« no previous file with comments | « no previous file | src/IceMemoryRegion.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceMemoryRegion.h - Memory region ------------*- C++ -*-===//
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 // 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 3 // 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. 4 // BSD-style license that can be found in the LICENSE file.
4 // 5 //
5 // Modified by the Subzero authors. 6 // Modified by the Subzero authors.
6 // 7 //
7 //===- subzero/src/IceMemoryRegion.h - Memory region ------------*- C++ -*-===// 8 //===----------------------------------------------------------------------===//
8 // 9 //
9 // The Subzero Code Generator 10 // The Subzero Code Generator
10 // 11 //
11 // This file is distributed under the University of Illinois Open Source 12 // This file is distributed under the University of Illinois Open Source
12 // License. See LICENSE.TXT for details. 13 // License. See LICENSE.TXT for details.
13 // 14 //
14 //===----------------------------------------------------------------------===// 15 //===----------------------------------------------------------------------===//
15 // 16 //
16 // This file declares the MemoryRegion class. It tracks a pointer 17 // This file declares the MemoryRegion class. It tracks a pointer
17 // plus its bounds for bounds-checking in debug mode. 18 // plus its bounds for bounds-checking in debug mode.
18 //===----------------------------------------------------------------------===// 19 //===----------------------------------------------------------------------===//
19 20
20 #ifndef SUBZERO_SRC_ICE_MEMORY_REGION_H_ 21 #ifndef SUBZERO_SRC_ICE_MEMORY_REGION_H_
21 #define SUBZERO_SRC_ICE_MEMORY_REGION_H_ 22 #define SUBZERO_SRC_ICE_MEMORY_REGION_H_
22 23
23 #include "IceDefs.h" 24 #include "IceDefs.h"
24 #include "IceUtils.h" 25 #include "IceUtils.h"
25 26
26 namespace Ice { 27 namespace Ice {
27 28
28 // Memory regions are useful for accessing memory with bounds check in 29 // Memory regions are useful for accessing memory with bounds check in
29 // debug mode. They can be safely passed by value and do not assume ownership 30 // debug mode. They can be safely passed by value and do not assume ownership
30 // of the region. 31 // of the region.
31 class MemoryRegion { 32 class MemoryRegion {
32 public: 33 public:
34 MemoryRegion(const MemoryRegion &other) = default;
35 MemoryRegion &operator=(const MemoryRegion &other) = default;
33 MemoryRegion() : pointer_(NULL), size_(0) {} 36 MemoryRegion() : pointer_(NULL), size_(0) {}
34 MemoryRegion(void *pointer, size_t size) : pointer_(pointer), size_(size) {} 37 MemoryRegion(void *pointer, size_t size) : pointer_(pointer), size_(size) {}
35 MemoryRegion(const MemoryRegion &other) { *this = other; }
36 MemoryRegion &operator=(const MemoryRegion &other) {
37 pointer_ = other.pointer_;
38 size_ = other.size_;
39 return *this;
40 }
41 38
42 void *pointer() const { return pointer_; } 39 void *pointer() const { return pointer_; }
43 size_t size() const { return size_; } 40 size_t size() const { return size_; }
44 41
45 size_t start() const { return reinterpret_cast<size_t>(pointer_); } 42 size_t start() const { return reinterpret_cast<size_t>(pointer_); }
46 size_t end() const { return start() + size_; } 43 size_t end() const { return start() + size_; }
47 44
48 template <typename T> T Load(size_t offset) const { 45 template <typename T> T Load(size_t offset) const {
49 return *ComputeInternalPointer<T>(offset); 46 return *ComputeInternalPointer<T>(offset);
50 } 47 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 return reinterpret_cast<T *>(start() + offset); 81 return reinterpret_cast<T *>(start() + offset);
85 } 82 }
86 83
87 void *pointer_; 84 void *pointer_;
88 size_t size_; 85 size_t size_;
89 }; 86 };
90 87
91 } // end of namespace Ice 88 } // end of namespace Ice
92 89
93 #endif // SUBZERO_SRC_ICE_MEMORY_REGION_H_ 90 #endif // SUBZERO_SRC_ICE_MEMORY_REGION_H_
OLDNEW
« no previous file with comments | « no previous file | src/IceMemoryRegion.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698