v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
v8memory.h
Go to the documentation of this file.
1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 #ifndef V8_MEMORY_H_
29 #define V8_MEMORY_H_
30 
31 namespace v8 {
32 namespace internal {
33 
34 // Memory provides an interface to 'raw' memory. It encapsulates the casts
35 // that typically are needed when incompatible pointer types are used.
36 
37 class Memory {
38  public:
39  static uint8_t& uint8_at(Address addr) {
40  return *reinterpret_cast<uint8_t*>(addr);
41  }
42 
43  static uint16_t& uint16_at(Address addr) {
44  return *reinterpret_cast<uint16_t*>(addr);
45  }
46 
47  static uint32_t& uint32_at(Address addr) {
48  return *reinterpret_cast<uint32_t*>(addr);
49  }
50 
51  static int32_t& int32_at(Address addr) {
52  return *reinterpret_cast<int32_t*>(addr);
53  }
54 
55  static uint64_t& uint64_at(Address addr) {
56  return *reinterpret_cast<uint64_t*>(addr);
57  }
58 
59  static int& int_at(Address addr) {
60  return *reinterpret_cast<int*>(addr);
61  }
62 
63  static unsigned& unsigned_at(Address addr) {
64  return *reinterpret_cast<unsigned*>(addr);
65  }
66 
67  static intptr_t& intptr_at(Address addr) {
68  return *reinterpret_cast<intptr_t*>(addr);
69  }
70 
71  static uintptr_t& uintptr_at(Address addr) {
72  return *reinterpret_cast<uintptr_t*>(addr);
73  }
74 
75  static double& double_at(Address addr) {
76  return *reinterpret_cast<double*>(addr);
77  }
78 
79  static Address& Address_at(Address addr) {
80  return *reinterpret_cast<Address*>(addr);
81  }
82 
83  static Object*& Object_at(Address addr) {
84  return *reinterpret_cast<Object**>(addr);
85  }
86 
88  return *reinterpret_cast<Handle<Object>*>(addr);
89  }
90 };
91 
92 } } // namespace v8::internal
93 
94 #endif // V8_MEMORY_H_
byte * Address
Definition: globals.h:186
static Object *& Object_at(Address addr)
Definition: v8memory.h:83
static Handle< Object > & Object_Handle_at(Address addr)
Definition: v8memory.h:87
static double & double_at(Address addr)
Definition: v8memory.h:75
int int32_t
Definition: unicode.cc:47
static intptr_t & intptr_at(Address addr)
Definition: v8memory.h:67
unsigned short uint16_t
Definition: unicode.cc:46
static uint16_t & uint16_at(Address addr)
Definition: v8memory.h:43
static uint8_t & uint8_at(Address addr)
Definition: v8memory.h:39
static Address & Address_at(Address addr)
Definition: v8memory.h:79
static int32_t & int32_at(Address addr)
Definition: v8memory.h:51
static int & int_at(Address addr)
Definition: v8memory.h:59
static uint64_t & uint64_at(Address addr)
Definition: v8memory.h:55
static unsigned & unsigned_at(Address addr)
Definition: v8memory.h:63
static uint32_t & uint32_at(Address addr)
Definition: v8memory.h:47
static uintptr_t & uintptr_at(Address addr)
Definition: v8memory.h:71