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

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 3401 matching lines...) Expand 10 before | Expand all | Expand 10 after
5805 // Breaking cycles and loops. 5806 // Breaking cycles and loops.
5806 RawClass* Object::clazz() const { 5807 RawClass* Object::clazz() const {
5807 uword raw_value = reinterpret_cast<uword>(raw_); 5808 uword raw_value = reinterpret_cast<uword>(raw_);
5808 if ((raw_value & kSmiTagMask) == kSmiTag) { 5809 if ((raw_value & kSmiTagMask) == kSmiTag) {
5809 return Smi::Class(); 5810 return Smi::Class();
5810 } 5811 }
5811 return Isolate::Current()->class_table()->At(raw()->GetClassId()); 5812 return Isolate::Current()->class_table()->At(raw()->GetClassId());
5812 } 5813 }
5813 5814
5814 5815
5815 void Object::SetRaw(RawObject* value) { 5816 inline void Object::SetRaw(RawObject* value) {
Ivan Posva 2013/06/22 01:01:36 DART_FORCE_INLINE would be a good alternative here
siva 2013/07/18 20:39:23 Done.
5816 // NOTE: The assignment "raw_ = value" should be the first statement in 5817 // NOTE: The assignment "raw_ = value" should be the first statement in
5817 // this function. Also do not use 'value' in this function after the 5818 // this function. Also do not use 'value' in this function after the
5818 // assignment (use 'raw_' instead). 5819 // assignment (use 'raw_' instead).
5819 raw_ = value; 5820 raw_ = value;
5820 if ((reinterpret_cast<uword>(raw_) & kSmiTagMask) == kSmiTag) { 5821 cpp_vtable vtable_ptr;
5821 set_vtable(Smi::handle_vtable_); 5822 if ((reinterpret_cast<uword>(value) & kSmiTagMask) == kSmiTag) {
5822 return; 5823 vtable_ptr = Smi::handle_vtable_;
Ivan Posva 2013/06/22 01:01:36 --verify_handles will fail below when being passed
siva 2013/07/18 20:39:23 Reverted this change as DART_FORCE_INLINE should m
5824 } else {
5825 intptr_t cid = value->GetClassId();
5826 if (cid >= kNumPredefinedCids) {
5827 cid = kInstanceCid;
5828 }
5829 vtable_ptr = builtin_vtables_[cid];
5823 } 5830 }
5824 intptr_t cid = raw_->GetClassId(); 5831 set_vtable(vtable_ptr);
5825 if (cid >= kNumPredefinedCids) {
5826 cid = kInstanceCid;
5827 }
5828 set_vtable(builtin_vtables_[cid]);
5829 #if defined(DEBUG) 5832 #if defined(DEBUG)
5830 if (FLAG_verify_handles) { 5833 if (FLAG_verify_handles) {
5831 Isolate* isolate = Isolate::Current(); 5834 Isolate* isolate = Isolate::Current();
5832 Heap* isolate_heap = isolate->heap(); 5835 Heap* isolate_heap = isolate->heap();
5833 Heap* vm_isolate_heap = Dart::vm_isolate()->heap(); 5836 Heap* vm_isolate_heap = Dart::vm_isolate()->heap();
5834 ASSERT(isolate_heap->Contains(RawObject::ToAddr(raw_)) || 5837 ASSERT(isolate_heap->Contains(RawObject::ToAddr(raw_)) ||
5835 vm_isolate_heap->Contains(RawObject::ToAddr(raw_))); 5838 vm_isolate_heap->Contains(RawObject::ToAddr(raw_)));
5836 } 5839 }
5837 #endif 5840 #endif
5838 } 5841 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
5921 5924
5922 5925
5923 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 5926 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
5924 intptr_t index) { 5927 intptr_t index) {
5925 return array.At((index * kEntryLength) + kTargetFunctionIndex); 5928 return array.At((index * kEntryLength) + kTargetFunctionIndex);
5926 } 5929 }
5927 5930
5928 } // namespace dart 5931 } // namespace dart
5929 5932
5930 #endif // VM_OBJECT_H_ 5933 #endif // VM_OBJECT_H_
OLDNEW
« runtime/vm/isolate.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