OLD | NEW |
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include <errno.h> | 50 #include <errno.h> |
51 #include <stdarg.h> | 51 #include <stdarg.h> |
52 | 52 |
53 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'. | 53 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'. |
54 // Old versions of the C library <signal.h> didn't define the type. | 54 // Old versions of the C library <signal.h> didn't define the type. |
55 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \ | 55 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \ |
56 defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) | 56 defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) |
57 #include <asm/sigcontext.h> | 57 #include <asm/sigcontext.h> |
58 #endif | 58 #endif |
59 | 59 |
| 60 #if defined(LEAK_SANITIZER) |
| 61 #include <sanitizer/lsan_interface.h> |
| 62 #endif |
| 63 |
60 #undef MAP_TYPE | 64 #undef MAP_TYPE |
61 | 65 |
62 #include "v8.h" | 66 #include "v8.h" |
63 | 67 |
64 #include "platform.h" | 68 #include "platform.h" |
65 #include "v8threads.h" | 69 #include "v8threads.h" |
66 #include "vm-state-inl.h" | 70 #include "vm-state-inl.h" |
67 | 71 |
68 | 72 |
69 namespace v8 { | 73 namespace v8 { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 if (aligned_size != request_size) { | 345 if (aligned_size != request_size) { |
342 size_t suffix_size = request_size - aligned_size; | 346 size_t suffix_size = request_size - aligned_size; |
343 OS::Free(aligned_base + aligned_size, suffix_size); | 347 OS::Free(aligned_base + aligned_size, suffix_size); |
344 request_size -= suffix_size; | 348 request_size -= suffix_size; |
345 } | 349 } |
346 | 350 |
347 ASSERT(aligned_size == request_size); | 351 ASSERT(aligned_size == request_size); |
348 | 352 |
349 address_ = static_cast<void*>(aligned_base); | 353 address_ = static_cast<void*>(aligned_base); |
350 size_ = aligned_size; | 354 size_ = aligned_size; |
| 355 #if defined(LEAK_SANITIZER) |
| 356 __lsan_register_root_region(address_, size_); |
| 357 #endif |
351 } | 358 } |
352 | 359 |
353 | 360 |
354 VirtualMemory::~VirtualMemory() { | 361 VirtualMemory::~VirtualMemory() { |
355 if (IsReserved()) { | 362 if (IsReserved()) { |
356 bool result = ReleaseRegion(address(), size()); | 363 bool result = ReleaseRegion(address(), size()); |
357 ASSERT(result); | 364 ASSERT(result); |
358 USE(result); | 365 USE(result); |
359 } | 366 } |
360 } | 367 } |
(...skipping 29 matching lines...) Expand all Loading... |
390 void* VirtualMemory::ReserveRegion(size_t size) { | 397 void* VirtualMemory::ReserveRegion(size_t size) { |
391 void* result = mmap(OS::GetRandomMmapAddr(), | 398 void* result = mmap(OS::GetRandomMmapAddr(), |
392 size, | 399 size, |
393 PROT_NONE, | 400 PROT_NONE, |
394 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, | 401 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, |
395 kMmapFd, | 402 kMmapFd, |
396 kMmapFdOffset); | 403 kMmapFdOffset); |
397 | 404 |
398 if (result == MAP_FAILED) return NULL; | 405 if (result == MAP_FAILED) return NULL; |
399 | 406 |
| 407 #if defined(LEAK_SANITIZER) |
| 408 __lsan_register_root_region(result, size); |
| 409 #endif |
400 return result; | 410 return result; |
401 } | 411 } |
402 | 412 |
403 | 413 |
404 bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) { | 414 bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) { |
405 #if defined(__native_client__) | 415 #if defined(__native_client__) |
406 // The Native Client port of V8 uses an interpreter, | 416 // The Native Client port of V8 uses an interpreter, |
407 // so code pages don't need PROT_EXEC. | 417 // so code pages don't need PROT_EXEC. |
408 int prot = PROT_READ | PROT_WRITE; | 418 int prot = PROT_READ | PROT_WRITE; |
409 #else | 419 #else |
(...skipping 16 matching lines...) Expand all Loading... |
426 return mmap(base, | 436 return mmap(base, |
427 size, | 437 size, |
428 PROT_NONE, | 438 PROT_NONE, |
429 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_FIXED, | 439 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_FIXED, |
430 kMmapFd, | 440 kMmapFd, |
431 kMmapFdOffset) != MAP_FAILED; | 441 kMmapFdOffset) != MAP_FAILED; |
432 } | 442 } |
433 | 443 |
434 | 444 |
435 bool VirtualMemory::ReleaseRegion(void* base, size_t size) { | 445 bool VirtualMemory::ReleaseRegion(void* base, size_t size) { |
| 446 #if defined(LEAK_SANITIZER) |
| 447 __lsan_unregister_root_region(base, size); |
| 448 #endif |
436 return munmap(base, size) == 0; | 449 return munmap(base, size) == 0; |
437 } | 450 } |
438 | 451 |
439 | 452 |
440 bool VirtualMemory::HasLazyCommits() { | 453 bool VirtualMemory::HasLazyCommits() { |
441 return true; | 454 return true; |
442 } | 455 } |
443 | 456 |
444 } } // namespace v8::internal | 457 } } // namespace v8::internal |
OLD | NEW |