| 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 11 matching lines...) Expand all Loading... |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 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_ZONE_INL_H_ | 28 #ifndef V8_ZONE_INL_H_ |
| 29 #define V8_ZONE_INL_H_ | 29 #define V8_ZONE_INL_H_ |
| 30 | 30 |
| 31 #include "zone.h" | 31 #include "zone.h" |
| 32 #include "v8-counters.h" |
| 32 | 33 |
| 33 namespace v8 { namespace internal { | 34 namespace v8 { namespace internal { |
| 34 | 35 |
| 35 | 36 |
| 36 inline void* Zone::New(int size) { | 37 inline void* Zone::New(int size) { |
| 37 ASSERT(AssertNoZoneAllocation::allow_allocation()); | 38 ASSERT(AssertNoZoneAllocation::allow_allocation()); |
| 39 ASSERT(ZoneScope::nesting() > 0); |
| 38 // Round up the requested size to fit the alignment. | 40 // Round up the requested size to fit the alignment. |
| 39 size = RoundUp(size, kAlignment); | 41 size = RoundUp(size, kAlignment); |
| 40 | 42 |
| 41 // Check if the requested size is available without expanding. | 43 // Check if the requested size is available without expanding. |
| 42 Address result = position_; | 44 Address result = position_; |
| 43 if ((position_ += size) > limit_) result = NewExpand(size); | 45 if ((position_ += size) > limit_) result = NewExpand(size); |
| 44 | 46 |
| 45 // Check that the result has the proper alignment and return it. | 47 // Check that the result has the proper alignment and return it. |
| 46 ASSERT(IsAddressAligned(result, kAlignment, 0)); | 48 ASSERT(IsAddressAligned(result, kAlignment, 0)); |
| 47 return reinterpret_cast<void*>(result); | 49 return reinterpret_cast<void*>(result); |
| 48 } | 50 } |
| 49 | 51 |
| 50 | 52 |
| 51 bool Zone::excess_allocation() { | 53 bool Zone::excess_allocation() { |
| 52 return segment_bytes_allocated_ > zone_excess_limit_; | 54 return segment_bytes_allocated_ > zone_excess_limit_; |
| 53 } | 55 } |
| 54 | 56 |
| 55 | 57 |
| 58 void Zone::adjust_segment_bytes_allocated(int delta) { |
| 59 segment_bytes_allocated_ += delta; |
| 60 Counters::zone_segment_bytes.Set(segment_bytes_allocated_); |
| 61 } |
| 62 |
| 63 |
| 56 } } // namespace v8::internal | 64 } } // namespace v8::internal |
| 57 | 65 |
| 58 #endif // V8_ZONE_INL_H_ | 66 #endif // V8_ZONE_INL_H_ |
| OLD | NEW |