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

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

Issue 9395016: First part of new ICData infrastructure: use a wrapper object instead of an array. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 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/ic_data_test.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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 kInstructionsClass, 152 kInstructionsClass,
153 kPcDescriptorsClass, 153 kPcDescriptorsClass,
154 kLocalVarDescriptorsClass, 154 kLocalVarDescriptorsClass,
155 kExceptionHandlersClass, 155 kExceptionHandlersClass,
156 kContextClass, 156 kContextClass,
157 kContextScopeClass, 157 kContextScopeClass,
158 kApiErrorClass, 158 kApiErrorClass,
159 kLanguageErrorClass, 159 kLanguageErrorClass,
160 kUnhandledExceptionClass, 160 kUnhandledExceptionClass,
161 kUnwindErrorClass, 161 kUnwindErrorClass,
162 kICDataClass,
162 kMaxId, 163 kMaxId,
163 kInvalidIndex = -1, 164 kInvalidIndex = -1,
164 }; 165 };
165 166
166 virtual ~Object() { } 167 virtual ~Object() { }
167 168
168 RawObject* raw() const { return raw_; } 169 RawObject* raw() const { return raw_; }
169 void operator=(RawObject* value) { SetRaw(value); } 170 void operator=(RawObject* value) { SetRaw(value); }
170 171
171 void set_tags(intptr_t value) const { 172 void set_tags(intptr_t value) const {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 return exception_handlers_class_; 291 return exception_handlers_class_;
291 } 292 }
292 static RawClass* context_class() { return context_class_; } 293 static RawClass* context_class() { return context_class_; }
293 static RawClass* context_scope_class() { return context_scope_class_; } 294 static RawClass* context_scope_class() { return context_scope_class_; }
294 static RawClass* api_error_class() { return api_error_class_; } 295 static RawClass* api_error_class() { return api_error_class_; }
295 static RawClass* language_error_class() { return language_error_class_; } 296 static RawClass* language_error_class() { return language_error_class_; }
296 static RawClass* unhandled_exception_class() { 297 static RawClass* unhandled_exception_class() {
297 return unhandled_exception_class_; 298 return unhandled_exception_class_;
298 } 299 }
299 static RawClass* unwind_error_class() { return unwind_error_class_; } 300 static RawClass* unwind_error_class() { return unwind_error_class_; }
301 static RawClass* icdata_class() { return icdata_class_; }
300 302
301 static int GetSingletonClassIndex(const RawClass* raw_class); 303 static int GetSingletonClassIndex(const RawClass* raw_class);
302 static RawClass* GetSingletonClass(int index); 304 static RawClass* GetSingletonClass(int index);
303 static const char* GetSingletonClassName(int index); 305 static const char* GetSingletonClassName(int index);
304 306
305 static RawClass* CreateAndRegisterInterface(const char* cname, 307 static RawClass* CreateAndRegisterInterface(const char* cname,
306 const Script& script, 308 const Script& script,
307 const Library& lib); 309 const Library& lib);
308 static void RegisterClass(const Class& cls, 310 static void RegisterClass(const Class& cls,
309 const char* cname, 311 const char* cname,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 static RawClass* instructions_class_; // Class of the Instructions vm object. 398 static RawClass* instructions_class_; // Class of the Instructions vm object.
397 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object. 399 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object.
398 static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors. 400 static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors.
399 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers. 401 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers.
400 static RawClass* context_class_; // Class of the Context vm object. 402 static RawClass* context_class_; // Class of the Context vm object.
401 static RawClass* context_scope_class_; // Class of ContextScope vm object. 403 static RawClass* context_scope_class_; // Class of ContextScope vm object.
402 static RawClass* api_error_class_; // Class of ApiError. 404 static RawClass* api_error_class_; // Class of ApiError.
403 static RawClass* language_error_class_; // Class of LanguageError. 405 static RawClass* language_error_class_; // Class of LanguageError.
404 static RawClass* unhandled_exception_class_; // Class of UnhandledException. 406 static RawClass* unhandled_exception_class_; // Class of UnhandledException.
405 static RawClass* unwind_error_class_; // Class of UnwindError. 407 static RawClass* unwind_error_class_; // Class of UnwindError.
408 static RawClass* icdata_class_; // Class of ICData.
406 409
407 friend void RawObject::Validate() const; 410 friend void RawObject::Validate() const;
408 friend class SnapshotReader; 411 friend class SnapshotReader;
409 412
410 // Disallow allocation. 413 // Disallow allocation.
411 void* operator new(size_t size); 414 void* operator new(size_t size);
412 // Disallow copy constructor. 415 // Disallow copy constructor.
413 DISALLOW_COPY_AND_ASSIGN(Object); 416 DISALLOW_COPY_AND_ASSIGN(Object);
414 }; 417 };
415 418
(...skipping 1662 matching lines...) Expand 10 before | Expand all | Expand 10 after
2078 StorePointer(&raw_ptr()->pc_descriptors_, descriptors.raw()); 2081 StorePointer(&raw_ptr()->pc_descriptors_, descriptors.raw());
2079 } 2082 }
2080 2083
2081 RawLocalVarDescriptors* var_descriptors() const { 2084 RawLocalVarDescriptors* var_descriptors() const {
2082 return raw_ptr()->var_descriptors_; 2085 return raw_ptr()->var_descriptors_;
2083 } 2086 }
2084 void set_var_descriptors(const LocalVarDescriptors& value) const { 2087 void set_var_descriptors(const LocalVarDescriptors& value) const {
2085 StorePointer(&raw_ptr()->var_descriptors_, value.raw()); 2088 StorePointer(&raw_ptr()->var_descriptors_, value.raw());
2086 } 2089 }
2087 2090
2088 // See class ICData for interpretation of the 'ic_data_' array.
2089 RawArray* ic_data() const;
2090 void set_ic_data(const Array& ic_data) const;
2091
2092 RawExceptionHandlers* exception_handlers() const { 2091 RawExceptionHandlers* exception_handlers() const {
2093 return raw_ptr()->exception_handlers_; 2092 return raw_ptr()->exception_handlers_;
2094 } 2093 }
2095 void set_exception_handlers(const ExceptionHandlers& handlers) const { 2094 void set_exception_handlers(const ExceptionHandlers& handlers) const {
2096 StorePointer(&raw_ptr()->exception_handlers_, handlers.raw()); 2095 StorePointer(&raw_ptr()->exception_handlers_, handlers.raw());
2097 } 2096 }
2098 2097
2099 RawFunction* function() const { 2098 RawFunction* function() const {
2100 return raw_ptr()->function_; 2099 return raw_ptr()->function_;
2101 } 2100 }
(...skipping 22 matching lines...) Expand all
2124 // Find pc of patch code buffer. Return 0 if not found. 2123 // Find pc of patch code buffer. Return 0 if not found.
2125 uword GetPatchCodePc() const; 2124 uword GetPatchCodePc() const;
2126 2125
2127 uword GetDeoptPcAtNodeId(intptr_t node_id) const; 2126 uword GetDeoptPcAtNodeId(intptr_t node_id) const;
2128 2127
2129 // Returns true if there is an object in the code between 'start_offset' 2128 // Returns true if there is an object in the code between 'start_offset'
2130 // (inclusive) and 'end_offset' (exclusive). 2129 // (inclusive) and 'end_offset' (exclusive).
2131 bool ObjectExistInArea(intptr_t start_offest, intptr_t end_offset) const; 2130 bool ObjectExistInArea(intptr_t start_offest, intptr_t end_offset) const;
2132 2131
2133 // Each (*node_ids)[n] has a an extracted ic data array (*arrays)[n]. 2132 // Each (*node_ids)[n] has a an extracted ic data array (*arrays)[n].
2134 void ExtractIcDataArraysAtCalls(GrowableArray<intptr_t>* node_ids, 2133 void ExtractIcDataArraysAtCalls(
2135 GrowableArray<const Array*>* arrays) const; 2134 GrowableArray<intptr_t>* node_ids,
2135 GrowableArray<const ICData*>* ic_data_objs) const;
2136 2136
2137 private: 2137 private:
2138 static const intptr_t kEntrySize = sizeof(int32_t); // NOLINT 2138 static const intptr_t kEntrySize = sizeof(int32_t); // NOLINT
2139 2139
2140 void set_instructions(RawInstructions* instructions) { 2140 void set_instructions(RawInstructions* instructions) {
2141 raw_ptr()->instructions_ = instructions; 2141 raw_ptr()->instructions_ = instructions;
2142 } 2142 }
2143 void set_pointer_offsets_length(intptr_t value) { 2143 void set_pointer_offsets_length(intptr_t value) {
2144 ASSERT(value >= 0); 2144 ASSERT(value >= 0);
2145 raw_ptr()->pointer_offsets_length_ = value; 2145 raw_ptr()->pointer_offsets_length_ = value;
(...skipping 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after
3605 // This is only safe because we create a new Smi, which does not cause 3605 // This is only safe because we create a new Smi, which does not cause
3606 // heap allocation. 3606 // heap allocation.
3607 raw_ptr()->data_length_ = Smi::New(value); 3607 raw_ptr()->data_length_ = Smi::New(value);
3608 } 3608 }
3609 3609
3610 HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance); 3610 HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance);
3611 friend class Class; 3611 friend class Class;
3612 }; 3612 };
3613 3613
3614 3614
3615 // Object holding information about an IC: test classes and their
3616 // corresponding classes.
3617 class ICData : public Instance {
3618 public:
3619 RawFunction* function() const {
3620 return raw_ptr()->function_;
3621 }
3622
3623 RawString* target_name() const {
3624 return raw_ptr()->target_name_;
3625 }
3626
3627 RawArray* ic_data() const {
3628 return raw_ptr()->ic_data_;
3629 }
3630
3631 intptr_t num_args_tested() const {
3632 return raw_ptr()->num_args_tested_;
3633 }
3634
3635 intptr_t id() const {
3636 return raw_ptr()->id_;
3637 }
3638
3639 intptr_t NumberOfChecks() const;
3640
3641 static intptr_t InstanceSize() {
3642 return RoundedAllocationSize(sizeof(RawICData));
3643 }
3644
3645 static intptr_t target_name_offset() {
3646 return OFFSET_OF(RawICData, target_name_);
3647 }
3648
3649 static intptr_t num_args_tested_offset() {
3650 return OFFSET_OF(RawICData, num_args_tested_);
3651 }
3652
3653 static intptr_t ic_data_offset() {
3654 return OFFSET_OF(RawICData, ic_data_);
3655 }
3656
3657 void AddCheck(const GrowableArray<const Class*>& classes,
3658 const Function& target) const;
3659 void GetCheckAt(intptr_t index,
3660 GrowableArray<const Class*>* classes,
3661 Function* target) const;
3662 void GetOneClassCheckAt(int index, Class* cls, Function* target) const;
3663
3664 static RawICData* New(const Function& caller_function,
3665 const String& target_name,
3666 intptr_t id,
3667 intptr_t num_args_tested);
3668
3669 private:
3670 void set_function(const Function& value) const;
3671 void set_target_name(const String& value) const;
3672 void set_id(intptr_t value) const;
3673 void set_num_args_tested(intptr_t value) const;
3674 void set_ic_data(const Array& value) const;
3675
3676 intptr_t TestEntryLength() const;
3677
3678 HEAP_OBJECT_IMPLEMENTATION(ICData, Instance);
3679 friend class Class;
3680 };
3681
3682
3615 // Breaking cycles and loops. 3683 // Breaking cycles and loops.
3616 RawClass* Object::clazz() const { 3684 RawClass* Object::clazz() const {
3617 uword raw_value = reinterpret_cast<uword>(raw_); 3685 uword raw_value = reinterpret_cast<uword>(raw_);
3618 if ((raw_value & kSmiTagMask) == kSmiTag) { 3686 if ((raw_value & kSmiTagMask) == kSmiTag) {
3619 return Smi::Class(); 3687 return Smi::Class();
3620 } 3688 }
3621 return raw_->ptr()->class_; 3689 return raw_->ptr()->class_;
3622 } 3690 }
3623 3691
3624 3692
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3670 } 3738 }
3671 3739
3672 3740
3673 void Context::SetAt(intptr_t index, const Instance& value) const { 3741 void Context::SetAt(intptr_t index, const Instance& value) const {
3674 StorePointer(InstanceAddr(index), value.raw()); 3742 StorePointer(InstanceAddr(index), value.raw());
3675 } 3743 }
3676 3744
3677 } // namespace dart 3745 } // namespace dart
3678 3746
3679 #endif // VM_OBJECT_H_ 3747 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/ic_data_test.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698