| OLD | NEW | 
|---|
| 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 20068 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 20079 | 20079 | 
| 20080 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20080 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { | 
| 20081   JSONObject jsobj(stream); | 20081   JSONObject jsobj(stream); | 
| 20082   PrintSharedInstanceJSON(&jsobj, ref); | 20082   PrintSharedInstanceJSON(&jsobj, ref); | 
| 20083   jsobj.AddProperty("kind", "List"); | 20083   jsobj.AddProperty("kind", "List"); | 
| 20084   jsobj.AddServiceId(*this); | 20084   jsobj.AddServiceId(*this); | 
| 20085   jsobj.AddProperty("length", Length()); | 20085   jsobj.AddProperty("length", Length()); | 
| 20086   if (ref) { | 20086   if (ref) { | 
| 20087     return; | 20087     return; | 
| 20088   } | 20088   } | 
|  | 20089   intptr_t offset; | 
|  | 20090   intptr_t count; | 
|  | 20091   stream->ComputeOffsetAndCount(Length(), &offset, &count); | 
|  | 20092   if (offset > 0) { | 
|  | 20093     jsobj.AddProperty("offset", offset); | 
|  | 20094   } | 
|  | 20095   if (count < Length()) { | 
|  | 20096     jsobj.AddProperty("count", count); | 
|  | 20097   } | 
|  | 20098   intptr_t limit = offset + count; | 
|  | 20099   ASSERT(limit <= Length()); | 
| 20089   { | 20100   { | 
| 20090     JSONArray jsarr(&jsobj, "elements"); | 20101     JSONArray jsarr(&jsobj, "elements"); | 
| 20091     Object& element = Object::Handle(); | 20102     Object& element = Object::Handle(); | 
| 20092     for (intptr_t index = 0; index < Length(); index++) { | 20103     for (intptr_t index = offset; index < limit; index++) { | 
| 20093       element = At(index); | 20104       element = At(index); | 
| 20094       jsarr.AddValue(element); | 20105       jsarr.AddValue(element); | 
| 20095     } | 20106     } | 
| 20096   } | 20107   } | 
| 20097 } | 20108 } | 
| 20098 | 20109 | 
| 20099 | 20110 | 
| 20100 RawArray* Array::Grow(const Array& source, | 20111 RawArray* Array::Grow(const Array& source, | 
| 20101                       intptr_t new_length, | 20112                       intptr_t new_length, | 
| 20102                       Heap::Space space) { | 20113                       Heap::Space space) { | 
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 20317 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, | 20328 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, | 
| 20318                                         bool ref) const { | 20329                                         bool ref) const { | 
| 20319   JSONObject jsobj(stream); | 20330   JSONObject jsobj(stream); | 
| 20320   PrintSharedInstanceJSON(&jsobj, ref); | 20331   PrintSharedInstanceJSON(&jsobj, ref); | 
| 20321   jsobj.AddProperty("kind", "List"); | 20332   jsobj.AddProperty("kind", "List"); | 
| 20322   jsobj.AddServiceId(*this); | 20333   jsobj.AddServiceId(*this); | 
| 20323   jsobj.AddProperty("length", Length()); | 20334   jsobj.AddProperty("length", Length()); | 
| 20324   if (ref) { | 20335   if (ref) { | 
| 20325     return; | 20336     return; | 
| 20326   } | 20337   } | 
|  | 20338   intptr_t offset; | 
|  | 20339   intptr_t count; | 
|  | 20340   stream->ComputeOffsetAndCount(Length(), &offset, &count); | 
|  | 20341   if (offset > 0) { | 
|  | 20342     jsobj.AddProperty("offset", offset); | 
|  | 20343   } | 
|  | 20344   if (count < Length()) { | 
|  | 20345     jsobj.AddProperty("count", count); | 
|  | 20346   } | 
|  | 20347   intptr_t limit = offset + count; | 
|  | 20348   ASSERT(limit <= Length()); | 
| 20327   { | 20349   { | 
| 20328     JSONArray jsarr(&jsobj, "elements"); | 20350     JSONArray jsarr(&jsobj, "elements"); | 
| 20329     Object& element = Object::Handle(); | 20351     Object& element = Object::Handle(); | 
| 20330     for (intptr_t index = 0; index < Length(); index++) { | 20352     for (intptr_t index = offset; index < limit; index++) { | 
| 20331       element = At(index); | 20353       element = At(index); | 
| 20332       jsarr.AddValue(element); | 20354       jsarr.AddValue(element); | 
| 20333     } | 20355     } | 
| 20334   } | 20356   } | 
| 20335 } | 20357 } | 
| 20336 | 20358 | 
| 20337 | 20359 | 
| 20338 // Equivalent to Dart's operator "==" and hashCode. | 20360 // Equivalent to Dart's operator "==" and hashCode. | 
| 20339 class DefaultHashTraits { | 20361 class DefaultHashTraits { | 
| 20340  public: | 20362  public: | 
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 20423 | 20445 | 
| 20424 void LinkedHashMap::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20446 void LinkedHashMap::PrintJSONImpl(JSONStream* stream, bool ref) const { | 
| 20425   JSONObject jsobj(stream); | 20447   JSONObject jsobj(stream); | 
| 20426   PrintSharedInstanceJSON(&jsobj, ref); | 20448   PrintSharedInstanceJSON(&jsobj, ref); | 
| 20427   jsobj.AddProperty("kind", "Map"); | 20449   jsobj.AddProperty("kind", "Map"); | 
| 20428   jsobj.AddServiceId(*this); | 20450   jsobj.AddServiceId(*this); | 
| 20429   jsobj.AddProperty("length", Length()); | 20451   jsobj.AddProperty("length", Length()); | 
| 20430   if (ref) { | 20452   if (ref) { | 
| 20431     return; | 20453     return; | 
| 20432   } | 20454   } | 
|  | 20455   intptr_t offset; | 
|  | 20456   intptr_t count; | 
|  | 20457   stream->ComputeOffsetAndCount(Length(), &offset, &count); | 
|  | 20458   if (offset > 0) { | 
|  | 20459     jsobj.AddProperty("offset", offset); | 
|  | 20460   } | 
|  | 20461   if (count < Length()) { | 
|  | 20462     jsobj.AddProperty("count", count); | 
|  | 20463   } | 
|  | 20464   intptr_t limit = offset + count; | 
|  | 20465   ASSERT(limit <= Length()); | 
| 20433   { | 20466   { | 
| 20434     JSONArray jsarr(&jsobj, "associations"); | 20467     JSONArray jsarr(&jsobj, "associations"); | 
| 20435     Object& object = Object::Handle(); | 20468     Object& object = Object::Handle(); | 
| 20436     LinkedHashMap::Iterator iterator(*this); | 20469     LinkedHashMap::Iterator iterator(*this); | 
| 20437     while (iterator.MoveNext()) { | 20470     int i = 0; | 
| 20438       JSONObject jsassoc(&jsarr); | 20471     while (iterator.MoveNext() && i < limit) { | 
| 20439       object = iterator.CurrentKey(); | 20472       if (i >= offset) { | 
| 20440       jsassoc.AddProperty("key", object); | 20473         JSONObject jsassoc(&jsarr); | 
| 20441       object = iterator.CurrentValue(); | 20474         object = iterator.CurrentKey(); | 
| 20442       jsassoc.AddProperty("value", object); | 20475         jsassoc.AddProperty("key", object); | 
|  | 20476         object = iterator.CurrentValue(); | 
|  | 20477         jsassoc.AddProperty("value", object); | 
|  | 20478       } | 
|  | 20479       i++; | 
| 20443     } | 20480     } | 
| 20444   } | 20481   } | 
| 20445 } | 20482 } | 
| 20446 | 20483 | 
| 20447 | 20484 | 
| 20448 RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3, | 20485 RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3, | 
| 20449                              Heap::Space space) { | 20486                              Heap::Space space) { | 
| 20450   ASSERT(Isolate::Current()->object_store()->float32x4_class() != | 20487   ASSERT(Isolate::Current()->object_store()->float32x4_class() != | 
| 20451          Class::null()); | 20488          Class::null()); | 
| 20452   Float32x4& result = Float32x4::Handle(); | 20489   Float32x4& result = Float32x4::Handle(); | 
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 20824   JSONObject jsobj(stream); | 20861   JSONObject jsobj(stream); | 
| 20825   PrintSharedInstanceJSON(&jsobj, ref); | 20862   PrintSharedInstanceJSON(&jsobj, ref); | 
| 20826   const Class& cls = Class::Handle(clazz()); | 20863   const Class& cls = Class::Handle(clazz()); | 
| 20827   const String& kind = String::Handle(cls.UserVisibleName()); | 20864   const String& kind = String::Handle(cls.UserVisibleName()); | 
| 20828   jsobj.AddProperty("kind", kind.ToCString()); | 20865   jsobj.AddProperty("kind", kind.ToCString()); | 
| 20829   jsobj.AddServiceId(*this); | 20866   jsobj.AddServiceId(*this); | 
| 20830   jsobj.AddProperty("length", Length()); | 20867   jsobj.AddProperty("length", Length()); | 
| 20831   if (ref) { | 20868   if (ref) { | 
| 20832     return; | 20869     return; | 
| 20833   } | 20870   } | 
| 20834 | 20871   intptr_t offset; | 
| 20835   { | 20872   intptr_t count; | 
|  | 20873   stream->ComputeOffsetAndCount(Length(), &offset, &count); | 
|  | 20874   if (offset > 0) { | 
|  | 20875     jsobj.AddProperty("offset", offset); | 
|  | 20876   } | 
|  | 20877   if (count < Length()) { | 
|  | 20878     jsobj.AddProperty("count", count); | 
|  | 20879   } | 
|  | 20880   if (count == 0) { | 
|  | 20881     jsobj.AddProperty("bytes", ""); | 
|  | 20882   } else { | 
| 20836     NoSafepointScope no_safepoint; | 20883     NoSafepointScope no_safepoint; | 
| 20837     jsobj.AddPropertyBase64("bytes", | 20884     jsobj.AddPropertyBase64("bytes", | 
| 20838                             reinterpret_cast<const uint8_t*>(DataAddr(0)), | 20885                             reinterpret_cast<const uint8_t*>( | 
| 20839                             LengthInBytes()); | 20886                                 DataAddr(offset * ElementSizeInBytes())), | 
|  | 20887                             count * ElementSizeInBytes()); | 
| 20840   } | 20888   } | 
| 20841 } | 20889 } | 
| 20842 | 20890 | 
| 20843 | 20891 | 
| 20844 FinalizablePersistentHandle* ExternalTypedData::AddFinalizer( | 20892 FinalizablePersistentHandle* ExternalTypedData::AddFinalizer( | 
| 20845     void* peer, Dart_WeakPersistentHandleFinalizer callback) const { | 20893     void* peer, Dart_WeakPersistentHandleFinalizer callback) const { | 
| 20846   return dart::AddFinalizer(*this, peer, callback); | 20894   return dart::AddFinalizer(*this, peer, callback); | 
| 20847 } | 20895 } | 
| 20848 | 20896 | 
| 20849 | 20897 | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 20875   JSONObject jsobj(stream); | 20923   JSONObject jsobj(stream); | 
| 20876   PrintSharedInstanceJSON(&jsobj, ref); | 20924   PrintSharedInstanceJSON(&jsobj, ref); | 
| 20877   const Class& cls = Class::Handle(clazz()); | 20925   const Class& cls = Class::Handle(clazz()); | 
| 20878   const String& kind = String::Handle(cls.UserVisibleName()); | 20926   const String& kind = String::Handle(cls.UserVisibleName()); | 
| 20879   jsobj.AddProperty("kind", kind.ToCString()); | 20927   jsobj.AddProperty("kind", kind.ToCString()); | 
| 20880   jsobj.AddServiceId(*this); | 20928   jsobj.AddServiceId(*this); | 
| 20881   jsobj.AddProperty("length", Length()); | 20929   jsobj.AddProperty("length", Length()); | 
| 20882   if (ref) { | 20930   if (ref) { | 
| 20883     return; | 20931     return; | 
| 20884   } | 20932   } | 
| 20885 | 20933   intptr_t offset; | 
| 20886   { | 20934   intptr_t count; | 
|  | 20935   stream->ComputeOffsetAndCount(Length(), &offset, &count); | 
|  | 20936   if (offset > 0) { | 
|  | 20937     jsobj.AddProperty("offset", offset); | 
|  | 20938   } | 
|  | 20939   if (count < Length()) { | 
|  | 20940     jsobj.AddProperty("count", count); | 
|  | 20941   } | 
|  | 20942   if (count == 0) { | 
|  | 20943     jsobj.AddProperty("bytes", ""); | 
|  | 20944   } else { | 
| 20887     NoSafepointScope no_safepoint; | 20945     NoSafepointScope no_safepoint; | 
| 20888     jsobj.AddPropertyBase64("bytes", | 20946     jsobj.AddPropertyBase64("bytes", | 
| 20889                             reinterpret_cast<const uint8_t*>(DataAddr(0)), | 20947                             reinterpret_cast<const uint8_t*>( | 
| 20890                             LengthInBytes()); | 20948                                 DataAddr(offset * ElementSizeInBytes())), | 
|  | 20949                             count * ElementSizeInBytes()); | 
| 20891   } | 20950   } | 
| 20892 } | 20951 } | 
| 20893 | 20952 | 
| 20894 | 20953 | 
| 20895 RawCapability* Capability::New(uint64_t id, Heap::Space space) { | 20954 RawCapability* Capability::New(uint64_t id, Heap::Space space) { | 
| 20896   Capability& result = Capability::Handle(); | 20955   Capability& result = Capability::Handle(); | 
| 20897   { | 20956   { | 
| 20898     RawObject* raw = Object::Allocate(Capability::kClassId, | 20957     RawObject* raw = Object::Allocate(Capability::kClassId, | 
| 20899                                       Capability::InstanceSize(), | 20958                                       Capability::InstanceSize(), | 
| 20900                                       space); | 20959                                       space); | 
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 21572   return tag_label.ToCString(); | 21631   return tag_label.ToCString(); | 
| 21573 } | 21632 } | 
| 21574 | 21633 | 
| 21575 | 21634 | 
| 21576 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21635 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 
| 21577   Instance::PrintJSONImpl(stream, ref); | 21636   Instance::PrintJSONImpl(stream, ref); | 
| 21578 } | 21637 } | 
| 21579 | 21638 | 
| 21580 | 21639 | 
| 21581 }  // namespace dart | 21640 }  // namespace dart | 
| OLD | NEW | 
|---|