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

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

Issue 11299298: Cache lookups at megamorphic call sites in optimized code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: One change I forgot. Created 8 years 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/megamorphic_cache_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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 static RawClass* deopt_info_class() { return deopt_info_class_; } 287 static RawClass* deopt_info_class() { return deopt_info_class_; }
288 static RawClass* context_class() { return context_class_; } 288 static RawClass* context_class() { return context_class_; }
289 static RawClass* context_scope_class() { return context_scope_class_; } 289 static RawClass* context_scope_class() { return context_scope_class_; }
290 static RawClass* api_error_class() { return api_error_class_; } 290 static RawClass* api_error_class() { return api_error_class_; }
291 static RawClass* language_error_class() { return language_error_class_; } 291 static RawClass* language_error_class() { return language_error_class_; }
292 static RawClass* unhandled_exception_class() { 292 static RawClass* unhandled_exception_class() {
293 return unhandled_exception_class_; 293 return unhandled_exception_class_;
294 } 294 }
295 static RawClass* unwind_error_class() { return unwind_error_class_; } 295 static RawClass* unwind_error_class() { return unwind_error_class_; }
296 static RawClass* icdata_class() { return icdata_class_; } 296 static RawClass* icdata_class() { return icdata_class_; }
297 static RawClass* megamorphic_cache_class() {
298 return megamorphic_cache_class_;
299 }
297 static RawClass* subtypetestcache_class() { return subtypetestcache_class_; } 300 static RawClass* subtypetestcache_class() { return subtypetestcache_class_; }
298 301
299 static RawError* Init(Isolate* isolate); 302 static RawError* Init(Isolate* isolate);
300 static void InitFromSnapshot(Isolate* isolate); 303 static void InitFromSnapshot(Isolate* isolate);
301 static void InitOnce(); 304 static void InitOnce();
302 static void RegisterSingletonClassNames(); 305 static void RegisterSingletonClassNames();
303 static void MakeUnusedSpaceTraversable(const Object& obj, 306 static void MakeUnusedSpaceTraversable(const Object& obj,
304 intptr_t original_size, 307 intptr_t original_size,
305 intptr_t used_size); 308 intptr_t used_size);
306 309
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 static RawClass* code_class_; // Class of the Code vm object. 424 static RawClass* code_class_; // Class of the Code vm object.
422 static RawClass* instructions_class_; // Class of the Instructions vm object. 425 static RawClass* instructions_class_; // Class of the Instructions vm object.
423 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object. 426 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object.
424 static RawClass* stackmap_class_; // Class of Stackmap vm object. 427 static RawClass* stackmap_class_; // Class of Stackmap vm object.
425 static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors. 428 static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors.
426 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers. 429 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers.
427 static RawClass* deopt_info_class_; // Class of DeoptInfo. 430 static RawClass* deopt_info_class_; // Class of DeoptInfo.
428 static RawClass* context_class_; // Class of the Context vm object. 431 static RawClass* context_class_; // Class of the Context vm object.
429 static RawClass* context_scope_class_; // Class of ContextScope vm object. 432 static RawClass* context_scope_class_; // Class of ContextScope vm object.
430 static RawClass* icdata_class_; // Class of ICData. 433 static RawClass* icdata_class_; // Class of ICData.
434 static RawClass* megamorphic_cache_class_; // Class of MegamorphiCache.
431 static RawClass* subtypetestcache_class_; // Class of SubtypeTestCache. 435 static RawClass* subtypetestcache_class_; // Class of SubtypeTestCache.
432 static RawClass* api_error_class_; // Class of ApiError. 436 static RawClass* api_error_class_; // Class of ApiError.
433 static RawClass* language_error_class_; // Class of LanguageError. 437 static RawClass* language_error_class_; // Class of LanguageError.
434 static RawClass* unhandled_exception_class_; // Class of UnhandledException. 438 static RawClass* unhandled_exception_class_; // Class of UnhandledException.
435 static RawClass* unwind_error_class_; // Class of UnwindError. 439 static RawClass* unwind_error_class_; // Class of UnwindError.
436 440
437 friend void ClassTable::Register(const Class& cls); 441 friend void ClassTable::Register(const Class& cls);
438 friend void RawObject::Validate(Isolate* isolate) const; 442 friend void RawObject::Validate(Isolate* isolate) const;
439 friend class Closure; 443 friend class Closure;
440 friend class SnapshotReader; 444 friend class SnapshotReader;
(...skipping 2484 matching lines...) Expand 10 before | Expand all | Expand 10 after
2925 #endif // DEBUG 2929 #endif // DEBUG
2926 2930
2927 intptr_t TestEntryLength() const; 2931 intptr_t TestEntryLength() const;
2928 void WriteSentinel() const; 2932 void WriteSentinel() const;
2929 2933
2930 HEAP_OBJECT_IMPLEMENTATION(ICData, Object); 2934 HEAP_OBJECT_IMPLEMENTATION(ICData, Object);
2931 friend class Class; 2935 friend class Class;
2932 }; 2936 };
2933 2937
2934 2938
2939 class MegamorphicCache : public Object {
2940 public:
2941 static const int kInitialCapacity = 16;
2942 static const double kLoadFactor = 0.75;
2943
2944 RawArray* buckets() const;
2945 void set_buckets(const Array& buckets) const;
2946
2947 intptr_t mask() const;
2948 void set_mask(intptr_t mask) const;
2949
2950 intptr_t filled_entry_count() const;
2951 void set_filled_entry_count(intptr_t num) const;
2952
2953 static intptr_t buckets_offset() {
2954 return OFFSET_OF(RawMegamorphicCache, buckets_);
2955 }
2956 static intptr_t mask_offset() {
2957 return OFFSET_OF(RawMegamorphicCache, mask_);
2958 }
2959
2960 static RawMegamorphicCache* New();
2961
2962 void EnsureCapacity() const;
2963
2964 void Insert(const Smi& class_id, const Function& target) const;
2965
2966 static intptr_t InstanceSize() {
2967 return RoundedAllocationSize(sizeof(RawMegamorphicCache));
2968 }
2969
2970 private:
2971 friend class Class;
2972
2973 enum {
2974 kClassIdIndex,
2975 kTargetFunctionIndex,
2976 kEntryLength,
2977 };
2978
2979 static inline void SetEntry(const Array& array,
2980 intptr_t index,
2981 const Smi& class_id,
2982 const Function& target);
2983
2984 static inline RawObject* GetClassId(const Array& array, intptr_t index);
2985 static inline RawObject* GetTargetFunction(const Array& array,
2986 intptr_t index);
2987
2988 HEAP_OBJECT_IMPLEMENTATION(MegamorphicCache, Object);
2989 };
2990
2991
2935 class SubtypeTestCache : public Object { 2992 class SubtypeTestCache : public Object {
2936 public: 2993 public:
2937 enum Entries { 2994 enum Entries {
2938 kInstanceClassId = 0, 2995 kInstanceClassId = 0,
2939 kInstanceTypeArguments = 1, 2996 kInstanceTypeArguments = 1,
2940 kInstantiatorTypeArguments = 2, 2997 kInstantiatorTypeArguments = 2,
2941 kTestResult = 3, 2998 kTestResult = 3,
2942 kTestEntryLength = 4, 2999 kTestEntryLength = 4,
2943 }; 3000 };
2944 3001
(...skipping 3049 matching lines...) Expand 10 before | Expand all | Expand 10 after
5994 return false; // Lengths don't match. 6051 return false; // Lengths don't match.
5995 } 6052 }
5996 for (intptr_t i = 0; i < len; i++) { 6053 for (intptr_t i = 0; i < len; i++) {
5997 if (this->CharAt(i) != str.CharAt(begin_index + i)) { 6054 if (this->CharAt(i) != str.CharAt(begin_index + i)) {
5998 return false; 6055 return false;
5999 } 6056 }
6000 } 6057 }
6001 return true; 6058 return true;
6002 } 6059 }
6003 6060
6061
6062 void MegamorphicCache::SetEntry(const Array& array,
6063 intptr_t index,
6064 const Smi& class_id,
6065 const Function& target) {
6066 array.SetAt((index * kEntryLength) + kClassIdIndex, class_id);
6067 array.SetAt((index * kEntryLength) + kTargetFunctionIndex, target);
6068 }
6069
6070
6071 RawObject* MegamorphicCache::GetClassId(const Array& array, intptr_t index) {
6072 return array.At((index * kEntryLength) + kClassIdIndex);
6073 }
6074
6075
6076 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6077 intptr_t index) {
6078 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6079 }
6080
6004 } // namespace dart 6081 } // namespace dart
6005 6082
6006 #endif // VM_OBJECT_H_ 6083 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/megamorphic_cache_table.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698