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

Side by Side Diff: runtime/vm/object.h

Issue 16174008: - Create isolate specific resuable handles and use them in the hot lookup paths. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 object() : super() {} \ 162 object() : super() {} \
163 BASE_OBJECT_IMPLEMENTATION(object, super) \ 163 BASE_OBJECT_IMPLEMENTATION(object, super) \
164 164
165 #define HEAP_OBJECT_IMPLEMENTATION(object, super) \ 165 #define HEAP_OBJECT_IMPLEMENTATION(object, super) \
166 OBJECT_IMPLEMENTATION(object, super); \ 166 OBJECT_IMPLEMENTATION(object, super); \
167 Raw##object* raw_ptr() const { \ 167 Raw##object* raw_ptr() const { \
168 ASSERT(raw() != null()); \ 168 ASSERT(raw() != null()); \
169 return raw()->ptr(); \ 169 return raw()->ptr(); \
170 } \ 170 } \
171 SNAPSHOT_READER_SUPPORT(object) \ 171 SNAPSHOT_READER_SUPPORT(object) \
172 friend class Isolate; \
172 friend class StackFrame; \ 173 friend class StackFrame; \
173 174
174 // This macro is used to denote types that do not have a sub-type. 175 // This macro is used to denote types that do not have a sub-type.
175 #define FINAL_HEAP_OBJECT_IMPLEMENTATION(object, super) \ 176 #define FINAL_HEAP_OBJECT_IMPLEMENTATION(object, super) \
176 public: /* NOLINT */ \ 177 public: /* NOLINT */ \
177 void operator=(Raw##object* value) { \ 178 void operator=(Raw##object* value) { \
178 raw_ = value; \ 179 raw_ = value; \
179 CHECK_HANDLE(); \ 180 CHECK_HANDLE(); \
180 } \ 181 } \
181 void operator^=(RawObject* value) { \ 182 void operator^=(RawObject* value) { \
182 raw_ = value; \ 183 raw_ = value; \
183 CHECK_HANDLE(); \ 184 CHECK_HANDLE(); \
184 } \ 185 } \
185 private: /* NOLINT */ \ 186 private: /* NOLINT */ \
186 object() : super() {} \ 187 object() : super() {} \
187 BASE_OBJECT_IMPLEMENTATION(object, super) \ 188 BASE_OBJECT_IMPLEMENTATION(object, super) \
188 Raw##object* raw_ptr() const { \ 189 Raw##object* raw_ptr() const { \
189 ASSERT(raw() != null()); \ 190 ASSERT(raw() != null()); \
190 return raw()->ptr(); \ 191 return raw()->ptr(); \
191 } \ 192 } \
192 SNAPSHOT_READER_SUPPORT(object) \ 193 SNAPSHOT_READER_SUPPORT(object) \
194 friend class Isolate; \
193 friend class StackFrame; \ 195 friend class StackFrame; \
194 196
195 class Object { 197 class Object {
196 public: 198 public:
197 virtual ~Object() { } 199 virtual ~Object() { }
198 200
199 RawObject* raw() const { return raw_; } 201 RawObject* raw() const { return raw_; }
200 void operator=(RawObject* value) { 202 void operator=(RawObject* value) {
201 initializeHandle(this, value); 203 initializeHandle(this, value);
202 } 204 }
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 static LanguageError* snapshot_writer_error_; 586 static LanguageError* snapshot_writer_error_;
585 587
586 friend void ClassTable::Register(const Class& cls); 588 friend void ClassTable::Register(const Class& cls);
587 friend void RawObject::Validate(Isolate* isolate) const; 589 friend void RawObject::Validate(Isolate* isolate) const;
588 friend class Closure; 590 friend class Closure;
589 friend class SnapshotReader; 591 friend class SnapshotReader;
590 friend class OneByteString; 592 friend class OneByteString;
591 friend class TwoByteString; 593 friend class TwoByteString;
592 friend class ExternalOneByteString; 594 friend class ExternalOneByteString;
593 friend class ExternalTwoByteString; 595 friend class ExternalTwoByteString;
596 friend class Isolate;
594 597
595 DISALLOW_ALLOCATION(); 598 DISALLOW_ALLOCATION();
596 DISALLOW_COPY_AND_ASSIGN(Object); 599 DISALLOW_COPY_AND_ASSIGN(Object);
597 }; 600 };
598 601
599 602
600 class Class : public Object { 603 class Class : public Object {
601 public: 604 public:
602 intptr_t instance_size() const { 605 intptr_t instance_size() const {
603 ASSERT(is_finalized() || is_prefinalized()); 606 ASSERT(is_finalized() || is_prefinalized());
(...skipping 1743 matching lines...) Expand 10 before | Expand all | Expand 10 after
2347 void AddMetadata(const Class& cls, 2350 void AddMetadata(const Class& cls,
2348 const String& name, 2351 const String& name,
2349 intptr_t token_pos) const; 2352 intptr_t token_pos) const;
2350 2353
2351 FINAL_HEAP_OBJECT_IMPLEMENTATION(Library, Object); 2354 FINAL_HEAP_OBJECT_IMPLEMENTATION(Library, Object);
2352 2355
2353 friend class Bootstrap; 2356 friend class Bootstrap;
2354 friend class Class; 2357 friend class Class;
2355 friend class Debugger; 2358 friend class Debugger;
2356 friend class DictionaryIterator; 2359 friend class DictionaryIterator;
2357 friend class Isolate;
2358 friend class Namespace; 2360 friend class Namespace;
2359 friend class Object; 2361 friend class Object;
2360 }; 2362 };
2361 2363
2362 2364
2363 class LibraryPrefix : public Object { 2365 class LibraryPrefix : public Object {
2364 public: 2366 public:
2365 RawString* name() const { return raw_ptr()->name_; } 2367 RawString* name() const { return raw_ptr()->name_; }
2366 virtual RawString* DictionaryName() const { return name(); } 2368 virtual RawString* DictionaryName() const { return name(); }
2367 2369
(...skipping 15 matching lines...) Expand all
2383 static const int kInitialSize = 2; 2385 static const int kInitialSize = 2;
2384 static const int kIncrementSize = 2; 2386 static const int kIncrementSize = 2;
2385 2387
2386 void set_name(const String& value) const; 2388 void set_name(const String& value) const;
2387 void set_imports(const Array& value) const; 2389 void set_imports(const Array& value) const;
2388 void set_num_imports(intptr_t value) const; 2390 void set_num_imports(intptr_t value) const;
2389 static RawLibraryPrefix* New(); 2391 static RawLibraryPrefix* New();
2390 2392
2391 FINAL_HEAP_OBJECT_IMPLEMENTATION(LibraryPrefix, Object); 2393 FINAL_HEAP_OBJECT_IMPLEMENTATION(LibraryPrefix, Object);
2392 friend class Class; 2394 friend class Class;
2393 friend class Isolate;
2394 }; 2395 };
2395 2396
2396 2397
2397 class Namespace : public Object { 2398 class Namespace : public Object {
2398 public: 2399 public:
2399 RawLibrary* library() const { return raw_ptr()->library_; } 2400 RawLibrary* library() const { return raw_ptr()->library_; }
2400 RawArray* show_names() const { return raw_ptr()->show_names_; } 2401 RawArray* show_names() const { return raw_ptr()->show_names_; }
2401 RawArray* hide_names() const { return raw_ptr()->hide_names_; } 2402 RawArray* hide_names() const { return raw_ptr()->hide_names_; }
2402 2403
2403 static intptr_t InstanceSize() { 2404 static intptr_t InstanceSize() {
(...skipping 3397 matching lines...) Expand 10 before | Expand all | Expand 10 after
5801 // Breaking cycles and loops. 5802 // Breaking cycles and loops.
5802 RawClass* Object::clazz() const { 5803 RawClass* Object::clazz() const {
5803 uword raw_value = reinterpret_cast<uword>(raw_); 5804 uword raw_value = reinterpret_cast<uword>(raw_);
5804 if ((raw_value & kSmiTagMask) == kSmiTag) { 5805 if ((raw_value & kSmiTagMask) == kSmiTag) {
5805 return Smi::Class(); 5806 return Smi::Class();
5806 } 5807 }
5807 return Isolate::Current()->class_table()->At(raw()->GetClassId()); 5808 return Isolate::Current()->class_table()->At(raw()->GetClassId());
5808 } 5809 }
5809 5810
5810 5811
5811 void Object::SetRaw(RawObject* value) { 5812 inline void Object::SetRaw(RawObject* value) {
5812 // NOTE: The assignment "raw_ = value" should be the first statement in 5813 // NOTE: The assignment "raw_ = value" should be the first statement in
5813 // this function. Also do not use 'value' in this function after the 5814 // this function. Also do not use 'value' in this function after the
5814 // assignment (use 'raw_' instead). 5815 // assignment (use 'raw_' instead).
5815 raw_ = value; 5816 raw_ = value;
5816 if ((reinterpret_cast<uword>(raw_) & kSmiTagMask) == kSmiTag) { 5817 cpp_vtable vtable_ptr;
5817 set_vtable(Smi::handle_vtable_); 5818 if ((reinterpret_cast<uword>(value) & kSmiTagMask) == kSmiTag) {
5818 return; 5819 vtable_ptr = Smi::handle_vtable_;
5820 } else {
5821 intptr_t cid = value->GetClassId();
5822 if (cid >= kNumPredefinedCids) {
5823 cid = kInstanceCid;
5824 }
5825 vtable_ptr = builtin_vtables_[cid];
5819 } 5826 }
5820 intptr_t cid = raw_->GetClassId(); 5827 set_vtable(vtable_ptr);
5821 if (cid >= kNumPredefinedCids) {
5822 cid = kInstanceCid;
5823 }
5824 set_vtable(builtin_vtables_[cid]);
5825 #if defined(DEBUG) 5828 #if defined(DEBUG)
5826 if (FLAG_verify_handles) { 5829 if (FLAG_verify_handles) {
5827 Isolate* isolate = Isolate::Current(); 5830 Isolate* isolate = Isolate::Current();
5828 Heap* isolate_heap = isolate->heap(); 5831 Heap* isolate_heap = isolate->heap();
5829 Heap* vm_isolate_heap = Dart::vm_isolate()->heap(); 5832 Heap* vm_isolate_heap = Dart::vm_isolate()->heap();
5830 ASSERT(isolate_heap->Contains(RawObject::ToAddr(raw_)) || 5833 ASSERT(isolate_heap->Contains(RawObject::ToAddr(raw_)) ||
5831 vm_isolate_heap->Contains(RawObject::ToAddr(raw_))); 5834 vm_isolate_heap->Contains(RawObject::ToAddr(raw_)));
5832 } 5835 }
5833 #endif 5836 #endif
5834 } 5837 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
5917 5920
5918 5921
5919 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 5922 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
5920 intptr_t index) { 5923 intptr_t index) {
5921 return array.At((index * kEntryLength) + kTargetFunctionIndex); 5924 return array.At((index * kEntryLength) + kTargetFunctionIndex);
5922 } 5925 }
5923 5926
5924 } // namespace dart 5927 } // namespace dart
5925 5928
5926 #endif // VM_OBJECT_H_ 5929 #endif // VM_OBJECT_H_
OLDNEW
« runtime/vm/handles.h ('K') | « runtime/vm/isolate.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698