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 uint16_t& uint16_at(Address addr) { |
| 40 return *reinterpret_cast<uint16_t*>(addr); |
| 41 } |
| 42 |
39 static uint32_t& uint32_at(Address addr) { | 43 static uint32_t& uint32_at(Address addr) { |
40 return *reinterpret_cast<uint32_t*>(addr); | 44 return *reinterpret_cast<uint32_t*>(addr); |
41 } | 45 } |
42 | 46 |
43 static int32_t& int32_at(Address addr) { | 47 static int32_t& int32_at(Address addr) { |
44 return *reinterpret_cast<int32_t*>(addr); | 48 return *reinterpret_cast<int32_t*>(addr); |
45 } | 49 } |
46 | 50 |
47 static uint64_t& uint64_at(Address addr) { | 51 static uint64_t& uint64_at(Address addr) { |
48 return *reinterpret_cast<uint64_t*>(addr); | 52 return *reinterpret_cast<uint64_t*>(addr); |
49 } | 53 } |
50 | 54 |
51 static int& int_at(Address addr) { | 55 static int& int_at(Address addr) { |
52 return *reinterpret_cast<int*>(addr); | 56 return *reinterpret_cast<int*>(addr); |
53 } | 57 } |
54 | 58 |
55 static Address& Address_at(Address addr) { | 59 static Address& Address_at(Address addr) { |
56 return *reinterpret_cast<Address*>(addr); | 60 return *reinterpret_cast<Address*>(addr); |
57 } | 61 } |
58 | 62 |
59 static Object*& Object_at(Address addr) { | 63 static Object*& Object_at(Address addr) { |
60 return *reinterpret_cast<Object**>(addr); | 64 return *reinterpret_cast<Object**>(addr); |
61 } | 65 } |
62 }; | 66 }; |
63 | 67 |
64 } } // namespace v8::internal | 68 } } // namespace v8::internal |
65 | 69 |
66 #endif // V8_MEMORY_H_ | 70 #endif // V8_MEMORY_H_ |
OLD | NEW |