| OLD | NEW |
| 1 // Copyright 2006-2008 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 40 ASSERT(ZoneScope::nesting() > 0); | 40 ASSERT(ZoneScope::nesting() > 0); |
| 41 // Round up the requested size to fit the alignment. | 41 // Round up the requested size to fit the alignment. |
| 42 size = RoundUp(size, kAlignment); | 42 size = RoundUp(size, kAlignment); |
| 43 | 43 |
| 44 // Check if the requested size is available without expanding. | 44 // Check if the requested size is available without expanding. |
| 45 Address result = position_; | 45 Address result = position_; |
| 46 if ((position_ += size) > limit_) result = NewExpand(size); | 46 if ((position_ += size) > limit_) result = NewExpand(size); |
| 47 | 47 |
| 48 // Check that the result has the proper alignment and return it. | 48 // Check that the result has the proper alignment and return it. |
| 49 ASSERT(IsAddressAligned(result, kAlignment, 0)); | 49 ASSERT(IsAddressAligned(result, kAlignment, 0)); |
| 50 allocation_size_ += size; |
| 50 return reinterpret_cast<void*>(result); | 51 return reinterpret_cast<void*>(result); |
| 51 } | 52 } |
| 52 | 53 |
| 53 | 54 |
| 54 template <typename T> | 55 template <typename T> |
| 55 T* Zone::NewArray(int length) { | 56 T* Zone::NewArray(int length) { |
| 56 return static_cast<T*>(Zone::New(length * sizeof(T))); | 57 return static_cast<T*>(Zone::New(length * sizeof(T))); |
| 57 } | 58 } |
| 58 | 59 |
| 59 | 60 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 73 // Reset the root to avoid unneeded iteration over all tree nodes | 74 // Reset the root to avoid unneeded iteration over all tree nodes |
| 74 // in the destructor. For a zone-allocated tree, nodes will be | 75 // in the destructor. For a zone-allocated tree, nodes will be |
| 75 // freed by the Zone. | 76 // freed by the Zone. |
| 76 SplayTree<Config, ZoneListAllocationPolicy>::ResetRoot(); | 77 SplayTree<Config, ZoneListAllocationPolicy>::ResetRoot(); |
| 77 } | 78 } |
| 78 | 79 |
| 79 | 80 |
| 80 } } // namespace v8::internal | 81 } } // namespace v8::internal |
| 81 | 82 |
| 82 #endif // V8_ZONE_INL_H_ | 83 #endif // V8_ZONE_INL_H_ |
| OLD | NEW |