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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // Computes the address of the nth byte in this segment. | 60 // Computes the address of the nth byte in this segment. |
61 Address address(int n) const { | 61 Address address(int n) const { |
62 return Address(this) + n; | 62 return Address(this) + n; |
63 } | 63 } |
64 | 64 |
65 Segment* next_; | 65 Segment* next_; |
66 int size_; | 66 int size_; |
67 }; | 67 }; |
68 | 68 |
69 | 69 |
70 Zone::Zone() | 70 Zone::Zone(Isolate* isolate) |
71 : zone_excess_limit_(256 * MB), | 71 : zone_excess_limit_(256 * MB), |
72 segment_bytes_allocated_(0), | 72 segment_bytes_allocated_(0), |
73 position_(0), | 73 position_(0), |
74 limit_(0), | 74 limit_(0), |
75 scope_nesting_(0), | 75 scope_nesting_(0), |
76 segment_head_(NULL) { | 76 segment_head_(NULL), |
| 77 isolate_(isolate) { |
77 } | 78 } |
78 unsigned Zone::allocation_size_ = 0; | 79 unsigned Zone::allocation_size_ = 0; |
79 | 80 |
80 ZoneScope::~ZoneScope() { | 81 ZoneScope::~ZoneScope() { |
81 ASSERT_EQ(Isolate::Current(), isolate_); | 82 if (ShouldDeleteOnExit()) zone_->DeleteAll(); |
82 if (ShouldDeleteOnExit()) isolate_->zone()->DeleteAll(); | 83 zone_->scope_nesting_--; |
83 isolate_->zone()->scope_nesting_--; | |
84 } | 84 } |
85 | 85 |
86 | 86 |
87 // Creates a new segment, sets it size, and pushes it to the front | 87 // Creates a new segment, sets it size, and pushes it to the front |
88 // of the segment chain. Returns the new segment. | 88 // of the segment chain. Returns the new segment. |
89 Segment* Zone::NewSegment(int size) { | 89 Segment* Zone::NewSegment(int size) { |
90 Segment* result = reinterpret_cast<Segment*>(Malloced::New(size)); | 90 Segment* result = reinterpret_cast<Segment*>(Malloced::New(size)); |
91 adjust_segment_bytes_allocated(size); | 91 adjust_segment_bytes_allocated(size); |
92 if (result != NULL) { | 92 if (result != NULL) { |
93 result->Initialize(segment_head_, size); | 93 result->Initialize(segment_head_, size); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 V8::FatalProcessOutOfMemory("Zone"); | 207 V8::FatalProcessOutOfMemory("Zone"); |
208 return NULL; | 208 return NULL; |
209 } | 209 } |
210 limit_ = segment->end(); | 210 limit_ = segment->end(); |
211 ASSERT(position_ <= limit_); | 211 ASSERT(position_ <= limit_); |
212 return result; | 212 return result; |
213 } | 213 } |
214 | 214 |
215 | 215 |
216 } } // namespace v8::internal | 216 } } // namespace v8::internal |
OLD | NEW |