Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: runtime/vm/pages.cc

Issue 2112043002: Land Ivan's change of 'Remove support for verified memory handling' (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address code review comments. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/pages.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "vm/lockers.h" 11 #include "vm/lockers.h"
12 #include "vm/object.h" 12 #include "vm/object.h"
13 #include "vm/os_thread.h" 13 #include "vm/os_thread.h"
14 #include "vm/safepoint.h" 14 #include "vm/safepoint.h"
15 #include "vm/verified_memory.h"
16 #include "vm/virtual_memory.h" 15 #include "vm/virtual_memory.h"
17 16
18 namespace dart { 17 namespace dart {
19 18
20 DEFINE_FLAG(int, heap_growth_rate, 0, 19 DEFINE_FLAG(int, heap_growth_rate, 0,
21 "The max number of pages the heap can grow at a time"); 20 "The max number of pages the heap can grow at a time");
22 DEFINE_FLAG(int, old_gen_growth_space_ratio, 20, 21 DEFINE_FLAG(int, old_gen_growth_space_ratio, 20,
23 "The desired maximum percentage of free space after old gen GC"); 22 "The desired maximum percentage of free space after old gen GC");
24 DEFINE_FLAG(int, old_gen_growth_time_ratio, 3, 23 DEFINE_FLAG(int, old_gen_growth_time_ratio, 3,
25 "The desired maximum percentage of time spent in old gen GC"); 24 "The desired maximum percentage of time spent in old gen GC");
(...skipping 24 matching lines...) Expand all
50 ASSERT(result != NULL); 49 ASSERT(result != NULL);
51 result->memory_ = memory; 50 result->memory_ = memory;
52 result->next_ = NULL; 51 result->next_ = NULL;
53 result->type_ = type; 52 result->type_ = type;
54 return result; 53 return result;
55 } 54 }
56 55
57 56
58 HeapPage* HeapPage::Allocate(intptr_t size_in_words, PageType type) { 57 HeapPage* HeapPage::Allocate(intptr_t size_in_words, PageType type) {
59 VirtualMemory* memory = 58 VirtualMemory* memory =
60 VerifiedMemory::Reserve(size_in_words << kWordSizeLog2); 59 VirtualMemory::Reserve(size_in_words << kWordSizeLog2);
61 if (memory == NULL) { 60 if (memory == NULL) {
62 return NULL; 61 return NULL;
63 } 62 }
64 HeapPage* result = Initialize(memory, type); 63 HeapPage* result = Initialize(memory, type);
65 if (result == NULL) { 64 if (result == NULL) {
66 delete memory; // Release reservation to OS. 65 delete memory; // Release reservation to OS.
67 return NULL; 66 return NULL;
68 } 67 }
69 return result; 68 return result;
70 } 69 }
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 AtomicOperations::IncrementBy(&(usage_.used_in_words), 1047 AtomicOperations::IncrementBy(&(usage_.used_in_words),
1049 (size >> kWordSizeLog2)); 1048 (size >> kWordSizeLog2));
1050 return result; 1049 return result;
1051 } 1050 }
1052 result = TryAllocateDataBumpLocked(size, growth_policy); 1051 result = TryAllocateDataBumpLocked(size, growth_policy);
1053 if (result != 0) return result; 1052 if (result != 0) return result;
1054 return TryAllocateDataLocked(size, growth_policy); 1053 return TryAllocateDataLocked(size, growth_policy);
1055 } 1054 }
1056 1055
1057 1056
1058 uword PageSpace::TryAllocateSmiInitializedLocked(intptr_t size,
1059 GrowthPolicy growth_policy) {
1060 uword result = TryAllocateDataBumpLocked(size, growth_policy);
1061 if (collections() != 0) {
1062 FATAL1("%" Pd " GCs before TryAllocateSmiInitializedLocked", collections());
1063 }
1064 #if defined(DEBUG)
1065 RawObject** begin = reinterpret_cast<RawObject**>(result);
1066 RawObject** end = reinterpret_cast<RawObject**>(result + size);
1067 for (RawObject** current = begin; current < end; ++current) {
1068 ASSERT(!(*current)->IsHeapObject());
1069 }
1070 #endif
1071 return result;
1072 }
1073
1074
1075 void PageSpace::SetupExternalPage(void* pointer, 1057 void PageSpace::SetupExternalPage(void* pointer,
1076 uword size, 1058 uword size,
1077 bool is_executable) { 1059 bool is_executable) {
1078 // Setup a HeapPage so precompiled Instructions can be traversed. 1060 // Setup a HeapPage so precompiled Instructions can be traversed.
1079 // Instructions are contiguous at [pointer, pointer + size). HeapPage 1061 // Instructions are contiguous at [pointer, pointer + size). HeapPage
1080 // expects to find objects at [memory->start() + ObjectStartOffset, 1062 // expects to find objects at [memory->start() + ObjectStartOffset,
1081 // memory->end()). 1063 // memory->end()).
1082 uword offset = HeapPage::ObjectStartOffset(); 1064 uword offset = HeapPage::ObjectStartOffset();
1083 pointer = reinterpret_cast<void*>(reinterpret_cast<uword>(pointer) - offset); 1065 pointer = reinterpret_cast<void*>(reinterpret_cast<uword>(pointer) - offset);
1084 size += offset; 1066 size += offset;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 return 0; 1218 return 0;
1237 } else { 1219 } else {
1238 ASSERT(total_time >= gc_time); 1220 ASSERT(total_time >= gc_time);
1239 int result = static_cast<int>((static_cast<double>(gc_time) / 1221 int result = static_cast<int>((static_cast<double>(gc_time) /
1240 static_cast<double>(total_time)) * 100); 1222 static_cast<double>(total_time)) * 100);
1241 return result; 1223 return result;
1242 } 1224 }
1243 } 1225 }
1244 1226
1245 } // namespace dart 1227 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/pages.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698