| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/api.h" | 5 #include "src/api.h" |
| 6 | 6 |
| 7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
| 8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
| 9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
| 10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 source_length_(source_length >= 0 ? | 690 source_length_(source_length >= 0 ? |
| 691 source_length : | 691 source_length : |
| 692 (source ? static_cast<int>(strlen(source)) : 0)), | 692 (source ? static_cast<int>(strlen(source)) : 0)), |
| 693 source_(source, source_length_), | 693 source_(source, source_length_), |
| 694 dep_count_(dep_count), | 694 dep_count_(dep_count), |
| 695 deps_(deps), | 695 deps_(deps), |
| 696 auto_enable_(false) { | 696 auto_enable_(false) { |
| 697 CHECK(source != NULL || source_length_ == 0); | 697 CHECK(source != NULL || source_length_ == 0); |
| 698 } | 698 } |
| 699 | 699 |
| 700 | |
| 701 ResourceConstraints::ResourceConstraints() | 700 ResourceConstraints::ResourceConstraints() |
| 702 : max_semi_space_size_(0), | 701 : max_semi_space_size_(0), |
| 703 max_old_space_size_(0), | 702 max_old_space_size_(0), |
| 704 max_executable_size_(0), | 703 max_executable_size_(0), |
| 705 stack_limit_(NULL), | 704 stack_limit_(NULL), |
| 706 code_range_size_(0) { } | 705 code_range_size_(0), |
| 706 max_pool_size_(0) {} |
| 707 | 707 |
| 708 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, | 708 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, |
| 709 uint64_t virtual_memory_limit) { | 709 uint64_t virtual_memory_limit) { |
| 710 #if V8_OS_ANDROID | 710 #if V8_OS_ANDROID |
| 711 // Android has higher physical memory requirements before raising the maximum | 711 // Android has higher physical memory requirements before raising the maximum |
| 712 // heap size limits since it has no swap space. | 712 // heap size limits since it has no swap space. |
| 713 const uint64_t low_limit = 512ul * i::MB; | 713 const uint64_t low_limit = 512ul * i::MB; |
| 714 const uint64_t medium_limit = 1ul * i::GB; | 714 const uint64_t medium_limit = 1ul * i::GB; |
| 715 const uint64_t high_limit = 2ul * i::GB; | 715 const uint64_t high_limit = 2ul * i::GB; |
| 716 #else | 716 #else |
| 717 const uint64_t low_limit = 512ul * i::MB; | 717 const uint64_t low_limit = 512ul * i::MB; |
| 718 const uint64_t medium_limit = 768ul * i::MB; | 718 const uint64_t medium_limit = 768ul * i::MB; |
| 719 const uint64_t high_limit = 1ul * i::GB; | 719 const uint64_t high_limit = 1ul * i::GB; |
| 720 #endif | 720 #endif |
| 721 | 721 |
| 722 if (physical_memory <= low_limit) { | 722 if (physical_memory <= low_limit) { |
| 723 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeLowMemoryDevice); | 723 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeLowMemoryDevice); |
| 724 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeLowMemoryDevice); | 724 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeLowMemoryDevice); |
| 725 set_max_executable_size(i::Heap::kMaxExecutableSizeLowMemoryDevice); | 725 set_max_executable_size(i::Heap::kMaxExecutableSizeLowMemoryDevice); |
| 726 set_max_pool_size(i::AccountingAllocator::kMaxPoolSizeLowMemoryDevice); |
| 726 } else if (physical_memory <= medium_limit) { | 727 } else if (physical_memory <= medium_limit) { |
| 727 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeMediumMemoryDevice); | 728 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeMediumMemoryDevice); |
| 728 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeMediumMemoryDevice); | 729 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeMediumMemoryDevice); |
| 729 set_max_executable_size(i::Heap::kMaxExecutableSizeMediumMemoryDevice); | 730 set_max_executable_size(i::Heap::kMaxExecutableSizeMediumMemoryDevice); |
| 731 set_max_pool_size(i::AccountingAllocator::kMaxPoolSizeMediumMemoryDevice); |
| 730 } else if (physical_memory <= high_limit) { | 732 } else if (physical_memory <= high_limit) { |
| 731 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeHighMemoryDevice); | 733 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeHighMemoryDevice); |
| 732 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHighMemoryDevice); | 734 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHighMemoryDevice); |
| 733 set_max_executable_size(i::Heap::kMaxExecutableSizeHighMemoryDevice); | 735 set_max_executable_size(i::Heap::kMaxExecutableSizeHighMemoryDevice); |
| 736 set_max_pool_size(i::AccountingAllocator::kMaxPoolSizeHighMemoryDevice); |
| 734 } else { | 737 } else { |
| 735 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeHugeMemoryDevice); | 738 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeHugeMemoryDevice); |
| 736 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHugeMemoryDevice); | 739 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHugeMemoryDevice); |
| 737 set_max_executable_size(i::Heap::kMaxExecutableSizeHugeMemoryDevice); | 740 set_max_executable_size(i::Heap::kMaxExecutableSizeHugeMemoryDevice); |
| 741 set_max_pool_size(i::AccountingAllocator::kMaxPoolSizeHugeMemoryDevice); |
| 738 } | 742 } |
| 739 | 743 |
| 740 if (virtual_memory_limit > 0 && i::kRequiresCodeRange) { | 744 if (virtual_memory_limit > 0 && i::kRequiresCodeRange) { |
| 741 // Reserve no more than 1/8 of the memory for the code range, but at most | 745 // Reserve no more than 1/8 of the memory for the code range, but at most |
| 742 // kMaximalCodeRangeSize. | 746 // kMaximalCodeRangeSize. |
| 743 set_code_range_size( | 747 set_code_range_size( |
| 744 i::Min(i::kMaximalCodeRangeSize / i::MB, | 748 i::Min(i::kMaximalCodeRangeSize / i::MB, |
| 745 static_cast<size_t>((virtual_memory_limit >> 3) / i::MB))); | 749 static_cast<size_t>((virtual_memory_limit >> 3) / i::MB))); |
| 746 } | 750 } |
| 747 } | 751 } |
| 748 | 752 |
| 749 | 753 |
| 750 void SetResourceConstraints(i::Isolate* isolate, | 754 void SetResourceConstraints(i::Isolate* isolate, |
| 751 const ResourceConstraints& constraints) { | 755 const ResourceConstraints& constraints) { |
| 752 int semi_space_size = constraints.max_semi_space_size(); | 756 int semi_space_size = constraints.max_semi_space_size(); |
| 753 int old_space_size = constraints.max_old_space_size(); | 757 int old_space_size = constraints.max_old_space_size(); |
| 754 int max_executable_size = constraints.max_executable_size(); | 758 int max_executable_size = constraints.max_executable_size(); |
| 755 size_t code_range_size = constraints.code_range_size(); | 759 size_t code_range_size = constraints.code_range_size(); |
| 760 size_t max_pool_size = constraints.max_pool_size(); |
| 756 if (semi_space_size != 0 || old_space_size != 0 || | 761 if (semi_space_size != 0 || old_space_size != 0 || |
| 757 max_executable_size != 0 || code_range_size != 0) { | 762 max_executable_size != 0 || code_range_size != 0) { |
| 758 isolate->heap()->ConfigureHeap(semi_space_size, old_space_size, | 763 isolate->heap()->ConfigureHeap(semi_space_size, old_space_size, |
| 759 max_executable_size, code_range_size); | 764 max_executable_size, code_range_size); |
| 760 } | 765 } |
| 766 isolate->allocator()->ConfigureSegmentPool(max_pool_size); |
| 767 |
| 761 if (constraints.stack_limit() != NULL) { | 768 if (constraints.stack_limit() != NULL) { |
| 762 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints.stack_limit()); | 769 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints.stack_limit()); |
| 763 isolate->stack_guard()->SetStackLimit(limit); | 770 isolate->stack_guard()->SetStackLimit(limit); |
| 764 } | 771 } |
| 765 } | 772 } |
| 766 | 773 |
| 767 | 774 |
| 768 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { | 775 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { |
| 769 LOG_API(isolate, Persistent, New); | 776 LOG_API(isolate, Persistent, New); |
| 770 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); | 777 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); |
| (...skipping 8644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9415 Address callback_address = | 9422 Address callback_address = |
| 9416 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9423 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 9417 VMState<EXTERNAL> state(isolate); | 9424 VMState<EXTERNAL> state(isolate); |
| 9418 ExternalCallbackScope call_scope(isolate, callback_address); | 9425 ExternalCallbackScope call_scope(isolate, callback_address); |
| 9419 callback(info); | 9426 callback(info); |
| 9420 } | 9427 } |
| 9421 | 9428 |
| 9422 | 9429 |
| 9423 } // namespace internal | 9430 } // namespace internal |
| 9424 } // namespace v8 | 9431 } // namespace v8 |
| OLD | NEW |