Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/pages.h" | 5 #include "vm/pages.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/compiler_stats.h" | 8 #include "vm/compiler_stats.h" |
| 9 #include "vm/gc_marker.h" | 9 #include "vm/gc_marker.h" |
| 10 #include "vm/gc_sweeper.h" | 10 #include "vm/gc_sweeper.h" |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 869 if (result != 0) { | 869 if (result != 0) { |
| 870 usage_.used_in_words += size >> kWordSizeLog2; | 870 usage_.used_in_words += size >> kWordSizeLog2; |
| 871 return result; | 871 return result; |
| 872 } | 872 } |
| 873 result = TryAllocateDataBumpLocked(size, growth_policy); | 873 result = TryAllocateDataBumpLocked(size, growth_policy); |
| 874 if (result != 0) return result; | 874 if (result != 0) return result; |
| 875 return TryAllocateDataLocked(size, growth_policy); | 875 return TryAllocateDataLocked(size, growth_policy); |
| 876 } | 876 } |
| 877 | 877 |
| 878 | 878 |
| 879 uword PageSpace::TryAllocateSmiInitializedLocked(intptr_t size, | |
| 880 GrowthPolicy growth_policy) { | |
| 881 uword result = TryAllocateDataBumpLocked(size, growth_policy); | |
| 882 if (collections() != 0) { | |
| 883 #if defined(DEBUG) | |
| 884 FATAL1("%" Pd " GCs before TryAllocateSmiInitializedLocked", collections()); | |
| 885 #else | |
| 886 // Shouldn't happen, but prefer slight slowdown over (exploitable?) crash. | |
|
Ivan Posva
2015/01/02 17:09:39
FATAL should better not be exploitable. We "reach"
koda
2015/01/02 17:30:53
Done.
| |
| 887 memset(reinterpret_cast<void*>(result), 0, size); | |
| 888 #endif // DEBUG | |
| 889 } | |
| 890 #if defined(DEBUG) | |
| 891 RawObject** begin = reinterpret_cast<RawObject**>(result); | |
| 892 RawObject** end = reinterpret_cast<RawObject**>(result + size); | |
| 893 for (RawObject** current = begin; current < end; ++current) { | |
| 894 ASSERT(!(*current)->IsHeapObject()); | |
| 895 } | |
| 896 #endif | |
| 897 return result; | |
| 898 } | |
| 899 | |
| 900 | |
| 879 PageSpaceController::PageSpaceController(Heap* heap, | 901 PageSpaceController::PageSpaceController(Heap* heap, |
| 880 int heap_growth_ratio, | 902 int heap_growth_ratio, |
| 881 int heap_growth_max, | 903 int heap_growth_max, |
| 882 int garbage_collection_time_ratio) | 904 int garbage_collection_time_ratio) |
| 883 : heap_(heap), | 905 : heap_(heap), |
| 884 is_enabled_(false), | 906 is_enabled_(false), |
| 885 grow_heap_(heap_growth_max / 2), | 907 grow_heap_(heap_growth_max / 2), |
| 886 heap_growth_ratio_(heap_growth_ratio), | 908 heap_growth_ratio_(heap_growth_ratio), |
| 887 desired_utilization_((100.0 - heap_growth_ratio) / 100.0), | 909 desired_utilization_((100.0 - heap_growth_ratio) / 100.0), |
| 888 heap_growth_max_(heap_growth_max), | 910 heap_growth_max_(heap_growth_max), |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 994 for (int i = 0; i < history_.Size() - 1; i++) { | 1016 for (int i = 0; i < history_.Size() - 1; i++) { |
| 995 Entry current = history_.Get(i); | 1017 Entry current = history_.Get(i); |
| 996 Entry previous = history_.Get(i + 1); | 1018 Entry previous = history_.Get(i + 1); |
| 997 gc_time += current.end - current.start; | 1019 gc_time += current.end - current.start; |
| 998 total_time += current.end - previous.end; | 1020 total_time += current.end - previous.end; |
| 999 } | 1021 } |
| 1000 if (total_time == 0) { | 1022 if (total_time == 0) { |
| 1001 return 0; | 1023 return 0; |
| 1002 } else { | 1024 } else { |
| 1003 ASSERT(total_time >= gc_time); | 1025 ASSERT(total_time >= gc_time); |
| 1004 int result= static_cast<int>((static_cast<double>(gc_time) / | 1026 int result = static_cast<int>((static_cast<double>(gc_time) / |
| 1005 static_cast<double>(total_time)) * 100); | 1027 static_cast<double>(total_time)) * 100); |
| 1006 return result; | 1028 return result; |
| 1007 } | 1029 } |
| 1008 } | 1030 } |
| 1009 | 1031 |
| 1010 } // namespace dart | 1032 } // namespace dart |
| OLD | NEW |