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_zone_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_zone_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_zone_pool_size( |
| 732 i::AccountingAllocator::kMaxPoolSizeMediumMemoryDevice); |
730 } else if (physical_memory <= high_limit) { | 733 } else if (physical_memory <= high_limit) { |
731 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeHighMemoryDevice); | 734 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeHighMemoryDevice); |
732 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHighMemoryDevice); | 735 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHighMemoryDevice); |
733 set_max_executable_size(i::Heap::kMaxExecutableSizeHighMemoryDevice); | 736 set_max_executable_size(i::Heap::kMaxExecutableSizeHighMemoryDevice); |
| 737 set_max_zone_pool_size( |
| 738 i::AccountingAllocator::kMaxPoolSizeHighMemoryDevice); |
734 } else { | 739 } else { |
735 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeHugeMemoryDevice); | 740 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeHugeMemoryDevice); |
736 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHugeMemoryDevice); | 741 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHugeMemoryDevice); |
737 set_max_executable_size(i::Heap::kMaxExecutableSizeHugeMemoryDevice); | 742 set_max_executable_size(i::Heap::kMaxExecutableSizeHugeMemoryDevice); |
| 743 set_max_zone_pool_size( |
| 744 i::AccountingAllocator::kMaxPoolSizeHugeMemoryDevice); |
738 } | 745 } |
739 | 746 |
740 if (virtual_memory_limit > 0 && i::kRequiresCodeRange) { | 747 if (virtual_memory_limit > 0 && i::kRequiresCodeRange) { |
741 // Reserve no more than 1/8 of the memory for the code range, but at most | 748 // Reserve no more than 1/8 of the memory for the code range, but at most |
742 // kMaximalCodeRangeSize. | 749 // kMaximalCodeRangeSize. |
743 set_code_range_size( | 750 set_code_range_size( |
744 i::Min(i::kMaximalCodeRangeSize / i::MB, | 751 i::Min(i::kMaximalCodeRangeSize / i::MB, |
745 static_cast<size_t>((virtual_memory_limit >> 3) / i::MB))); | 752 static_cast<size_t>((virtual_memory_limit >> 3) / i::MB))); |
746 } | 753 } |
747 } | 754 } |
748 | 755 |
749 | 756 |
750 void SetResourceConstraints(i::Isolate* isolate, | 757 void SetResourceConstraints(i::Isolate* isolate, |
751 const ResourceConstraints& constraints) { | 758 const ResourceConstraints& constraints) { |
752 int semi_space_size = constraints.max_semi_space_size(); | 759 int semi_space_size = constraints.max_semi_space_size(); |
753 int old_space_size = constraints.max_old_space_size(); | 760 int old_space_size = constraints.max_old_space_size(); |
754 int max_executable_size = constraints.max_executable_size(); | 761 int max_executable_size = constraints.max_executable_size(); |
755 size_t code_range_size = constraints.code_range_size(); | 762 size_t code_range_size = constraints.code_range_size(); |
| 763 size_t max_pool_size = constraints.max_zone_pool_size(); |
756 if (semi_space_size != 0 || old_space_size != 0 || | 764 if (semi_space_size != 0 || old_space_size != 0 || |
757 max_executable_size != 0 || code_range_size != 0) { | 765 max_executable_size != 0 || code_range_size != 0) { |
758 isolate->heap()->ConfigureHeap(semi_space_size, old_space_size, | 766 isolate->heap()->ConfigureHeap(semi_space_size, old_space_size, |
759 max_executable_size, code_range_size); | 767 max_executable_size, code_range_size); |
760 } | 768 } |
| 769 isolate->allocator()->ConfigureSegmentPool(max_pool_size); |
| 770 |
761 if (constraints.stack_limit() != NULL) { | 771 if (constraints.stack_limit() != NULL) { |
762 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints.stack_limit()); | 772 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints.stack_limit()); |
763 isolate->stack_guard()->SetStackLimit(limit); | 773 isolate->stack_guard()->SetStackLimit(limit); |
764 } | 774 } |
765 } | 775 } |
766 | 776 |
767 | 777 |
768 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { | 778 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { |
769 LOG_API(isolate, Persistent, New); | 779 LOG_API(isolate, Persistent, New); |
770 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); | 780 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 = | 9425 Address callback_address = |
9416 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9426 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
9417 VMState<EXTERNAL> state(isolate); | 9427 VMState<EXTERNAL> state(isolate); |
9418 ExternalCallbackScope call_scope(isolate, callback_address); | 9428 ExternalCallbackScope call_scope(isolate, callback_address); |
9419 callback(info); | 9429 callback(info); |
9420 } | 9430 } |
9421 | 9431 |
9422 | 9432 |
9423 } // namespace internal | 9433 } // namespace internal |
9424 } // namespace v8 | 9434 } // namespace v8 |
OLD | NEW |