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

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

Issue 343803002: Finishes removing intptr_t from raw object fields. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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/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/cpu.h" 10 #include "vm/cpu.h"
(...skipping 10614 matching lines...) Expand 10 before | Expand all | Expand 10 after
10625 Stackmap::InstanceSize(length), 10625 Stackmap::InstanceSize(length),
10626 Heap::kOld); 10626 Heap::kOld);
10627 NoGCScope no_gc; 10627 NoGCScope no_gc;
10628 result ^= raw; 10628 result ^= raw;
10629 result.SetLength(length); 10629 result.SetLength(length);
10630 } 10630 }
10631 // When constructing a stackmap we store the pc offset in the stackmap's 10631 // When constructing a stackmap we store the pc offset in the stackmap's
10632 // PC. StackmapTableBuilder::FinalizeStackmaps will replace it with the pc 10632 // PC. StackmapTableBuilder::FinalizeStackmaps will replace it with the pc
10633 // address. 10633 // address.
10634 ASSERT(pc_offset >= 0); 10634 ASSERT(pc_offset >= 0);
10635 result.SetPC(pc_offset); 10635 result.SetPcOffset(pc_offset);
10636 for (intptr_t i = 0; i < length; ++i) { 10636 for (intptr_t i = 0; i < length; ++i) {
10637 result.SetBit(i, bmap->Get(i)); 10637 result.SetBit(i, bmap->Get(i));
10638 } 10638 }
10639 result.SetRegisterBitCount(register_bit_count); 10639 result.SetRegisterBitCount(register_bit_count);
10640 return result.raw(); 10640 return result.raw();
10641 } 10641 }
10642 10642
10643 10643
10644 const char* Stackmap::ToCString() const { 10644 const char* Stackmap::ToCString() const {
10645 if (IsNull()) { 10645 if (IsNull()) {
10646 return "{null}"; 10646 return "{null}";
10647 } else { 10647 } else {
10648 const char* kFormat = "%#" Px ": "; 10648 const char* kFormat = "%#" Px ": ";
10649 intptr_t fixed_length = OS::SNPrint(NULL, 0, kFormat, PC()) + 1; 10649 intptr_t fixed_length = OS::SNPrint(NULL, 0, kFormat, PcOffset()) + 1;
10650 Isolate* isolate = Isolate::Current(); 10650 Isolate* isolate = Isolate::Current();
10651 // Guard against integer overflow in the computation of alloc_size. 10651 // Guard against integer overflow in the computation of alloc_size.
10652 // 10652 //
10653 // TODO(kmillikin): We could just truncate the string if someone 10653 // TODO(kmillikin): We could just truncate the string if someone
10654 // tries to print a 2 billion plus entry stackmap. 10654 // tries to print a 2 billion plus entry stackmap.
10655 if (Length() > (kIntptrMax - fixed_length)) { 10655 if (Length() > (kIntptrMax - fixed_length)) {
10656 FATAL1("Length() is unexpectedly large (%" Pd ")", Length()); 10656 FATAL1("Length() is unexpectedly large (%" Pd ")", Length());
10657 } 10657 }
10658 intptr_t alloc_size = fixed_length + Length(); 10658 intptr_t alloc_size = fixed_length + Length();
10659 char* chars = isolate->current_zone()->Alloc<char>(alloc_size); 10659 char* chars = isolate->current_zone()->Alloc<char>(alloc_size);
10660 intptr_t index = OS::SNPrint(chars, alloc_size, kFormat, PC()); 10660 intptr_t index = OS::SNPrint(chars, alloc_size, kFormat, PcOffset());
10661 for (intptr_t i = 0; i < Length(); i++) { 10661 for (intptr_t i = 0; i < Length(); i++) {
10662 chars[index++] = IsObject(i) ? '1' : '0'; 10662 chars[index++] = IsObject(i) ? '1' : '0';
10663 } 10663 }
10664 chars[index] = '\0'; 10664 chars[index] = '\0';
10665 return chars; 10665 return chars;
10666 } 10666 }
10667 } 10667 }
10668 10668
10669 10669
10670 void Stackmap::PrintJSONImpl(JSONStream* stream, bool ref) const { 10670 void Stackmap::PrintJSONImpl(JSONStream* stream, bool ref) const {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
10721 UNREACHABLE(); 10721 UNREACHABLE();
10722 return "Unknown"; 10722 return "Unknown";
10723 } 10723 }
10724 } 10724 }
10725 10725
10726 10726
10727 static int PrintVarInfo(char* buffer, int len, 10727 static int PrintVarInfo(char* buffer, int len,
10728 intptr_t i, 10728 intptr_t i,
10729 const String& var_name, 10729 const String& var_name,
10730 const RawLocalVarDescriptors::VarInfo& info) { 10730 const RawLocalVarDescriptors::VarInfo& info) {
10731 if (info.kind == RawLocalVarDescriptors::kContextLevel) { 10731 const int8_t kind = info.kind();
10732 const int32_t index = info.index();
10733 if (kind == RawLocalVarDescriptors::kContextLevel) {
10732 return OS::SNPrint(buffer, len, 10734 return OS::SNPrint(buffer, len,
10733 "%2" Pd " %-13s level=%-3" Pd " scope=%-3d" 10735 "%2" Pd " %-13s level=%-3d scope=%-3d"
10734 " begin=%-3" Pd " end=%" Pd "\n", 10736 " begin=%-3d end=%d\n",
10735 i, 10737 i,
10736 VarKindString(info.kind), 10738 VarKindString(kind),
10737 info.index, 10739 index,
10738 info.scope_id, 10740 info.scope_id,
10739 info.begin_pos, 10741 info.begin_pos,
10740 info.end_pos); 10742 info.end_pos);
10741 } else if (info.kind == RawLocalVarDescriptors::kContextVar) { 10743 } else if (kind == RawLocalVarDescriptors::kContextVar) {
10742 return OS::SNPrint(buffer, len, 10744 return OS::SNPrint(buffer, len,
10743 "%2" Pd " %-13s level=%-3d index=%-3" Pd "" 10745 "%2" Pd " %-13s level=%-3d index=%-3d"
10744 " begin=%-3" Pd " end=%-3" Pd " name=%s\n", 10746 " begin=%-3d end=%-3d name=%s\n",
10745 i, 10747 i,
10746 VarKindString(info.kind), 10748 VarKindString(kind),
10747 info.scope_id, 10749 info.scope_id,
10748 info.index, 10750 index,
10749 info.begin_pos, 10751 info.begin_pos,
10750 info.end_pos, 10752 info.end_pos,
10751 var_name.ToCString()); 10753 var_name.ToCString());
10752 } else { 10754 } else {
10753 return OS::SNPrint(buffer, len, 10755 return OS::SNPrint(buffer, len,
10754 "%2" Pd " %-13s scope=%-3d index=%-3" Pd "" 10756 "%2" Pd " %-13s scope=%-3d index=%-3d"
10755 " begin=%-3" Pd " end=%-3" Pd " name=%s\n", 10757 " begin=%-3d end=%-3d name=%s\n",
10756 i, 10758 i,
10757 VarKindString(info.kind), 10759 VarKindString(kind),
10758 info.scope_id, 10760 info.scope_id,
10759 info.index, 10761 index,
10760 info.begin_pos, 10762 info.begin_pos,
10761 info.end_pos, 10763 info.end_pos,
10762 var_name.ToCString()); 10764 var_name.ToCString());
10763 } 10765 }
10764 } 10766 }
10765 10767
10766 10768
10767 const char* LocalVarDescriptors::ToCString() const { 10769 const char* LocalVarDescriptors::ToCString() const {
10768 if (IsNull()) { 10770 if (IsNull()) {
10769 return "LocalVarDescriptors(NULL)"; 10771 return "LocalVarDescriptors(NULL)";
(...skipping 30 matching lines...) Expand all
10800 void LocalVarDescriptors::PrintJSONImpl(JSONStream* stream, 10802 void LocalVarDescriptors::PrintJSONImpl(JSONStream* stream,
10801 bool ref) const { 10803 bool ref) const {
10802 Object::PrintJSONImpl(stream, ref); 10804 Object::PrintJSONImpl(stream, ref);
10803 } 10805 }
10804 10806
10805 10807
10806 RawLocalVarDescriptors* LocalVarDescriptors::New(intptr_t num_variables) { 10808 RawLocalVarDescriptors* LocalVarDescriptors::New(intptr_t num_variables) {
10807 ASSERT(Object::var_descriptors_class() != Class::null()); 10809 ASSERT(Object::var_descriptors_class() != Class::null());
10808 if (num_variables < 0 || num_variables > kMaxElements) { 10810 if (num_variables < 0 || num_variables > kMaxElements) {
10809 // This should be caught before we reach here. 10811 // This should be caught before we reach here.
10810 FATAL1("Fatal error in LocalVarDescriptors::New: " 10812 FATAL2("Fatal error in LocalVarDescriptors::New: "
10811 "invalid num_variables %" Pd "\n", num_variables); 10813 "invalid num_variables %" Pd ". Maximum is: %d\n",
10814 num_variables, RawLocalVarDescriptors::kMaxIndex);
10812 } 10815 }
10813 LocalVarDescriptors& result = LocalVarDescriptors::Handle(); 10816 LocalVarDescriptors& result = LocalVarDescriptors::Handle();
10814 { 10817 {
10815 uword size = LocalVarDescriptors::InstanceSize(num_variables); 10818 uword size = LocalVarDescriptors::InstanceSize(num_variables);
10816 RawObject* raw = Object::Allocate(LocalVarDescriptors::kClassId, 10819 RawObject* raw = Object::Allocate(LocalVarDescriptors::kClassId,
10817 size, 10820 size,
10818 Heap::kOld); 10821 Heap::kOld);
10819 NoGCScope no_gc; 10822 NoGCScope no_gc;
10820 result ^= raw; 10823 result ^= raw;
10821 result.raw_ptr()->length_ = num_variables; 10824 result.raw_ptr()->length_ = num_variables;
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after
12220 ? EntryPoint() + patch_code_pc_offset() : 0; 12223 ? EntryPoint() + patch_code_pc_offset() : 0;
12221 } 12224 }
12222 12225
12223 12226
12224 uword Code::GetLazyDeoptPc() const { 12227 uword Code::GetLazyDeoptPc() const {
12225 return (lazy_deopt_pc_offset() != kInvalidPc) 12228 return (lazy_deopt_pc_offset() != kInvalidPc)
12226 ? EntryPoint() + lazy_deopt_pc_offset() : 0; 12229 ? EntryPoint() + lazy_deopt_pc_offset() : 0;
12227 } 12230 }
12228 12231
12229 12232
12230 RawStackmap* Code::GetStackmap(uword pc, Array* maps, Stackmap* map) const { 12233 RawStackmap* Code::GetStackmap(
12234 uint32_t pc_offset, Array* maps, Stackmap* map) const {
12231 // This code is used during iterating frames during a GC and hence it 12235 // This code is used during iterating frames during a GC and hence it
12232 // should not in turn start a GC. 12236 // should not in turn start a GC.
12233 NoGCScope no_gc; 12237 NoGCScope no_gc;
12234 if (stackmaps() == Array::null()) { 12238 if (stackmaps() == Array::null()) {
12235 // No stack maps are present in the code object which means this 12239 // No stack maps are present in the code object which means this
12236 // frame relies on tagged pointers. 12240 // frame relies on tagged pointers.
12237 return Stackmap::null(); 12241 return Stackmap::null();
12238 } 12242 }
12239 // A stack map is present in the code object, use the stack map to visit 12243 // A stack map is present in the code object, use the stack map to visit
12240 // frame slots which are marked as having objects. 12244 // frame slots which are marked as having objects.
12241 *maps = stackmaps(); 12245 *maps = stackmaps();
12242 *map = Stackmap::null(); 12246 *map = Stackmap::null();
12243 for (intptr_t i = 0; i < maps->Length(); i++) { 12247 for (intptr_t i = 0; i < maps->Length(); i++) {
12244 *map ^= maps->At(i); 12248 *map ^= maps->At(i);
12245 ASSERT(!map->IsNull()); 12249 ASSERT(!map->IsNull());
12246 if (map->PC() == pc) { 12250 if (map->PcOffset() == pc_offset) {
12247 return map->raw(); // We found a stack map for this frame. 12251 return map->raw(); // We found a stack map for this frame.
12248 } 12252 }
12249 } 12253 }
12250 // If the code has stackmaps, it must have them for all safepoints. 12254 // If the code has stackmaps, it must have them for all safepoints.
12251 UNREACHABLE(); 12255 UNREACHABLE();
12252 return Stackmap::null(); 12256 return Stackmap::null();
12253 } 12257 }
12254 12258
12255 12259
12256 RawContext* Context::New(intptr_t num_variables, Heap::Space space) { 12260 RawContext* Context::New(intptr_t num_variables, Heap::Space space) {
(...skipping 6945 matching lines...) Expand 10 before | Expand all | Expand 10 after
19202 19206
19203 RawJSRegExp* JSRegExp::FromDataStartAddress(void* data) { 19207 RawJSRegExp* JSRegExp::FromDataStartAddress(void* data) {
19204 JSRegExp& regexp = JSRegExp::Handle(); 19208 JSRegExp& regexp = JSRegExp::Handle();
19205 intptr_t addr = reinterpret_cast<intptr_t>(data) - sizeof(RawJSRegExp); 19209 intptr_t addr = reinterpret_cast<intptr_t>(data) - sizeof(RawJSRegExp);
19206 regexp ^= RawObject::FromAddr(addr); 19210 regexp ^= RawObject::FromAddr(addr);
19207 return regexp.raw(); 19211 return regexp.raw();
19208 } 19212 }
19209 19213
19210 19214
19211 const char* JSRegExp::Flags() const { 19215 const char* JSRegExp::Flags() const {
19212 switch (raw_ptr()->flags_) { 19216 switch (flags()) {
19213 case kGlobal | kIgnoreCase | kMultiLine : 19217 case kGlobal | kIgnoreCase | kMultiLine :
19214 case kIgnoreCase | kMultiLine : 19218 case kIgnoreCase | kMultiLine :
19215 return "im"; 19219 return "im";
19216 case kGlobal | kIgnoreCase : 19220 case kGlobal | kIgnoreCase :
19217 case kIgnoreCase: 19221 case kIgnoreCase:
19218 return "i"; 19222 return "i";
19219 case kGlobal | kMultiLine : 19223 case kGlobal | kMultiLine :
19220 case kMultiLine: 19224 case kMultiLine:
19221 return "m"; 19225 return "m";
19222 default: 19226 default:
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
19473 return tag_label.ToCString(); 19477 return tag_label.ToCString();
19474 } 19478 }
19475 19479
19476 19480
19477 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 19481 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
19478 Instance::PrintJSONImpl(stream, ref); 19482 Instance::PrintJSONImpl(stream, ref);
19479 } 19483 }
19480 19484
19481 19485
19482 } // namespace dart 19486 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | runtime/vm/raw_object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698