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

Unified Diff: runtime/vm/become.cc

Issue 2207643002: Narrow the scope of writable code to the forwarding phase of become instead of the whole isolate re… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/isolate_reload.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/become.cc
diff --git a/runtime/vm/become.cc b/runtime/vm/become.cc
index a4d9fd1e5847bfa20f5d77b1d3b6b5049c2e1523..a037f9d8b846a6ac46dee457ad94a1c4d4190412 100644
--- a/runtime/vm/become.cc
+++ b/runtime/vm/become.cc
@@ -148,17 +148,46 @@ class ForwardHeapPointersHandleVisitor : public HandleVisitor {
};
+// On IA32, object pointers are embedded directly in the instruction stream,
+// which is normally write-protected, so we need to make it temporarily writable
+// to forward the pointers. On all other architectures, object pointers are
+// accessed through ObjectPools.
+class WritableCodeLiteralsScope : public ValueObject {
+ public:
+ explicit WritableCodeLiteralsScope(Heap* heap) : heap_(heap) {
+#if defined(TARGET_ARCH_IA32)
+ if (FLAG_write_protect_code) {
+ heap_->WriteProtectCode(false);
+ }
+#endif
+ }
+
+ ~WritableCodeLiteralsScope() {
+#if defined(TARGET_ARCH_IA32)
+ if (FLAG_write_protect_code) {
+ heap_->WriteProtectCode(true);
+ }
+#endif
+ }
+
+ private:
+ Heap* heap_;
+};
+
+
void Become::MakeDummyObject(const Instance& instance) {
// Make the forward pointer point to itself.
// This is needed to distinguish it from a real forward object.
ForwardObjectTo(instance.raw(), instance.raw());
}
+
static bool IsDummyObject(RawObject* object) {
if (!object->IsForwardingCorpse()) return false;
return GetForwardedObject(object) == object;
}
+
void Become::ElementsForwardIdentity(const Array& before, const Array& after) {
Thread* thread = Thread::Current();
Isolate* isolate = thread->isolate();
@@ -210,9 +239,12 @@ void Become::ElementsForwardIdentity(const Array& before, const Array& after) {
isolate->VisitWeakPersistentHandles(&handle_visitor);
// Heap pointers (may require updating the remembered set)
- ForwardHeapPointersVisitor object_visitor(&pointer_visitor);
- heap->VisitObjects(&object_visitor);
- pointer_visitor.VisitingObject(NULL);
+ {
+ WritableCodeLiteralsScope writable_code(heap);
+ ForwardHeapPointersVisitor object_visitor(&pointer_visitor);
+ heap->VisitObjects(&object_visitor);
+ pointer_visitor.VisitingObject(NULL);
+ }
#if !defined(PRODUCT)
tds.SetNumArguments(2);
« no previous file with comments | « no previous file | runtime/vm/isolate_reload.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698