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

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

Issue 8539008: 8-byte align zone allocations of objects that may require it. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 1 month 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
« no previous file with comments | « src/zone.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 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
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 Isolate::Current()->set_zone_allow_allocation(prev_); 46 Isolate::Current()->set_zone_allow_allocation(prev_);
47 } 47 }
48 48
49 49
50 inline void* Zone::New(int size) { 50 inline void* Zone::New(int size) {
51 ASSERT(Isolate::Current()->zone_allow_allocation()); 51 ASSERT(Isolate::Current()->zone_allow_allocation());
52 ASSERT(ZoneScope::nesting() > 0); 52 ASSERT(ZoneScope::nesting() > 0);
53 // Round up the requested size to fit the alignment. 53 // Round up the requested size to fit the alignment.
54 size = RoundUp(size, kAlignment); 54 size = RoundUp(size, kAlignment);
55 55
56 // If the allocation size is divisible by 8 then we return an 8-byte aligned
57 // address.
58 if (kPointerSize == 4 && kAlignment == 4) {
59 position_ += ((~size) & 4) & (reinterpret_cast<intptr_t>(position_) & 4);
60 } else {
61 ASSERT(kAlignment >= kPointerSize);
62 }
63
56 // Check if the requested size is available without expanding. 64 // Check if the requested size is available without expanding.
57 Address result = position_; 65 Address result = position_;
58 66
59 if (size > limit_ - position_) { 67 if (size > limit_ - position_) {
60 result = NewExpand(size); 68 result = NewExpand(size);
61 } else { 69 } else {
62 position_ += size; 70 position_ += size;
63 } 71 }
64 72
65 // Check that the result has the proper alignment and return it. 73 // Check that the result has the proper alignment and return it.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 144
137 145
138 int ZoneScope::nesting() { 146 int ZoneScope::nesting() {
139 return Isolate::Current()->zone()->scope_nesting_; 147 return Isolate::Current()->zone()->scope_nesting_;
140 } 148 }
141 149
142 150
143 } } // namespace v8::internal 151 } } // namespace v8::internal
144 152
145 #endif // V8_ZONE_INL_H_ 153 #endif // V8_ZONE_INL_H_
OLDNEW
« no previous file with comments | « src/zone.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698