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 13036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13047 | 13047 |
13048 bool Instance::IsValidFieldOffset(intptr_t offset) const { | 13048 bool Instance::IsValidFieldOffset(intptr_t offset) const { |
13049 Isolate* isolate = Isolate::Current(); | 13049 Isolate* isolate = Isolate::Current(); |
13050 REUSABLE_CLASS_HANDLESCOPE(isolate); | 13050 REUSABLE_CLASS_HANDLESCOPE(isolate); |
13051 Class& cls = isolate->ClassHandle(); | 13051 Class& cls = isolate->ClassHandle(); |
13052 cls = clazz(); | 13052 cls = clazz(); |
13053 return (offset >= 0 && offset <= (cls.instance_size() - kWordSize)); | 13053 return (offset >= 0 && offset <= (cls.instance_size() - kWordSize)); |
13054 } | 13054 } |
13055 | 13055 |
13056 | 13056 |
| 13057 intptr_t Instance::ElementSizeFor(intptr_t cid) { |
| 13058 if (RawObject::IsExternalTypedDataClassId(cid)) { |
| 13059 return ExternalTypedData::ElementSizeInBytes(cid); |
| 13060 } else if (RawObject::IsTypedDataClassId(cid)) { |
| 13061 return TypedData::ElementSizeInBytes(cid); |
| 13062 } |
| 13063 switch (cid) { |
| 13064 case kArrayCid: |
| 13065 case kImmutableArrayCid: |
| 13066 return Array::kBytesPerElement; |
| 13067 case kOneByteStringCid: |
| 13068 return OneByteString::kBytesPerElement; |
| 13069 case kTwoByteStringCid: |
| 13070 return TwoByteString::kBytesPerElement; |
| 13071 default: |
| 13072 UNIMPLEMENTED(); |
| 13073 return 0; |
| 13074 } |
| 13075 } |
| 13076 |
| 13077 |
| 13078 intptr_t Instance::DataOffsetFor(intptr_t cid) { |
| 13079 if (RawObject::IsExternalTypedDataClassId(cid)) { |
| 13080 // Elements start at offset 0 of the external data. |
| 13081 return 0; |
| 13082 } |
| 13083 if (RawObject::IsTypedDataClassId(cid)) { |
| 13084 return TypedData::data_offset(); |
| 13085 } |
| 13086 switch (cid) { |
| 13087 case kArrayCid: |
| 13088 case kImmutableArrayCid: |
| 13089 return Array::data_offset(); |
| 13090 case kOneByteStringCid: |
| 13091 return OneByteString::data_offset(); |
| 13092 case kTwoByteStringCid: |
| 13093 return TwoByteString::data_offset(); |
| 13094 default: |
| 13095 UNIMPLEMENTED(); |
| 13096 return Array::data_offset(); |
| 13097 } |
| 13098 } |
| 13099 |
| 13100 |
13057 const char* Instance::ToCString() const { | 13101 const char* Instance::ToCString() const { |
13058 if (IsNull()) { | 13102 if (IsNull()) { |
13059 return "null"; | 13103 return "null"; |
13060 } else if (raw() == Object::sentinel().raw()) { | 13104 } else if (raw() == Object::sentinel().raw()) { |
13061 return "sentinel"; | 13105 return "sentinel"; |
13062 } else if (raw() == Object::transition_sentinel().raw()) { | 13106 } else if (raw() == Object::transition_sentinel().raw()) { |
13063 return "transition_sentinel"; | 13107 return "transition_sentinel"; |
13064 } else if (raw() == Object::unknown_constant().raw()) { | 13108 } else if (raw() == Object::unknown_constant().raw()) { |
13065 return "unknown_constant"; | 13109 return "unknown_constant"; |
13066 } else if (raw() == Object::non_constant().raw()) { | 13110 } else if (raw() == Object::non_constant().raw()) { |
(...skipping 5798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18865 return tag_label.ToCString(); | 18909 return tag_label.ToCString(); |
18866 } | 18910 } |
18867 | 18911 |
18868 | 18912 |
18869 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 18913 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
18870 Instance::PrintJSONImpl(stream, ref); | 18914 Instance::PrintJSONImpl(stream, ref); |
18871 } | 18915 } |
18872 | 18916 |
18873 | 18917 |
18874 } // namespace dart | 18918 } // namespace dart |
OLD | NEW |