OLD | NEW |
---|---|
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 public: | 44 public: |
45 void* operator new(size_t size) { return New(size); } | 45 void* operator new(size_t size) { return New(size); } |
46 void operator delete(void* p) { Delete(p); } | 46 void operator delete(void* p) { Delete(p); } |
47 | 47 |
48 static void FatalProcessOutOfMemory(); | 48 static void FatalProcessOutOfMemory(); |
49 static void* New(size_t size); | 49 static void* New(size_t size); |
50 static void Delete(void* p); | 50 static void Delete(void* p); |
51 }; | 51 }; |
52 | 52 |
53 | 53 |
54 // Superclass for classes with custom allocation. | |
55 class CustomlyAllocated { | |
antonm
2011/04/06 11:01:48
I don't like the name, but I cannot come up with a
Vitaly Repeshko
2011/04/06 19:11:01
Yeah, since it requires hiding both new/delete and
| |
56 private: | |
57 void* operator new(size_t size); | |
58 void operator delete(void* p); | |
59 }; | |
60 | |
61 | |
54 // A macro is used for defining the base class used for embedded instances. | 62 // A macro is used for defining the base class used for embedded instances. |
55 // The reason is some compilers allocate a minimum of one word for the | 63 // The reason is some compilers allocate a minimum of one word for the |
56 // superclass. The macro prevents the use of new & delete in debug mode. | 64 // superclass. The macro prevents the use of new & delete in debug mode. |
57 // In release mode we are not willing to pay this overhead. | 65 // In release mode we are not willing to pay this overhead. |
58 | 66 |
59 #ifdef DEBUG | 67 #ifdef DEBUG |
60 // Superclass for classes with instances allocated inside stack | 68 // Superclass for classes with instances allocated inside stack |
61 // activations or inside other objects. | 69 // activations or inside other objects. |
62 class Embedded { | 70 class Embedded { |
63 public: | 71 public: |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 | 142 |
135 friend class Isolate; | 143 friend class Isolate; |
136 | 144 |
137 DISALLOW_IMPLICIT_CONSTRUCTORS(PreallocatedStorage); | 145 DISALLOW_IMPLICIT_CONSTRUCTORS(PreallocatedStorage); |
138 }; | 146 }; |
139 | 147 |
140 | 148 |
141 } } // namespace v8::internal | 149 } } // namespace v8::internal |
142 | 150 |
143 #endif // V8_ALLOCATION_H_ | 151 #endif // V8_ALLOCATION_H_ |
OLD | NEW |