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

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

Issue 10835034: Fix an off-by-one error in the stack frame iteration. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Renaming per review comments. Created 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.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) 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 6612 matching lines...) Expand 10 before | Expand all | Expand 10 after
6623 } 6623 }
6624 #endif // DEBUG 6624 #endif // DEBUG
6625 } 6625 }
6626 6626
6627 6627
6628 void Stackmap::SetCode(const Code& code) const { 6628 void Stackmap::SetCode(const Code& code) const {
6629 StorePointer(&raw_ptr()->code_, code.raw()); 6629 StorePointer(&raw_ptr()->code_, code.raw());
6630 } 6630 }
6631 6631
6632 6632
6633 bool Stackmap::GetBit(intptr_t bit_offset) const { 6633 bool Stackmap::GetBit(intptr_t bit_index) const {
6634 ASSERT(InRange(bit_offset)); 6634 ASSERT(InRange(bit_index));
6635 int byte_offset = bit_offset >> kBitsPerByteLog2; 6635 int byte_index = bit_index >> kBitsPerByteLog2;
6636 int bit_remainder = bit_offset & (kBitsPerByte - 1); 6636 int bit_remainder = bit_index & (kBitsPerByte - 1);
6637 uint8_t byte_mask = 1U << bit_remainder; 6637 uint8_t byte_mask = 1U << bit_remainder;
6638 uint8_t byte = raw_ptr()->data_[byte_offset]; 6638 uint8_t byte = raw_ptr()->data_[byte_index];
6639 return (byte & byte_mask); 6639 return (byte & byte_mask);
6640 } 6640 }
6641 6641
6642 6642
6643 void Stackmap::SetBit(intptr_t bit_offset, bool value) const { 6643 void Stackmap::SetBit(intptr_t bit_index, bool value) const {
6644 ASSERT(InRange(bit_offset)); 6644 ASSERT(InRange(bit_index));
6645 int byte_offset = bit_offset >> kBitsPerByteLog2; 6645 int byte_index = bit_index >> kBitsPerByteLog2;
6646 int bit_remainder = bit_offset & (kBitsPerByte - 1); 6646 int bit_remainder = bit_index & (kBitsPerByte - 1);
6647 uint8_t byte_mask = 1U << bit_remainder; 6647 uint8_t byte_mask = 1U << bit_remainder;
6648 uint8_t* byte_addr = &(raw_ptr()->data_[byte_offset]); 6648 uint8_t* byte_addr = &(raw_ptr()->data_[byte_index]);
6649 if (value) { 6649 if (value) {
6650 *byte_addr |= byte_mask; 6650 *byte_addr |= byte_mask;
6651 } else { 6651 } else {
6652 *byte_addr &= ~byte_mask; 6652 *byte_addr &= ~byte_mask;
6653 } 6653 }
6654 } 6654 }
6655 6655
6656 6656
6657 RawStackmap* Stackmap::New(uword pc_offset, BitmapBuilder* bmap) { 6657 RawStackmap* Stackmap::New(uword pc_offset, BitmapBuilder* bmap) {
6658 ASSERT(Object::stackmap_class() != Class::null()); 6658 ASSERT(Object::stackmap_class() != Class::null());
6659 ASSERT(bmap != NULL); 6659 ASSERT(bmap != NULL);
6660 Stackmap& result = Stackmap::Handle(); 6660 Stackmap& result = Stackmap::Handle();
6661 intptr_t size = bmap->SizeInBytes(); 6661 intptr_t size = bmap->SizeInBytes();
6662 { 6662 {
6663 // Stackmap data objects are associated with a code object, allocate them 6663 // Stackmap data objects are associated with a code object, allocate them
6664 // in old generation. 6664 // in old generation.
6665 RawObject* raw = Object::Allocate(Stackmap::kInstanceKind, 6665 RawObject* raw = Object::Allocate(Stackmap::kInstanceKind,
6666 Stackmap::InstanceSize(size), 6666 Stackmap::InstanceSize(size),
6667 Heap::kOld); 6667 Heap::kOld);
6668 NoGCScope no_gc; 6668 NoGCScope no_gc;
6669 result ^= raw; 6669 result ^= raw;
6670 result.set_bitmap_size_in_bytes(size); 6670 result.set_bitmap_size_in_bytes(size);
6671 } 6671 }
6672 result.SetPC(pc_offset); 6672 result.SetPC(pc_offset);
6673 intptr_t bound = bmap->SizeInBits(); 6673 intptr_t bound = bmap->SizeInBits();
6674 for (intptr_t i = 0; i < bound; i++) { 6674 for (intptr_t i = 0; i < bound; i++) {
6675 result.SetBit(i, bmap->Get(i)); 6675 result.SetBit(i, bmap->Get(i));
6676 } 6676 }
6677 result.SetMinBitOffset(bmap->Minimum()); 6677 result.SetMinBitIndex(bmap->Minimum());
6678 result.SetMaxBitOffset(bmap->Maximum()); 6678 result.SetMaxBitIndex(bmap->Maximum());
6679 return result.raw(); 6679 return result.raw();
6680 } 6680 }
6681 6681
6682 6682
6683 void Stackmap::set_bitmap_size_in_bytes(intptr_t value) const { 6683 void Stackmap::set_bitmap_size_in_bytes(intptr_t value) const {
6684 // This is only safe because we create a new Smi, which does not cause 6684 // This is only safe because we create a new Smi, which does not cause
6685 // heap allocation. 6685 // heap allocation.
6686 raw_ptr()->bitmap_size_in_bytes_ = Smi::New(value); 6686 raw_ptr()->bitmap_size_in_bytes_ = Smi::New(value);
6687 } 6687 }
6688 6688
6689 6689
6690 const char* Stackmap::ToCString() const { 6690 const char* Stackmap::ToCString() const {
6691 if (IsNull()) { 6691 if (IsNull()) {
6692 return "{null}"; 6692 return "{null}";
6693 } else { 6693 } else {
6694 intptr_t index = OS::SNPrint(NULL, 0, "0x%lx { ", PC()); 6694 intptr_t index = OS::SNPrint(NULL, 0, "0x%lx { ", PC());
6695 intptr_t alloc_size = 6695 intptr_t alloc_size =
6696 index + ((MaximumBitOffset() + 1) * 2) + 2; // "{ 1 0 .... }". 6696 index + ((MaximumBitIndex() + 1) * 2) + 2; // "{ 1 0 .... }".
6697 Isolate* isolate = Isolate::Current(); 6697 Isolate* isolate = Isolate::Current();
6698 char* chars = reinterpret_cast<char*>( 6698 char* chars = reinterpret_cast<char*>(
6699 isolate->current_zone()->Allocate(alloc_size)); 6699 isolate->current_zone()->Allocate(alloc_size));
6700 index = OS::SNPrint(chars, alloc_size, "0x%lx { ", PC()); 6700 index = OS::SNPrint(chars, alloc_size, "0x%lx { ", PC());
6701 for (intptr_t i = 0; i <= MaximumBitOffset(); i++) { 6701 for (intptr_t i = 0; i <= MaximumBitIndex(); i++) {
6702 index += OS::SNPrint((chars + index), 6702 index += OS::SNPrint((chars + index),
6703 (alloc_size - index), 6703 (alloc_size - index),
6704 "%d ", 6704 "%d ",
6705 IsObject(i) ? 1 : 0); 6705 IsObject(i) ? 1 : 0);
6706 } 6706 }
6707 OS::SNPrint((chars + index), (alloc_size - index), "}"); 6707 OS::SNPrint((chars + index), (alloc_size - index), "}");
6708 return chars; 6708 return chars;
6709 } 6709 }
6710 } 6710 }
6711 6711
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
7106 node_ids->Add(node_id); 7106 node_ids->Add(node_id);
7107 ic_data_obj = CodePatcher::GetInstanceCallIcDataAt(descriptors.PC(i)); 7107 ic_data_obj = CodePatcher::GetInstanceCallIcDataAt(descriptors.PC(i));
7108 ic_data_objs.Add(ic_data_obj); 7108 ic_data_objs.Add(ic_data_obj);
7109 } 7109 }
7110 } 7110 }
7111 return max_id; 7111 return max_id;
7112 } 7112 }
7113 7113
7114 7114
7115 RawStackmap* Code::GetStackmap(uword pc, Array* maps, Stackmap* map) const { 7115 RawStackmap* Code::GetStackmap(uword pc, Array* maps, Stackmap* map) const {
7116 // This code is used only during iterating frames during a GC and hence 7116 // This code is used during iterating frames during a GC and hence it
7117 // it should not in turn start a GC. 7117 // should not in turn start a GC.
7118 NoGCScope no_gc; 7118 NoGCScope no_gc;
7119 if (stackmaps() == Array::null()) { 7119 if (stackmaps() == Array::null()) {
7120 // No stack maps are present in the code object which means this 7120 // No stack maps are present in the code object which means this
7121 // frame relies on tagged pointers. 7121 // frame relies on tagged pointers.
7122 return Stackmap::null(); 7122 return Stackmap::null();
7123 } 7123 }
7124 // A stack map is present in the code object, use the stack map to visit 7124 // A stack map is present in the code object, use the stack map to visit
7125 // frame slots which are marked as having objects. 7125 // frame slots which are marked as having objects.
7126 *maps = stackmaps(); 7126 *maps = stackmaps();
7127 *map = Stackmap::null(); 7127 *map = Stackmap::null();
(...skipping 3723 matching lines...) Expand 10 before | Expand all | Expand 10 after
10851 const String& str = String::Handle(pattern()); 10851 const String& str = String::Handle(pattern());
10852 const char* format = "JSRegExp: pattern=%s flags=%s"; 10852 const char* format = "JSRegExp: pattern=%s flags=%s";
10853 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 10853 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
10854 char* chars = reinterpret_cast<char*>( 10854 char* chars = reinterpret_cast<char*>(
10855 Isolate::Current()->current_zone()->Allocate(len + 1)); 10855 Isolate::Current()->current_zone()->Allocate(len + 1));
10856 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 10856 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
10857 return chars; 10857 return chars;
10858 } 10858 }
10859 10859
10860 } // namespace dart 10860 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698