OLD | NEW |
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 2134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2145 | 2145 |
2146 // Returns true if this function represents a signature function without code. | 2146 // Returns true if this function represents a signature function without code. |
2147 bool IsSignatureFunction() const { | 2147 bool IsSignatureFunction() const { |
2148 return kind() == RawFunction::kSignatureFunction; | 2148 return kind() == RawFunction::kSignatureFunction; |
2149 } | 2149 } |
2150 | 2150 |
2151 bool IsAsyncFunction() const { | 2151 bool IsAsyncFunction() const { |
2152 return modifier() == RawFunction::kAsync; | 2152 return modifier() == RawFunction::kAsync; |
2153 } | 2153 } |
2154 | 2154 |
| 2155 bool IsAsyncClosure() const { |
| 2156 return is_generated_body() && |
| 2157 Function::Handle(parent_function()).IsAsyncFunction(); |
| 2158 } |
| 2159 |
| 2160 bool IsGenerator() const { |
| 2161 return (modifier() & RawFunction::kGeneratorBit) != 0; |
| 2162 } |
| 2163 |
| 2164 bool IsSyncGenerator() const { |
| 2165 return modifier() == RawFunction::kSyncGen; |
| 2166 } |
| 2167 |
| 2168 bool IsSyncGenClosure() const { |
| 2169 return is_generated_body() && |
| 2170 Function::Handle(parent_function()).IsSyncGenerator(); |
| 2171 } |
| 2172 |
| 2173 bool IsAsyncOrGenerator() const { |
| 2174 return modifier() != RawFunction::kNoModifier; |
| 2175 } |
| 2176 |
2155 static intptr_t InstanceSize() { | 2177 static intptr_t InstanceSize() { |
2156 return RoundedAllocationSize(sizeof(RawFunction)); | 2178 return RoundedAllocationSize(sizeof(RawFunction)); |
2157 } | 2179 } |
2158 | 2180 |
2159 static RawFunction* New(const String& name, | 2181 static RawFunction* New(const String& name, |
2160 RawFunction::Kind kind, | 2182 RawFunction::Kind kind, |
2161 bool is_static, | 2183 bool is_static, |
2162 bool is_const, | 2184 bool is_const, |
2163 bool is_abstract, | 2185 bool is_abstract, |
2164 bool is_external, | 2186 bool is_external, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2232 V(Reflectable, is_reflectable) \ | 2254 V(Reflectable, is_reflectable) \ |
2233 V(Debuggable, is_debuggable) \ | 2255 V(Debuggable, is_debuggable) \ |
2234 V(Optimizable, is_optimizable) \ | 2256 V(Optimizable, is_optimizable) \ |
2235 V(Inlinable, is_inlinable) \ | 2257 V(Inlinable, is_inlinable) \ |
2236 V(Intrinsic, is_intrinsic) \ | 2258 V(Intrinsic, is_intrinsic) \ |
2237 V(Native, is_native) \ | 2259 V(Native, is_native) \ |
2238 V(Redirecting, is_redirecting) \ | 2260 V(Redirecting, is_redirecting) \ |
2239 V(External, is_external) \ | 2261 V(External, is_external) \ |
2240 V(AllowsHoistingCheckClass, allows_hoisting_check_class) \ | 2262 V(AllowsHoistingCheckClass, allows_hoisting_check_class) \ |
2241 V(AllowsBoundsCheckGeneralization, allows_bounds_check_generalization) \ | 2263 V(AllowsBoundsCheckGeneralization, allows_bounds_check_generalization) \ |
2242 V(AsyncClosure, is_async_closure) \ | 2264 V(GeneratedBody, is_generated_body) \ |
2243 V(AlwaysInline, always_inline) \ | 2265 V(AlwaysInline, always_inline) \ |
2244 V(PolymorphicTarget, is_polymorphic_target) \ | 2266 V(PolymorphicTarget, is_polymorphic_target) \ |
2245 | 2267 |
2246 #define DEFINE_ACCESSORS(name, accessor_name) \ | 2268 #define DEFINE_ACCESSORS(name, accessor_name) \ |
2247 void set_##accessor_name(bool value) const { \ | 2269 void set_##accessor_name(bool value) const { \ |
2248 set_kind_tag(name##Bit::update(value, raw_ptr()->kind_tag_)); \ | 2270 set_kind_tag(name##Bit::update(value, raw_ptr()->kind_tag_)); \ |
2249 } \ | 2271 } \ |
2250 bool accessor_name() const { \ | 2272 bool accessor_name() const { \ |
2251 return name##Bit::decode(raw_ptr()->kind_tag_); \ | 2273 return name##Bit::decode(raw_ptr()->kind_tag_); \ |
2252 } | 2274 } |
2253 FOR_EACH_FUNCTION_KIND_BIT(DEFINE_ACCESSORS) | 2275 FOR_EACH_FUNCTION_KIND_BIT(DEFINE_ACCESSORS) |
2254 #undef DEFINE_ACCESSORS | 2276 #undef DEFINE_ACCESSORS |
2255 | 2277 |
2256 private: | 2278 private: |
2257 void set_ic_data_array(const Array& value) const; | 2279 void set_ic_data_array(const Array& value) const; |
2258 | 2280 |
2259 enum KindTagBits { | 2281 enum KindTagBits { |
2260 kKindTagPos = 0, | 2282 kKindTagPos = 0, |
2261 kKindTagSize = 4, | 2283 kKindTagSize = 4, |
2262 kRecognizedTagPos = kKindTagPos + kKindTagSize, | 2284 kRecognizedTagPos = kKindTagPos + kKindTagSize, |
2263 kRecognizedTagSize = 8, | 2285 kRecognizedTagSize = 8, |
2264 kModifierPos = kRecognizedTagPos + kRecognizedTagSize, | 2286 kModifierPos = kRecognizedTagPos + kRecognizedTagSize, |
| 2287 kModifierSize = 2, |
| 2288 kLastModifierBitPos = kModifierPos + (kModifierSize - 1), |
2265 // Single bit sized fields start here. | 2289 // Single bit sized fields start here. |
2266 #define DECLARE_BIT(name, _) k##name##Bit, | 2290 #define DECLARE_BIT(name, _) k##name##Bit, |
2267 FOR_EACH_FUNCTION_KIND_BIT(DECLARE_BIT) | 2291 FOR_EACH_FUNCTION_KIND_BIT(DECLARE_BIT) |
2268 #undef DECLARE_BIT | 2292 #undef DECLARE_BIT |
2269 kNumTagBits | 2293 kNumTagBits |
2270 }; | 2294 }; |
2271 | 2295 |
2272 COMPILE_ASSERT( | 2296 COMPILE_ASSERT( |
2273 MethodRecognizer::kNumRecognizedMethods < (1 << kRecognizedTagSize)); | 2297 MethodRecognizer::kNumRecognizedMethods < (1 << kRecognizedTagSize)); |
2274 COMPILE_ASSERT( | 2298 COMPILE_ASSERT( |
2275 kNumTagBits <= | 2299 kNumTagBits <= |
2276 (kBitsPerByte * sizeof(static_cast<RawFunction*>(0)->kind_tag_))); | 2300 (kBitsPerByte * sizeof(static_cast<RawFunction*>(0)->kind_tag_))); |
2277 | 2301 |
2278 class KindBits : | 2302 class KindBits : |
2279 public BitField<RawFunction::Kind, kKindTagPos, kKindTagSize> {}; // NOLINT | 2303 public BitField<RawFunction::Kind, kKindTagPos, kKindTagSize> {}; // NOLINT |
| 2304 |
2280 class RecognizedBits : public BitField<MethodRecognizer::Kind, | 2305 class RecognizedBits : public BitField<MethodRecognizer::Kind, |
2281 kRecognizedTagPos, | 2306 kRecognizedTagPos, |
2282 kRecognizedTagSize> {}; | 2307 kRecognizedTagSize> {}; |
2283 class ModifierBits : | 2308 class ModifierBits : |
2284 public BitField<RawFunction::AsyncModifier, kModifierPos, 1> {}; // NOLIN
T | 2309 public BitField<RawFunction::AsyncModifier, |
| 2310 kModifierPos, |
| 2311 kModifierSize> {}; // NOLINT |
2285 | 2312 |
2286 #define DEFINE_BIT(name, _) \ | 2313 #define DEFINE_BIT(name, _) \ |
2287 class name##Bit : public BitField<bool, k##name##Bit, 1> {}; | 2314 class name##Bit : public BitField<bool, k##name##Bit, 1> {}; |
2288 FOR_EACH_FUNCTION_KIND_BIT(DEFINE_BIT) | 2315 FOR_EACH_FUNCTION_KIND_BIT(DEFINE_BIT) |
2289 #undef DEFINE_BIT | 2316 #undef DEFINE_BIT |
2290 | 2317 |
2291 void set_name(const String& value) const; | 2318 void set_name(const String& value) const; |
2292 void set_kind(RawFunction::Kind value) const; | 2319 void set_kind(RawFunction::Kind value) const; |
2293 void set_parent_function(const Function& value) const; | 2320 void set_parent_function(const Function& value) const; |
2294 void set_owner(const Object& value) const; | 2321 void set_owner(const Object& value) const; |
(...skipping 5470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7765 | 7792 |
7766 | 7793 |
7767 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 7794 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
7768 intptr_t index) { | 7795 intptr_t index) { |
7769 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 7796 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
7770 } | 7797 } |
7771 | 7798 |
7772 } // namespace dart | 7799 } // namespace dart |
7773 | 7800 |
7774 #endif // VM_OBJECT_H_ | 7801 #endif // VM_OBJECT_H_ |
OLD | NEW |