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

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

Issue 1374373004: Clarify heap write protection interface and use WritableVMIsolateScope to resolve issue 23217. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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.cc ('k') | no next file » | 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/snapshot.h" 5 #include "vm/snapshot.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 1990 matching lines...) Expand 10 before | Expand all | Expand 10 after
2001 writer.FillHeader(writer.kind()); 2001 writer.FillHeader(writer.kind());
2002 writer.UnmarkAll(); 2002 writer.UnmarkAll();
2003 2003
2004 isolate_snapshot_size_ = writer.BytesWritten(); 2004 isolate_snapshot_size_ = writer.BytesWritten();
2005 } else { 2005 } else {
2006 writer.ThrowException(writer.exception_type(), writer.exception_msg()); 2006 writer.ThrowException(writer.exception_type(), writer.exception_msg());
2007 } 2007 }
2008 } 2008 }
2009 2009
2010 2010
2011 class WritableVMIsolateScope : StackResource {
2012 public:
2013 explicit WritableVMIsolateScope(Thread* thread) : StackResource(thread) {
2014 Dart::vm_isolate()->heap()->WriteProtect(false);
2015 }
2016
2017 ~WritableVMIsolateScope() {
2018 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0);
2019 Dart::vm_isolate()->heap()->WriteProtect(true);
2020 }
2021 };
2022
2023
2024 void FullSnapshotWriter::WriteFullSnapshot() { 2011 void FullSnapshotWriter::WriteFullSnapshot() {
2025 if (!vm_isolate_is_symbolic_) { 2012 if (!vm_isolate_is_symbolic_) {
2026 // TODO(asiva): Don't mutate object headers during serialization. 2013 // TODO(asiva): Don't mutate object headers during serialization.
2027 WritableVMIsolateScope scope(Thread::Current()); 2014 WritableVMIsolateScope scope(Thread::Current());
2028 2015
2029 if (vm_isolate_snapshot_buffer() != NULL) { 2016 if (vm_isolate_snapshot_buffer() != NULL) {
2030 WriteVmIsolateSnapshot(); 2017 WriteVmIsolateSnapshot();
2031 } 2018 }
2032 WriteIsolateFullSnapshot(); 2019 WriteIsolateFullSnapshot();
2033 2020
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
2804 NoSafepointScope no_safepoint; 2791 NoSafepointScope no_safepoint;
2805 WriteObject(obj.raw()); 2792 WriteObject(obj.raw());
2806 UnmarkAll(); 2793 UnmarkAll();
2807 } else { 2794 } else {
2808 ThrowException(exception_type(), exception_msg()); 2795 ThrowException(exception_type(), exception_msg());
2809 } 2796 }
2810 } 2797 }
2811 2798
2812 2799
2813 } // namespace dart 2800 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/pages.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698