| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 Address start() const { return address(sizeof(Segment)); } | 58 Address start() const { return address(sizeof(Segment)); } |
| 59 Address end() const { return address(size_); } | 59 Address end() const { return address(size_); } |
| 60 | 60 |
| 61 static Segment* head() { return head_; } | 61 static Segment* head() { return head_; } |
| 62 static void set_head(Segment* head) { head_ = head; } | 62 static void set_head(Segment* head) { head_ = head; } |
| 63 | 63 |
| 64 // Creates a new segment, sets it size, and pushes it to the front | 64 // Creates a new segment, sets it size, and pushes it to the front |
| 65 // of the segment chain. Returns the new segment. | 65 // of the segment chain. Returns the new segment. |
| 66 static Segment* New(int size) { | 66 static Segment* New(int size) { |
| 67 Segment* result = reinterpret_cast<Segment*>(Malloced::New(size)); | 67 Segment* result = reinterpret_cast<Segment*>(Malloced::New(size)); |
| 68 Zone::segment_bytes_allocated_ += size; | 68 Zone::adjust_segment_bytes_allocated(size); |
| 69 if (result != NULL) { | 69 if (result != NULL) { |
| 70 result->next_ = head_; | 70 result->next_ = head_; |
| 71 result->size_ = size; | 71 result->size_ = size; |
| 72 head_ = result; | 72 head_ = result; |
| 73 } | 73 } |
| 74 return result; | 74 return result; |
| 75 } | 75 } |
| 76 | 76 |
| 77 // Deletes the given segment. Does not touch the segment chain. | 77 // Deletes the given segment. Does not touch the segment chain. |
| 78 static void Delete(Segment* segment, int size) { | 78 static void Delete(Segment* segment, int size) { |
| 79 Zone::segment_bytes_allocated_ -= size; | 79 Zone::adjust_segment_bytes_allocated(-size); |
| 80 Malloced::Delete(segment); | 80 Malloced::Delete(segment); |
| 81 } | 81 } |
| 82 | 82 |
| 83 static int bytes_allocated() { return bytes_allocated_; } | 83 static int bytes_allocated() { return bytes_allocated_; } |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 // Computes the address of the nth byte in this segment. | 86 // Computes the address of the nth byte in this segment. |
| 87 Address address(int n) const { | 87 Address address(int n) const { |
| 88 return Address(this) + n; | 88 return Address(this) + n; |
| 89 } | 89 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // Recompute 'top' and 'limit' based on the new segment. | 171 // Recompute 'top' and 'limit' based on the new segment. |
| 172 Address result = RoundUp(segment->start(), kAlignment); | 172 Address result = RoundUp(segment->start(), kAlignment); |
| 173 position_ = result + size; | 173 position_ = result + size; |
| 174 limit_ = segment->end(); | 174 limit_ = segment->end(); |
| 175 ASSERT(position_ <= limit_); | 175 ASSERT(position_ <= limit_); |
| 176 return result; | 176 return result; |
| 177 } | 177 } |
| 178 | 178 |
| 179 | 179 |
| 180 } } // namespace v8::internal | 180 } } // namespace v8::internal |
| OLD | NEW |