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

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

Issue 1410573006: Cache initial (empty) ic_data arrays so that they are not repeatedly allocated. Factor out descript… (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: address comment Created 5 years, 1 month 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
« no previous file with comments | « runtime/vm/dart.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 1994 matching lines...) Expand 10 before | Expand all | Expand 10 after
2005 2005
2006 // It is only meaningful to interptret range feedback stored in the ICData 2006 // It is only meaningful to interptret range feedback stored in the ICData
2007 // when all checks are Mint or Smi. 2007 // when all checks are Mint or Smi.
2008 bool HasRangeFeedback() const; 2008 bool HasRangeFeedback() const;
2009 RangeFeedback DecodeRangeFeedbackAt(intptr_t idx) const; 2009 RangeFeedback DecodeRangeFeedbackAt(intptr_t idx) const;
2010 2010
2011 void PrintToJSONArray(const JSONArray& jsarray, 2011 void PrintToJSONArray(const JSONArray& jsarray,
2012 intptr_t token_pos, 2012 intptr_t token_pos,
2013 bool is_static_call) const; 2013 bool is_static_call) const;
2014 2014
2015 // Initialize the preallocated empty ICData entry arrays.
2016 static void InitOnce();
2017
2018 enum {
2019 kCachedICDataArrayCount = 4
2020 };
2021
2015 private: 2022 private:
2016 static RawICData* New(); 2023 static RawICData* New();
2017 2024
2018 RawArray* ic_data() const { 2025 RawArray* ic_data() const {
2019 return raw_ptr()->ic_data_; 2026 return raw_ptr()->ic_data_;
2020 } 2027 }
2021 2028
2022 void set_owner(const Function& value) const; 2029 void set_owner(const Function& value) const;
2023 void set_target_name(const String& value) const; 2030 void set_target_name(const String& value) const;
2024 void set_arguments_descriptor(const Array& value) const; 2031 void set_arguments_descriptor(const Array& value) const;
(...skipping 19 matching lines...) Expand all
2044 class IssuedJSWarningBit : public BitField<bool, kIssuedJSWarningBit, 1> {}; 2051 class IssuedJSWarningBit : public BitField<bool, kIssuedJSWarningBit, 1> {};
2045 class RangeFeedbackBits : public BitField<uint32_t, 2052 class RangeFeedbackBits : public BitField<uint32_t,
2046 ICData::kRangeFeedbackPos, ICData::kRangeFeedbackSize> {}; // NOLINT 2053 ICData::kRangeFeedbackPos, ICData::kRangeFeedbackSize> {}; // NOLINT
2047 2054
2048 #if defined(DEBUG) 2055 #if defined(DEBUG)
2049 // Used in asserts to verify that a check is not added twice. 2056 // Used in asserts to verify that a check is not added twice.
2050 bool HasCheck(const GrowableArray<intptr_t>& cids) const; 2057 bool HasCheck(const GrowableArray<intptr_t>& cids) const;
2051 #endif // DEBUG 2058 #endif // DEBUG
2052 2059
2053 intptr_t TestEntryLength() const; 2060 intptr_t TestEntryLength() const;
2061 static RawArray* NewNonCachedEmptyICDataArray(intptr_t num_args_tested);
2062 static RawArray* NewEmptyICDataArray(intptr_t num_args_tested);
2063 static RawICData* NewDescriptor(Zone* zone,
2064 const Function& owner,
2065 const String& target_name,
2066 const Array& arguments_descriptor,
2067 intptr_t deopt_id,
2068 intptr_t num_args_tested);
2069
2054 static void WriteSentinel(const Array& data, intptr_t test_entry_length); 2070 static void WriteSentinel(const Array& data, intptr_t test_entry_length);
2055 2071
2072 // A cache of VM heap allocated preinitialized empty ic data entry arrays.
2073 static RawArray* cached_icdata_arrays_[kCachedICDataArrayCount];
2074
2056 FINAL_HEAP_OBJECT_IMPLEMENTATION(ICData, Object); 2075 FINAL_HEAP_OBJECT_IMPLEMENTATION(ICData, Object);
2057 friend class Class; 2076 friend class Class;
2077 friend class SnapshotReader;
2078 friend class SnapshotWriter;
2058 }; 2079 };
2059 2080
2060 2081
2061 class Function : public Object { 2082 class Function : public Object {
2062 public: 2083 public:
2063 RawString* name() const { return raw_ptr()->name_; } 2084 RawString* name() const { return raw_ptr()->name_; }
2064 RawString* PrettyName() const; 2085 RawString* PrettyName() const;
2065 RawString* UserVisibleName() const; 2086 RawString* UserVisibleName() const;
2066 RawString* QualifiedPrettyName() const; 2087 RawString* QualifiedPrettyName() const;
2067 RawString* QualifiedUserVisibleName() const; 2088 RawString* QualifiedUserVisibleName() const;
(...skipping 6108 matching lines...) Expand 10 before | Expand all | Expand 10 after
8176 8197
8177 8198
8178 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 8199 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
8179 intptr_t index) { 8200 intptr_t index) {
8180 return array.At((index * kEntryLength) + kTargetFunctionIndex); 8201 return array.At((index * kEntryLength) + kTargetFunctionIndex);
8181 } 8202 }
8182 8203
8183 } // namespace dart 8204 } // namespace dart
8184 8205
8185 #endif // VM_OBJECT_H_ 8206 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/dart.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698