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

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

Issue 10540045: - Get handle vtable from a static table for predefined classes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
« no previous file with comments | « runtime/vm/class_table.cc ('k') | runtime/vm/object.cc » ('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 #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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 372
373 private: 373 private:
374 static void InitializeObject(uword address, intptr_t id, intptr_t size); 374 static void InitializeObject(uword address, intptr_t id, intptr_t size);
375 375
376 cpp_vtable* vtable_address() const { 376 cpp_vtable* vtable_address() const {
377 uword vtable_addr = reinterpret_cast<uword>(this); 377 uword vtable_addr = reinterpret_cast<uword>(this);
378 return reinterpret_cast<cpp_vtable*>(vtable_addr); 378 return reinterpret_cast<cpp_vtable*>(vtable_addr);
379 } 379 }
380 380
381 static cpp_vtable handle_vtable_; 381 static cpp_vtable handle_vtable_;
382 static cpp_vtable builtin_vtables_[kNumPredefinedKinds];
382 383
383 // The static values below are singletons shared between the different 384 // The static values below are singletons shared between the different
384 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_. 385 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_.
385 static RawObject* null_; 386 static RawObject* null_;
386 static RawInstance* sentinel_; 387 static RawInstance* sentinel_;
387 static RawInstance* transition_sentinel_; 388 static RawInstance* transition_sentinel_;
388 389
389 static RawClass* class_class_; // Class of the Class vm object. 390 static RawClass* class_class_; // Class of the Class vm object.
390 static RawClass* null_class_; // Class of the null object. 391 static RawClass* null_class_; // Class of the null object.
391 static RawClass* dynamic_class_; // Class of the 'Dynamic' type. 392 static RawClass* dynamic_class_; // Class of the 'Dynamic' type.
(...skipping 19 matching lines...) Expand all
411 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers. 412 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers.
412 static RawClass* context_class_; // Class of the Context vm object. 413 static RawClass* context_class_; // Class of the Context vm object.
413 static RawClass* context_scope_class_; // Class of ContextScope vm object. 414 static RawClass* context_scope_class_; // Class of ContextScope vm object.
414 static RawClass* icdata_class_; // Class of ICData. 415 static RawClass* icdata_class_; // Class of ICData.
415 static RawClass* subtypetestcache_class_; // Class of SubtypeTestCache. 416 static RawClass* subtypetestcache_class_; // Class of SubtypeTestCache.
416 static RawClass* api_error_class_; // Class of ApiError. 417 static RawClass* api_error_class_; // Class of ApiError.
417 static RawClass* language_error_class_; // Class of LanguageError. 418 static RawClass* language_error_class_; // Class of LanguageError.
418 static RawClass* unhandled_exception_class_; // Class of UnhandledException. 419 static RawClass* unhandled_exception_class_; // Class of UnhandledException.
419 static RawClass* unwind_error_class_; // Class of UnwindError. 420 static RawClass* unwind_error_class_; // Class of UnwindError.
420 421
422 friend void ClassTable::Register(const Class& cls);
421 friend void RawObject::Validate(Isolate* isolate) const; 423 friend void RawObject::Validate(Isolate* isolate) const;
422 friend class SnapshotReader; 424 friend class SnapshotReader;
423 425
424 // Disallow allocation. 426 // Disallow allocation.
425 void* operator new(size_t size); 427 void* operator new(size_t size);
426 // Disallow copy constructor. 428 // Disallow copy constructor.
427 DISALLOW_COPY_AND_ASSIGN(Object); 429 DISALLOW_COPY_AND_ASSIGN(Object);
428 }; 430 };
429 431
430 432
(...skipping 4463 matching lines...) Expand 10 before | Expand all | Expand 10 after
4894 4896
4895 void Object::SetRaw(RawObject* value) { 4897 void Object::SetRaw(RawObject* value) {
4896 // NOTE: The assignment "raw_ = value" should be the first statement in 4898 // NOTE: The assignment "raw_ = value" should be the first statement in
4897 // this function. Also do not use 'value' in this function after the 4899 // this function. Also do not use 'value' in this function after the
4898 // assignment (use 'raw_' instead). 4900 // assignment (use 'raw_' instead).
4899 raw_ = value; 4901 raw_ = value;
4900 if ((reinterpret_cast<uword>(raw_) & kSmiTagMask) == kSmiTag) { 4902 if ((reinterpret_cast<uword>(raw_) & kSmiTagMask) == kSmiTag) {
4901 set_vtable(Smi::handle_vtable_); 4903 set_vtable(Smi::handle_vtable_);
4902 return; 4904 return;
4903 } 4905 }
4904 #ifdef DEBUG 4906 #if defined(DEBUG)
4905 Heap* isolate_heap = Isolate::Current()->heap(); 4907 Isolate* isolate = Isolate::Current();
4908 Heap* isolate_heap = isolate->heap();
4906 Heap* vm_isolate_heap = Dart::vm_isolate()->heap(); 4909 Heap* vm_isolate_heap = Dart::vm_isolate()->heap();
4907 ASSERT(isolate_heap->Contains(reinterpret_cast<uword>(raw_->ptr())) || 4910 ASSERT(isolate_heap->Contains(reinterpret_cast<uword>(raw_->ptr())) ||
4908 vm_isolate_heap->Contains(reinterpret_cast<uword>(raw_->ptr()))); 4911 vm_isolate_heap->Contains(reinterpret_cast<uword>(raw_->ptr())));
4909 #endif 4912 #endif
4910 if (raw_ == null_) { 4913 if (raw_ == null_) {
4911 set_vtable(handle_vtable_); 4914 set_vtable(handle_vtable_);
siva 2012/06/07 17:32:25 I am wondering if we should pull the "if (raw_ ==
Ivan Posva 2012/06/07 20:00:56 Done. https://chromiumcodereview.appspot.com/10541
4912 } else { 4915 } else {
4913 RawClass* raw_class = 4916 intptr_t cid = raw_->GetClassId();
4914 Isolate::Current()->class_table()->At(raw_->GetClassId()); 4917 if (cid < kNumPredefinedKinds) {
4915 set_vtable(raw_class->ptr()->handle_vtable_); 4918 ASSERT(builtin_vtables_[cid] ==
4919 isolate->class_table()->At(cid)->ptr()->handle_vtable_);
4920 set_vtable(builtin_vtables_[cid]);
4921 } else {
4922 #if !defined(DEBUG)
4923 Isolate* isolate = Isolate::Current();
4924 #endif
4925 RawClass* raw_class = isolate->class_table()->At(cid);
4926 set_vtable(raw_class->ptr()->handle_vtable_);
4927 }
4916 } 4928 }
4917 } 4929 }
4918 4930
4919 4931
4920 bool Function::HasCode() const { 4932 bool Function::HasCode() const {
4921 return raw_ptr()->code_ != Code::null(); 4933 return raw_ptr()->code_ != Code::null();
4922 } 4934 }
4923 4935
4924 4936
4925 intptr_t Field::Offset() const { 4937 intptr_t Field::Offset() const {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4959 } 4971 }
4960 4972
4961 4973
4962 intptr_t Stackmap::SizeInBits() const { 4974 intptr_t Stackmap::SizeInBits() const {
4963 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); 4975 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte);
4964 } 4976 }
4965 4977
4966 } // namespace dart 4978 } // namespace dart
4967 4979
4968 #endif // VM_OBJECT_H_ 4980 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/class_table.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698