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" |
11 #include "vm/isolate_reload.h" | 11 #include "vm/isolate_reload.h" |
12 #include "vm/object.h" | 12 #include "vm/object.h" |
13 #include "vm/raw_object.h" | 13 #include "vm/raw_object.h" |
14 #include "vm/safepoint.h" | 14 #include "vm/safepoint.h" |
15 #include "vm/timeline.h" | 15 #include "vm/timeline.h" |
16 #include "vm/visitor.h" | 16 #include "vm/visitor.h" |
17 | 17 |
18 namespace dart { | 18 namespace dart { |
19 | 19 |
20 ForwardingCorpse* ForwardingCorpse::AsForwarder(uword addr, intptr_t size) { | 20 ForwardingCorpse* ForwardingCorpse::AsForwarder(uword addr, intptr_t size) { |
21 ASSERT(size >= kObjectAlignment); | 21 ASSERT(size >= kObjectAlignment); |
22 ASSERT(Utils::IsAligned(size, kObjectAlignment)); | 22 ASSERT(Utils::IsAligned(size, kObjectAlignment)); |
23 | 23 |
24 ForwardingCorpse* result = reinterpret_cast<ForwardingCorpse*>(addr); | 24 ForwardingCorpse* result = reinterpret_cast<ForwardingCorpse*>(addr); |
25 | 25 |
26 uword tags = 0; | 26 uint32_t tags = 0; |
27 tags = RawObject::SizeTag::update(size, tags); | 27 tags = RawObject::SizeTag::update(size, tags); |
28 tags = RawObject::ClassIdTag::update(kForwardingCorpse, tags); | 28 tags = RawObject::ClassIdTag::update(kForwardingCorpse, tags); |
29 | 29 |
30 result->tags_ = tags; | 30 result->tags_ = tags; |
31 if (size > RawObject::SizeTag::kMaxSizeTag) { | 31 if (size > RawObject::SizeTag::kMaxSizeTag) { |
32 *result->SizeAddress() = size; | 32 *result->SizeAddress() = size; |
33 } | 33 } |
34 result->set_target(Object::null()); | 34 result->set_target(Object::null()); |
35 return result; | 35 return result; |
36 } | 36 } |
(...skipping 218 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 |