| 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 2552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2563 } | 2563 } |
| 2564 intptr_t NumOptionalNamedParameters() const { | 2564 intptr_t NumOptionalNamedParameters() const { |
| 2565 const intptr_t num_opt_params = raw_ptr()->num_optional_parameters_; | 2565 const intptr_t num_opt_params = raw_ptr()->num_optional_parameters_; |
| 2566 return (num_opt_params < 0) ? -num_opt_params : 0; | 2566 return (num_opt_params < 0) ? -num_opt_params : 0; |
| 2567 } | 2567 } |
| 2568 | 2568 |
| 2569 intptr_t NumParameters() const; | 2569 intptr_t NumParameters() const; |
| 2570 | 2570 |
| 2571 intptr_t NumImplicitParameters() const; | 2571 intptr_t NumImplicitParameters() const; |
| 2572 | 2572 |
| 2573 static intptr_t usage_counter_offset() { | |
| 2574 #if defined(DART_PRECOMPILED_RUNTIME) | 2573 #if defined(DART_PRECOMPILED_RUNTIME) |
| 2575 UNREACHABLE(); | 2574 #define DEFINE_GETTERS_AND_SETTERS(return_type, type, name) \ |
| 2576 return 0; | 2575 static intptr_t name##_offset() { \ |
| 2576 UNREACHABLE(); \ |
| 2577 return 0; \ |
| 2578 } \ |
| 2579 return_type name() const { return 0; } \ |
| 2580 \ |
| 2581 void set_##name(type value) const { UNREACHABLE(); } |
| 2577 #else | 2582 #else |
| 2578 return OFFSET_OF(RawFunction, usage_counter_); | 2583 #define DEFINE_GETTERS_AND_SETTERS(return_type, type, name) \ |
| 2584 static intptr_t name##_offset() { return OFFSET_OF(RawFunction, name##_); } \ |
| 2585 return_type name() const { return raw_ptr()->name##_; } \ |
| 2586 \ |
| 2587 void set_##name(type value) const { \ |
| 2588 StoreNonPointer(&raw_ptr()->name##_, value); \ |
| 2589 } |
| 2579 #endif | 2590 #endif |
| 2580 } | 2591 |
| 2581 intptr_t usage_counter() const { | 2592 JIT_FUNCTION_COUNTERS(DEFINE_GETTERS_AND_SETTERS) |
| 2582 #if defined(DART_PRECOMPILED_RUNTIME) | 2593 |
| 2583 return 0; | 2594 #undef DEFINE_GETTERS_AND_SETTERS |
| 2584 #else | 2595 |
| 2585 return raw_ptr()->usage_counter_; | 2596 static const intptr_t kMaxInstructionCount = (1 << 16) - 1; |
| 2586 #endif | 2597 |
| 2587 } | 2598 void SetOptimizedInstructionCountClamped(uintptr_t value) const { |
| 2588 void set_usage_counter(intptr_t value) const { | 2599 if (value > kMaxInstructionCount) value = kMaxInstructionCount; |
| 2589 #if defined(DART_PRECOMPILED_RUNTIME) | 2600 set_optimized_instruction_count(value); |
| 2590 UNREACHABLE(); | |
| 2591 #else | |
| 2592 // TODO(Srdjan): Assert that this is thread-safe, i.e., only | |
| 2593 // set from mutator-thread or while at a safepoint (e.g., during marking). | |
| 2594 StoreNonPointer(&raw_ptr()->usage_counter_, value); | |
| 2595 #endif | |
| 2596 } | 2601 } |
| 2597 | 2602 |
| 2598 int8_t deoptimization_counter() const { | 2603 void SetOptimizedCallSiteCountClamped(uintptr_t value) const { |
| 2599 #if defined(DART_PRECOMPILED_RUNTIME) | 2604 if (value > kMaxInstructionCount) value = kMaxInstructionCount; |
| 2600 return 0; | 2605 set_optimized_call_site_count(value); |
| 2601 #else | |
| 2602 return raw_ptr()->deoptimization_counter_; | |
| 2603 #endif | |
| 2604 } | |
| 2605 void set_deoptimization_counter(int8_t value) const { | |
| 2606 #if defined(DART_PRECOMPILED_RUNTIME) | |
| 2607 UNREACHABLE(); | |
| 2608 #else | |
| 2609 ASSERT(value >= 0); | |
| 2610 StoreNonPointer(&raw_ptr()->deoptimization_counter_, value); | |
| 2611 #endif | |
| 2612 } | |
| 2613 | |
| 2614 static const intptr_t kMaxInstructionCount = (1 << 16) - 1; | |
| 2615 intptr_t optimized_instruction_count() const { | |
| 2616 #if defined(DART_PRECOMPILED_RUNTIME) | |
| 2617 UNREACHABLE(); | |
| 2618 return 0; | |
| 2619 #else | |
| 2620 return raw_ptr()->optimized_instruction_count_; | |
| 2621 #endif | |
| 2622 } | |
| 2623 void set_optimized_instruction_count(intptr_t value) const { | |
| 2624 #if defined(DART_PRECOMPILED_RUNTIME) | |
| 2625 UNREACHABLE(); | |
| 2626 #else | |
| 2627 ASSERT(value >= 0); | |
| 2628 if (value > kMaxInstructionCount) { | |
| 2629 value = kMaxInstructionCount; | |
| 2630 } | |
| 2631 StoreNonPointer(&raw_ptr()->optimized_instruction_count_, | |
| 2632 static_cast<uint16_t>(value)); | |
| 2633 #endif | |
| 2634 } | |
| 2635 | |
| 2636 intptr_t optimized_call_site_count() const { | |
| 2637 #if defined(DART_PRECOMPILED_RUNTIME) | |
| 2638 return 0; | |
| 2639 #else | |
| 2640 return raw_ptr()->optimized_call_site_count_; | |
| 2641 #endif | |
| 2642 } | |
| 2643 void set_optimized_call_site_count(intptr_t value) const { | |
| 2644 #if defined(DART_PRECOMPILED_RUNTIME) | |
| 2645 UNREACHABLE(); | |
| 2646 #else | |
| 2647 ASSERT(value >= 0); | |
| 2648 if (value > kMaxInstructionCount) { | |
| 2649 value = kMaxInstructionCount; | |
| 2650 } | |
| 2651 StoreNonPointer(&raw_ptr()->optimized_call_site_count_, | |
| 2652 static_cast<uint16_t>(value)); | |
| 2653 #endif | |
| 2654 } | |
| 2655 | |
| 2656 intptr_t kernel_offset() const { | |
| 2657 #if defined(DART_PRECOMPILED_RUNTIME) | |
| 2658 return 0; | |
| 2659 #else | |
| 2660 return raw_ptr()->kernel_offset_; | |
| 2661 #endif | |
| 2662 } | |
| 2663 | |
| 2664 void set_kernel_offset(intptr_t kernel_offset) const { | |
| 2665 #if !defined(DART_PRECOMPILED_RUNTIME) | |
| 2666 StoreNonPointer(&raw_ptr()->kernel_offset_, kernel_offset); | |
| 2667 #endif | |
| 2668 } | 2606 } |
| 2669 | 2607 |
| 2670 RawTypedData* kernel_data() const { return raw_ptr()->kernel_data_; } | 2608 RawTypedData* kernel_data() const { return raw_ptr()->kernel_data_; } |
| 2671 void set_kernel_data(const TypedData& data) const; | 2609 void set_kernel_data(const TypedData& data) const; |
| 2672 | 2610 |
| 2673 bool IsOptimizable() const; | 2611 bool IsOptimizable() const; |
| 2674 void SetIsOptimizable(bool value) const; | 2612 void SetIsOptimizable(bool value) const; |
| 2675 | 2613 |
| 2676 bool CanBeInlined() const; | 2614 bool CanBeInlined() const; |
| 2677 | 2615 |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2944 bool clone_ic_data) const; | 2882 bool clone_ic_data) const; |
| 2945 | 2883 |
| 2946 RawArray* ic_data_array() const; | 2884 RawArray* ic_data_array() const; |
| 2947 void ClearICDataArray() const; | 2885 void ClearICDataArray() const; |
| 2948 | 2886 |
| 2949 // Sets deopt reason in all ICData-s with given deopt_id. | 2887 // Sets deopt reason in all ICData-s with given deopt_id. |
| 2950 void SetDeoptReasonForAll(intptr_t deopt_id, ICData::DeoptReasonId reason); | 2888 void SetDeoptReasonForAll(intptr_t deopt_id, ICData::DeoptReasonId reason); |
| 2951 | 2889 |
| 2952 void set_modifier(RawFunction::AsyncModifier value) const; | 2890 void set_modifier(RawFunction::AsyncModifier value) const; |
| 2953 | 2891 |
| 2954 // 'was_compiled' is true if the function was compiled once in this | 2892 // 'WasCompiled' is true if the function was compiled once in this |
| 2955 // VM instantiation. It is independent from presence of type feedback | 2893 // VM instantiation. It is independent from presence of type feedback |
| 2956 // (ic_data_array) and code, which may be loaded from a snapshot. | 2894 // (ic_data_array) and code, which may be loaded from a snapshot. |
| 2957 void set_was_compiled(bool value) const { | 2895 void SetWasCompiled(bool value) const { |
| 2958 #if defined(DART_PRECOMPILED_RUNTIME) | 2896 set_was_compiled_numeric(value ? 1 : 0); |
| 2959 UNREACHABLE(); | |
| 2960 #else | |
| 2961 StoreNonPointer(&raw_ptr()->was_compiled_, value ? 1 : 0); | |
| 2962 #endif | |
| 2963 } | 2897 } |
| 2964 bool was_compiled() const { | 2898 |
| 2965 #if defined(DART_PRECOMPILED_RUNTIME) | 2899 bool WasCompiled() const { return was_compiled_numeric() != 0; } |
| 2966 UNREACHABLE(); | |
| 2967 return true; | |
| 2968 #else | |
| 2969 return raw_ptr()->was_compiled_ == 1; | |
| 2970 #endif | |
| 2971 } | |
| 2972 | 2900 |
| 2973 // static: Considered during class-side or top-level resolution rather than | 2901 // static: Considered during class-side or top-level resolution rather than |
| 2974 // instance-side resolution. | 2902 // instance-side resolution. |
| 2975 // const: Valid target of a const constructor call. | 2903 // const: Valid target of a const constructor call. |
| 2976 // abstract: Skipped during instance-side resolution. | 2904 // abstract: Skipped during instance-side resolution. |
| 2977 // reflectable: Enumerated by mirrors, invocable by mirrors. False for private | 2905 // reflectable: Enumerated by mirrors, invocable by mirrors. False for private |
| 2978 // functions of dart: libraries. | 2906 // functions of dart: libraries. |
| 2979 // debuggable: Valid location of a breakpoint. Synthetic code is not | 2907 // debuggable: Valid location of a breakpoint. Synthetic code is not |
| 2980 // debuggable. | 2908 // debuggable. |
| 2981 // visible: Frame is included in stack traces. Synthetic code such as | 2909 // visible: Frame is included in stack traces. Synthetic code such as |
| (...skipping 6024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9006 | 8934 |
| 9007 inline void TypeArguments::SetHash(intptr_t value) const { | 8935 inline void TypeArguments::SetHash(intptr_t value) const { |
| 9008 // This is only safe because we create a new Smi, which does not cause | 8936 // This is only safe because we create a new Smi, which does not cause |
| 9009 // heap allocation. | 8937 // heap allocation. |
| 9010 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); | 8938 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); |
| 9011 } | 8939 } |
| 9012 | 8940 |
| 9013 } // namespace dart | 8941 } // namespace dart |
| 9014 | 8942 |
| 9015 #endif // RUNTIME_VM_OBJECT_H_ | 8943 #endif // RUNTIME_VM_OBJECT_H_ |
| OLD | NEW |