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

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

Issue 53004: Add basic infrastructure for protecting V8's heap when leaving the VM... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 9 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
« src/spaces.h ('K') | « src/spaces.cc ('k') | tools/test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 212 }
213 213
214 214
215 PagedSpace* MemoryAllocator::PageOwner(Page* page) { 215 PagedSpace* MemoryAllocator::PageOwner(Page* page) {
216 int chunk_id = GetChunkId(page); 216 int chunk_id = GetChunkId(page);
217 ASSERT(IsValidChunk(chunk_id)); 217 ASSERT(IsValidChunk(chunk_id));
218 return chunks_[chunk_id].owner(); 218 return chunks_[chunk_id].owner();
219 } 219 }
220 220
221 221
222 bool MemoryAllocator::InInitialChunk(Address address) {
223 if (initial_chunk_ == NULL) return false;
224
225 Address start = static_cast<Address>(initial_chunk_->address());
226 return (start <= address) && (address < start + initial_chunk_->size());
227 }
228
229
230 #ifdef ENABLE_HEAP_PROTECTION
231
232 void MemoryAllocator::Protect(Address start, size_t size) {
233 OS::Protect(start, size);
234 }
235
236
237 void MemoryAllocator::Unprotect(Address start,
238 size_t size,
239 Executability executable) {
240 OS::Unprotect(start, size, executable);
241 }
242
243
244 void MemoryAllocator::ProtectChunkFromPage(Page* page) {
245 int id = GetChunkId(page);
246 OS::Protect(chunks_[id].address(), chunks_[id].size());
247 }
248
249
250 void MemoryAllocator::UnprotectChunkFromPage(Page* page) {
251 int id = GetChunkId(page);
252 OS::Unprotect(chunks_[id].address(), chunks_[id].size(),
253 chunks_[id].owner()->executable() == EXECUTABLE);
254 }
255
256 #endif
257
258
222 // -------------------------------------------------------------------------- 259 // --------------------------------------------------------------------------
223 // PagedSpace 260 // PagedSpace
224 261
225 bool PagedSpace::Contains(Address addr) { 262 bool PagedSpace::Contains(Address addr) {
226 Page* p = Page::FromAddress(addr); 263 Page* p = Page::FromAddress(addr);
227 ASSERT(p->is_valid()); 264 ASSERT(p->is_valid());
228 265
229 return MemoryAllocator::IsPageInSpace(p, this); 266 return MemoryAllocator::IsPageInSpace(p, this);
230 } 267 }
231 268
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 ASSERT(space->low() <= alloc_info->top 347 ASSERT(space->low() <= alloc_info->top
311 && alloc_info->top <= space->high() 348 && alloc_info->top <= space->high()
312 && alloc_info->limit == space->high()); 349 && alloc_info->limit == space->high());
313 #endif 350 #endif
314 return obj; 351 return obj;
315 } 352 }
316 353
317 } } // namespace v8::internal 354 } } // namespace v8::internal
318 355
319 #endif // V8_SPACES_INL_H_ 356 #endif // V8_SPACES_INL_H_
OLDNEW
« src/spaces.h ('K') | « src/spaces.cc ('k') | tools/test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698