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

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

Issue 7277038: make gc branch compile on Win32. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Addressed review comments Created 9 years, 5 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/incremental-marking.cc ('k') | src/spaces.h » ('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 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 *ptr = value; 1427 *ptr = value;
1428 } 1428 }
1429 1429
1430 1430
1431 bool VirtualMemory::IsReserved() { 1431 bool VirtualMemory::IsReserved() {
1432 return address_ != NULL; 1432 return address_ != NULL;
1433 } 1433 }
1434 1434
1435 1435
1436 VirtualMemory::VirtualMemory(size_t size) { 1436 VirtualMemory::VirtualMemory(size_t size) {
1437 address_ = VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS); 1437 address_ = ReserveRegion(size);
1438 size_ = size; 1438 size_ = size;
1439 } 1439 }
1440 1440
1441 1441
1442 VirtualMemory::~VirtualMemory() { 1442 VirtualMemory::~VirtualMemory() {
1443 if (IsReserved()) { 1443 if (IsReserved()) {
1444 if (0 == VirtualFree(address(), 0, MEM_RELEASE)) address_ = NULL; 1444 if (0 == VirtualFree(address(), 0, MEM_RELEASE)) address_ = NULL;
1445 } 1445 }
1446 } 1446 }
1447 1447
1448 1448
1449 bool VirtualMemory::Commit(void* address, size_t size, bool is_executable) { 1449 bool VirtualMemory::Commit(void* address, size_t size, bool is_executable) {
1450 int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; 1450 if (CommitRegion(address, size, is_executable)) {
1451 if (NULL == VirtualAlloc(address, size, MEM_COMMIT, prot)) { 1451 UpdateAllocatedSpaceLimits(address, static_cast<int>(size));
1452 return false; 1452 return true;
1453 } 1453 }
1454 1454 return false;
1455 UpdateAllocatedSpaceLimits(address, static_cast<int>(size));
1456 return true;
1457 } 1455 }
1458 1456
1459 1457
1460 bool VirtualMemory::Uncommit(void* address, size_t size) { 1458 bool VirtualMemory::Uncommit(void* address, size_t size) {
1461 ASSERT(IsReserved()); 1459 ASSERT(IsReserved());
1462 return VirtualFree(address, size, MEM_DECOMMIT) != false; 1460 return UncommitRegion(address, size);
1463 } 1461 }
1464 1462
1465 1463
1464 void* VirtualMemory::ReserveRegion(size_t size) {
1465 return VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS);
1466 }
1467
1468
1469 bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) {
1470 int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
1471 if (NULL == VirtualAlloc(base, size, MEM_COMMIT, prot)) {
1472 return false;
1473 }
1474
1475 UpdateAllocatedSpaceLimits(base, static_cast<int>(size));
1476 return true;
1477 }
1478
1479
1480 bool VirtualMemory::UncommitRegion(void* base, size_t size) {
1481 return VirtualFree(base, size, MEM_DECOMMIT) != false;
1482 }
1483
1484
1485 bool VirtualMemory::ReleaseRegion(void* base, size_t size) {
1486 return VirtualFree(base, size, MEM_DECOMMIT) != false;
1487 }
1488
1489
1490
1466 // ---------------------------------------------------------------------------- 1491 // ----------------------------------------------------------------------------
1467 // Win32 thread support. 1492 // Win32 thread support.
1468 1493
1469 // Definition of invalid thread handle and id. 1494 // Definition of invalid thread handle and id.
1470 static const HANDLE kNoThread = INVALID_HANDLE_VALUE; 1495 static const HANDLE kNoThread = INVALID_HANDLE_VALUE;
1471 1496
1472 // Entry point for threads. The supplied argument is a pointer to the thread 1497 // Entry point for threads. The supplied argument is a pointer to the thread
1473 // object. The entry function dispatches to the run method in the thread 1498 // object. The entry function dispatches to the run method in the thread
1474 // object. It is important that this function has __stdcall calling 1499 // object. It is important that this function has __stdcall calling
1475 // convention. 1500 // convention.
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
2012 2037
2013 void Sampler::Stop() { 2038 void Sampler::Stop() {
2014 ASSERT(IsActive()); 2039 ASSERT(IsActive());
2015 SamplerThread::RemoveActiveSampler(this); 2040 SamplerThread::RemoveActiveSampler(this);
2016 SetActive(false); 2041 SetActive(false);
2017 } 2042 }
2018 2043
2019 #endif // ENABLE_LOGGING_AND_PROFILING 2044 #endif // ENABLE_LOGGING_AND_PROFILING
2020 2045
2021 } } // namespace v8::internal 2046 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/incremental-marking.cc ('k') | src/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698