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

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, 7 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
« no previous file with comments | « vm/isolate.cc ('k') | vm/object.cc » ('j') | vm/raw_object.cc » ('J')
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 #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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // Filter stores based on source and target. 366 // Filter stores based on source and target.
367 if (value->IsNewObject() && raw()->IsOldObject()) { 367 if (value->IsNewObject() && raw()->IsOldObject()) {
368 uword ptr = reinterpret_cast<uword>(addr); 368 uword ptr = reinterpret_cast<uword>(addr);
369 Isolate::Current()->store_buffer()->AddPointer(ptr); 369 Isolate::Current()->store_buffer()->AddPointer(ptr);
370 } 370 }
371 } 371 }
372 372
373 RawObject* raw_; // The raw object reference. 373 RawObject* raw_; // The raw object reference.
374 374
375 private: 375 private:
376 static void InitializeObject(uword address, intptr_t size); 376 static void InitializeObject(uword address, intptr_t index, intptr_t size);
377 377
378 cpp_vtable* vtable_address() const { 378 cpp_vtable* vtable_address() const {
379 uword vtable_addr = reinterpret_cast<uword>(this); 379 uword vtable_addr = reinterpret_cast<uword>(this);
380 return reinterpret_cast<cpp_vtable*>(vtable_addr); 380 return reinterpret_cast<cpp_vtable*>(vtable_addr);
381 } 381 }
382 382
383 static cpp_vtable handle_vtable_; 383 static cpp_vtable handle_vtable_;
384 384
385 // The static values below are singletons shared between the different 385 // The static values below are singletons shared between the different
386 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_. 386 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 (value + kWordSize == raw_ptr()->instance_size_))); 456 (value + kWordSize == raw_ptr()->instance_size_)));
457 raw_ptr()->next_field_offset_ = value; 457 raw_ptr()->next_field_offset_ = value;
458 } 458 }
459 459
460 cpp_vtable handle_vtable() const { return raw_ptr()->handle_vtable_; } 460 cpp_vtable handle_vtable() const { return raw_ptr()->handle_vtable_; }
461 void set_handle_vtable(cpp_vtable value) const { 461 void set_handle_vtable(cpp_vtable value) const {
462 raw_ptr()->handle_vtable_ = value; 462 raw_ptr()->handle_vtable_ = value;
463 } 463 }
464 464
465 ObjectKind instance_kind() const { return raw_ptr()->instance_kind_; } 465 ObjectKind instance_kind() const { return raw_ptr()->instance_kind_; }
466 void set_instance_kind(ObjectKind value) { 466 void set_instance_kind(ObjectKind value) const {
467 raw_ptr()->instance_kind_ = value; 467 raw_ptr()->instance_kind_ = value;
468 } 468 }
469 469
470 intptr_t index() const { return raw_ptr()->index_; }
471 void set_index(intptr_t value) const {
472 raw_ptr()->index_ = value;
473 }
474
470 RawString* Name() const; 475 RawString* Name() const;
471 476
472 RawScript* script() const { return raw_ptr()->script_; } 477 RawScript* script() const { return raw_ptr()->script_; }
473 478
474 intptr_t token_index() const { return raw_ptr()->token_index_; } 479 intptr_t token_index() const { return raw_ptr()->token_index_; }
475 480
476 // This class represents the signature class of a closure function if 481 // This class represents the signature class of a closure function if
477 // signature_function() is not null. 482 // signature_function() is not null.
478 // The associated function may be a closure function (with code) or a 483 // The associated function may be a closure function (with code) or a
479 // signature function (without code) solely describing the result type and 484 // signature function (without code) solely describing the result type and
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 } 675 }
671 void set_allocation_stub(const Code& value) const; 676 void set_allocation_stub(const Code& value) const;
672 677
673 RawArray* constants() const; 678 RawArray* constants() const;
674 679
675 void Finalize() const; 680 void Finalize() const;
676 681
677 // Allocate a class used for VM internal objects. 682 // Allocate a class used for VM internal objects.
678 template <class FakeObject> static RawClass* New(); 683 template <class FakeObject> static RawClass* New();
679 684
680 // Allocate an instance class which has a VM implementation.
681 template <class FakeInstance> static RawClass* New(const String& name,
682 const Script& script,
683 intptr_t token_index);
684
685 // Allocate instance classes and interfaces. 685 // Allocate instance classes and interfaces.
686 static RawClass* New(const String& name, 686 static RawClass* New(const String& name,
687 const Script& script, 687 const Script& script,
688 intptr_t token_index); 688 intptr_t token_index);
689 static RawClass* NewInterface(const String& name, 689 static RawClass* NewInterface(const String& name,
690 const Script& script, 690 const Script& script,
691 intptr_t token_index); 691 intptr_t token_index);
692 static RawClass* NewNativeWrapper(Library* library, 692 static RawClass* NewNativeWrapper(Library* library,
693 const String& name, 693 const String& name,
694 int num_fields); 694 int num_fields);
(...skipping 28 matching lines...) Expand all
723 723
724 void CalculateFieldOffsets() const; 724 void CalculateFieldOffsets() const;
725 725
726 // Assigns empty array to all raw class array fields. 726 // Assigns empty array to all raw class array fields.
727 void InitEmptyFields(); 727 void InitEmptyFields();
728 728
729 RawFunction* LookupAccessorFunction(const char* prefix, 729 RawFunction* LookupAccessorFunction(const char* prefix,
730 intptr_t prefix_length, 730 intptr_t prefix_length,
731 const String& name) const; 731 const String& name) const;
732 732
733 // Allocate an instance class which has a VM implementation.
734 template <class FakeInstance> static RawClass* New(intptr_t index);
735 template <class FakeInstance> static RawClass* New(const String& name,
736 const Script& script,
737 intptr_t token_index);
738
733 HEAP_OBJECT_IMPLEMENTATION(Class, Object); 739 HEAP_OBJECT_IMPLEMENTATION(Class, Object);
734 friend class Object; 740 friend class Object;
735 friend class Instance; 741 friend class Instance;
736 friend class Type; 742 friend class Type;
737 }; 743 };
738 744
739 745
740 // Unresolved class is used for storing unresolved names which will be resolved 746 // Unresolved class is used for storing unresolved names which will be resolved
741 // to a class after all classes have been loaded and finalized. 747 // to a class after all classes have been loaded and finalized.
742 class UnresolvedClass : public Object { 748 class UnresolvedClass : public Object {
(...skipping 3187 matching lines...) Expand 10 before | Expand all | Expand 10 after
3930 friend class Class; 3936 friend class Class;
3931 }; 3937 };
3932 3938
3933 3939
3934 // Breaking cycles and loops. 3940 // Breaking cycles and loops.
3935 RawClass* Object::clazz() const { 3941 RawClass* Object::clazz() const {
3936 uword raw_value = reinterpret_cast<uword>(raw_); 3942 uword raw_value = reinterpret_cast<uword>(raw_);
3937 if ((raw_value & kSmiTagMask) == kSmiTag) { 3943 if ((raw_value & kSmiTagMask) == kSmiTag) {
3938 return Smi::Class(); 3944 return Smi::Class();
3939 } 3945 }
3940 return raw_->ptr()->class_; 3946 RawClass* result = raw_->ptr()->class_;
3947 ASSERT(result->ptr()->index_ ==
3948 RawObject::ClassTag::decode(raw_->ptr()->tags_));
3949 ASSERT(Isolate::Current()->class_table()->At(
3950 RawObject::ClassTag::decode(raw_->ptr()->tags_)) == result);
3951 return result;
3941 } 3952 }
3942 3953
3943 3954
3944 void Object::SetRaw(RawObject* value) { 3955 void Object::SetRaw(RawObject* value) {
3945 // NOTE: The assignment "raw_ = value" should be the first statement in 3956 // NOTE: The assignment "raw_ = value" should be the first statement in
3946 // this function. Also do not use 'value' in this function after the 3957 // this function. Also do not use 'value' in this function after the
3947 // assignment (use 'raw_' instead). 3958 // assignment (use 'raw_' instead).
3948 raw_ = value; 3959 raw_ = value;
3949 if ((reinterpret_cast<uword>(raw_) & kSmiTagMask) == kSmiTag) { 3960 if ((reinterpret_cast<uword>(raw_) & kSmiTagMask) == kSmiTag) {
3950 set_vtable(Smi::handle_vtable_); 3961 set_vtable(Smi::handle_vtable_);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4003 } 4014 }
4004 4015
4005 4016
4006 intptr_t Stackmap::SizeInBits() const { 4017 intptr_t Stackmap::SizeInBits() const {
4007 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); 4018 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte);
4008 } 4019 }
4009 4020
4010 } // namespace dart 4021 } // namespace dart
4011 4022
4012 #endif // VM_OBJECT_H_ 4023 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « vm/isolate.cc ('k') | vm/object.cc » ('j') | vm/raw_object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698