OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 Isolate::Current()->set_zone_allow_allocation(prev_); | 46 Isolate::Current()->set_zone_allow_allocation(prev_); |
47 } | 47 } |
48 | 48 |
49 | 49 |
50 inline void* Zone::New(int size) { | 50 inline void* Zone::New(int size) { |
51 ASSERT(Isolate::Current()->zone_allow_allocation()); | 51 ASSERT(Isolate::Current()->zone_allow_allocation()); |
52 ASSERT(ZoneScope::nesting() > 0); | 52 ASSERT(ZoneScope::nesting() > 0); |
53 // Round up the requested size to fit the alignment. | 53 // Round up the requested size to fit the alignment. |
54 size = RoundUp(size, kAlignment); | 54 size = RoundUp(size, kAlignment); |
55 | 55 |
| 56 // If the allocation size is divisible by 8 then we return an 8-byte aligned |
| 57 // address. |
| 58 if (kPointerSize == 4 && kAlignment == 4) { |
| 59 position_ += ((~size) & 4) & (reinterpret_cast<intptr_t>(position_) & 4); |
| 60 } else { |
| 61 ASSERT(kAlignment >= kPointerSize); |
| 62 } |
| 63 |
56 // Check if the requested size is available without expanding. | 64 // Check if the requested size is available without expanding. |
57 Address result = position_; | 65 Address result = position_; |
58 | 66 |
59 if (size > limit_ - position_) { | 67 if (size > limit_ - position_) { |
60 result = NewExpand(size); | 68 result = NewExpand(size); |
61 } else { | 69 } else { |
62 position_ += size; | 70 position_ += size; |
63 } | 71 } |
64 | 72 |
65 // Check that the result has the proper alignment and return it. | 73 // Check that the result has the proper alignment and return it. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 144 |
137 | 145 |
138 int ZoneScope::nesting() { | 146 int ZoneScope::nesting() { |
139 return Isolate::Current()->zone()->scope_nesting_; | 147 return Isolate::Current()->zone()->scope_nesting_; |
140 } | 148 } |
141 | 149 |
142 | 150 |
143 } } // namespace v8::internal | 151 } } // namespace v8::internal |
144 | 152 |
145 #endif // V8_ZONE_INL_H_ | 153 #endif // V8_ZONE_INL_H_ |
OLD | NEW |