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

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

Issue 1150103005: Provide a logical view of VM-internal maps in Observatory. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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/object.h ('k') | runtime/vm/object_test.cc » ('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/cpu.h" 10 #include "vm/cpu.h"
(...skipping 19339 matching lines...) Expand 10 before | Expand all | Expand 10 after
19350 old_tags); 19350 old_tags);
19351 tags = CompareAndSwapTags(old_tags, new_tags); 19351 tags = CompareAndSwapTags(old_tags, new_tags);
19352 } while (tags != old_tags); 19352 } while (tags != old_tags);
19353 } 19353 }
19354 19354
19355 19355
19356 const char* Array::ToCString() const { 19356 const char* Array::ToCString() const {
19357 if (IsNull()) { 19357 if (IsNull()) {
19358 return IsImmutable() ? "_ImmutableList NULL" : "_List NULL"; 19358 return IsImmutable() ? "_ImmutableList NULL" : "_List NULL";
19359 } 19359 }
19360 const char* format = IsImmutable() ? 19360 Zone* zone = Isolate::Current()->current_zone();
19361 "_ImmutableList len:%" Pd : "_List len:%" Pd; 19361 const char* format = IsImmutable() ? "_ImmutableList len:%" Pd
19362 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; 19362 : "_List len:%" Pd;
19363 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 19363 return zone->PrintToString(format, Length());
19364 OS::SNPrint(chars, len, format, Length());
19365 return chars;
19366 } 19364 }
19367 19365
19368 19366
19369 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { 19367 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const {
19370 JSONObject jsobj(stream); 19368 JSONObject jsobj(stream);
19371 PrintSharedInstanceJSON(&jsobj, ref); 19369 PrintSharedInstanceJSON(&jsobj, ref);
19372 jsobj.AddProperty("kind", "List"); 19370 jsobj.AddProperty("kind", "List");
19373 jsobj.AddServiceId(*this); 19371 jsobj.AddServiceId(*this);
19374 jsobj.AddProperty("length", Length()); 19372 jsobj.AddProperty("length", Length());
19375 if (ref) { 19373 if (ref) {
19376 return; 19374 return;
19377 } 19375 }
19378 { 19376 {
19379 JSONArray jsarr(&jsobj, "elements"); 19377 JSONArray jsarr(&jsobj, "elements");
19378 Object& element = Object::Handle();
19380 for (intptr_t index = 0; index < Length(); index++) { 19379 for (intptr_t index = 0; index < Length(); index++) {
19381 JSONObject jselement(&jsarr); 19380 JSONObject jselement(&jsarr);
19382 jselement.AddProperty("index", index); 19381 jselement.AddProperty("index", index);
19383 19382
19384 Object& element = Object::Handle(At(index)); 19383 element = At(index);
19385 jselement.AddProperty("value", element); 19384 jselement.AddProperty("value", element);
19386 } 19385 }
19387 } 19386 }
19388 } 19387 }
19389 19388
19390 19389
19391 RawArray* Array::Grow(const Array& source, 19390 RawArray* Array::Grow(const Array& source,
19392 intptr_t new_length, 19391 intptr_t new_length,
19393 Heap::Space space) { 19392 Heap::Space space) {
19394 Isolate* isolate = Isolate::Current(); 19393 Isolate* isolate = Isolate::Current();
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
19616 JSONObject jsobj(stream); 19615 JSONObject jsobj(stream);
19617 PrintSharedInstanceJSON(&jsobj, ref); 19616 PrintSharedInstanceJSON(&jsobj, ref);
19618 jsobj.AddProperty("kind", "List"); 19617 jsobj.AddProperty("kind", "List");
19619 jsobj.AddServiceId(*this); 19618 jsobj.AddServiceId(*this);
19620 jsobj.AddProperty("length", Length()); 19619 jsobj.AddProperty("length", Length());
19621 if (ref) { 19620 if (ref) {
19622 return; 19621 return;
19623 } 19622 }
19624 { 19623 {
19625 JSONArray jsarr(&jsobj, "elements"); 19624 JSONArray jsarr(&jsobj, "elements");
19625 Object& element = Object::Handle();
19626 for (intptr_t index = 0; index < Length(); index++) { 19626 for (intptr_t index = 0; index < Length(); index++) {
19627 JSONObject jselement(&jsarr); 19627 JSONObject jselement(&jsarr);
19628 jselement.AddProperty("index", index); 19628 jselement.AddProperty("index", index);
19629 19629
19630 Object& element = Object::Handle(At(index)); 19630 element = At(index);
19631 jselement.AddProperty("value", element); 19631 jselement.AddProperty("value", element);
19632 } 19632 }
19633 } 19633 }
19634 } 19634 }
19635 19635
19636 19636
19637 // Equivalent to Dart's operator "==" and hashCode. 19637 // Equivalent to Dart's operator "==" and hashCode.
19638 class DefaultHashTraits { 19638 class DefaultHashTraits {
19639 public: 19639 public:
19640 static bool IsMatch(const Object& a, const Object& b) { 19640 static bool IsMatch(const Object& a, const Object& b) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
19708 LinkedHashMap::InstanceSize(), 19708 LinkedHashMap::InstanceSize(),
19709 space); 19709 space);
19710 NoSafepointScope no_safepoint; 19710 NoSafepointScope no_safepoint;
19711 result ^= raw; 19711 result ^= raw;
19712 } 19712 }
19713 return result.raw(); 19713 return result.raw();
19714 } 19714 }
19715 19715
19716 19716
19717 const char* LinkedHashMap::ToCString() const { 19717 const char* LinkedHashMap::ToCString() const {
19718 // TODO(koda): Print key/value pairs. 19718 Zone* zone = Isolate::Current()->current_zone();
19719 return "_LinkedHashMap"; 19719 return zone->PrintToString("_LinkedHashMap len:%" Pd, Length());
19720 } 19720 }
19721 19721
19722 19722
19723 void LinkedHashMap::PrintJSONImpl(JSONStream* stream, bool ref) const { 19723 void LinkedHashMap::PrintJSONImpl(JSONStream* stream, bool ref) const {
19724 JSONObject jsobj(stream); 19724 JSONObject jsobj(stream);
19725 PrintSharedInstanceJSON(&jsobj, ref); 19725 PrintSharedInstanceJSON(&jsobj, ref);
19726 jsobj.AddProperty("kind", "Map"); 19726 jsobj.AddProperty("kind", "Map");
19727 jsobj.AddServiceId(*this); 19727 jsobj.AddServiceId(*this);
19728 // TODO(koda): Print length. 19728 jsobj.AddProperty("length", Length());
19729 if (ref) { 19729 if (ref) {
19730 return; 19730 return;
19731 } 19731 }
19732 // TODO(koda): Print key/value pairs. 19732 {
19733 JSONArray jsarr(&jsobj, "associations");
19734 Object& object = Object::Handle();
19735 LinkedHashMap::Iterator iterator(*this);
19736 while (iterator.MoveNext()) {
19737 JSONObject jsassoc(&jsarr);
19738 object = iterator.CurrentKey();
19739 jsassoc.AddProperty("key", object);
19740 object = iterator.CurrentValue();
19741 jsassoc.AddProperty("value", object);
19742 }
19743 }
19733 } 19744 }
19734 19745
19735 19746
19736 RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3, 19747 RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3,
19737 Heap::Space space) { 19748 Heap::Space space) {
19738 ASSERT(Isolate::Current()->object_store()->float32x4_class() != 19749 ASSERT(Isolate::Current()->object_store()->float32x4_class() !=
19739 Class::null()); 19750 Class::null());
19740 Float32x4& result = Float32x4::Handle(); 19751 Float32x4& result = Float32x4::Handle();
19741 { 19752 {
19742 RawObject* raw = Object::Allocate(Float32x4::kClassId, 19753 RawObject* raw = Object::Allocate(Float32x4::kClassId,
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after
20815 return tag_label.ToCString(); 20826 return tag_label.ToCString();
20816 } 20827 }
20817 20828
20818 20829
20819 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20830 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20820 Instance::PrintJSONImpl(stream, ref); 20831 Instance::PrintJSONImpl(stream, ref);
20821 } 20832 }
20822 20833
20823 20834
20824 } // namespace dart 20835 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698