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

Side by Side Diff: vm/object.h

Issue 9965042: - Add a class index to the classes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
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 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // Filter stores based on source and target. 355 // Filter stores based on source and target.
356 if (value->IsNewObject() && raw()->IsOldObject()) { 356 if (value->IsNewObject() && raw()->IsOldObject()) {
357 uword ptr = reinterpret_cast<uword>(addr); 357 uword ptr = reinterpret_cast<uword>(addr);
358 Isolate::Current()->store_buffer()->AddPointer(ptr); 358 Isolate::Current()->store_buffer()->AddPointer(ptr);
359 } 359 }
360 } 360 }
361 361
362 RawObject* raw_; // The raw object reference. 362 RawObject* raw_; // The raw object reference.
363 363
364 private: 364 private:
365 static void InitializeObject(uword address, intptr_t size); 365 static void InitializeObject(uword address, intptr_t index, intptr_t size);
366 366
367 cpp_vtable* vtable_address() const { 367 cpp_vtable* vtable_address() const {
368 return reinterpret_cast<cpp_vtable*>(reinterpret_cast<word>(this)); 368 return reinterpret_cast<cpp_vtable*>(reinterpret_cast<word>(this));
369 } 369 }
370 370
371 static cpp_vtable handle_vtable_; 371 static cpp_vtable handle_vtable_;
372 372
373 // The static values below are singletons shared between the different 373 // The static values below are singletons shared between the different
374 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_. 374 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_.
375 static RawObject* null_; 375 static RawObject* null_;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 (value + kWordSize == raw_ptr()->instance_size_))); 444 (value + kWordSize == raw_ptr()->instance_size_)));
445 raw_ptr()->next_field_offset_ = value; 445 raw_ptr()->next_field_offset_ = value;
446 } 446 }
447 447
448 cpp_vtable handle_vtable() const { return raw_ptr()->handle_vtable_; } 448 cpp_vtable handle_vtable() const { return raw_ptr()->handle_vtable_; }
449 void set_handle_vtable(cpp_vtable value) const { 449 void set_handle_vtable(cpp_vtable value) const {
450 raw_ptr()->handle_vtable_ = value; 450 raw_ptr()->handle_vtable_ = value;
451 } 451 }
452 452
453 ObjectKind instance_kind() const { return raw_ptr()->instance_kind_; } 453 ObjectKind instance_kind() const { return raw_ptr()->instance_kind_; }
454 void set_instance_kind(ObjectKind value) { 454 void set_instance_kind(ObjectKind value) const {
455 raw_ptr()->instance_kind_ = value; 455 raw_ptr()->instance_kind_ = value;
456 } 456 }
457 457
458 intptr_t index() const { return raw_ptr()->index_; }
459 void set_index(intptr_t value) const {
460 raw_ptr()->index_ = value;
461 }
462
458 RawString* Name() const; 463 RawString* Name() const;
459 464
460 RawScript* script() const { return raw_ptr()->script_; } 465 RawScript* script() const { return raw_ptr()->script_; }
461 466
462 intptr_t token_index() const { return raw_ptr()->token_index_; } 467 intptr_t token_index() const { return raw_ptr()->token_index_; }
463 468
464 // This class represents the signature class of a closure function if 469 // This class represents the signature class of a closure function if
465 // signature_function() is not null. 470 // signature_function() is not null.
466 // The associated function may be a closure function (with code) or a 471 // The associated function may be a closure function (with code) or a
467 // signature function (without code) solely describing the result type and 472 // signature function (without code) solely describing the result type and
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 } 660 }
656 void set_allocation_stub(const Code& value) const; 661 void set_allocation_stub(const Code& value) const;
657 662
658 RawArray* constants() const; 663 RawArray* constants() const;
659 664
660 void Finalize() const; 665 void Finalize() const;
661 666
662 // Allocate a class used for VM internal objects. 667 // Allocate a class used for VM internal objects.
663 template <class FakeObject> static RawClass* New(); 668 template <class FakeObject> static RawClass* New();
664 669
665 // Allocate an instance class which has a VM implementation.
666 template <class FakeInstance> static RawClass* New(const String& name,
667 const Script& script,
668 intptr_t token_index);
669
670 // Allocate instance classes and interfaces. 670 // Allocate instance classes and interfaces.
671 static RawClass* New(const String& name, 671 static RawClass* New(const String& name,
672 const Script& script, 672 const Script& script,
673 intptr_t token_index); 673 intptr_t token_index);
674 static RawClass* NewInterface(const String& name, 674 static RawClass* NewInterface(const String& name,
675 const Script& script, 675 const Script& script,
676 intptr_t token_index); 676 intptr_t token_index);
677 static RawClass* NewNativeWrapper(Library* library, 677 static RawClass* NewNativeWrapper(Library* library,
678 const String& name, 678 const String& name,
679 int num_fields); 679 int num_fields);
(...skipping 28 matching lines...) Expand all
708 708
709 void CalculateFieldOffsets() const; 709 void CalculateFieldOffsets() const;
710 710
711 // Assigns empty array to all raw class array fields. 711 // Assigns empty array to all raw class array fields.
712 void InitEmptyFields(); 712 void InitEmptyFields();
713 713
714 RawFunction* LookupAccessorFunction(const char* prefix, 714 RawFunction* LookupAccessorFunction(const char* prefix,
715 intptr_t prefix_length, 715 intptr_t prefix_length,
716 const String& name) const; 716 const String& name) const;
717 717
718 // Allocate an instance class which has a VM implementation.
719 template <class FakeInstance> static RawClass* New(intptr_t index);
720 template <class FakeInstance> static RawClass* New(const String& name,
721 const Script& script,
722 intptr_t token_index);
723
718 HEAP_OBJECT_IMPLEMENTATION(Class, Object); 724 HEAP_OBJECT_IMPLEMENTATION(Class, Object);
719 friend class Object; 725 friend class Object;
720 friend class Instance; 726 friend class Instance;
721 friend class Type; 727 friend class Type;
722 }; 728 };
723 729
724 730
725 // Unresolved class is used for storing unresolved names which will be resolved 731 // Unresolved class is used for storing unresolved names which will be resolved
726 // to a class after all classes have been loaded and finalized. 732 // to a class after all classes have been loaded and finalized.
727 class UnresolvedClass : public Object { 733 class UnresolvedClass : public Object {
(...skipping 3113 matching lines...) Expand 10 before | Expand all | Expand 10 after
3841 friend class Class; 3847 friend class Class;
3842 }; 3848 };
3843 3849
3844 3850
3845 // Breaking cycles and loops. 3851 // Breaking cycles and loops.
3846 RawClass* Object::clazz() const { 3852 RawClass* Object::clazz() const {
3847 uword raw_value = reinterpret_cast<uword>(raw_); 3853 uword raw_value = reinterpret_cast<uword>(raw_);
3848 if ((raw_value & kSmiTagMask) == kSmiTag) { 3854 if ((raw_value & kSmiTagMask) == kSmiTag) {
3849 return Smi::Class(); 3855 return Smi::Class();
3850 } 3856 }
3851 return raw_->ptr()->class_; 3857 RawClass* result = raw_->ptr()->class_;
3858 ASSERT(result->ptr()->index_ ==
3859 RawObject::ClassTag::decode(raw_->ptr()->tags_));
siva 2012/04/02 18:29:21 Also assert class_table.At(RawObject::ClassTag::de
Ivan Posva 2012/04/29 21:08:25 Done.
3860 return result;
3852 } 3861 }
3853 3862
3854 3863
3855 void Object::SetRaw(RawObject* value) { 3864 void Object::SetRaw(RawObject* value) {
3856 // NOTE: The assignment "raw_ = value" should be the first statement in 3865 // NOTE: The assignment "raw_ = value" should be the first statement in
3857 // this function. Also do not use 'value' in this function after the 3866 // this function. Also do not use 'value' in this function after the
3858 // assignment (use 'raw_' instead). 3867 // assignment (use 'raw_' instead).
3859 raw_ = value; 3868 raw_ = value;
3860 if ((reinterpret_cast<uword>(raw_) & kSmiTagMask) == kSmiTag) { 3869 if ((reinterpret_cast<uword>(raw_) & kSmiTagMask) == kSmiTag) {
3861 set_vtable(Smi::handle_vtable_); 3870 set_vtable(Smi::handle_vtable_);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3914 } 3923 }
3915 3924
3916 3925
3917 intptr_t Stackmap::SizeInBits() const { 3926 intptr_t Stackmap::SizeInBits() const {
3918 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); 3927 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte);
3919 } 3928 }
3920 3929
3921 } // namespace dart 3930 } // namespace dart
3922 3931
3923 #endif // VM_OBJECT_H_ 3932 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698