Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: src/zone-inl.h

Issue 2493002: - Remove [static] from methods in Zone and associated helpers. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
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 "isolate.h"
31 #include "zone.h" 32 #include "zone.h"
32 #include "v8-counters.h" 33 #include "v8-counters.h"
33 34
34 namespace v8 { 35 namespace v8 {
35 namespace internal { 36 namespace internal {
36 37
37 38
39 AssertNoZoneAllocation::AssertNoZoneAllocation()
40 : prev_(Isolate::Current()->zone_allow_allocation()) {
41 Isolate::Current()->set_zone_allow_allocation(false);
42 }
43
44
45 AssertNoZoneAllocation::~AssertNoZoneAllocation() {
46 Isolate::Current()->set_zone_allow_allocation(prev_);
47 }
48
49
38 inline void* Zone::New(int size) { 50 inline void* Zone::New(int size) {
39 ASSERT(AssertNoZoneAllocation::allow_allocation()); 51 ASSERT(Isolate::Current()->zone_allow_allocation());
40 ASSERT(ZoneScope::nesting() > 0); 52 ASSERT(ZoneScope::nesting() > 0);
41 // Round up the requested size to fit the alignment. 53 // Round up the requested size to fit the alignment.
42 size = RoundUp(size, kAlignment); 54 size = RoundUp(size, kAlignment);
43 55
44 // Check if the requested size is available without expanding. 56 // Check if the requested size is available without expanding.
45 Address result = position_; 57 Address result = position_;
46 if ((position_ += size) > limit_) result = NewExpand(size); 58 if ((position_ += size) > limit_) result = NewExpand(size);
47 59
48 // Check that the result has the proper alignment and return it. 60 // Check that the result has the proper alignment and return it.
49 ASSERT(IsAddressAligned(result, kAlignment, 0)); 61 ASSERT(IsAddressAligned(result, kAlignment, 0));
50 return reinterpret_cast<void*>(result); 62 return reinterpret_cast<void*>(result);
51 } 63 }
52 64
53 65
54 template <typename T> 66 template <typename T>
55 T* Zone::NewArray(int length) { 67 T* Zone::NewArray(int length) {
56 return static_cast<T*>(Zone::New(length * sizeof(T))); 68 return static_cast<T*>(New(length * sizeof(T)));
57 } 69 }
58 70
59 71
60 bool Zone::excess_allocation() { 72 bool Zone::excess_allocation() {
61 return segment_bytes_allocated_ > zone_excess_limit_; 73 return segment_bytes_allocated_ > zone_excess_limit_;
62 } 74 }
63 75
64 76
65 void Zone::adjust_segment_bytes_allocated(int delta) { 77 void Zone::adjust_segment_bytes_allocated(int delta) {
66 segment_bytes_allocated_ += delta; 78 segment_bytes_allocated_ += delta;
67 Counters::zone_segment_bytes.Set(segment_bytes_allocated_); 79 Counters::zone_segment_bytes.Set(segment_bytes_allocated_);
68 } 80 }
69 81
70 82
71 template <typename Config> 83 template <typename Config>
72 ZoneSplayTree<Config>::~ZoneSplayTree() { 84 ZoneSplayTree<Config>::~ZoneSplayTree() {
73 // Reset the root to avoid unneeded iteration over all tree nodes 85 // Reset the root to avoid unneeded iteration over all tree nodes
74 // in the destructor. For a zone-allocated tree, nodes will be 86 // in the destructor. For a zone-allocated tree, nodes will be
75 // freed by the Zone. 87 // freed by the Zone.
76 SplayTree<Config, ZoneListAllocationPolicy>::ResetRoot(); 88 SplayTree<Config, ZoneListAllocationPolicy>::ResetRoot();
77 } 89 }
78 90
79 91
92 // TODO(isolates): maybe replace uses of this with placement new so that
Vitaly Repeshko 2010/06/02 15:30:40 "placement new" -> "new operator that takes a zone
93 // the zone pointer can be locally cached
94 void* ZoneObject::operator new(size_t size) {
95 return ZONE->New(static_cast<int>(size));
96 }
97
98
99 inline void* ZoneListAllocationPolicy::New(int size) {
100 return ZONE->New(size);
101 }
102
103
80 } } // namespace v8::internal 104 } } // namespace v8::internal
81 105
82 #endif // V8_ZONE_INL_H_ 106 #endif // V8_ZONE_INL_H_
OLDNEW
« src/isolate.cc ('K') | « src/zone.cc ('k') | test/cctest/test-ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698