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 |
(...skipping 20 matching lines...) Expand all Loading... | |
737 set_max_executable_size(i::Heap::kMaxExecutableSizeHugeMemoryDevice); | 737 set_max_executable_size(i::Heap::kMaxExecutableSizeHugeMemoryDevice); |
738 } | 738 } |
739 | 739 |
740 if (virtual_memory_limit > 0 && i::kRequiresCodeRange) { | 740 if (virtual_memory_limit > 0 && i::kRequiresCodeRange) { |
741 // Reserve no more than 1/8 of the memory for the code range, but at most | 741 // Reserve no more than 1/8 of the memory for the code range, but at most |
742 // kMaximalCodeRangeSize. | 742 // kMaximalCodeRangeSize. |
743 set_code_range_size( | 743 set_code_range_size( |
744 i::Min(i::kMaximalCodeRangeSize / i::MB, | 744 i::Min(i::kMaximalCodeRangeSize / i::MB, |
745 static_cast<size_t>((virtual_memory_limit >> 3) / i::MB))); | 745 static_cast<size_t>((virtual_memory_limit >> 3) / i::MB))); |
746 } | 746 } |
747 | |
748 if (physical_memory <= low_limit) { | |
Michael Lippautz
2016/10/19 08:56:06
And by "use categories already defined above", I a
| |
749 set_max_pool_size(i::AccountingAllocator::kMaxPoolSizeLowMemoryDevice); | |
750 } else if (physical_memory <= medium_limit) { | |
751 set_max_pool_size(i::AccountingAllocator::kMaxPoolSizeMediumMemoryDevice); | |
752 } else if (physical_memory <= high_limit) { | |
753 set_max_pool_size(i::AccountingAllocator::kMaxPoolSizeHighMemoryDevice); | |
754 } else { | |
755 set_max_pool_size(i::AccountingAllocator::kMaxPoolSizeHugeMemoryDevice); | |
756 } | |
747 } | 757 } |
748 | 758 |
749 | 759 |
750 void SetResourceConstraints(i::Isolate* isolate, | 760 void SetResourceConstraints(i::Isolate* isolate, |
751 const ResourceConstraints& constraints) { | 761 const ResourceConstraints& constraints) { |
752 int semi_space_size = constraints.max_semi_space_size(); | 762 int semi_space_size = constraints.max_semi_space_size(); |
753 int old_space_size = constraints.max_old_space_size(); | 763 int old_space_size = constraints.max_old_space_size(); |
754 int max_executable_size = constraints.max_executable_size(); | 764 int max_executable_size = constraints.max_executable_size(); |
755 size_t code_range_size = constraints.code_range_size(); | 765 size_t code_range_size = constraints.code_range_size(); |
766 size_t max_pool_size = constraints.max_pool_size(); | |
756 if (semi_space_size != 0 || old_space_size != 0 || | 767 if (semi_space_size != 0 || old_space_size != 0 || |
757 max_executable_size != 0 || code_range_size != 0) { | 768 max_executable_size != 0 || code_range_size != 0) { |
758 isolate->heap()->ConfigureHeap(semi_space_size, old_space_size, | 769 isolate->heap()->ConfigureHeap(semi_space_size, old_space_size, |
759 max_executable_size, code_range_size); | 770 max_executable_size, code_range_size); |
760 } | 771 } |
772 isolate->allocator()->ConfigureSegmentPool(max_pool_size); | |
773 | |
761 if (constraints.stack_limit() != NULL) { | 774 if (constraints.stack_limit() != NULL) { |
762 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints.stack_limit()); | 775 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints.stack_limit()); |
763 isolate->stack_guard()->SetStackLimit(limit); | 776 isolate->stack_guard()->SetStackLimit(limit); |
764 } | 777 } |
765 } | 778 } |
766 | 779 |
767 | 780 |
768 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { | 781 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { |
769 LOG_API(isolate, Persistent, New); | 782 LOG_API(isolate, Persistent, New); |
770 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); | 783 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 = | 9428 Address callback_address = |
9416 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9429 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
9417 VMState<EXTERNAL> state(isolate); | 9430 VMState<EXTERNAL> state(isolate); |
9418 ExternalCallbackScope call_scope(isolate, callback_address); | 9431 ExternalCallbackScope call_scope(isolate, callback_address); |
9419 callback(info); | 9432 callback(info); |
9420 } | 9433 } |
9421 | 9434 |
9422 | 9435 |
9423 } // namespace internal | 9436 } // namespace internal |
9424 } // namespace v8 | 9437 } // namespace v8 |
OLD | NEW |