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 RUNTIME_VM_OBJECT_H_ | 5 #ifndef RUNTIME_VM_OBJECT_H_ |
6 #define RUNTIME_VM_OBJECT_H_ | 6 #define RUNTIME_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 2344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2355 } | 2355 } |
2356 intptr_t NumOptionalNamedParameters() const { | 2356 intptr_t NumOptionalNamedParameters() const { |
2357 const intptr_t num_opt_params = raw_ptr()->num_optional_parameters_; | 2357 const intptr_t num_opt_params = raw_ptr()->num_optional_parameters_; |
2358 return (num_opt_params < 0) ? -num_opt_params : 0; | 2358 return (num_opt_params < 0) ? -num_opt_params : 0; |
2359 } | 2359 } |
2360 | 2360 |
2361 intptr_t NumParameters() const; | 2361 intptr_t NumParameters() const; |
2362 | 2362 |
2363 intptr_t NumImplicitParameters() const; | 2363 intptr_t NumImplicitParameters() const; |
2364 | 2364 |
2365 static intptr_t usage_counter_offset() { | |
2366 #if defined(DART_PRECOMPILED_RUNTIME) | 2365 #if defined(DART_PRECOMPILED_RUNTIME) |
2367 UNREACHABLE(); | 2366 #define DEFINE_GETTERS_AND_SETTERS(return_type, type, name) \ |
2368 return 0; | 2367 static intptr_t name##_offset() { \ |
| 2368 UNREACHABLE(); \ |
| 2369 return 0; \ |
| 2370 } \ |
| 2371 return_type name() const { return 0; } \ |
| 2372 \ |
| 2373 void set_##name(type value) const { UNREACHABLE(); } |
2369 #else | 2374 #else |
2370 return OFFSET_OF(RawFunction, usage_counter_); | 2375 #define DEFINE_GETTERS_AND_SETTERS(return_type, type, name) \ |
| 2376 static intptr_t name##_offset() { return OFFSET_OF(RawFunction, name##_); } \ |
| 2377 return_type name() const { return raw_ptr()->name##_; } \ |
| 2378 \ |
| 2379 void set_##name(type value) const { \ |
| 2380 StoreNonPointer(&raw_ptr()->name##_, value); \ |
| 2381 } |
2371 #endif | 2382 #endif |
2372 } | 2383 |
2373 intptr_t usage_counter() const { | 2384 JIT_FUNCTION_COUNTERS(DEFINE_GETTERS_AND_SETTERS) |
2374 #if defined(DART_PRECOMPILED_RUNTIME) | 2385 |
2375 return 0; | 2386 #undef DEFINE_GETTERS_AND_SETTERS |
2376 #else | 2387 |
2377 return raw_ptr()->usage_counter_; | 2388 static const intptr_t kMaxInstructionCount = (1 << 16) - 1; |
2378 #endif | 2389 |
2379 } | 2390 void SetOptimizedInstructionCountClamped(uintptr_t value) const { |
2380 void set_usage_counter(intptr_t value) const { | 2391 if (value > kMaxInstructionCount) value = kMaxInstructionCount; |
2381 #if defined(DART_PRECOMPILED_RUNTIME) | 2392 set_optimized_instruction_count(value); |
2382 UNREACHABLE(); | |
2383 #else | |
2384 // TODO(Srdjan): Assert that this is thread-safe, i.e., only | |
2385 // set from mutator-thread or while at a safepoint (e.g., during marking). | |
2386 StoreNonPointer(&raw_ptr()->usage_counter_, value); | |
2387 #endif | |
2388 } | 2393 } |
2389 | 2394 |
2390 int8_t deoptimization_counter() const { | 2395 void SetOptimizedCallSiteCountClamped(uintptr_t value) const { |
2391 #if defined(DART_PRECOMPILED_RUNTIME) | 2396 if (value > kMaxInstructionCount) value = kMaxInstructionCount; |
2392 return 0; | 2397 set_optimized_call_site_count(value); |
2393 #else | |
2394 return raw_ptr()->deoptimization_counter_; | |
2395 #endif | |
2396 } | |
2397 void set_deoptimization_counter(int8_t value) const { | |
2398 #if defined(DART_PRECOMPILED_RUNTIME) | |
2399 UNREACHABLE(); | |
2400 #else | |
2401 ASSERT(value >= 0); | |
2402 StoreNonPointer(&raw_ptr()->deoptimization_counter_, value); | |
2403 #endif | |
2404 } | |
2405 | |
2406 static const intptr_t kMaxInstructionCount = (1 << 16) - 1; | |
2407 intptr_t optimized_instruction_count() const { | |
2408 #if defined(DART_PRECOMPILED_RUNTIME) | |
2409 UNREACHABLE(); | |
2410 return 0; | |
2411 #else | |
2412 return raw_ptr()->optimized_instruction_count_; | |
2413 #endif | |
2414 } | |
2415 void set_optimized_instruction_count(intptr_t value) const { | |
2416 #if defined(DART_PRECOMPILED_RUNTIME) | |
2417 UNREACHABLE(); | |
2418 #else | |
2419 ASSERT(value >= 0); | |
2420 if (value > kMaxInstructionCount) { | |
2421 value = kMaxInstructionCount; | |
2422 } | |
2423 StoreNonPointer(&raw_ptr()->optimized_instruction_count_, | |
2424 static_cast<uint16_t>(value)); | |
2425 #endif | |
2426 } | |
2427 | |
2428 intptr_t optimized_call_site_count() const { | |
2429 #if defined(DART_PRECOMPILED_RUNTIME) | |
2430 return 0; | |
2431 #else | |
2432 return raw_ptr()->optimized_call_site_count_; | |
2433 #endif | |
2434 } | |
2435 void set_optimized_call_site_count(intptr_t value) const { | |
2436 #if defined(DART_PRECOMPILED_RUNTIME) | |
2437 UNREACHABLE(); | |
2438 #else | |
2439 ASSERT(value >= 0); | |
2440 if (value > kMaxInstructionCount) { | |
2441 value = kMaxInstructionCount; | |
2442 } | |
2443 StoreNonPointer(&raw_ptr()->optimized_call_site_count_, | |
2444 static_cast<uint16_t>(value)); | |
2445 #endif | |
2446 } | |
2447 | |
2448 intptr_t kernel_offset() const { | |
2449 #if defined(DART_PRECOMPILED_RUNTIME) | |
2450 return 0; | |
2451 #else | |
2452 return raw_ptr()->kernel_offset_; | |
2453 #endif | |
2454 } | |
2455 | |
2456 void set_kernel_offset(intptr_t kernel_offset) const { | |
2457 #if !defined(DART_PRECOMPILED_RUNTIME) | |
2458 StoreNonPointer(&raw_ptr()->kernel_offset_, kernel_offset); | |
2459 #endif | |
2460 } | 2398 } |
2461 | 2399 |
2462 RawTypedData* kernel_data() const { return raw_ptr()->kernel_data_; } | 2400 RawTypedData* kernel_data() const { return raw_ptr()->kernel_data_; } |
2463 void set_kernel_data(const TypedData& data) const; | 2401 void set_kernel_data(const TypedData& data) const; |
2464 | 2402 |
2465 bool IsOptimizable() const; | 2403 bool IsOptimizable() const; |
2466 void SetIsOptimizable(bool value) const; | 2404 void SetIsOptimizable(bool value) const; |
2467 | 2405 |
2468 bool CanBeInlined() const; | 2406 bool CanBeInlined() const; |
2469 | 2407 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2736 bool clone_ic_data) const; | 2674 bool clone_ic_data) const; |
2737 | 2675 |
2738 RawArray* ic_data_array() const; | 2676 RawArray* ic_data_array() const; |
2739 void ClearICDataArray() const; | 2677 void ClearICDataArray() const; |
2740 | 2678 |
2741 // Sets deopt reason in all ICData-s with given deopt_id. | 2679 // Sets deopt reason in all ICData-s with given deopt_id. |
2742 void SetDeoptReasonForAll(intptr_t deopt_id, ICData::DeoptReasonId reason); | 2680 void SetDeoptReasonForAll(intptr_t deopt_id, ICData::DeoptReasonId reason); |
2743 | 2681 |
2744 void set_modifier(RawFunction::AsyncModifier value) const; | 2682 void set_modifier(RawFunction::AsyncModifier value) const; |
2745 | 2683 |
2746 // 'was_compiled' is true if the function was compiled once in this | 2684 // 'WasCompiled' is true if the function was compiled once in this |
2747 // VM instantiation. It is independent from presence of type feedback | 2685 // VM instantiation. It is independent from presence of type feedback |
2748 // (ic_data_array) and code, which may be loaded from a snapshot. | 2686 // (ic_data_array) and code, which may be loaded from a snapshot. |
2749 void set_was_compiled(bool value) const { | 2687 void SetWasCompiled(bool value) const { |
2750 #if defined(DART_PRECOMPILED_RUNTIME) | 2688 set_was_compiled_numeric(value ? 1 : 0); |
2751 UNREACHABLE(); | |
2752 #else | |
2753 StoreNonPointer(&raw_ptr()->was_compiled_, value ? 1 : 0); | |
2754 #endif | |
2755 } | |
2756 bool was_compiled() const { | |
2757 #if defined(DART_PRECOMPILED_RUNTIME) | |
2758 UNREACHABLE(); | |
2759 return true; | |
2760 #else | |
2761 return raw_ptr()->was_compiled_ == 1; | |
2762 #endif | |
2763 } | 2689 } |
2764 | 2690 |
2765 // static: Considered during class-side or top-level resolution rather than | 2691 bool WasCompiled() const { return was_compiled_numeric() != 0; } |
2766 // instance-side resolution. | 2692 |
2767 // const: Valid target of a const constructor call. | 2693 // static: Considered during class-side or top-level resolution rather than |
2768 // abstract: Skipped during instance-side resolution. | 2694 // instance-side resolution. |
2769 // reflectable: Enumerated by mirrors, invocable by mirrors. False for private | 2695 // const: Valid target of a const constructor call. |
2770 // functions of dart: libraries. | 2696 // abstract: Skipped during instance-side resolution. |
2771 // debuggable: Valid location of a breakpoint. Synthetic code is not | 2697 // reflectable: Enumerated by mirrors, invocable by mirrors. False for private |
2772 // debuggable. | 2698 // functions of dart: libraries. |
2773 // visible: Frame is included in stack traces. Synthetic code such as | 2699 // debuggable: Valid location of a breakpoint. Synthetic code is not |
2774 // dispatchers is not visible. Synthetic code that can trigger | 2700 // debuggable. |
2775 // exceptions such as the outer async functions that create Futures | 2701 // visible: Frame is included in stack traces. Synthetic code such as |
2776 // is visible. | 2702 // dispatchers is not visible. Synthetic code that can trigger |
2777 // optimizable: Candidate for going through the optimizing compiler. False for | 2703 // exceptions such as the outer async functions that create Futures |
2778 // some functions known to be execute infrequently and functions | 2704 // is visible. |
2779 // which have been de-optimized too many times. | 2705 // optimizable: Candidate for going through the optimizing compiler. False for |
2780 // instrinsic: Has a hand-written assembly prologue. | 2706 // some functions known to be execute infrequently and functions |
2781 // inlinable: Candidate for inlining. False for functions with features we | 2707 // which have been de-optimized too many times. |
2782 // don't support during inlining (e.g., optional parameters), | 2708 // instrinsic: Has a hand-written assembly prologue. |
2783 // functions which are too big, etc. | 2709 // inlinable: Candidate for inlining. False for functions with features we |
2784 // native: Bridge to C/C++ code. | 2710 // don't support during inlining (e.g., optional parameters), |
2785 // redirecting: Redirecting generative or factory constructor. | 2711 // functions which are too big, etc. |
2786 // external: Just a declaration that expects to be defined in another patch | 2712 // native: Bridge to C/C++ code. |
2787 // file. | 2713 // redirecting: Redirecting generative or factory constructor. |
| 2714 // external: Just a declaration that expects to be defined in another patch |
| 2715 // file. |
2788 | 2716 |
2789 #define FOR_EACH_FUNCTION_KIND_BIT(V) \ | 2717 #define FOR_EACH_FUNCTION_KIND_BIT(V) \ |
2790 V(Static, is_static) \ | 2718 V(Static, is_static) \ |
2791 V(Const, is_const) \ | 2719 V(Const, is_const) \ |
2792 V(Abstract, is_abstract) \ | 2720 V(Abstract, is_abstract) \ |
2793 V(Reflectable, is_reflectable) \ | 2721 V(Reflectable, is_reflectable) \ |
2794 V(Visible, is_visible) \ | 2722 V(Visible, is_visible) \ |
2795 V(Debuggable, is_debuggable) \ | 2723 V(Debuggable, is_debuggable) \ |
2796 V(Optimizable, is_optimizable) \ | 2724 V(Optimizable, is_optimizable) \ |
2797 V(Inlinable, is_inlinable) \ | 2725 V(Inlinable, is_inlinable) \ |
(...skipping 6214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9012 | 8940 |
9013 inline void TypeArguments::SetHash(intptr_t value) const { | 8941 inline void TypeArguments::SetHash(intptr_t value) const { |
9014 // This is only safe because we create a new Smi, which does not cause | 8942 // This is only safe because we create a new Smi, which does not cause |
9015 // heap allocation. | 8943 // heap allocation. |
9016 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); | 8944 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); |
9017 } | 8945 } |
9018 | 8946 |
9019 } // namespace dart | 8947 } // namespace dart |
9020 | 8948 |
9021 #endif // RUNTIME_VM_OBJECT_H_ | 8949 #endif // RUNTIME_VM_OBJECT_H_ |
OLD | NEW |