| 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/raw_object.h" | 5 #include "vm/raw_object.h" |
| 6 | 6 |
| 7 #include "vm/class_table.h" | 7 #include "vm/class_table.h" |
| 8 #include "vm/freelist.h" | 8 #include "vm/freelist.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 intptr_t RawObject::SizeFromClass() const { | 43 intptr_t RawObject::SizeFromClass() const { |
| 44 Isolate* isolate = Isolate::Current(); | 44 Isolate* isolate = Isolate::Current(); |
| 45 NoHandleScope no_handles(isolate); | 45 NoHandleScope no_handles(isolate); |
| 46 | 46 |
| 47 // Only reasonable to be called on heap objects. | 47 // Only reasonable to be called on heap objects. |
| 48 ASSERT(IsHeapObject()); | 48 ASSERT(IsHeapObject()); |
| 49 | 49 |
| 50 RawClass* raw_class = isolate->class_table()->At(GetClassId()); | 50 RawClass* raw_class = isolate->class_table()->At(GetClassId()); |
| 51 intptr_t instance_size = raw_class->ptr()->instance_size_; | 51 intptr_t instance_size = raw_class->ptr()->instance_size_; |
| 52 ObjectKind instance_kind = raw_class->ptr()->instance_kind_; | 52 intptr_t class_id = raw_class->ptr()->id_; |
| 53 | 53 |
| 54 if (instance_size == 0) { | 54 if (instance_size == 0) { |
| 55 switch (instance_kind) { | 55 switch (class_id) { |
| 56 case kTokenStream: { | 56 case kTokenStreamCid: { |
| 57 const RawTokenStream* raw_tokens = | 57 const RawTokenStream* raw_tokens = |
| 58 reinterpret_cast<const RawTokenStream*>(this); | 58 reinterpret_cast<const RawTokenStream*>(this); |
| 59 intptr_t tokens_length = Smi::Value(raw_tokens->ptr()->length_); | 59 intptr_t tokens_length = Smi::Value(raw_tokens->ptr()->length_); |
| 60 instance_size = TokenStream::InstanceSize(tokens_length); | 60 instance_size = TokenStream::InstanceSize(tokens_length); |
| 61 break; | 61 break; |
| 62 } | 62 } |
| 63 case kCode: { | 63 case kCodeCid: { |
| 64 const RawCode* raw_code = reinterpret_cast<const RawCode*>(this); | 64 const RawCode* raw_code = reinterpret_cast<const RawCode*>(this); |
| 65 intptr_t pointer_offsets_length = | 65 intptr_t pointer_offsets_length = |
| 66 raw_code->ptr()->pointer_offsets_length_; | 66 raw_code->ptr()->pointer_offsets_length_; |
| 67 instance_size = Code::InstanceSize(pointer_offsets_length); | 67 instance_size = Code::InstanceSize(pointer_offsets_length); |
| 68 break; | 68 break; |
| 69 } | 69 } |
| 70 case kInstructions: { | 70 case kInstructionsCid: { |
| 71 const RawInstructions* raw_instructions = | 71 const RawInstructions* raw_instructions = |
| 72 reinterpret_cast<const RawInstructions*>(this); | 72 reinterpret_cast<const RawInstructions*>(this); |
| 73 intptr_t instructions_size = raw_instructions->ptr()->size_; | 73 intptr_t instructions_size = raw_instructions->ptr()->size_; |
| 74 instance_size = Instructions::InstanceSize(instructions_size); | 74 instance_size = Instructions::InstanceSize(instructions_size); |
| 75 break; | 75 break; |
| 76 } | 76 } |
| 77 case kContext: { | 77 case kContextCid: { |
| 78 const RawContext* raw_context = | 78 const RawContext* raw_context = |
| 79 reinterpret_cast<const RawContext*>(this); | 79 reinterpret_cast<const RawContext*>(this); |
| 80 intptr_t num_variables = raw_context->ptr()->num_variables_; | 80 intptr_t num_variables = raw_context->ptr()->num_variables_; |
| 81 instance_size = Context::InstanceSize(num_variables); | 81 instance_size = Context::InstanceSize(num_variables); |
| 82 break; | 82 break; |
| 83 } | 83 } |
| 84 case kContextScope: { | 84 case kContextScopeCid: { |
| 85 const RawContextScope* raw_context_scope = | 85 const RawContextScope* raw_context_scope = |
| 86 reinterpret_cast<const RawContextScope*>(this); | 86 reinterpret_cast<const RawContextScope*>(this); |
| 87 intptr_t num_variables = raw_context_scope->ptr()->num_variables_; | 87 intptr_t num_variables = raw_context_scope->ptr()->num_variables_; |
| 88 instance_size = ContextScope::InstanceSize(num_variables); | 88 instance_size = ContextScope::InstanceSize(num_variables); |
| 89 break; | 89 break; |
| 90 } | 90 } |
| 91 case kBigint: { | 91 case kBigintCid: { |
| 92 const RawBigint* raw_bgi = reinterpret_cast<const RawBigint*>(this); | 92 const RawBigint* raw_bgi = reinterpret_cast<const RawBigint*>(this); |
| 93 intptr_t length = raw_bgi->ptr()->allocated_length_; | 93 intptr_t length = raw_bgi->ptr()->allocated_length_; |
| 94 instance_size = Bigint::InstanceSize(length); | 94 instance_size = Bigint::InstanceSize(length); |
| 95 break; | 95 break; |
| 96 } | 96 } |
| 97 case kOneByteString: { | 97 case kOneByteStringCid: { |
| 98 const RawOneByteString* raw_string = | 98 const RawOneByteString* raw_string = |
| 99 reinterpret_cast<const RawOneByteString*>(this); | 99 reinterpret_cast<const RawOneByteString*>(this); |
| 100 intptr_t string_length = Smi::Value(raw_string->ptr()->length_); | 100 intptr_t string_length = Smi::Value(raw_string->ptr()->length_); |
| 101 instance_size = OneByteString::InstanceSize(string_length); | 101 instance_size = OneByteString::InstanceSize(string_length); |
| 102 break; | 102 break; |
| 103 } | 103 } |
| 104 case kTwoByteString: { | 104 case kTwoByteStringCid: { |
| 105 const RawTwoByteString* raw_string = | 105 const RawTwoByteString* raw_string = |
| 106 reinterpret_cast<const RawTwoByteString*>(this); | 106 reinterpret_cast<const RawTwoByteString*>(this); |
| 107 intptr_t string_length = Smi::Value(raw_string->ptr()->length_); | 107 intptr_t string_length = Smi::Value(raw_string->ptr()->length_); |
| 108 instance_size = TwoByteString::InstanceSize(string_length); | 108 instance_size = TwoByteString::InstanceSize(string_length); |
| 109 break; | 109 break; |
| 110 } | 110 } |
| 111 case kFourByteString: { | 111 case kFourByteStringCid: { |
| 112 const RawFourByteString* raw_string = | 112 const RawFourByteString* raw_string = |
| 113 reinterpret_cast<const RawFourByteString*>(this); | 113 reinterpret_cast<const RawFourByteString*>(this); |
| 114 intptr_t string_length = Smi::Value(raw_string->ptr()->length_); | 114 intptr_t string_length = Smi::Value(raw_string->ptr()->length_); |
| 115 instance_size = FourByteString::InstanceSize(string_length); | 115 instance_size = FourByteString::InstanceSize(string_length); |
| 116 break; | 116 break; |
| 117 } | 117 } |
| 118 case kArray: | 118 case kArrayCid: |
| 119 case kImmutableArray: { | 119 case kImmutableArrayCid: { |
| 120 const RawArray* raw_array = reinterpret_cast<const RawArray*>(this); | 120 const RawArray* raw_array = reinterpret_cast<const RawArray*>(this); |
| 121 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); | 121 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); |
| 122 instance_size = Array::InstanceSize(array_length); | 122 instance_size = Array::InstanceSize(array_length); |
| 123 break; | 123 break; |
| 124 } | 124 } |
| 125 case kInt8Array: { | 125 case kInt8ArrayCid: { |
| 126 const RawInt8Array* raw_byte_array = | 126 const RawInt8Array* raw_byte_array = |
| 127 reinterpret_cast<const RawInt8Array*>(this); | 127 reinterpret_cast<const RawInt8Array*>(this); |
| 128 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | 128 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); |
| 129 instance_size = Int8Array::InstanceSize(byte_array_length); | 129 instance_size = Int8Array::InstanceSize(byte_array_length); |
| 130 break; | 130 break; |
| 131 } | 131 } |
| 132 case kUint8Array: { | 132 case kUint8ArrayCid: { |
| 133 const RawUint8Array* raw_byte_array = | 133 const RawUint8Array* raw_byte_array = |
| 134 reinterpret_cast<const RawUint8Array*>(this); | 134 reinterpret_cast<const RawUint8Array*>(this); |
| 135 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | 135 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); |
| 136 instance_size = Uint8Array::InstanceSize(byte_array_length); | 136 instance_size = Uint8Array::InstanceSize(byte_array_length); |
| 137 break; | 137 break; |
| 138 } | 138 } |
| 139 case kInt16Array: { | 139 case kInt16ArrayCid: { |
| 140 const RawInt16Array* raw_byte_array = | 140 const RawInt16Array* raw_byte_array = |
| 141 reinterpret_cast<const RawInt16Array*>(this); | 141 reinterpret_cast<const RawInt16Array*>(this); |
| 142 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | 142 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); |
| 143 instance_size = Int16Array::InstanceSize(byte_array_length); | 143 instance_size = Int16Array::InstanceSize(byte_array_length); |
| 144 break; | 144 break; |
| 145 } | 145 } |
| 146 case kUint16Array: { | 146 case kUint16ArrayCid: { |
| 147 const RawUint16Array* raw_byte_array = | 147 const RawUint16Array* raw_byte_array = |
| 148 reinterpret_cast<const RawUint16Array*>(this); | 148 reinterpret_cast<const RawUint16Array*>(this); |
| 149 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | 149 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); |
| 150 instance_size = Uint16Array::InstanceSize(byte_array_length); | 150 instance_size = Uint16Array::InstanceSize(byte_array_length); |
| 151 break; | 151 break; |
| 152 } | 152 } |
| 153 case kInt32Array: { | 153 case kInt32ArrayCid: { |
| 154 const RawInt32Array* raw_byte_array = | 154 const RawInt32Array* raw_byte_array = |
| 155 reinterpret_cast<const RawInt32Array*>(this); | 155 reinterpret_cast<const RawInt32Array*>(this); |
| 156 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | 156 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); |
| 157 instance_size = Int32Array::InstanceSize(byte_array_length); | 157 instance_size = Int32Array::InstanceSize(byte_array_length); |
| 158 break; | 158 break; |
| 159 } | 159 } |
| 160 case kUint32Array: { | 160 case kUint32ArrayCid: { |
| 161 const RawUint32Array* raw_byte_array = | 161 const RawUint32Array* raw_byte_array = |
| 162 reinterpret_cast<const RawUint32Array*>(this); | 162 reinterpret_cast<const RawUint32Array*>(this); |
| 163 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | 163 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); |
| 164 instance_size = Uint32Array::InstanceSize(byte_array_length); | 164 instance_size = Uint32Array::InstanceSize(byte_array_length); |
| 165 break; | 165 break; |
| 166 } | 166 } |
| 167 case kInt64Array: { | 167 case kInt64ArrayCid: { |
| 168 const RawInt64Array* raw_byte_array = | 168 const RawInt64Array* raw_byte_array = |
| 169 reinterpret_cast<const RawInt64Array*>(this); | 169 reinterpret_cast<const RawInt64Array*>(this); |
| 170 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | 170 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); |
| 171 instance_size = Int64Array::InstanceSize(byte_array_length); | 171 instance_size = Int64Array::InstanceSize(byte_array_length); |
| 172 break; | 172 break; |
| 173 } | 173 } |
| 174 case kUint64Array: { | 174 case kUint64ArrayCid: { |
| 175 const RawUint64Array* raw_byte_array = | 175 const RawUint64Array* raw_byte_array = |
| 176 reinterpret_cast<const RawUint64Array*>(this); | 176 reinterpret_cast<const RawUint64Array*>(this); |
| 177 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | 177 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); |
| 178 instance_size = Uint64Array::InstanceSize(byte_array_length); | 178 instance_size = Uint64Array::InstanceSize(byte_array_length); |
| 179 break; | 179 break; |
| 180 } | 180 } |
| 181 case kFloat32Array: { | 181 case kFloat32ArrayCid: { |
| 182 const RawFloat32Array* raw_byte_array = | 182 const RawFloat32Array* raw_byte_array = |
| 183 reinterpret_cast<const RawFloat32Array*>(this); | 183 reinterpret_cast<const RawFloat32Array*>(this); |
| 184 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | 184 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); |
| 185 instance_size = Float32Array::InstanceSize(byte_array_length); | 185 instance_size = Float32Array::InstanceSize(byte_array_length); |
| 186 break; | 186 break; |
| 187 } | 187 } |
| 188 case kFloat64Array: { | 188 case kFloat64ArrayCid: { |
| 189 const RawFloat64Array* raw_byte_array = | 189 const RawFloat64Array* raw_byte_array = |
| 190 reinterpret_cast<const RawFloat64Array*>(this); | 190 reinterpret_cast<const RawFloat64Array*>(this); |
| 191 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | 191 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); |
| 192 instance_size = Float64Array::InstanceSize(byte_array_length); | 192 instance_size = Float64Array::InstanceSize(byte_array_length); |
| 193 break; | 193 break; |
| 194 } | 194 } |
| 195 case kTypeArguments: { | 195 case kTypeArgumentsCid: { |
| 196 const RawTypeArguments* raw_array = | 196 const RawTypeArguments* raw_array = |
| 197 reinterpret_cast<const RawTypeArguments*>(this); | 197 reinterpret_cast<const RawTypeArguments*>(this); |
| 198 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); | 198 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); |
| 199 instance_size = TypeArguments::InstanceSize(array_length); | 199 instance_size = TypeArguments::InstanceSize(array_length); |
| 200 break; | 200 break; |
| 201 } | 201 } |
| 202 case kPcDescriptors: { | 202 case kPcDescriptorsCid: { |
| 203 const RawPcDescriptors* raw_descriptors = | 203 const RawPcDescriptors* raw_descriptors = |
| 204 reinterpret_cast<const RawPcDescriptors*>(this); | 204 reinterpret_cast<const RawPcDescriptors*>(this); |
| 205 intptr_t num_descriptors = Smi::Value(raw_descriptors->ptr()->length_); | 205 intptr_t num_descriptors = Smi::Value(raw_descriptors->ptr()->length_); |
| 206 instance_size = PcDescriptors::InstanceSize(num_descriptors); | 206 instance_size = PcDescriptors::InstanceSize(num_descriptors); |
| 207 break; | 207 break; |
| 208 } | 208 } |
| 209 case kStackmap: { | 209 case kStackmapCid: { |
| 210 const RawStackmap* map = reinterpret_cast<const RawStackmap*>(this); | 210 const RawStackmap* map = reinterpret_cast<const RawStackmap*>(this); |
| 211 intptr_t size_in_bytes = Smi::Value(map->ptr()->bitmap_size_in_bytes_); | 211 intptr_t size_in_bytes = Smi::Value(map->ptr()->bitmap_size_in_bytes_); |
| 212 instance_size = Stackmap::InstanceSize(size_in_bytes); | 212 instance_size = Stackmap::InstanceSize(size_in_bytes); |
| 213 break; | 213 break; |
| 214 } | 214 } |
| 215 case kLocalVarDescriptors: { | 215 case kLocalVarDescriptorsCid: { |
| 216 const RawLocalVarDescriptors* raw_descriptors = | 216 const RawLocalVarDescriptors* raw_descriptors = |
| 217 reinterpret_cast<const RawLocalVarDescriptors*>(this); | 217 reinterpret_cast<const RawLocalVarDescriptors*>(this); |
| 218 intptr_t num_descriptors = raw_descriptors->ptr()->length_; | 218 intptr_t num_descriptors = raw_descriptors->ptr()->length_; |
| 219 instance_size = LocalVarDescriptors::InstanceSize(num_descriptors); | 219 instance_size = LocalVarDescriptors::InstanceSize(num_descriptors); |
| 220 break; | 220 break; |
| 221 } | 221 } |
| 222 case kExceptionHandlers: { | 222 case kExceptionHandlersCid: { |
| 223 const RawExceptionHandlers* raw_handlers = | 223 const RawExceptionHandlers* raw_handlers = |
| 224 reinterpret_cast<const RawExceptionHandlers*>(this); | 224 reinterpret_cast<const RawExceptionHandlers*>(this); |
| 225 intptr_t num_handlers = Smi::Value(raw_handlers->ptr()->length_); | 225 intptr_t num_handlers = Smi::Value(raw_handlers->ptr()->length_); |
| 226 instance_size = ExceptionHandlers::InstanceSize(num_handlers); | 226 instance_size = ExceptionHandlers::InstanceSize(num_handlers); |
| 227 break; | 227 break; |
| 228 } | 228 } |
| 229 case kDeoptInfo: { | 229 case kDeoptInfoCid: { |
| 230 const RawDeoptInfo* raw_deopt_info = | 230 const RawDeoptInfo* raw_deopt_info = |
| 231 reinterpret_cast<const RawDeoptInfo*>(this); | 231 reinterpret_cast<const RawDeoptInfo*>(this); |
| 232 intptr_t num_entries = Smi::Value(raw_deopt_info->ptr()->length_); | 232 intptr_t num_entries = Smi::Value(raw_deopt_info->ptr()->length_); |
| 233 instance_size = DeoptInfo::InstanceSize(num_entries); | 233 instance_size = DeoptInfo::InstanceSize(num_entries); |
| 234 break; | 234 break; |
| 235 } | 235 } |
| 236 case kJSRegExp: { | 236 case kJSRegExpCid: { |
| 237 const RawJSRegExp* raw_jsregexp = | 237 const RawJSRegExp* raw_jsregexp = |
| 238 reinterpret_cast<const RawJSRegExp*>(this); | 238 reinterpret_cast<const RawJSRegExp*>(this); |
| 239 intptr_t data_length = Smi::Value(raw_jsregexp->ptr()->data_length_); | 239 intptr_t data_length = Smi::Value(raw_jsregexp->ptr()->data_length_); |
| 240 instance_size = JSRegExp::InstanceSize(data_length); | 240 instance_size = JSRegExp::InstanceSize(data_length); |
| 241 break; | 241 break; |
| 242 } | 242 } |
| 243 case kFreeListElement: { | 243 case kFreeListElement: { |
| 244 ASSERT(FreeBit::decode(ptr()->tags_)); | 244 ASSERT(FreeBit::decode(ptr()->tags_)); |
| 245 uword addr = RawObject::ToAddr(const_cast<RawObject*>(this)); | 245 uword addr = RawObject::ToAddr(const_cast<RawObject*>(this)); |
| 246 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); | 246 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); |
| 247 instance_size = element->Size(); | 247 instance_size = element->Size(); |
| 248 break; | 248 break; |
| 249 } | 249 } |
| 250 default: | 250 default: |
| 251 UNREACHABLE(); | 251 UNREACHABLE(); |
| 252 break; | 252 break; |
| 253 } | 253 } |
| 254 } | 254 } |
| 255 ASSERT(instance_size != 0); | 255 ASSERT(instance_size != 0); |
| 256 uword tags = ptr()->tags_; | 256 uword tags = ptr()->tags_; |
| 257 ASSERT((instance_size == SizeTag::decode(tags)) || | 257 ASSERT((instance_size == SizeTag::decode(tags)) || |
| 258 (SizeTag::decode(tags) == 0)); | 258 (SizeTag::decode(tags) == 0)); |
| 259 return instance_size; | 259 return instance_size; |
| 260 } | 260 } |
| 261 | 261 |
| 262 | 262 |
| 263 ObjectKind RawObject::GetObjectKind() const { | |
| 264 intptr_t class_id = GetClassId(); | |
| 265 ObjectKind kind; | |
| 266 if (class_id < kNumPredefinedKinds) { | |
| 267 kind = static_cast<ObjectKind>(class_id); | |
| 268 } else { | |
| 269 RawClass* raw_class = Isolate::Current()->class_table()->At(class_id); | |
| 270 kind = raw_class->ptr()->instance_kind_; | |
| 271 } | |
| 272 return kind; | |
| 273 } | |
| 274 | |
| 275 | |
| 276 intptr_t RawObject::VisitPointers(ObjectPointerVisitor* visitor) { | 263 intptr_t RawObject::VisitPointers(ObjectPointerVisitor* visitor) { |
| 277 intptr_t size = 0; | 264 intptr_t size = 0; |
| 278 NoHandleScope no_handles(visitor->isolate()); | 265 NoHandleScope no_handles(visitor->isolate()); |
| 279 | 266 |
| 280 // Only reasonable to be called on heap objects. | 267 // Only reasonable to be called on heap objects. |
| 281 ASSERT(IsHeapObject()); | 268 ASSERT(IsHeapObject()); |
| 282 | 269 |
| 283 // Read the necessary data out of the class before visting the class itself. | 270 // Read the necessary data out of the class before visting the class itself. |
| 284 intptr_t class_id = GetClassId(); | 271 intptr_t class_id = GetClassId(); |
| 285 ObjectKind kind; | |
| 286 | 272 |
| 287 if (class_id < kNumPredefinedKinds) { | 273 if (class_id < kNumPredefinedCids) { |
| 288 kind = static_cast<ObjectKind>(class_id); | 274 switch (class_id) { |
| 275 #define RAW_VISITPOINTERS(clazz) \ |
| 276 case clazz::kClassId: { \ |
| 277 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(this); \ |
| 278 size = Raw##clazz::Visit##clazz##Pointers(raw_obj, visitor); \ |
| 279 break; \ |
| 280 } |
| 281 CLASS_LIST_NO_OBJECT(RAW_VISITPOINTERS) |
| 282 #undef RAW_VISITPOINTERS |
| 283 case kFreeListElement: { |
| 284 ASSERT(FreeBit::decode(ptr()->tags_)); |
| 285 uword addr = RawObject::ToAddr(const_cast<RawObject*>(this)); |
| 286 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); |
| 287 size = element->Size(); |
| 288 break; |
| 289 } |
| 290 default: |
| 291 OS::Print("Class Id: %d\n", class_id); |
| 292 UNREACHABLE(); |
| 293 break; |
| 294 } |
| 289 } else { | 295 } else { |
| 290 RawClass* raw_class = Isolate::Current()->class_table()->At(class_id); | 296 RawClass* raw_class = Isolate::Current()->class_table()->At(class_id); |
| 291 kind = raw_class->ptr()->instance_kind_; | 297 if (Class::IsSignatureClass(raw_class)) { |
| 292 } | 298 RawClosure* raw_obj = reinterpret_cast<RawClosure*>(this); |
| 293 | 299 size = RawClosure::VisitClosurePointers(raw_obj, visitor); |
| 294 switch (kind) { | 300 } else { |
| 295 #define RAW_VISITPOINTERS(clazz) \ | 301 RawInstance* raw_obj = reinterpret_cast<RawInstance*>(this); |
| 296 case clazz::kInstanceKind: { \ | 302 size = RawInstance::VisitInstancePointers(raw_obj, visitor); |
| 297 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(this); \ | |
| 298 size = Raw##clazz::Visit##clazz##Pointers(raw_obj, visitor); \ | |
| 299 break; \ | |
| 300 } | 303 } |
| 301 CLASS_LIST_NO_OBJECT(RAW_VISITPOINTERS) | |
| 302 #undef RAW_VISITPOINTERS | |
| 303 case kFreeListElement: { | |
| 304 ASSERT(FreeBit::decode(ptr()->tags_)); | |
| 305 uword addr = RawObject::ToAddr(const_cast<RawObject*>(this)); | |
| 306 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); | |
| 307 size = element->Size(); | |
| 308 break; | |
| 309 } | |
| 310 default: | |
| 311 OS::Print("Kind: %d\n", kind); | |
| 312 UNREACHABLE(); | |
| 313 break; | |
| 314 } | 304 } |
| 315 | 305 |
| 316 ASSERT(size != 0); | 306 ASSERT(size != 0); |
| 317 ASSERT(size == Size()); | 307 ASSERT(size == Size()); |
| 318 return size; | 308 return size; |
| 319 } | 309 } |
| 320 | 310 |
| 321 | 311 |
| 322 bool RawObject::FindObject(FindObjectVisitor* visitor) { | 312 bool RawObject::FindObject(FindObjectVisitor* visitor) { |
| 323 ASSERT(visitor != NULL); | 313 ASSERT(visitor != NULL); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 intptr_t RawInstructions::VisitInstructionsPointers( | 444 intptr_t RawInstructions::VisitInstructionsPointers( |
| 455 RawInstructions* raw_obj, ObjectPointerVisitor* visitor) { | 445 RawInstructions* raw_obj, ObjectPointerVisitor* visitor) { |
| 456 RawInstructions* obj = raw_obj->ptr(); | 446 RawInstructions* obj = raw_obj->ptr(); |
| 457 visitor->VisitPointer(reinterpret_cast<RawObject**>(&obj->code_)); | 447 visitor->VisitPointer(reinterpret_cast<RawObject**>(&obj->code_)); |
| 458 return Instructions::InstanceSize(obj->size_); | 448 return Instructions::InstanceSize(obj->size_); |
| 459 } | 449 } |
| 460 | 450 |
| 461 | 451 |
| 462 bool RawInstructions::ContainsPC(RawObject* raw_obj, uword pc) { | 452 bool RawInstructions::ContainsPC(RawObject* raw_obj, uword pc) { |
| 463 uword tags = raw_obj->ptr()->tags_; | 453 uword tags = raw_obj->ptr()->tags_; |
| 464 if (RawObject::ClassIdTag::decode(tags) == kInstructions) { | 454 if (RawObject::ClassIdTag::decode(tags) == kInstructionsCid) { |
| 465 RawInstructions* raw_instr = reinterpret_cast<RawInstructions*>(raw_obj); | 455 RawInstructions* raw_instr = reinterpret_cast<RawInstructions*>(raw_obj); |
| 466 uword start_pc = | 456 uword start_pc = |
| 467 reinterpret_cast<uword>(raw_instr->ptr()) + Instructions::HeaderSize(); | 457 reinterpret_cast<uword>(raw_instr->ptr()) + Instructions::HeaderSize(); |
| 468 uword end_pc = start_pc + raw_instr->ptr()->size_; | 458 uword end_pc = start_pc + raw_instr->ptr()->size_; |
| 469 ASSERT(end_pc > start_pc); | 459 ASSERT(end_pc > start_pc); |
| 470 if ((pc >= start_pc) && (pc < end_pc)) { | 460 if ((pc >= start_pc) && (pc < end_pc)) { |
| 471 return true; | 461 return true; |
| 472 } | 462 } |
| 473 } | 463 } |
| 474 return false; | 464 return false; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 RawUnwindError* raw_obj, ObjectPointerVisitor* visitor) { | 576 RawUnwindError* raw_obj, ObjectPointerVisitor* visitor) { |
| 587 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 577 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 588 return UnwindError::InstanceSize(); | 578 return UnwindError::InstanceSize(); |
| 589 } | 579 } |
| 590 | 580 |
| 591 | 581 |
| 592 intptr_t RawInstance::VisitInstancePointers(RawInstance* raw_obj, | 582 intptr_t RawInstance::VisitInstancePointers(RawInstance* raw_obj, |
| 593 ObjectPointerVisitor* visitor) { | 583 ObjectPointerVisitor* visitor) { |
| 594 // Make sure that we got here with the tagged pointer as this. | 584 // Make sure that we got here with the tagged pointer as this. |
| 595 ASSERT(raw_obj->IsHeapObject()); | 585 ASSERT(raw_obj->IsHeapObject()); |
| 596 RawClass* cls = Isolate::Current()->class_table()->At( | 586 RawClass* cls = Isolate::Current()->class_table()->At(raw_obj->GetClassId()); |
| 597 raw_obj->GetClassId()); | |
| 598 intptr_t instance_size = cls->ptr()->instance_size_; | 587 intptr_t instance_size = cls->ptr()->instance_size_; |
| 599 intptr_t num_native_fields = cls->ptr()->num_native_fields_; | 588 intptr_t num_native_fields = cls->ptr()->num_native_fields_; |
| 600 | 589 |
| 601 // Calculate the first and last raw object pointer fields. | 590 // Calculate the first and last raw object pointer fields. |
| 602 uword obj_addr = RawObject::ToAddr(raw_obj); | 591 uword obj_addr = RawObject::ToAddr(raw_obj); |
| 603 uword from = obj_addr + sizeof(RawObject) + num_native_fields * kWordSize; | 592 uword from = obj_addr + sizeof(RawObject) + num_native_fields * kWordSize; |
| 604 uword to = obj_addr + instance_size - kWordSize; | 593 uword to = obj_addr + instance_size - kWordSize; |
| 605 visitor->VisitPointers(reinterpret_cast<RawObject**>(from), | 594 visitor->VisitPointers(reinterpret_cast<RawObject**>(from), |
| 606 reinterpret_cast<RawObject**>(to)); | 595 reinterpret_cast<RawObject**>(to)); |
| 607 return instance_size; | 596 return instance_size; |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj, | 954 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj, |
| 966 ObjectPointerVisitor* visitor) { | 955 ObjectPointerVisitor* visitor) { |
| 967 // Make sure that we got here with the tagged pointer as this. | 956 // Make sure that we got here with the tagged pointer as this. |
| 968 ASSERT(raw_obj->IsHeapObject()); | 957 ASSERT(raw_obj->IsHeapObject()); |
| 969 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_); | 958 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_); |
| 970 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 959 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 971 return JSRegExp::InstanceSize(length); | 960 return JSRegExp::InstanceSize(length); |
| 972 } | 961 } |
| 973 | 962 |
| 974 } // namespace dart | 963 } // namespace dart |
| OLD | NEW |