| 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 264 |
| 265 #if defined(HASH_IN_OBJECT_HEADER) |
| 266 Object::SetCachedHash(after_obj, Object::GetCachedHash(before_obj)); |
| 267 #else |
| 265 // Forward the identity hash too if it has one. | 268 // Forward the identity hash too if it has one. |
| 266 intptr_t hash = heap->GetHash(before_obj); | 269 intptr_t hash = heap->GetHash(before_obj); |
| 267 if (hash != 0) { | 270 if (hash != 0) { |
| 268 ASSERT(heap->GetHash(after_obj) == 0); | 271 ASSERT(heap->GetHash(after_obj) == 0); |
| 269 heap->SetHash(after_obj, hash); | 272 heap->SetHash(after_obj, hash); |
| 270 } | 273 } |
| 274 #endif |
| 271 } | 275 } |
| 272 | 276 |
| 273 { | 277 { |
| 274 // Follow forwarding pointers. | 278 // Follow forwarding pointers. |
| 275 | 279 |
| 276 // C++ pointers | 280 // C++ pointers |
| 277 ForwardPointersVisitor pointer_visitor(isolate); | 281 ForwardPointersVisitor pointer_visitor(isolate); |
| 278 isolate->VisitObjectPointers(&pointer_visitor, true); | 282 isolate->VisitObjectPointers(&pointer_visitor, true); |
| 279 | 283 |
| 280 // Weak persistent handles. | 284 // Weak persistent handles. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 298 } | 302 } |
| 299 | 303 |
| 300 #if defined(DEBUG) | 304 #if defined(DEBUG) |
| 301 for (intptr_t i = 0; i < before.Length(); i++) { | 305 for (intptr_t i = 0; i < before.Length(); i++) { |
| 302 ASSERT(before.At(i) == after.At(i)); | 306 ASSERT(before.At(i) == after.At(i)); |
| 303 } | 307 } |
| 304 #endif | 308 #endif |
| 305 } | 309 } |
| 306 | 310 |
| 307 } // namespace dart | 311 } // namespace dart |
| OLD | NEW |