OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 18 matching lines...) Expand all Loading... |
29 #define V8_MEMORY_H_ | 29 #define V8_MEMORY_H_ |
30 | 30 |
31 namespace v8 { | 31 namespace v8 { |
32 namespace internal { | 32 namespace internal { |
33 | 33 |
34 // Memory provides an interface to 'raw' memory. It encapsulates the casts | 34 // Memory provides an interface to 'raw' memory. It encapsulates the casts |
35 // that typically are needed when incompatible pointer types are used. | 35 // that typically are needed when incompatible pointer types are used. |
36 | 36 |
37 class Memory { | 37 class Memory { |
38 public: | 38 public: |
| 39 static uint8_t& uint8_at(Address addr) { |
| 40 return *reinterpret_cast<uint8_t*>(addr); |
| 41 } |
| 42 |
39 static uint16_t& uint16_at(Address addr) { | 43 static uint16_t& uint16_at(Address addr) { |
40 return *reinterpret_cast<uint16_t*>(addr); | 44 return *reinterpret_cast<uint16_t*>(addr); |
41 } | 45 } |
42 | 46 |
43 static uint32_t& uint32_at(Address addr) { | 47 static uint32_t& uint32_at(Address addr) { |
44 return *reinterpret_cast<uint32_t*>(addr); | 48 return *reinterpret_cast<uint32_t*>(addr); |
45 } | 49 } |
46 | 50 |
47 static int32_t& int32_at(Address addr) { | 51 static int32_t& int32_at(Address addr) { |
48 return *reinterpret_cast<int32_t*>(addr); | 52 return *reinterpret_cast<int32_t*>(addr); |
(...skipping 16 matching lines...) Expand all Loading... |
65 } | 69 } |
66 | 70 |
67 static Handle<Object>& Object_Handle_at(Address addr) { | 71 static Handle<Object>& Object_Handle_at(Address addr) { |
68 return *reinterpret_cast<Handle<Object>*>(addr); | 72 return *reinterpret_cast<Handle<Object>*>(addr); |
69 } | 73 } |
70 }; | 74 }; |
71 | 75 |
72 } } // namespace v8::internal | 76 } } // namespace v8::internal |
73 | 77 |
74 #endif // V8_MEMORY_H_ | 78 #endif // V8_MEMORY_H_ |
OLD | NEW |