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

Side by Side Diff: runtime/vm/become.cc

Issue 2240663004: Dump information when we hit a FATAL in become (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 unified diff | Download patch
« no previous file with comments | « runtime/vm/become.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 ForwardObjectTo(instance.raw(), instance.raw()); 185 ForwardObjectTo(instance.raw(), instance.raw());
186 } 186 }
187 187
188 188
189 static bool IsDummyObject(RawObject* object) { 189 static bool IsDummyObject(RawObject* object) {
190 if (!object->IsForwardingCorpse()) return false; 190 if (!object->IsForwardingCorpse()) return false;
191 return GetForwardedObject(object) == object; 191 return GetForwardedObject(object) == object;
192 } 192 }
193 193
194 194
195 void Become::CrashDump(RawObject* before_obj, RawObject* after_obj) {
196 OS::PrintErr("DETECTED FATAL ISSUE IN BECOME MAPPINGS\n");
197
198 OS::PrintErr("BEFORE ADDRESS: %p\n", before_obj);
199 OS::PrintErr("BEFORE IS HEAP OBJECT: %s",
200 before_obj->IsHeapObject() ? "YES" : "NO");
201 OS::PrintErr("BEFORE IS VM HEAP OBJECT: %s",
202 before_obj->IsVMHeapObject() ? "YES" : "NO");
203
204 OS::PrintErr("AFTER ADDRESS: %p\n", after_obj);
205 OS::PrintErr("AFTER IS HEAP OBJECT: %s",
206 after_obj->IsHeapObject() ? "YES" : "NO");
207 OS::PrintErr("AFTER IS VM HEAP OBJECT: %s",
208 after_obj->IsVMHeapObject() ? "YES" : "NO");
209
210 if (before_obj->IsHeapObject()) {
211 OS::PrintErr("BEFORE OBJECT CLASS ID=%" Pd "\n", before_obj->GetClassId());
212 const Object& obj = Object::Handle(before_obj);
213 OS::PrintErr("BEFORE OBJECT AS STRING=%s\n", obj.ToCString());
214 }
215
216 if (after_obj->IsHeapObject()) {
217 OS::PrintErr("AFTER OBJECT CLASS ID=%" Pd "\n", after_obj->GetClassId());
218 const Object& obj = Object::Handle(after_obj);
219 OS::PrintErr("AFTER OBJECT AS STRING=%s\n", obj.ToCString());
220 }
221 }
222
223
195 void Become::ElementsForwardIdentity(const Array& before, const Array& after) { 224 void Become::ElementsForwardIdentity(const Array& before, const Array& after) {
196 Thread* thread = Thread::Current(); 225 Thread* thread = Thread::Current();
197 Isolate* isolate = thread->isolate(); 226 Isolate* isolate = thread->isolate();
198 Heap* heap = isolate->heap(); 227 Heap* heap = isolate->heap();
199 228
200 TIMELINE_FUNCTION_GC_DURATION(thread, "Become::ElementsForwardIdentity"); 229 TIMELINE_FUNCTION_GC_DURATION(thread, "Become::ElementsForwardIdentity");
201 HeapIterationScope his; 230 HeapIterationScope his;
202 231
203 // Setup forwarding pointers. 232 // Setup forwarding pointers.
204 ASSERT(before.Length() == after.Length()); 233 ASSERT(before.Length() == after.Length());
205 for (intptr_t i = 0; i < before.Length(); i++) { 234 for (intptr_t i = 0; i < before.Length(); i++) {
206 RawObject* before_obj = before.At(i); 235 RawObject* before_obj = before.At(i);
207 RawObject* after_obj = after.At(i); 236 RawObject* after_obj = after.At(i);
208 237
209 if (before_obj == after_obj) { 238 if (before_obj == after_obj) {
210 FATAL("become: Cannot self-forward"); 239 FATAL("become: Cannot self-forward");
211 } 240 }
212 if (!before_obj->IsHeapObject()) { 241 if (!before_obj->IsHeapObject()) {
242 CrashDump(before_obj, after_obj);
213 FATAL("become: Cannot forward immediates"); 243 FATAL("become: Cannot forward immediates");
214 } 244 }
215 if (!after_obj->IsHeapObject()) { 245 if (!after_obj->IsHeapObject()) {
216 FATAL("become: Cannot become an immediates"); 246 CrashDump(before_obj, after_obj);
247 FATAL("become: Cannot become immediates");
217 } 248 }
218 if (before_obj->IsVMHeapObject()) { 249 if (before_obj->IsVMHeapObject()) {
250 CrashDump(before_obj, after_obj);
219 FATAL("become: Cannot forward VM heap objects"); 251 FATAL("become: Cannot forward VM heap objects");
220 } 252 }
221 if (before_obj->IsForwardingCorpse() && !IsDummyObject(before_obj)) { 253 if (before_obj->IsForwardingCorpse() && !IsDummyObject(before_obj)) {
222 FATAL("become: Cannot forward to multiple targets"); 254 FATAL("become: Cannot forward to multiple targets");
223 } 255 }
224 if (after_obj->IsForwardingCorpse()) { 256 if (after_obj->IsForwardingCorpse()) {
225 // The Smalltalk become does allow this, and for very special cases 257 // The Smalltalk become does allow this, and for very special cases
226 // 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
227 // cases do not arise in Dart, better to prohibit it. 259 // cases do not arise in Dart, better to prohibit it.
228 FATAL("become: No indirect chains of forwarding"); 260 FATAL("become: No indirect chains of forwarding");
(...skipping 30 matching lines...) Expand all
259 } 291 }
260 292
261 #if defined(DEBUG) 293 #if defined(DEBUG)
262 for (intptr_t i = 0; i < before.Length(); i++) { 294 for (intptr_t i = 0; i < before.Length(); i++) {
263 ASSERT(before.At(i) == after.At(i)); 295 ASSERT(before.At(i) == after.At(i));
264 } 296 }
265 #endif 297 #endif
266 } 298 }
267 299
268 } // namespace dart 300 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/become.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698