| 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 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 | 885 |
| 886 allocated_ = 0; | 886 allocated_ = 0; |
| 887 | 887 |
| 888 steps_count_++; | 888 steps_count_++; |
| 889 steps_count_since_last_gc_++; | 889 steps_count_since_last_gc_++; |
| 890 | 890 |
| 891 bool speed_up = false; | 891 bool speed_up = false; |
| 892 | 892 |
| 893 if ((steps_count_ % kAllocationMarkingFactorSpeedupInterval) == 0) { | 893 if ((steps_count_ % kAllocationMarkingFactorSpeedupInterval) == 0) { |
| 894 if (FLAG_trace_gc) { | 894 if (FLAG_trace_gc) { |
| 895 PrintF("Speed up marking after %d steps\n", | 895 PrintPID("Speed up marking after %d steps\n", |
| 896 static_cast<int>(kAllocationMarkingFactorSpeedupInterval)); | 896 static_cast<int>(kAllocationMarkingFactorSpeedupInterval)); |
| 897 } | 897 } |
| 898 speed_up = true; | 898 speed_up = true; |
| 899 } | 899 } |
| 900 | 900 |
| 901 bool space_left_is_very_small = | 901 bool space_left_is_very_small = |
| 902 (old_generation_space_available_at_start_of_incremental_ < 10 * MB); | 902 (old_generation_space_available_at_start_of_incremental_ < 10 * MB); |
| 903 | 903 |
| 904 bool only_1_nth_of_space_that_was_available_still_left = | 904 bool only_1_nth_of_space_that_was_available_still_left = |
| 905 (SpaceLeftInOldSpace() * (allocation_marking_factor_ + 1) < | 905 (SpaceLeftInOldSpace() * (allocation_marking_factor_ + 1) < |
| 906 old_generation_space_available_at_start_of_incremental_); | 906 old_generation_space_available_at_start_of_incremental_); |
| 907 | 907 |
| 908 if (space_left_is_very_small || | 908 if (space_left_is_very_small || |
| 909 only_1_nth_of_space_that_was_available_still_left) { | 909 only_1_nth_of_space_that_was_available_still_left) { |
| 910 if (FLAG_trace_gc) PrintF("Speed up marking because of low space left\n"); | 910 if (FLAG_trace_gc) PrintPID("Speed up marking because of low space left\n"); |
| 911 speed_up = true; | 911 speed_up = true; |
| 912 } | 912 } |
| 913 | 913 |
| 914 bool size_of_old_space_multiplied_by_n_during_marking = | 914 bool size_of_old_space_multiplied_by_n_during_marking = |
| 915 (heap_->PromotedTotalSize() > | 915 (heap_->PromotedTotalSize() > |
| 916 (allocation_marking_factor_ + 1) * | 916 (allocation_marking_factor_ + 1) * |
| 917 old_generation_space_used_at_start_of_incremental_); | 917 old_generation_space_used_at_start_of_incremental_); |
| 918 if (size_of_old_space_multiplied_by_n_during_marking) { | 918 if (size_of_old_space_multiplied_by_n_during_marking) { |
| 919 speed_up = true; | 919 speed_up = true; |
| 920 if (FLAG_trace_gc) { | 920 if (FLAG_trace_gc) { |
| 921 PrintF("Speed up marking because of heap size increase\n"); | 921 PrintPID("Speed up marking because of heap size increase\n"); |
| 922 } | 922 } |
| 923 } | 923 } |
| 924 | 924 |
| 925 int64_t promoted_during_marking = heap_->PromotedTotalSize() | 925 int64_t promoted_during_marking = heap_->PromotedTotalSize() |
| 926 - old_generation_space_used_at_start_of_incremental_; | 926 - old_generation_space_used_at_start_of_incremental_; |
| 927 intptr_t delay = allocation_marking_factor_ * MB; | 927 intptr_t delay = allocation_marking_factor_ * MB; |
| 928 intptr_t scavenge_slack = heap_->MaxSemiSpaceSize(); | 928 intptr_t scavenge_slack = heap_->MaxSemiSpaceSize(); |
| 929 | 929 |
| 930 // We try to scan at at least twice the speed that we are allocating. | 930 // We try to scan at at least twice the speed that we are allocating. |
| 931 if (promoted_during_marking > bytes_scanned_ / 2 + scavenge_slack + delay) { | 931 if (promoted_during_marking > bytes_scanned_ / 2 + scavenge_slack + delay) { |
| 932 if (FLAG_trace_gc) { | 932 if (FLAG_trace_gc) { |
| 933 PrintF("Speed up marking because marker was not keeping up\n"); | 933 PrintPID("Speed up marking because marker was not keeping up\n"); |
| 934 } | 934 } |
| 935 speed_up = true; | 935 speed_up = true; |
| 936 } | 936 } |
| 937 | 937 |
| 938 if (speed_up) { | 938 if (speed_up) { |
| 939 if (state_ != MARKING) { | 939 if (state_ != MARKING) { |
| 940 if (FLAG_trace_gc) { | 940 if (FLAG_trace_gc) { |
| 941 PrintF("Postponing speeding up marking until marking starts\n"); | 941 PrintPID("Postponing speeding up marking until marking starts\n"); |
| 942 } | 942 } |
| 943 } else { | 943 } else { |
| 944 allocation_marking_factor_ += kAllocationMarkingFactorSpeedup; | 944 allocation_marking_factor_ += kAllocationMarkingFactorSpeedup; |
| 945 allocation_marking_factor_ = static_cast<int>( | 945 allocation_marking_factor_ = static_cast<int>( |
| 946 Min(kMaxAllocationMarkingFactor, | 946 Min(kMaxAllocationMarkingFactor, |
| 947 static_cast<intptr_t>(allocation_marking_factor_ * 1.3))); | 947 static_cast<intptr_t>(allocation_marking_factor_ * 1.3))); |
| 948 if (FLAG_trace_gc) { | 948 if (FLAG_trace_gc) { |
| 949 PrintF("Marking speed increased to %d\n", allocation_marking_factor_); | 949 PrintPID("Marking speed increased to %d\n", allocation_marking_factor_); |
| 950 } | 950 } |
| 951 } | 951 } |
| 952 } | 952 } |
| 953 | 953 |
| 954 if (FLAG_trace_incremental_marking || FLAG_trace_gc) { | 954 if (FLAG_trace_incremental_marking || FLAG_trace_gc) { |
| 955 double end = OS::TimeCurrentMillis(); | 955 double end = OS::TimeCurrentMillis(); |
| 956 double delta = (end - start); | 956 double delta = (end - start); |
| 957 longest_step_ = Max(longest_step_, delta); | 957 longest_step_ = Max(longest_step_, delta); |
| 958 steps_took_ += delta; | 958 steps_took_ += delta; |
| 959 steps_took_since_last_gc_ += delta; | 959 steps_took_since_last_gc_ += delta; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 975 allocation_marking_factor_ = kInitialAllocationMarkingFactor; | 975 allocation_marking_factor_ = kInitialAllocationMarkingFactor; |
| 976 bytes_scanned_ = 0; | 976 bytes_scanned_ = 0; |
| 977 } | 977 } |
| 978 | 978 |
| 979 | 979 |
| 980 int64_t IncrementalMarking::SpaceLeftInOldSpace() { | 980 int64_t IncrementalMarking::SpaceLeftInOldSpace() { |
| 981 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSizeOfObjects(); | 981 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSizeOfObjects(); |
| 982 } | 982 } |
| 983 | 983 |
| 984 } } // namespace v8::internal | 984 } } // namespace v8::internal |
| OLD | NEW |