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

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

Issue 468793004: VM: Improve performance of method recognizer and unify the it with the intrinsifier. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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/method_recognizer.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"
11 #include "vm/json_stream.h" 11 #include "vm/json_stream.h"
12 #include "vm/bitmap.h" 12 #include "vm/bitmap.h"
13 #include "vm/dart.h" 13 #include "vm/dart.h"
14 #include "vm/globals.h" 14 #include "vm/globals.h"
15 #include "vm/handles.h" 15 #include "vm/handles.h"
16 #include "vm/heap.h" 16 #include "vm/heap.h"
17 #include "vm/isolate.h" 17 #include "vm/isolate.h"
18 #include "vm/method_recognizer.h"
18 #include "vm/os.h" 19 #include "vm/os.h"
19 #include "vm/raw_object.h" 20 #include "vm/raw_object.h"
20 #include "vm/report.h" 21 #include "vm/report.h"
21 #include "vm/scanner.h" 22 #include "vm/scanner.h"
22 #include "vm/tags.h" 23 #include "vm/tags.h"
23 24
24 namespace dart { 25 namespace dart {
25 26
26 // Forward declarations. 27 // Forward declarations.
27 #define DEFINE_FORWARD_DECLARATION(clazz) \ 28 #define DEFINE_FORWARD_DECLARATION(clazz) \
(...skipping 1804 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 bool is_visible() const { 1833 bool is_visible() const {
1833 return VisibleBit::decode(raw_ptr()->kind_tag_); 1834 return VisibleBit::decode(raw_ptr()->kind_tag_);
1834 } 1835 }
1835 void set_is_visible(bool value) const; 1836 void set_is_visible(bool value) const;
1836 1837
1837 bool is_intrinsic() const { 1838 bool is_intrinsic() const {
1838 return IntrinsicBit::decode(raw_ptr()->kind_tag_); 1839 return IntrinsicBit::decode(raw_ptr()->kind_tag_);
1839 } 1840 }
1840 void set_is_intrinsic(bool value) const; 1841 void set_is_intrinsic(bool value) const;
1841 1842
1842 bool is_recognized() const { 1843 MethodRecognizer::Kind recognized_kind() const {
1843 return RecognizedBit::decode(raw_ptr()->kind_tag_); 1844 return RecognizedBits::decode(raw_ptr()->kind_tag_);
1844 } 1845 }
1845 void set_is_recognized(bool value) const; 1846 void set_recognized_kind(MethodRecognizer::Kind value) const;
1847
1848 bool IsRecognized() const {
1849 return recognized_kind() != MethodRecognizer::kUnknown;
1850 }
1846 1851
1847 bool is_redirecting() const { 1852 bool is_redirecting() const {
1848 return RedirectingBit::decode(raw_ptr()->kind_tag_); 1853 return RedirectingBit::decode(raw_ptr()->kind_tag_);
1849 } 1854 }
1850 void set_is_redirecting(bool value) const; 1855 void set_is_redirecting(bool value) const;
1851 1856
1852 bool allows_hoisting_check_class() const { 1857 bool allows_hoisting_check_class() const {
1853 return AllowsHoistingCheckClassBit::decode(raw_ptr()->kind_tag_); 1858 return AllowsHoistingCheckClassBit::decode(raw_ptr()->kind_tag_);
1854 } 1859 }
1855 void set_allows_hoisting_check_class(bool value) const; 1860 void set_allows_hoisting_check_class(bool value) const;
1856 1861
1862 bool is_always_inline() const {
srdjan 2014/08/20 17:13:46 Optional: is_always_inline reads a little hard; ho
Cutch 2014/08/20 17:17:25 +1
Florian Schneider 2014/08/21 09:31:08 Agree. I went for just always_inline instead.
1863 return AlwaysInlineBit::decode(raw_ptr()->kind_tag_);
1864 }
1865 void set_is_always_inline(bool value) const {
1866 set_kind_tag(AlwaysInlineBit::update(value, raw_ptr()->kind_tag_));
1867 }
1868
1869 bool is_polymorphic_target() const {
1870 return PolymorphicTargetBit::decode(raw_ptr()->kind_tag_);
1871 }
1872 void set_is_polymorphic_target(bool value) const {
1873 set_kind_tag(PolymorphicTargetBit::update(value, raw_ptr()->kind_tag_));
1874 }
1875
1876
1857 bool HasOptimizedCode() const; 1877 bool HasOptimizedCode() const;
1858 1878
1859 // Returns true if the argument counts are valid for calling this function. 1879 // Returns true if the argument counts are valid for calling this function.
1860 // Otherwise, it returns false and the reason (if error_message is not NULL). 1880 // Otherwise, it returns false and the reason (if error_message is not NULL).
1861 bool AreValidArgumentCounts(intptr_t num_arguments, 1881 bool AreValidArgumentCounts(intptr_t num_arguments,
1862 intptr_t num_named_arguments, 1882 intptr_t num_named_arguments,
1863 String* error_message) const; 1883 String* error_message) const;
1864 1884
1865 // Returns true if the total argument count and the names of optional 1885 // Returns true if the total argument count and the names of optional
1866 // arguments are valid for calling this function. 1886 // arguments are valid for calling this function.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2020 static const int kCtorPhaseAll = (kCtorPhaseInit | kCtorPhaseBody); 2040 static const int kCtorPhaseAll = (kCtorPhaseInit | kCtorPhaseBody);
2021 2041
2022 void set_modifier(RawFunction::AsyncModifier value) const; 2042 void set_modifier(RawFunction::AsyncModifier value) const;
2023 2043
2024 private: 2044 private:
2025 void set_ic_data_array(const Array& value) const; 2045 void set_ic_data_array(const Array& value) const;
2026 2046
2027 enum KindTagBits { 2047 enum KindTagBits {
2028 kKindTagPos = 0, 2048 kKindTagPos = 0,
2029 kKindTagSize = 4, 2049 kKindTagSize = 4,
2030 kStaticBit = kKindTagPos + kKindTagSize, // = 4 2050 kRecognizedTagPos = kKindTagPos + kKindTagSize,
2031 kConstBit = 5, 2051 kRecognizedTagSize = 8,
2032 kAbstractBit = 6, 2052 // Single bit sized fields start here.
2033 kVisibleBit = 7, 2053 kStaticBit = kRecognizedTagPos + kRecognizedTagSize,
2034 kOptimizableBit = 8, 2054 kConstBit,
2035 kInlinableBit = 9, 2055 kAbstractBit,
2036 kIntrinsicBit = 10, 2056 kVisibleBit,
2037 kRecognizedBit = 11, 2057 kOptimizableBit,
2038 kNativeBit = 12, 2058 kInlinableBit,
2039 kRedirectingBit = 13, 2059 kIntrinsicBit,
2040 kExternalBit = 14, 2060 kNativeBit,
2041 kAllowsHoistingCheckClassBit = 15, 2061 kRedirectingBit,
2042 kModifierPos = 16, 2062 kExternalBit,
2043 kAsyncClosureBit = 17, 2063 kAllowsHoistingCheckClassBit,
2064 kModifierPos,
2065 kAsyncClosureBit,
2066 kAlwaysInlineBit,
2067 kPolymorphicTargetBit,
2068 kNumTagBits
2044 }; 2069 };
2070
2071 COMPILE_ASSERT(
2072 MethodRecognizer::kNumRecognizedMethods < (1 << kRecognizedTagSize));
2073 COMPILE_ASSERT(
2074 kNumTagBits <= (kBitsPerByte * sizeof(RawFunction::kind_tag_)));
2075
2045 class KindBits : 2076 class KindBits :
2046 public BitField<RawFunction::Kind, kKindTagPos, kKindTagSize> {}; // NOLINT 2077 public BitField<RawFunction::Kind, kKindTagPos, kKindTagSize> {}; // NOLINT
2078 class RecognizedBits : public BitField<MethodRecognizer::Kind,
2079 kRecognizedTagPos,
2080 kRecognizedTagSize> {};
2047 class StaticBit : public BitField<bool, kStaticBit, 1> {}; 2081 class StaticBit : public BitField<bool, kStaticBit, 1> {};
2048 class ConstBit : public BitField<bool, kConstBit, 1> {}; 2082 class ConstBit : public BitField<bool, kConstBit, 1> {};
2049 class AbstractBit : public BitField<bool, kAbstractBit, 1> {}; 2083 class AbstractBit : public BitField<bool, kAbstractBit, 1> {};
2050 class VisibleBit : public BitField<bool, kVisibleBit, 1> {}; 2084 class VisibleBit : public BitField<bool, kVisibleBit, 1> {};
2051 class OptimizableBit : public BitField<bool, kOptimizableBit, 1> {}; 2085 class OptimizableBit : public BitField<bool, kOptimizableBit, 1> {};
2052 class InlinableBit : public BitField<bool, kInlinableBit, 1> {}; 2086 class InlinableBit : public BitField<bool, kInlinableBit, 1> {};
2053 class IntrinsicBit : public BitField<bool, kIntrinsicBit, 1> {}; 2087 class IntrinsicBit : public BitField<bool, kIntrinsicBit, 1> {};
2054 class RecognizedBit : public BitField<bool, kRecognizedBit, 1> {};
2055 class NativeBit : public BitField<bool, kNativeBit, 1> {}; 2088 class NativeBit : public BitField<bool, kNativeBit, 1> {};
2056 class ExternalBit : public BitField<bool, kExternalBit, 1> {}; 2089 class ExternalBit : public BitField<bool, kExternalBit, 1> {};
2057 class RedirectingBit : public BitField<bool, kRedirectingBit, 1> {}; 2090 class RedirectingBit : public BitField<bool, kRedirectingBit, 1> {};
2058 class AllowsHoistingCheckClassBit : 2091 class AllowsHoistingCheckClassBit :
2059 public BitField<bool, kAllowsHoistingCheckClassBit, 1> {}; // NOLINT 2092 public BitField<bool, kAllowsHoistingCheckClassBit, 1> {}; // NOLINT
2060 class ModifierBits : 2093 class ModifierBits :
2061 public BitField<RawFunction::AsyncModifier, kModifierPos, 1> {}; // NOLIN T 2094 public BitField<RawFunction::AsyncModifier, kModifierPos, 1> {}; // NOLIN T
2062 class AsyncClosureBit : public BitField<bool, kAsyncClosureBit, 1> {}; 2095 class AsyncClosureBit : public BitField<bool, kAsyncClosureBit, 1> {};
2096 class AlwaysInlineBit : public BitField<bool, kAlwaysInlineBit, 1> {};
2097 class PolymorphicTargetBit :
2098 public BitField<bool, kPolymorphicTargetBit, 1> {}; // NOLINT
2063 2099
2064 void set_name(const String& value) const; 2100 void set_name(const String& value) const;
2065 void set_kind(RawFunction::Kind value) const; 2101 void set_kind(RawFunction::Kind value) const;
2066 void set_is_static(bool value) const; 2102 void set_is_static(bool value) const;
2067 void set_is_const(bool value) const; 2103 void set_is_const(bool value) const;
2068 void set_is_external(bool value) const; 2104 void set_is_external(bool value) const;
2069 void set_parent_function(const Function& value) const; 2105 void set_parent_function(const Function& value) const;
2070 void set_owner(const Object& value) const; 2106 void set_owner(const Object& value) const;
2071 RawFunction* implicit_closure_function() const; 2107 RawFunction* implicit_closure_function() const;
2072 void set_implicit_closure_function(const Function& value) const; 2108 void set_implicit_closure_function(const Function& value) const;
(...skipping 5236 matching lines...) Expand 10 before | Expand all | Expand 10 after
7309 7345
7310 7346
7311 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7347 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
7312 intptr_t index) { 7348 intptr_t index) {
7313 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7349 return array.At((index * kEntryLength) + kTargetFunctionIndex);
7314 } 7350 }
7315 7351
7316 } // namespace dart 7352 } // namespace dart
7317 7353
7318 #endif // VM_OBJECT_H_ 7354 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/method_recognizer.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698