Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 #endif | 58 #endif |
| 59 #if V8_TARGET_ARCH_MIPS && !V8_INTERPRETED_REGEXP | 59 #if V8_TARGET_ARCH_MIPS && !V8_INTERPRETED_REGEXP |
| 60 #include "regexp-macro-assembler.h" | 60 #include "regexp-macro-assembler.h" |
| 61 #include "mips/regexp-macro-assembler-mips.h" | 61 #include "mips/regexp-macro-assembler-mips.h" |
| 62 #endif | 62 #endif |
| 63 | 63 |
| 64 namespace v8 { | 64 namespace v8 { |
| 65 namespace internal { | 65 namespace internal { |
| 66 | 66 |
| 67 | 67 |
| 68 // semispace_size_ should be a power of 2 and old_generation_size_ should be | |
| 69 // a multiple of Page::kPageSize. | |
| 70 #if V8_TARGET_ARCH_X64 | |
| 71 #define LUMP_OF_MEMORY (2 * MB) | |
| 72 #else | |
| 73 #define LUMP_OF_MEMORY MB | |
| 74 #endif | |
| 75 #if defined(ANDROID) || V8_TARGET_ARCH_MIPS | |
|
Hannes Payer (out of office)
2013/09/19 14:50:57
I never liked the ifdef here. Now it's time to get
rmcilroy
2013/09/19 15:01:34
I don't like this ifdef particularly either, but I
Hannes Payer (out of office)
2013/09/19 16:25:28
Well, what I mean is that we should have these ifd
rmcilroy
2013/09/19 19:46:11
There are more V8 embedders than just d8 and chrom
| |
| 76 #define DEFAULT_SEMISPACE_MAX_SIZE (4 * Max(LUMP_OF_MEMORY, Page::kPageSize)) | |
| 77 #define DEFAULT_OLD_GENERATION_MAX_SIZE (192*MB) | |
| 78 #define DEFAULT_EXECUTABLE_MAX_SIZE (192*MB) | |
| 79 #else | |
| 80 #define DEFAULT_SEMISPACE_MAX_SIZE (8 * Max(LUMP_OF_MEMORY, Page::kPageSize)) | |
| 81 #define DEFAULT_OLD_GENERATION_MAX_SIZE (700ul * LUMP_OF_MEMORY) | |
| 82 #define DEFAULT_EXECUTABLE_MAX_SIZE (256l * LUMP_OF_MEMORY) | |
| 83 #endif | |
| 84 | |
| 85 | |
| 68 Heap::Heap() | 86 Heap::Heap() |
| 69 : isolate_(NULL), | 87 : isolate_(NULL), |
| 70 // semispace_size_ should be a power of 2 and old_generation_size_ should be | |
| 71 // a multiple of Page::kPageSize. | |
| 72 #if V8_TARGET_ARCH_X64 | 88 #if V8_TARGET_ARCH_X64 |
| 73 #define LUMP_OF_MEMORY (2 * MB) | |
| 74 code_range_size_(512*MB), | 89 code_range_size_(512*MB), |
| 75 #else | 90 #else |
| 76 #define LUMP_OF_MEMORY MB | |
| 77 code_range_size_(0), | 91 code_range_size_(0), |
| 78 #endif | 92 #endif |
| 79 #if defined(ANDROID) || V8_TARGET_ARCH_MIPS | 93 reserved_semispace_size_(DEFAULT_SEMISPACE_MAX_SIZE), |
|
Hannes Payer (out of office)
2013/09/19 14:50:57
Here we could set the values to proper default val
rmcilroy
2013/09/19 15:01:34
I'm not sure what you mean here?
Hannes Payer (out of office)
2013/09/19 16:25:28
What I meant is to set the values to
reserved_semi
rmcilroy
2013/09/19 19:46:11
Maybe we could just set these all to zero initiall
| |
| 80 reserved_semispace_size_(4 * Max(LUMP_OF_MEMORY, Page::kPageSize)), | 94 max_semispace_size_(DEFAULT_SEMISPACE_MAX_SIZE), |
| 81 max_semispace_size_(4 * Max(LUMP_OF_MEMORY, Page::kPageSize)), | |
| 82 initial_semispace_size_(Page::kPageSize), | 95 initial_semispace_size_(Page::kPageSize), |
| 83 max_old_generation_size_(192*MB), | 96 max_old_generation_size_(DEFAULT_OLD_GENERATION_MAX_SIZE), |
| 84 max_executable_size_(max_old_generation_size_), | 97 max_executable_size_(DEFAULT_EXECUTABLE_MAX_SIZE), |
| 85 #else | |
| 86 reserved_semispace_size_(8 * Max(LUMP_OF_MEMORY, Page::kPageSize)), | |
| 87 max_semispace_size_(8 * Max(LUMP_OF_MEMORY, Page::kPageSize)), | |
| 88 initial_semispace_size_(Page::kPageSize), | |
| 89 max_old_generation_size_(700ul * LUMP_OF_MEMORY), | |
| 90 max_executable_size_(256l * LUMP_OF_MEMORY), | |
| 91 #endif | |
| 92 | |
| 93 // Variables set based on semispace_size_ and old_generation_size_ in | 98 // Variables set based on semispace_size_ and old_generation_size_ in |
| 94 // ConfigureHeap (survived_since_last_expansion_, external_allocation_limit_) | 99 // ConfigureHeap (survived_since_last_expansion_, external_allocation_limit_) |
| 95 // Will be 4 * reserved_semispace_size_ to ensure that young | 100 // Will be 4 * reserved_semispace_size_ to ensure that young |
| 96 // generation can be aligned to its size. | 101 // generation can be aligned to its size. |
| 97 survived_since_last_expansion_(0), | 102 survived_since_last_expansion_(0), |
| 98 sweep_generation_(0), | 103 sweep_generation_(0), |
| 99 always_allocate_scope_depth_(0), | 104 always_allocate_scope_depth_(0), |
| 100 linear_allocation_scope_depth_(0), | 105 linear_allocation_scope_depth_(0), |
| 101 contexts_disposed_(0), | 106 contexts_disposed_(0), |
| 102 global_ic_age_(0), | 107 global_ic_age_(0), |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 last_idle_notification_gc_count_init_(false), | 159 last_idle_notification_gc_count_init_(false), |
| 155 mark_sweeps_since_idle_round_started_(0), | 160 mark_sweeps_since_idle_round_started_(0), |
| 156 gc_count_at_last_idle_gc_(0), | 161 gc_count_at_last_idle_gc_(0), |
| 157 scavenges_since_last_idle_round_(kIdleScavengeThreshold), | 162 scavenges_since_last_idle_round_(kIdleScavengeThreshold), |
| 158 gcs_since_last_deopt_(0), | 163 gcs_since_last_deopt_(0), |
| 159 #ifdef VERIFY_HEAP | 164 #ifdef VERIFY_HEAP |
| 160 no_weak_embedded_maps_verification_scope_depth_(0), | 165 no_weak_embedded_maps_verification_scope_depth_(0), |
| 161 #endif | 166 #endif |
| 162 promotion_queue_(this), | 167 promotion_queue_(this), |
| 163 configured_(false), | 168 configured_(false), |
| 169 limits_changed_from_defaults_(false), | |
| 164 chunks_queued_for_free_(NULL), | 170 chunks_queued_for_free_(NULL), |
| 165 relocation_mutex_(NULL) { | 171 relocation_mutex_(NULL) { |
| 166 // Allow build-time customization of the max semispace size. Building | 172 // Allow build-time customization of the max semispace size. Building |
| 167 // V8 with snapshots and a non-default max semispace size is much | 173 // V8 with snapshots and a non-default max semispace size is much |
| 168 // easier if you can define it as part of the build environment. | 174 // easier if you can define it as part of the build environment. |
| 169 #if defined(V8_MAX_SEMISPACE_SIZE) | 175 #if defined(V8_MAX_SEMISPACE_SIZE) |
| 170 max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; | 176 max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; |
| 171 #endif | 177 #endif |
|
Hannes Payer (out of office)
2013/09/19 14:50:57
Can you bring back this newline?
| |
| 172 | |
| 173 intptr_t max_virtual = OS::MaxVirtualMemory(); | 178 intptr_t max_virtual = OS::MaxVirtualMemory(); |
| 174 | 179 |
| 175 if (max_virtual > 0) { | 180 if (max_virtual > 0) { |
| 176 if (code_range_size_ > 0) { | 181 if (code_range_size_ > 0) { |
| 177 // Reserve no more than 1/8 of the memory for the code range. | 182 // Reserve no more than 1/8 of the memory for the code range. |
| 178 code_range_size_ = Min(code_range_size_, max_virtual >> 3); | 183 code_range_size_ = Min(code_range_size_, max_virtual >> 3); |
| 179 } | 184 } |
| 180 } | 185 } |
| 181 | 186 |
| 182 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); | 187 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); |
| (...skipping 6483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6666 | 6671 |
| 6667 | 6672 |
| 6668 // TODO(1236194): Since the heap size is configurable on the command line | 6673 // TODO(1236194): Since the heap size is configurable on the command line |
| 6669 // and through the API, we should gracefully handle the case that the heap | 6674 // and through the API, we should gracefully handle the case that the heap |
| 6670 // size is not big enough to fit all the initial objects. | 6675 // size is not big enough to fit all the initial objects. |
| 6671 bool Heap::ConfigureHeap(int max_semispace_size, | 6676 bool Heap::ConfigureHeap(int max_semispace_size, |
| 6672 intptr_t max_old_gen_size, | 6677 intptr_t max_old_gen_size, |
| 6673 intptr_t max_executable_size) { | 6678 intptr_t max_executable_size) { |
| 6674 if (HasBeenSetUp()) return false; | 6679 if (HasBeenSetUp()) return false; |
| 6675 | 6680 |
| 6681 if (isolate_->is_memory_constrained() && !limits_changed_from_defaults_) { | |
| 6682 // Update the default values if this is a memory constrained device. | |
| 6683 // TODO(rmcilroy): Ideally these should be set correctly in the constructor | |
| 6684 // based on this flag, but the flag isn't setup correctly at that point. | |
| 6685 max_semispace_size_ = DEFAULT_SEMISPACE_MAX_SIZE / 4; | |
| 6686 reserved_semispace_size_ = DEFAULT_SEMISPACE_MAX_SIZE / 4; | |
| 6687 max_old_generation_size_ = DEFAULT_OLD_GENERATION_MAX_SIZE / 2; | |
| 6688 max_executable_size_ = DEFAULT_EXECUTABLE_MAX_SIZE / 2; | |
|
Hannes Payer (out of office)
2013/09/19 14:50:57
The embedder would just set the right values, no m
rmcilroy
2013/09/19 15:01:34
The embedder doesn't need to set these values (if
Hannes Payer (out of office)
2013/09/19 16:25:28
But SetResourceConstraints could just set it to th
rmcilroy
2013/09/19 19:46:11
Do you mean the embedder could just pass the corre
| |
| 6689 } | |
| 6690 | |
| 6676 if (FLAG_stress_compaction) { | 6691 if (FLAG_stress_compaction) { |
| 6677 // This will cause more frequent GCs when stressing. | 6692 // This will cause more frequent GCs when stressing. |
| 6678 max_semispace_size_ = Page::kPageSize; | 6693 max_semispace_size_ = Page::kPageSize; |
| 6679 } | 6694 } |
| 6680 | 6695 |
| 6681 if (max_semispace_size > 0) { | 6696 if (max_semispace_size > 0) { |
| 6682 if (max_semispace_size < Page::kPageSize) { | 6697 if (max_semispace_size < Page::kPageSize) { |
| 6683 max_semispace_size = Page::kPageSize; | 6698 max_semispace_size = Page::kPageSize; |
| 6684 if (FLAG_trace_gc) { | 6699 if (FLAG_trace_gc) { |
| 6685 PrintPID("Max semispace size cannot be less than %dkbytes\n", | 6700 PrintPID("Max semispace size cannot be less than %dkbytes\n", |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 6706 // If we are not using snapshots we reserve space for the actual | 6721 // If we are not using snapshots we reserve space for the actual |
| 6707 // max semispace size. | 6722 // max semispace size. |
| 6708 reserved_semispace_size_ = max_semispace_size_; | 6723 reserved_semispace_size_ = max_semispace_size_; |
| 6709 } | 6724 } |
| 6710 | 6725 |
| 6711 if (max_old_gen_size > 0) max_old_generation_size_ = max_old_gen_size; | 6726 if (max_old_gen_size > 0) max_old_generation_size_ = max_old_gen_size; |
| 6712 if (max_executable_size > 0) { | 6727 if (max_executable_size > 0) { |
| 6713 max_executable_size_ = RoundUp(max_executable_size, Page::kPageSize); | 6728 max_executable_size_ = RoundUp(max_executable_size, Page::kPageSize); |
| 6714 } | 6729 } |
| 6715 | 6730 |
| 6731 if (max_semispace_size > 0 || max_old_gen_size > 0 || | |
| 6732 max_executable_size_ > 0) { | |
| 6733 // Did we change anything from their defaults. | |
| 6734 limits_changed_from_defaults_ = true; | |
| 6735 } | |
| 6736 | |
| 6716 // The max executable size must be less than or equal to the max old | 6737 // The max executable size must be less than or equal to the max old |
| 6717 // generation size. | 6738 // generation size. |
| 6718 if (max_executable_size_ > max_old_generation_size_) { | 6739 if (max_executable_size_ > max_old_generation_size_) { |
| 6719 max_executable_size_ = max_old_generation_size_; | 6740 max_executable_size_ = max_old_generation_size_; |
| 6720 } | 6741 } |
| 6721 | 6742 |
| 6722 // The new space size must be a power of two to support single-bit testing | 6743 // The new space size must be a power of two to support single-bit testing |
| 6723 // for containment. | 6744 // for containment. |
| 6724 max_semispace_size_ = RoundUpToPowerOf2(max_semispace_size_); | 6745 max_semispace_size_ = RoundUpToPowerOf2(max_semispace_size_); |
| 6725 reserved_semispace_size_ = RoundUpToPowerOf2(reserved_semispace_size_); | 6746 reserved_semispace_size_ = RoundUpToPowerOf2(reserved_semispace_size_); |
| (...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8085 if (FLAG_concurrent_recompilation) { | 8106 if (FLAG_concurrent_recompilation) { |
| 8086 heap_->relocation_mutex_->Lock(); | 8107 heap_->relocation_mutex_->Lock(); |
| 8087 #ifdef DEBUG | 8108 #ifdef DEBUG |
| 8088 heap_->relocation_mutex_locked_by_optimizer_thread_ = | 8109 heap_->relocation_mutex_locked_by_optimizer_thread_ = |
| 8089 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); | 8110 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); |
| 8090 #endif // DEBUG | 8111 #endif // DEBUG |
| 8091 } | 8112 } |
| 8092 } | 8113 } |
| 8093 | 8114 |
| 8094 } } // namespace v8::internal | 8115 } } // namespace v8::internal |
| OLD | NEW |