Chromium Code Reviews| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 FATAL("become: Cannot forward to multiple targets"); | 254 FATAL("become: Cannot forward to multiple targets"); |
| 255 } | 255 } |
| 256 if (after_obj->IsForwardingCorpse()) { | 256 if (after_obj->IsForwardingCorpse()) { |
| 257 // The Smalltalk become does allow this, and for very special cases | 257 // The Smalltalk become does allow this, and for very special cases |
| 258 // it is important (shape changes to Class or Mixin), but as these | 258 // it is important (shape changes to Class or Mixin), but as these |
| 259 // cases do not arise in Dart, better to prohibit it. | 259 // cases do not arise in Dart, better to prohibit it. |
| 260 FATAL("become: No indirect chains of forwarding"); | 260 FATAL("become: No indirect chains of forwarding"); |
| 261 } | 261 } |
| 262 | 262 |
| 263 ForwardObjectTo(before_obj, after_obj); | 263 ForwardObjectTo(before_obj, after_obj); |
| 264 | |
| 265 // Forward the identity hash too if it has one. | |
| 266 intptr_t hash = heap->GetHash(before_obj); | |
| 267 if (hash != 0) { | |
| 268 ASSERT(heap->GetHash(after_obj) == 0); | |
| 269 heap->SetHash(after_obj, hash); | |
| 270 } | |
|
siva
2016/08/19 00:08:15
How does this work for internal VM objects, for ex
rmacnak
2016/08/19 00:16:54
A String's usual hash is the one inline in the obj
| |
| 264 } | 271 } |
| 265 | 272 |
| 266 { | 273 { |
| 267 // Follow forwarding pointers. | 274 // Follow forwarding pointers. |
| 268 | 275 |
| 269 // C++ pointers | 276 // C++ pointers |
| 270 ForwardPointersVisitor pointer_visitor(isolate); | 277 ForwardPointersVisitor pointer_visitor(isolate); |
| 271 isolate->VisitObjectPointers(&pointer_visitor, true); | 278 isolate->VisitObjectPointers(&pointer_visitor, true); |
| 272 | 279 |
| 273 // Weak persistent handles. | 280 // Weak persistent handles. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 291 } | 298 } |
| 292 | 299 |
| 293 #if defined(DEBUG) | 300 #if defined(DEBUG) |
| 294 for (intptr_t i = 0; i < before.Length(); i++) { | 301 for (intptr_t i = 0; i < before.Length(); i++) { |
| 295 ASSERT(before.At(i) == after.At(i)); | 302 ASSERT(before.At(i) == after.At(i)); |
| 296 } | 303 } |
| 297 #endif | 304 #endif |
| 298 } | 305 } |
| 299 | 306 |
| 300 } // namespace dart | 307 } // namespace dart |
| OLD | NEW |