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 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 source_(source, source_length_), | 806 source_(source, source_length_), |
807 dep_count_(dep_count), | 807 dep_count_(dep_count), |
808 deps_(deps), | 808 deps_(deps), |
809 auto_enable_(false) { | 809 auto_enable_(false) { |
810 CHECK(source != NULL || source_length_ == 0); | 810 CHECK(source != NULL || source_length_ == 0); |
811 } | 811 } |
812 | 812 |
813 ResourceConstraints::ResourceConstraints() | 813 ResourceConstraints::ResourceConstraints() |
814 : max_semi_space_size_(0), | 814 : max_semi_space_size_(0), |
815 max_old_space_size_(0), | 815 max_old_space_size_(0), |
816 max_executable_size_(0), | |
817 stack_limit_(NULL), | 816 stack_limit_(NULL), |
818 code_range_size_(0), | 817 code_range_size_(0), |
819 max_zone_pool_size_(0) {} | 818 max_zone_pool_size_(0) {} |
820 | 819 |
821 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, | 820 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, |
822 uint64_t virtual_memory_limit) { | 821 uint64_t virtual_memory_limit) { |
823 #if V8_OS_ANDROID | 822 #if V8_OS_ANDROID |
824 // Android has higher physical memory requirements before raising the maximum | 823 // Android has higher physical memory requirements before raising the maximum |
825 // heap size limits since it has no swap space. | 824 // heap size limits since it has no swap space. |
826 const uint64_t low_limit = 512ul * i::MB; | 825 const uint64_t low_limit = 512ul * i::MB; |
827 const uint64_t medium_limit = 1ul * i::GB; | 826 const uint64_t medium_limit = 1ul * i::GB; |
828 const uint64_t high_limit = 2ul * i::GB; | 827 const uint64_t high_limit = 2ul * i::GB; |
829 #else | 828 #else |
830 const uint64_t low_limit = 512ul * i::MB; | 829 const uint64_t low_limit = 512ul * i::MB; |
831 const uint64_t medium_limit = 768ul * i::MB; | 830 const uint64_t medium_limit = 768ul * i::MB; |
832 const uint64_t high_limit = 1ul * i::GB; | 831 const uint64_t high_limit = 1ul * i::GB; |
833 #endif | 832 #endif |
834 | 833 |
835 if (physical_memory <= low_limit) { | 834 if (physical_memory <= low_limit) { |
836 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeLowMemoryDevice); | 835 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeLowMemoryDevice); |
837 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeLowMemoryDevice); | 836 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeLowMemoryDevice); |
838 set_max_executable_size(i::Heap::kMaxExecutableSizeLowMemoryDevice); | |
839 set_max_zone_pool_size(i::AccountingAllocator::kMaxPoolSizeLowMemoryDevice); | 837 set_max_zone_pool_size(i::AccountingAllocator::kMaxPoolSizeLowMemoryDevice); |
840 } else if (physical_memory <= medium_limit) { | 838 } else if (physical_memory <= medium_limit) { |
841 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeMediumMemoryDevice); | 839 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeMediumMemoryDevice); |
842 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeMediumMemoryDevice); | 840 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeMediumMemoryDevice); |
843 set_max_executable_size(i::Heap::kMaxExecutableSizeMediumMemoryDevice); | |
844 set_max_zone_pool_size( | 841 set_max_zone_pool_size( |
845 i::AccountingAllocator::kMaxPoolSizeMediumMemoryDevice); | 842 i::AccountingAllocator::kMaxPoolSizeMediumMemoryDevice); |
846 } else if (physical_memory <= high_limit) { | 843 } else if (physical_memory <= high_limit) { |
847 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeHighMemoryDevice); | 844 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeHighMemoryDevice); |
848 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHighMemoryDevice); | 845 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHighMemoryDevice); |
849 set_max_executable_size(i::Heap::kMaxExecutableSizeHighMemoryDevice); | |
850 set_max_zone_pool_size( | 846 set_max_zone_pool_size( |
851 i::AccountingAllocator::kMaxPoolSizeHighMemoryDevice); | 847 i::AccountingAllocator::kMaxPoolSizeHighMemoryDevice); |
852 } else { | 848 } else { |
853 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeHugeMemoryDevice); | 849 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeHugeMemoryDevice); |
854 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHugeMemoryDevice); | 850 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHugeMemoryDevice); |
855 set_max_executable_size(i::Heap::kMaxExecutableSizeHugeMemoryDevice); | |
856 set_max_zone_pool_size( | 851 set_max_zone_pool_size( |
857 i::AccountingAllocator::kMaxPoolSizeHugeMemoryDevice); | 852 i::AccountingAllocator::kMaxPoolSizeHugeMemoryDevice); |
858 } | 853 } |
859 | 854 |
860 if (virtual_memory_limit > 0 && i::kRequiresCodeRange) { | 855 if (virtual_memory_limit > 0 && i::kRequiresCodeRange) { |
861 // Reserve no more than 1/8 of the memory for the code range, but at most | 856 // Reserve no more than 1/8 of the memory for the code range, but at most |
862 // kMaximalCodeRangeSize. | 857 // kMaximalCodeRangeSize. |
863 set_code_range_size( | 858 set_code_range_size( |
864 i::Min(i::kMaximalCodeRangeSize / i::MB, | 859 i::Min(i::kMaximalCodeRangeSize / i::MB, |
865 static_cast<size_t>((virtual_memory_limit >> 3) / i::MB))); | 860 static_cast<size_t>((virtual_memory_limit >> 3) / i::MB))); |
866 } | 861 } |
867 } | 862 } |
868 | 863 |
869 | 864 |
870 void SetResourceConstraints(i::Isolate* isolate, | 865 void SetResourceConstraints(i::Isolate* isolate, |
871 const ResourceConstraints& constraints) { | 866 const ResourceConstraints& constraints) { |
872 int semi_space_size = constraints.max_semi_space_size(); | 867 int semi_space_size = constraints.max_semi_space_size(); |
873 int old_space_size = constraints.max_old_space_size(); | 868 int old_space_size = constraints.max_old_space_size(); |
874 int max_executable_size = constraints.max_executable_size(); | |
875 size_t code_range_size = constraints.code_range_size(); | 869 size_t code_range_size = constraints.code_range_size(); |
876 size_t max_pool_size = constraints.max_zone_pool_size(); | 870 size_t max_pool_size = constraints.max_zone_pool_size(); |
877 if (semi_space_size != 0 || old_space_size != 0 || | 871 if (semi_space_size != 0 || old_space_size != 0 || code_range_size != 0) { |
878 max_executable_size != 0 || code_range_size != 0) { | |
879 isolate->heap()->ConfigureHeap(semi_space_size, old_space_size, | 872 isolate->heap()->ConfigureHeap(semi_space_size, old_space_size, |
880 code_range_size); | 873 code_range_size); |
881 } | 874 } |
882 isolate->allocator()->ConfigureSegmentPool(max_pool_size); | 875 isolate->allocator()->ConfigureSegmentPool(max_pool_size); |
883 | 876 |
884 if (constraints.stack_limit() != NULL) { | 877 if (constraints.stack_limit() != NULL) { |
885 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints.stack_limit()); | 878 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints.stack_limit()); |
886 isolate->stack_guard()->SetStackLimit(limit); | 879 isolate->stack_guard()->SetStackLimit(limit); |
887 } | 880 } |
888 } | 881 } |
(...skipping 9575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10464 Address callback_address = | 10457 Address callback_address = |
10465 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10458 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
10466 VMState<EXTERNAL> state(isolate); | 10459 VMState<EXTERNAL> state(isolate); |
10467 ExternalCallbackScope call_scope(isolate, callback_address); | 10460 ExternalCallbackScope call_scope(isolate, callback_address); |
10468 callback(info); | 10461 callback(info); |
10469 } | 10462 } |
10470 | 10463 |
10471 | 10464 |
10472 } // namespace internal | 10465 } // namespace internal |
10473 } // namespace v8 | 10466 } // namespace v8 |
OLD | NEW |