OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 12 matching lines...) Expand all Loading... | |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifndef V8_ALLOCATION_H_ | 28 #ifndef V8_ALLOCATION_H_ |
29 #define V8_ALLOCATION_H_ | 29 #define V8_ALLOCATION_H_ |
30 | 30 |
31 #include "globals.h" | 31 #include "globals.h" |
32 | 32 |
33 /* Round up n to be a multiple of sz, where sz is a power of 2. */ | |
34 #define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1)) | |
35 | |
36 // Specify memory alignment for structs, classes, etc. | |
Benedikt Meurer
2013/08/14 11:38:09
Please move the ALIGN_AT definition to globals.h,
yurys
2013/08/14 13:19:01
Done.
| |
37 // Use like: | |
38 // class ALIGN_AT(16) MyClass { ... } | |
39 // ALIGN_AT(16) int array[4]; | |
40 #if defined(_MSC_VER) | |
41 #define ALIGN_AT(byte_alignment) __declspec(align(byte_alignment)) | |
42 #elif defined(__GNUC__) || defined(__APPLE__) | |
Benedikt Meurer
2013/08/14 11:38:09
Why __APPLE__ here? This is actually a compiler th
yurys
2013/08/14 13:19:01
Done. Removed __APPLE__.
| |
43 #define ALIGN_AT(byte_alignment) __attribute__((aligned(byte_alignment))) | |
44 #else | |
45 #error "ALIGN_AT is not supported for your compiler" | |
Benedikt Meurer
2013/08/14 11:38:09
Since the alignment is an optimization, I think it
yurys
2013/08/14 13:19:01
Done.
| |
46 #endif | |
47 | |
33 namespace v8 { | 48 namespace v8 { |
34 namespace internal { | 49 namespace internal { |
35 | 50 |
36 // Called when allocation routines fail to allocate. | 51 // Called when allocation routines fail to allocate. |
37 // This function should not return, but should terminate the current | 52 // This function should not return, but should terminate the current |
38 // processing. | 53 // processing. |
39 void FatalProcessOutOfMemory(const char* message); | 54 void FatalProcessOutOfMemory(const char* message); |
40 | 55 |
41 // Superclass for classes managed with new & delete. | 56 // Superclass for classes managed with new & delete. |
42 class Malloced { | 57 class Malloced { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 | 148 |
134 struct PreallocatedStorageAllocationPolicy { | 149 struct PreallocatedStorageAllocationPolicy { |
135 INLINE(void* New(size_t size)); | 150 INLINE(void* New(size_t size)); |
136 INLINE(static void Delete(void* ptr)); | 151 INLINE(static void Delete(void* ptr)); |
137 }; | 152 }; |
138 | 153 |
139 | 154 |
140 } } // namespace v8::internal | 155 } } // namespace v8::internal |
141 | 156 |
142 #endif // V8_ALLOCATION_H_ | 157 #endif // V8_ALLOCATION_H_ |
OLD | NEW |