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 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 source_length : | 874 source_length : |
875 (source ? static_cast<int>(strlen(source)) : 0)), | 875 (source ? static_cast<int>(strlen(source)) : 0)), |
876 source_(source, source_length_), | 876 source_(source, source_length_), |
877 dep_count_(dep_count), | 877 dep_count_(dep_count), |
878 deps_(deps), | 878 deps_(deps), |
879 auto_enable_(false) { | 879 auto_enable_(false) { |
880 CHECK(source != NULL || source_length_ == 0); | 880 CHECK(source != NULL || source_length_ == 0); |
881 } | 881 } |
882 | 882 |
883 ResourceConstraints::ResourceConstraints() | 883 ResourceConstraints::ResourceConstraints() |
884 : max_semi_space_size_(0), | 884 : max_semi_space_size_in_kb_(0), |
885 max_old_space_size_(0), | 885 max_old_space_size_(0), |
886 stack_limit_(NULL), | 886 stack_limit_(NULL), |
887 code_range_size_(0), | 887 code_range_size_(0), |
888 max_zone_pool_size_(0) {} | 888 max_zone_pool_size_(0) {} |
889 | 889 |
890 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, | 890 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, |
891 uint64_t virtual_memory_limit) { | 891 uint64_t virtual_memory_limit) { |
892 set_max_semi_space_size( | 892 set_max_semi_space_size_in_kb( |
893 static_cast<int>(i::Heap::ComputeMaxSemiSpaceSize(physical_memory))); | 893 static_cast<int>(i::Heap::ComputeMaxSemiSpaceSize(physical_memory))); |
894 set_max_old_space_size( | 894 set_max_old_space_size( |
895 static_cast<int>(i::Heap::ComputeMaxOldGenerationSize(physical_memory))); | 895 static_cast<int>(i::Heap::ComputeMaxOldGenerationSize(physical_memory))); |
896 set_max_zone_pool_size(i::AccountingAllocator::kMaxPoolSize); | 896 set_max_zone_pool_size(i::AccountingAllocator::kMaxPoolSize); |
897 | 897 |
898 if (virtual_memory_limit > 0 && i::kRequiresCodeRange) { | 898 if (virtual_memory_limit > 0 && i::kRequiresCodeRange) { |
899 // Reserve no more than 1/8 of the memory for the code range, but at most | 899 // Reserve no more than 1/8 of the memory for the code range, but at most |
900 // kMaximalCodeRangeSize. | 900 // kMaximalCodeRangeSize. |
901 set_code_range_size( | 901 set_code_range_size( |
902 i::Min(i::kMaximalCodeRangeSize / i::MB, | 902 i::Min(i::kMaximalCodeRangeSize / i::MB, |
903 static_cast<size_t>((virtual_memory_limit >> 3) / i::MB))); | 903 static_cast<size_t>((virtual_memory_limit >> 3) / i::MB))); |
904 } | 904 } |
905 } | 905 } |
906 | 906 |
907 void SetResourceConstraints(i::Isolate* isolate, | 907 void SetResourceConstraints(i::Isolate* isolate, |
908 const ResourceConstraints& constraints) { | 908 const ResourceConstraints& constraints) { |
909 int semi_space_size = constraints.max_semi_space_size(); | 909 int semi_space_size = constraints.max_semi_space_size_in_kb(); |
910 int old_space_size = constraints.max_old_space_size(); | 910 int old_space_size = constraints.max_old_space_size(); |
911 size_t code_range_size = constraints.code_range_size(); | 911 size_t code_range_size = constraints.code_range_size(); |
912 size_t max_pool_size = constraints.max_zone_pool_size(); | 912 size_t max_pool_size = constraints.max_zone_pool_size(); |
913 if (semi_space_size != 0 || old_space_size != 0 || code_range_size != 0) { | 913 if (semi_space_size != 0 || old_space_size != 0 || code_range_size != 0) { |
914 isolate->heap()->ConfigureHeap(semi_space_size, old_space_size, | 914 isolate->heap()->ConfigureHeap(semi_space_size, old_space_size, |
915 code_range_size); | 915 code_range_size); |
916 } | 916 } |
917 isolate->allocator()->ConfigureSegmentPool(max_pool_size); | 917 isolate->allocator()->ConfigureSegmentPool(max_pool_size); |
918 | 918 |
919 if (constraints.stack_limit() != NULL) { | 919 if (constraints.stack_limit() != NULL) { |
(...skipping 9621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10541 Address callback_address = | 10541 Address callback_address = |
10542 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10542 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
10543 VMState<EXTERNAL> state(isolate); | 10543 VMState<EXTERNAL> state(isolate); |
10544 ExternalCallbackScope call_scope(isolate, callback_address); | 10544 ExternalCallbackScope call_scope(isolate, callback_address); |
10545 callback(info); | 10545 callback(info); |
10546 } | 10546 } |
10547 | 10547 |
10548 | 10548 |
10549 } // namespace internal | 10549 } // namespace internal |
10550 } // namespace v8 | 10550 } // namespace v8 |
OLD | NEW |