| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/become.h" | 5 #include "vm/become.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 | 9 |
| 10 #include "vm/dart_api_state.h" | 10 #include "vm/dart_api_state.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 int count_; | 145 int count_; |
| 146 | 146 |
| 147 DISALLOW_COPY_AND_ASSIGN(ForwardHeapPointersHandleVisitor); | 147 DISALLOW_COPY_AND_ASSIGN(ForwardHeapPointersHandleVisitor); |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 | 150 |
| 151 // On IA32, object pointers are embedded directly in the instruction stream, | 151 // On IA32, object pointers are embedded directly in the instruction stream, |
| 152 // which is normally write-protected, so we need to make it temporarily writable | 152 // which is normally write-protected, so we need to make it temporarily writable |
| 153 // to forward the pointers. On all other architectures, object pointers are | 153 // to forward the pointers. On all other architectures, object pointers are |
| 154 // accessed through ObjectPools. | 154 // accessed through ObjectPools. |
| 155 #if defined(TARGET_ARCH_IA32) |
| 155 class WritableCodeLiteralsScope : public ValueObject { | 156 class WritableCodeLiteralsScope : public ValueObject { |
| 156 public: | 157 public: |
| 157 explicit WritableCodeLiteralsScope(Heap* heap) : heap_(heap) { | 158 explicit WritableCodeLiteralsScope(Heap* heap) : heap_(heap) { |
| 158 #if defined(TARGET_ARCH_IA32) | |
| 159 if (FLAG_write_protect_code) { | 159 if (FLAG_write_protect_code) { |
| 160 heap_->WriteProtectCode(false); | 160 heap_->WriteProtectCode(false); |
| 161 } | 161 } |
| 162 #endif | |
| 163 } | 162 } |
| 164 | 163 |
| 165 ~WritableCodeLiteralsScope() { | 164 ~WritableCodeLiteralsScope() { |
| 166 #if defined(TARGET_ARCH_IA32) | |
| 167 if (FLAG_write_protect_code) { | 165 if (FLAG_write_protect_code) { |
| 168 heap_->WriteProtectCode(true); | 166 heap_->WriteProtectCode(true); |
| 169 } | 167 } |
| 170 #endif | |
| 171 } | 168 } |
| 172 | 169 |
| 173 private: | 170 private: |
| 174 Heap* heap_; | 171 Heap* heap_; |
| 175 }; | 172 }; |
| 173 #else |
| 174 class WritableCodeLiteralsScope : public ValueObject { |
| 175 public: |
| 176 explicit WritableCodeLiteralsScope(Heap* heap) { } |
| 177 ~WritableCodeLiteralsScope() { } |
| 178 }; |
| 179 #endif |
| 176 | 180 |
| 177 | 181 |
| 178 void Become::MakeDummyObject(const Instance& instance) { | 182 void Become::MakeDummyObject(const Instance& instance) { |
| 179 // Make the forward pointer point to itself. | 183 // Make the forward pointer point to itself. |
| 180 // This is needed to distinguish it from a real forward object. | 184 // This is needed to distinguish it from a real forward object. |
| 181 ForwardObjectTo(instance.raw(), instance.raw()); | 185 ForwardObjectTo(instance.raw(), instance.raw()); |
| 182 } | 186 } |
| 183 | 187 |
| 184 | 188 |
| 185 static bool IsDummyObject(RawObject* object) { | 189 static bool IsDummyObject(RawObject* object) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 } | 259 } |
| 256 | 260 |
| 257 #if defined(DEBUG) | 261 #if defined(DEBUG) |
| 258 for (intptr_t i = 0; i < before.Length(); i++) { | 262 for (intptr_t i = 0; i < before.Length(); i++) { |
| 259 ASSERT(before.At(i) == after.At(i)); | 263 ASSERT(before.At(i) == after.At(i)); |
| 260 } | 264 } |
| 261 #endif | 265 #endif |
| 262 } | 266 } |
| 263 | 267 |
| 264 } // namespace dart | 268 } // namespace dart |
| OLD | NEW |