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

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

Issue 1526123002: VM: Const-correctness fixes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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/profiler_service.cc ('k') | runtime/vm/runtime_entry.h » ('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/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/dart.h" 8 #include "vm/dart.h"
9 #include "vm/freelist.h" 9 #include "vm/freelist.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 break; 158 break;
159 } 159 }
160 case kExceptionHandlersCid: { 160 case kExceptionHandlersCid: {
161 const RawExceptionHandlers* raw_handlers = 161 const RawExceptionHandlers* raw_handlers =
162 reinterpret_cast<const RawExceptionHandlers*>(this); 162 reinterpret_cast<const RawExceptionHandlers*>(this);
163 intptr_t num_handlers = raw_handlers->ptr()->num_entries_; 163 intptr_t num_handlers = raw_handlers->ptr()->num_entries_;
164 instance_size = ExceptionHandlers::InstanceSize(num_handlers); 164 instance_size = ExceptionHandlers::InstanceSize(num_handlers);
165 break; 165 break;
166 } 166 }
167 case kFreeListElement: { 167 case kFreeListElement: {
168 uword addr = RawObject::ToAddr(const_cast<RawObject*>(this)); 168 uword addr = RawObject::ToAddr(this);
169 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); 169 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr);
170 instance_size = element->Size(); 170 instance_size = element->Size();
171 break; 171 break;
172 } 172 }
173 default: { 173 default: {
174 // Get the (constant) instance size out of the class object. 174 // Get the (constant) instance size out of the class object.
175 // TODO(koda): Add Size(ClassTable*) interface to allow caching in loops. 175 // TODO(koda): Add Size(ClassTable*) interface to allow caching in loops.
176 Isolate* isolate = Isolate::Current(); 176 Isolate* isolate = Isolate::Current();
177 ClassTable* class_table = isolate->class_table(); 177 ClassTable* class_table = isolate->class_table();
178 #if defined(DEBUG) 178 #if defined(DEBUG)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 case kTypedData##clazz##ViewCid: 270 case kTypedData##clazz##ViewCid:
271 CLASS_LIST_TYPED_DATA(RAW_VISITPOINTERS) 271 CLASS_LIST_TYPED_DATA(RAW_VISITPOINTERS)
272 case kByteDataViewCid: 272 case kByteDataViewCid:
273 case kByteBufferCid: { 273 case kByteBufferCid: {
274 RawInstance* raw_obj = reinterpret_cast<RawInstance*>(this); 274 RawInstance* raw_obj = reinterpret_cast<RawInstance*>(this);
275 size = RawInstance::VisitInstancePointers(raw_obj, visitor); 275 size = RawInstance::VisitInstancePointers(raw_obj, visitor);
276 break; 276 break;
277 } 277 }
278 #undef RAW_VISITPOINTERS 278 #undef RAW_VISITPOINTERS
279 case kFreeListElement: { 279 case kFreeListElement: {
280 uword addr = RawObject::ToAddr(const_cast<RawObject*>(this)); 280 uword addr = RawObject::ToAddr(this);
281 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); 281 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr);
282 size = element->Size(); 282 size = element->Size();
283 break; 283 break;
284 } 284 }
285 case kNullCid: 285 case kNullCid:
286 size = Size(); 286 size = Size();
287 break; 287 break;
288 default: 288 default:
289 OS::Print("Class Id: %" Pd "\n", class_id); 289 OS::Print("Class Id: %" Pd "\n", class_id);
290 UNREACHABLE(); 290 UNREACHABLE();
291 break; 291 break;
292 } 292 }
293 } else { 293 } else {
294 RawInstance* raw_obj = reinterpret_cast<RawInstance*>(this); 294 RawInstance* raw_obj = reinterpret_cast<RawInstance*>(this);
295 size = RawInstance::VisitInstancePointers(raw_obj, visitor); 295 size = RawInstance::VisitInstancePointers(raw_obj, visitor);
296 } 296 }
297 297
298 ASSERT(size != 0); 298 ASSERT(size != 0);
299 ASSERT(size == Size()); 299 ASSERT(size == Size());
300 return size; 300 return size;
301 } 301 }
302 302
303 303
304 bool RawObject::FindObject(FindObjectVisitor* visitor) { 304 bool RawObject::FindObject(FindObjectVisitor* visitor) {
305 ASSERT(visitor != NULL); 305 ASSERT(visitor != NULL);
306 return visitor->FindObject(const_cast<RawObject*>(this)); 306 return visitor->FindObject(this);
307 } 307 }
308 308
309 309
310 intptr_t RawClass::VisitClassPointers(RawClass* raw_obj, 310 intptr_t RawClass::VisitClassPointers(RawClass* raw_obj,
311 ObjectPointerVisitor* visitor) { 311 ObjectPointerVisitor* visitor) {
312 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 312 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
313 return Class::InstanceSize(); 313 return Class::InstanceSize();
314 } 314 }
315 315
316 316
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 intptr_t RawUserTag::VisitUserTagPointers( 934 intptr_t RawUserTag::VisitUserTagPointers(
935 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { 935 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) {
936 // Make sure that we got here with the tagged pointer as this. 936 // Make sure that we got here with the tagged pointer as this.
937 ASSERT(raw_obj->IsHeapObject()); 937 ASSERT(raw_obj->IsHeapObject());
938 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 938 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
939 return UserTag::InstanceSize(); 939 return UserTag::InstanceSize();
940 } 940 }
941 941
942 942
943 } // namespace dart 943 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/profiler_service.cc ('k') | runtime/vm/runtime_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698