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

Side by Side Diff: vm/raw_object.cc

Issue 9791048: - Wire the stack frame iterator to use stack maps for traversing objects if there are stack maps in… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/raw_object.h" 5 #include "vm/raw_object.h"
6 6
7 #include "vm/freelist.h" 7 #include "vm/freelist.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/visitor.h" 10 #include "vm/visitor.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 UNREACHABLE(); 221 UNREACHABLE();
222 break; 222 break;
223 } 223 }
224 224
225 ASSERT(size != 0); 225 ASSERT(size != 0);
226 ASSERT(size == Size()); 226 ASSERT(size == Size());
227 return size; 227 return size;
228 } 228 }
229 229
230 230
231 bool RawObject::FindObject(FindObjectVisitor* visitor) {
232 ASSERT(visitor != NULL);
233 return visitor->FindObject(const_cast<RawObject*>(this));
234 }
235
236
237 bool RawObject::IsRawInstruction(RawObject* raw_obj) {
238 RawClass* raw_class = raw_obj->ptr()->class_;
239 ObjectKind instance_kind = raw_class->ptr()->instance_kind_;
240 return (instance_kind == kInstructions);
241 }
242
243
231 intptr_t RawClass::VisitClassPointers(RawClass* raw_obj, 244 intptr_t RawClass::VisitClassPointers(RawClass* raw_obj,
232 ObjectPointerVisitor* visitor) { 245 ObjectPointerVisitor* visitor) {
233 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 246 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
234 return Class::InstanceSize(); 247 return Class::InstanceSize();
235 } 248 }
236 249
237 250
238 intptr_t RawUnresolvedClass::VisitUnresolvedClassPointers( 251 intptr_t RawUnresolvedClass::VisitUnresolvedClassPointers(
239 RawUnresolvedClass* raw_obj, ObjectPointerVisitor* visitor) { 252 RawUnresolvedClass* raw_obj, ObjectPointerVisitor* visitor) {
240 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 253 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 uword entry_point = reinterpret_cast<uword>(obj->instructions_->ptr()) + 367 uword entry_point = reinterpret_cast<uword>(obj->instructions_->ptr()) +
355 Instructions::HeaderSize(); 368 Instructions::HeaderSize();
356 for (intptr_t i = 0; i < length; i++) { 369 for (intptr_t i = 0; i < length; i++) {
357 int32_t offset = obj->data_[i]; 370 int32_t offset = obj->data_[i];
358 visitor->VisitPointer(reinterpret_cast<RawObject**>(entry_point + offset)); 371 visitor->VisitPointer(reinterpret_cast<RawObject**>(entry_point + offset));
359 } 372 }
360 return Code::InstanceSize(length); 373 return Code::InstanceSize(length);
361 } 374 }
362 375
363 376
377 RawStackmap* RawCode::GetStackmap(uword pc) const {
378 RawArray* stackmaps = ptr()->stackmaps_;
379 if (stackmaps == Array::null()) {
380 // No stack maps are present in the code object which means this
381 // frame relies on tagged pointers.
382 return Stackmap::null();
383 }
384 // A stack map is present in the code object, use the stack map to visit
385 // frame slots which are marked as having objects.
386 RawStackmap* previous_map = Stackmap::null();
387 RawStackmap* map = Stackmap::null();
388 for (intptr_t i = 0; i < stackmaps->Length(); i++) {
389 map = reinterpret_cast<RawStackmap*>(stackmaps->DataAt(i));
390 ASSERT(map != Stackmap::null());
391 if (map->PC() == pc) {
392 break; // We found a stack map for this frame.
393 }
394 if (map->PC() > pc) {
395 // We have not found a stackmap corresponding to the PC of this frame,
396 // we will use the closest previous stack map.
397 map = previous_map;
398 break;
399 }
400 previous_map = map;
401 }
402 return map;
403 }
404
405
364 intptr_t RawInstructions::VisitInstructionsPointers( 406 intptr_t RawInstructions::VisitInstructionsPointers(
365 RawInstructions* raw_obj, ObjectPointerVisitor* visitor) { 407 RawInstructions* raw_obj, ObjectPointerVisitor* visitor) {
366 RawInstructions* obj = raw_obj->ptr(); 408 RawInstructions* obj = raw_obj->ptr();
367 visitor->VisitPointer(reinterpret_cast<RawObject**>(&obj->code_)); 409 visitor->VisitPointer(reinterpret_cast<RawObject**>(&obj->code_));
368 return Instructions::InstanceSize(obj->size_); 410 return Instructions::InstanceSize(obj->size_);
369 } 411 }
370 412
371 413
414 bool RawInstructions::ContainsPC(RawObject* raw_obj, uword pc) {
415 if (IsRawInstruction(raw_obj)) {
416 RawInstructions* raw_instr = reinterpret_cast<RawInstructions*>(raw_obj);
417 uword start_pc =
418 reinterpret_cast<uword>(raw_instr->ptr()) + Instructions::HeaderSize();
419 uword end_pc = start_pc + raw_instr->ptr()->size_;
420 ASSERT(end_pc > start_pc);
421 if (pc >= start_pc && pc < end_pc) {
srdjan 2012/03/28 21:56:36 Add parentheses. Maybe: return (pc >= start_pc) &
siva 2012/03/29 19:01:27 Done.
422 return true;
423 }
424 }
425 return false;
426 }
427
428
372 intptr_t RawPcDescriptors::VisitPcDescriptorsPointers( 429 intptr_t RawPcDescriptors::VisitPcDescriptorsPointers(
373 RawPcDescriptors* raw_obj, ObjectPointerVisitor* visitor) { 430 RawPcDescriptors* raw_obj, ObjectPointerVisitor* visitor) {
374 RawPcDescriptors* obj = raw_obj->ptr(); 431 RawPcDescriptors* obj = raw_obj->ptr();
375 intptr_t length = Smi::Value(obj->length_); 432 intptr_t length = Smi::Value(obj->length_);
376 visitor->VisitPointer(reinterpret_cast<RawObject**>(&obj->length_)); 433 visitor->VisitPointer(reinterpret_cast<RawObject**>(&obj->length_));
377 return PcDescriptors::InstanceSize(length); 434 return PcDescriptors::InstanceSize(length);
378 } 435 }
379 436
380 437
381 intptr_t RawStackmap::VisitStackmapPointers(RawStackmap* raw_obj, 438 intptr_t RawStackmap::VisitStackmapPointers(RawStackmap* raw_obj,
382 ObjectPointerVisitor* visitor) { 439 ObjectPointerVisitor* visitor) {
383 RawStackmap* obj = raw_obj->ptr(); 440 RawStackmap* obj = raw_obj->ptr();
384 intptr_t size_in_bytes = Smi::Value(obj->bitmap_size_in_bytes_); 441 intptr_t size_in_bytes = Smi::Value(obj->bitmap_size_in_bytes_);
385 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 442 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
386 return Stackmap::InstanceSize(size_in_bytes); 443 return Stackmap::InstanceSize(size_in_bytes);
387 } 444 }
388 445
389 446
447 bool RawStackmap::IsObject(intptr_t bit_offset) const {
448 int byte_offset = bit_offset >> kBitsPerByteLog2;
449 int bit_remainder = bit_offset & (kBitsPerByte - 1);
450 uint8_t byte_mask = 1U << bit_remainder;
451 uint8_t byte = ptr()->data_[byte_offset];
srdjan 2012/03/28 21:56:36 All of locals can be const.
siva 2012/03/29 19:01:27 Done.
452 return (byte & byte_mask);
453 }
454
455
456 intptr_t RawStackmap::SizeInBits() const {
457 return (Smi::Value(ptr()->bitmap_size_in_bytes_) * kBitsPerByte);
458 }
459
460
390 intptr_t RawLocalVarDescriptors::VisitLocalVarDescriptorsPointers( 461 intptr_t RawLocalVarDescriptors::VisitLocalVarDescriptorsPointers(
391 RawLocalVarDescriptors* raw_obj, ObjectPointerVisitor* visitor) { 462 RawLocalVarDescriptors* raw_obj, ObjectPointerVisitor* visitor) {
392 RawLocalVarDescriptors* obj = raw_obj->ptr(); 463 RawLocalVarDescriptors* obj = raw_obj->ptr();
393 intptr_t len = obj->length_; 464 intptr_t len = obj->length_;
394 visitor->VisitPointer(reinterpret_cast<RawObject**>(&obj->names_)); 465 visitor->VisitPointer(reinterpret_cast<RawObject**>(&obj->names_));
395 return LocalVarDescriptors::InstanceSize(len); 466 return LocalVarDescriptors::InstanceSize(len);
396 } 467 }
397 468
398 469
399 intptr_t RawExceptionHandlers::VisitExceptionHandlersPointers( 470 intptr_t RawExceptionHandlers::VisitExceptionHandlersPointers(
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 673
603 674
604 intptr_t RawArray::VisitArrayPointers(RawArray* raw_obj, 675 intptr_t RawArray::VisitArrayPointers(RawArray* raw_obj,
605 ObjectPointerVisitor* visitor) { 676 ObjectPointerVisitor* visitor) {
606 intptr_t length = Smi::Value(raw_obj->ptr()->length_); 677 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
607 visitor->VisitPointers(raw_obj->from(), raw_obj->to(length)); 678 visitor->VisitPointers(raw_obj->from(), raw_obj->to(length));
608 return Array::InstanceSize(length); 679 return Array::InstanceSize(length);
609 } 680 }
610 681
611 682
683 intptr_t RawArray::Length() const {
684 return Smi::Value(ptr()->length_);
685 }
686
687
612 intptr_t RawImmutableArray::VisitImmutableArrayPointers( 688 intptr_t RawImmutableArray::VisitImmutableArrayPointers(
613 RawImmutableArray* raw_obj, ObjectPointerVisitor* visitor) { 689 RawImmutableArray* raw_obj, ObjectPointerVisitor* visitor) {
614 return RawArray::VisitArrayPointers(raw_obj, visitor); 690 return RawArray::VisitArrayPointers(raw_obj, visitor);
615 } 691 }
616 692
617 693
618 intptr_t RawGrowableObjectArray::VisitGrowableObjectArrayPointers( 694 intptr_t RawGrowableObjectArray::VisitGrowableObjectArrayPointers(
619 RawGrowableObjectArray* raw_obj, ObjectPointerVisitor* visitor) { 695 RawGrowableObjectArray* raw_obj, ObjectPointerVisitor* visitor) {
620 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 696 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
621 return GrowableObjectArray::InstanceSize(); 697 return GrowableObjectArray::InstanceSize();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj, 746 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj,
671 ObjectPointerVisitor* visitor) { 747 ObjectPointerVisitor* visitor) {
672 // Make sure that we got here with the tagged pointer as this. 748 // Make sure that we got here with the tagged pointer as this.
673 ASSERT(raw_obj->IsHeapObject()); 749 ASSERT(raw_obj->IsHeapObject());
674 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_); 750 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_);
675 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 751 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
676 return JSRegExp::InstanceSize(length); 752 return JSRegExp::InstanceSize(length);
677 } 753 }
678 754
679 } // namespace dart 755 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698