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

Side by Side Diff: src/platform-win32.cc

Issue 14162004: Unified the structure of VirtualMemory implementations across platforms a bit. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 8 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
« no previous file with comments | « src/platform-solaris.cc ('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 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 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 address = ReserveRegion(request_size); 1511 address = ReserveRegion(request_size);
1512 if (address == NULL) return; 1512 if (address == NULL) return;
1513 } 1513 }
1514 address_ = address; 1514 address_ = address;
1515 size_ = request_size; 1515 size_ = request_size;
1516 } 1516 }
1517 1517
1518 1518
1519 VirtualMemory::~VirtualMemory() { 1519 VirtualMemory::~VirtualMemory() {
1520 if (IsReserved()) { 1520 if (IsReserved()) {
1521 bool result = ReleaseRegion(address_, size_); 1521 bool result = ReleaseRegion(address(), size());
1522 ASSERT(result); 1522 ASSERT(result);
1523 USE(result); 1523 USE(result);
1524 } 1524 }
1525 } 1525 }
1526 1526
1527 1527
1528 bool VirtualMemory::IsReserved() { 1528 bool VirtualMemory::IsReserved() {
1529 return address_ != NULL; 1529 return address_ != NULL;
1530 } 1530 }
1531 1531
(...skipping 12 matching lines...) Expand all
1544 return false; 1544 return false;
1545 } 1545 }
1546 1546
1547 1547
1548 bool VirtualMemory::Uncommit(void* address, size_t size) { 1548 bool VirtualMemory::Uncommit(void* address, size_t size) {
1549 ASSERT(IsReserved()); 1549 ASSERT(IsReserved());
1550 return UncommitRegion(address, size); 1550 return UncommitRegion(address, size);
1551 } 1551 }
1552 1552
1553 1553
1554 bool VirtualMemory::Guard(void* address) {
1555 if (NULL == VirtualAlloc(address,
1556 OS::CommitPageSize(),
1557 MEM_COMMIT,
1558 PAGE_READONLY | PAGE_GUARD)) {
1559 return false;
1560 }
1561 return true;
1562 }
1563
1564
1554 void* VirtualMemory::ReserveRegion(size_t size) { 1565 void* VirtualMemory::ReserveRegion(size_t size) {
1555 return RandomizedVirtualAlloc(size, MEM_RESERVE, PAGE_NOACCESS); 1566 return RandomizedVirtualAlloc(size, MEM_RESERVE, PAGE_NOACCESS);
1556 } 1567 }
1557 1568
1558 1569
1559 bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) { 1570 bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) {
1560 int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; 1571 int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
1561 if (NULL == VirtualAlloc(base, size, MEM_COMMIT, prot)) { 1572 if (NULL == VirtualAlloc(base, size, MEM_COMMIT, prot)) {
1562 return false; 1573 return false;
1563 } 1574 }
1564 1575
1565 UpdateAllocatedSpaceLimits(base, static_cast<int>(size)); 1576 UpdateAllocatedSpaceLimits(base, static_cast<int>(size));
1566 return true; 1577 return true;
1567 } 1578 }
1568 1579
1569 1580
1570 bool VirtualMemory::Guard(void* address) {
1571 if (NULL == VirtualAlloc(address,
1572 OS::CommitPageSize(),
1573 MEM_COMMIT,
1574 PAGE_READONLY | PAGE_GUARD)) {
1575 return false;
1576 }
1577 return true;
1578 }
1579
1580
1581 bool VirtualMemory::UncommitRegion(void* base, size_t size) { 1581 bool VirtualMemory::UncommitRegion(void* base, size_t size) {
1582 return VirtualFree(base, size, MEM_DECOMMIT) != 0; 1582 return VirtualFree(base, size, MEM_DECOMMIT) != 0;
1583 } 1583 }
1584 1584
1585 1585
1586 bool VirtualMemory::ReleaseRegion(void* base, size_t size) { 1586 bool VirtualMemory::ReleaseRegion(void* base, size_t size) {
1587 return VirtualFree(base, 0, MEM_RELEASE) != 0; 1587 return VirtualFree(base, 0, MEM_RELEASE) != 0;
1588 } 1588 }
1589 1589
1590 1590
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
2175 2175
2176 2176
2177 void Sampler::Stop() { 2177 void Sampler::Stop() {
2178 ASSERT(IsActive()); 2178 ASSERT(IsActive());
2179 SamplerThread::RemoveActiveSampler(this); 2179 SamplerThread::RemoveActiveSampler(this);
2180 SetActive(false); 2180 SetActive(false);
2181 } 2181 }
2182 2182
2183 2183
2184 } } // namespace v8::internal 2184 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-solaris.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698