| 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 return *vm_isolate_snapshot_object_table_; | 492 return *vm_isolate_snapshot_object_table_; |
| 493 } | 493 } |
| 494 static const Type& dynamic_type() { | 494 static const Type& dynamic_type() { |
| 495 ASSERT(dynamic_type_ != NULL); | 495 ASSERT(dynamic_type_ != NULL); |
| 496 return *dynamic_type_; | 496 return *dynamic_type_; |
| 497 } | 497 } |
| 498 static const Type& void_type() { | 498 static const Type& void_type() { |
| 499 ASSERT(void_type_ != NULL); | 499 ASSERT(void_type_ != NULL); |
| 500 return *void_type_; | 500 return *void_type_; |
| 501 } | 501 } |
| 502 static const Type& vector_type() { |
| 503 ASSERT(vector_type_ != NULL); |
| 504 return *vector_type_; |
| 505 } |
| 502 | 506 |
| 503 static void set_vm_isolate_snapshot_object_table(const Array& table); | 507 static void set_vm_isolate_snapshot_object_table(const Array& table); |
| 504 | 508 |
| 505 static RawClass* class_class() { return class_class_; } | 509 static RawClass* class_class() { return class_class_; } |
| 506 static RawClass* dynamic_class() { return dynamic_class_; } | 510 static RawClass* dynamic_class() { return dynamic_class_; } |
| 507 static RawClass* void_class() { return void_class_; } | 511 static RawClass* void_class() { return void_class_; } |
| 508 static RawClass* unresolved_class_class() { return unresolved_class_class_; } | 512 static RawClass* unresolved_class_class() { return unresolved_class_class_; } |
| 509 static RawClass* type_arguments_class() { return type_arguments_class_; } | 513 static RawClass* type_arguments_class() { return type_arguments_class_; } |
| 510 static RawClass* patch_class_class() { return patch_class_class_; } | 514 static RawClass* patch_class_class() { return patch_class_class_; } |
| 511 static RawClass* function_class() { return function_class_; } | 515 static RawClass* function_class() { return function_class_; } |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 static cpp_vtable handle_vtable_; | 760 static cpp_vtable handle_vtable_; |
| 757 static cpp_vtable builtin_vtables_[kNumPredefinedCids]; | 761 static cpp_vtable builtin_vtables_[kNumPredefinedCids]; |
| 758 | 762 |
| 759 // The static values below are singletons shared between the different | 763 // The static values below are singletons shared between the different |
| 760 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_. | 764 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_. |
| 761 static RawObject* null_; | 765 static RawObject* null_; |
| 762 | 766 |
| 763 static RawClass* class_class_; // Class of the Class vm object. | 767 static RawClass* class_class_; // Class of the Class vm object. |
| 764 static RawClass* dynamic_class_; // Class of the 'dynamic' type. | 768 static RawClass* dynamic_class_; // Class of the 'dynamic' type. |
| 765 static RawClass* void_class_; // Class of the 'void' type. | 769 static RawClass* void_class_; // Class of the 'void' type. |
| 770 static RawClass* vector_class_; // Class of the 'vector' type. |
| 766 static RawClass* unresolved_class_class_; // Class of UnresolvedClass. | 771 static RawClass* unresolved_class_class_; // Class of UnresolvedClass. |
| 767 static RawClass* type_arguments_class_; // Class of TypeArguments vm object. | 772 static RawClass* type_arguments_class_; // Class of TypeArguments vm object. |
| 768 static RawClass* patch_class_class_; // Class of the PatchClass vm object. | 773 static RawClass* patch_class_class_; // Class of the PatchClass vm object. |
| 769 static RawClass* function_class_; // Class of the Function vm object. | 774 static RawClass* function_class_; // Class of the Function vm object. |
| 770 static RawClass* closure_data_class_; // Class of ClosureData vm obj. | 775 static RawClass* closure_data_class_; // Class of ClosureData vm obj. |
| 771 static RawClass* signature_data_class_; // Class of SignatureData vm obj. | 776 static RawClass* signature_data_class_; // Class of SignatureData vm obj. |
| 772 static RawClass* redirection_data_class_; // Class of RedirectionData vm obj. | 777 static RawClass* redirection_data_class_; // Class of RedirectionData vm obj. |
| 773 static RawClass* field_class_; // Class of the Field vm object. | 778 static RawClass* field_class_; // Class of the Field vm object. |
| 774 static RawClass* literal_token_class_; // Class of LiteralToken vm object. | 779 static RawClass* literal_token_class_; // Class of LiteralToken vm object. |
| 775 static RawClass* token_stream_class_; // Class of the TokenStream vm object. | 780 static RawClass* token_stream_class_; // Class of the TokenStream vm object. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 static Bool* bool_true_; | 827 static Bool* bool_true_; |
| 823 static Bool* bool_false_; | 828 static Bool* bool_false_; |
| 824 static Smi* smi_illegal_cid_; | 829 static Smi* smi_illegal_cid_; |
| 825 static LanguageError* snapshot_writer_error_; | 830 static LanguageError* snapshot_writer_error_; |
| 826 static LanguageError* branch_offset_error_; | 831 static LanguageError* branch_offset_error_; |
| 827 static LanguageError* speculative_inlining_error_; | 832 static LanguageError* speculative_inlining_error_; |
| 828 static LanguageError* background_compilation_error_; | 833 static LanguageError* background_compilation_error_; |
| 829 static Array* vm_isolate_snapshot_object_table_; | 834 static Array* vm_isolate_snapshot_object_table_; |
| 830 static Type* dynamic_type_; | 835 static Type* dynamic_type_; |
| 831 static Type* void_type_; | 836 static Type* void_type_; |
| 837 static Type* vector_type_; |
| 832 | 838 |
| 833 friend void ClassTable::Register(const Class& cls); | 839 friend void ClassTable::Register(const Class& cls); |
| 834 friend void RawObject::Validate(Isolate* isolate) const; | 840 friend void RawObject::Validate(Isolate* isolate) const; |
| 835 friend class Closure; | 841 friend class Closure; |
| 836 friend class SnapshotReader; | 842 friend class SnapshotReader; |
| 837 friend class InstanceDeserializationCluster; | 843 friend class InstanceDeserializationCluster; |
| 838 friend class OneByteString; | 844 friend class OneByteString; |
| 839 friend class TwoByteString; | 845 friend class TwoByteString; |
| 840 friend class ExternalOneByteString; | 846 friend class ExternalOneByteString; |
| 841 friend class ExternalTwoByteString; | 847 friend class ExternalTwoByteString; |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 | 1572 |
| 1567 static RawUnresolvedClass* New(); | 1573 static RawUnresolvedClass* New(); |
| 1568 | 1574 |
| 1569 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass, Object); | 1575 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass, Object); |
| 1570 friend class Class; | 1576 friend class Class; |
| 1571 }; | 1577 }; |
| 1572 | 1578 |
| 1573 | 1579 |
| 1574 // Classification of type genericity according to type parameter owners. | 1580 // Classification of type genericity according to type parameter owners. |
| 1575 enum Genericity { | 1581 enum Genericity { |
| 1576 kAny, // Consider type params of current class and functions. | 1582 kAny, // Consider type params of current class and functions. |
| 1577 kCurrentClass, // Consider type params of current class only. | 1583 kCurrentClass, // Consider type params of current class only. |
| 1578 kFunctions, // Consider type params of current and parent functions. | 1584 kFunctions, // Consider type params of current and parent functions. |
| 1579 }; | 1585 }; |
| 1580 | 1586 |
| 1581 | 1587 |
| 1582 // A TypeArguments is an array of AbstractType. | 1588 // A TypeArguments is an array of AbstractType. |
| 1583 class TypeArguments : public Object { | 1589 class TypeArguments : public Object { |
| 1584 public: | 1590 public: |
| 1585 // We use 30 bits for the hash code so hashes in a snapshot taken on a | 1591 // We use 30 bits for the hash code so hashes in a snapshot taken on a |
| 1586 // 64-bit architecture stay in Smi range when loaded on a 32-bit | 1592 // 64-bit architecture stay in Smi range when loaded on a 32-bit |
| 1587 // architecture. | 1593 // architecture. |
| 1588 static const intptr_t kHashBits = 30; | 1594 static const intptr_t kHashBits = 30; |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2388 bool IsInvokeFieldDispatcher() const { | 2394 bool IsInvokeFieldDispatcher() const { |
| 2389 return kind() == RawFunction::kInvokeFieldDispatcher; | 2395 return kind() == RawFunction::kInvokeFieldDispatcher; |
| 2390 } | 2396 } |
| 2391 | 2397 |
| 2392 // Returns true iff an implicit closure function has been created | 2398 // Returns true iff an implicit closure function has been created |
| 2393 // for this function. | 2399 // for this function. |
| 2394 bool HasImplicitClosureFunction() const { | 2400 bool HasImplicitClosureFunction() const { |
| 2395 return implicit_closure_function() != null(); | 2401 return implicit_closure_function() != null(); |
| 2396 } | 2402 } |
| 2397 | 2403 |
| 2404 // Returns true iff a converted closure function has been created |
| 2405 // for this function. |
| 2406 bool HasConvertedClosureFunction() const { |
| 2407 return converted_closure_function() != null(); |
| 2408 } |
| 2409 |
| 2398 // Return the closure function implicitly created for this function. | 2410 // Return the closure function implicitly created for this function. |
| 2399 // If none exists yet, create one and remember it. | 2411 // If none exists yet, create one and remember it. |
| 2400 RawFunction* ImplicitClosureFunction() const; | 2412 RawFunction* ImplicitClosureFunction() const; |
| 2401 void DropUncompiledImplicitClosureFunction() const; | 2413 void DropUncompiledImplicitClosureFunction() const; |
| 2402 | 2414 |
| 2415 // Return the converted closure function created for this function. |
| 2416 // If none exists yet, create one and remember it. |
| 2417 RawFunction* ConvertedClosureFunction() const; |
| 2418 void DropUncompiledConvertedClosureFunction() const; |
| 2419 |
| 2403 // Return the closure implicitly created for this function. | 2420 // Return the closure implicitly created for this function. |
| 2404 // If none exists yet, create one and remember it. | 2421 // If none exists yet, create one and remember it. |
| 2405 RawInstance* ImplicitStaticClosure() const; | 2422 RawInstance* ImplicitStaticClosure() const; |
| 2406 | 2423 |
| 2407 RawInstance* ImplicitInstanceClosure(const Instance& receiver) const; | 2424 RawInstance* ImplicitInstanceClosure(const Instance& receiver) const; |
| 2408 | 2425 |
| 2409 RawSmi* GetClosureHashCode() const; | 2426 RawSmi* GetClosureHashCode() const; |
| 2410 | 2427 |
| 2411 // Redirection information for a redirecting factory. | 2428 // Redirection information for a redirecting factory. |
| 2412 bool IsRedirectingFactory() const; | 2429 bool IsRedirectingFactory() const; |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2751 } | 2768 } |
| 2752 | 2769 |
| 2753 // Returns true if this function represents a generated irregexp function. | 2770 // Returns true if this function represents a generated irregexp function. |
| 2754 bool IsIrregexpFunction() const { | 2771 bool IsIrregexpFunction() const { |
| 2755 return kind() == RawFunction::kIrregexpFunction; | 2772 return kind() == RawFunction::kIrregexpFunction; |
| 2756 } | 2773 } |
| 2757 | 2774 |
| 2758 // Returns true if this function represents an implicit closure function. | 2775 // Returns true if this function represents an implicit closure function. |
| 2759 bool IsImplicitClosureFunction() const; | 2776 bool IsImplicitClosureFunction() const; |
| 2760 | 2777 |
| 2778 // Returns true if this function represents a converted closure function. |
| 2779 bool IsConvertedClosureFunction() const { |
| 2780 return kind() == RawFunction::kConvertedClosureFunction; |
| 2781 } |
| 2782 |
| 2761 // Returns true if this function represents a non implicit closure function. | 2783 // Returns true if this function represents a non implicit closure function. |
| 2762 bool IsNonImplicitClosureFunction() const { | 2784 bool IsNonImplicitClosureFunction() const { |
| 2763 return IsClosureFunction() && !IsImplicitClosureFunction(); | 2785 return IsClosureFunction() && !IsImplicitClosureFunction(); |
| 2764 } | 2786 } |
| 2765 | 2787 |
| 2766 // Returns true if this function represents an implicit static closure | 2788 // Returns true if this function represents an implicit static closure |
| 2767 // function. | 2789 // function. |
| 2768 bool IsImplicitStaticClosureFunction() const { | 2790 bool IsImplicitStaticClosureFunction() const { |
| 2769 return is_static() && IsImplicitClosureFunction(); | 2791 return is_static() && IsImplicitClosureFunction(); |
| 2770 } | 2792 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2843 bool is_native, | 2865 bool is_native, |
| 2844 const Object& owner, | 2866 const Object& owner, |
| 2845 TokenPosition token_pos, | 2867 TokenPosition token_pos, |
| 2846 Heap::Space space = Heap::kOld); | 2868 Heap::Space space = Heap::kOld); |
| 2847 | 2869 |
| 2848 // Allocates a new Function object representing a closure function. | 2870 // Allocates a new Function object representing a closure function. |
| 2849 static RawFunction* NewClosureFunction(const String& name, | 2871 static RawFunction* NewClosureFunction(const String& name, |
| 2850 const Function& parent, | 2872 const Function& parent, |
| 2851 TokenPosition token_pos); | 2873 TokenPosition token_pos); |
| 2852 | 2874 |
| 2875 // Allocates a new Function object representing a converted closure function. |
| 2876 static RawFunction* NewConvertedClosureFunction(const String& name, |
| 2877 const Function& parent, |
| 2878 TokenPosition token_pos); |
| 2879 |
| 2853 // Allocates a new Function object representing a signature function. | 2880 // Allocates a new Function object representing a signature function. |
| 2854 // The owner is the scope class of the function type. | 2881 // The owner is the scope class of the function type. |
| 2855 static RawFunction* NewSignatureFunction(const Object& owner, | 2882 static RawFunction* NewSignatureFunction(const Object& owner, |
| 2856 TokenPosition token_pos, | 2883 TokenPosition token_pos, |
| 2857 Heap::Space space = Heap::kOld); | 2884 Heap::Space space = Heap::kOld); |
| 2858 | 2885 |
| 2859 static RawFunction* NewEvalFunction(const Class& owner, | 2886 static RawFunction* NewEvalFunction(const Class& owner, |
| 2860 const Script& script, | 2887 const Script& script, |
| 2861 bool is_static); | 2888 bool is_static); |
| 2862 | 2889 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3004 class name##Bit : public BitField<uint32_t, bool, k##name##Bit, 1> {}; | 3031 class name##Bit : public BitField<uint32_t, bool, k##name##Bit, 1> {}; |
| 3005 FOR_EACH_FUNCTION_KIND_BIT(DEFINE_BIT) | 3032 FOR_EACH_FUNCTION_KIND_BIT(DEFINE_BIT) |
| 3006 #undef DEFINE_BIT | 3033 #undef DEFINE_BIT |
| 3007 | 3034 |
| 3008 void set_name(const String& value) const; | 3035 void set_name(const String& value) const; |
| 3009 void set_kind(RawFunction::Kind value) const; | 3036 void set_kind(RawFunction::Kind value) const; |
| 3010 void set_parent_function(const Function& value) const; | 3037 void set_parent_function(const Function& value) const; |
| 3011 void set_owner(const Object& value) const; | 3038 void set_owner(const Object& value) const; |
| 3012 RawFunction* implicit_closure_function() const; | 3039 RawFunction* implicit_closure_function() const; |
| 3013 void set_implicit_closure_function(const Function& value) const; | 3040 void set_implicit_closure_function(const Function& value) const; |
| 3041 RawFunction* converted_closure_function() const; |
| 3042 void set_converted_closure_function(const Function& value) const; |
| 3014 RawInstance* implicit_static_closure() const; | 3043 RawInstance* implicit_static_closure() const; |
| 3015 void set_implicit_static_closure(const Instance& closure) const; | 3044 void set_implicit_static_closure(const Instance& closure) const; |
| 3016 RawScript* eval_script() const; | 3045 RawScript* eval_script() const; |
| 3017 void set_eval_script(const Script& value) const; | 3046 void set_eval_script(const Script& value) const; |
| 3018 void set_num_optional_parameters(intptr_t value) const; // Encoded value. | 3047 void set_num_optional_parameters(intptr_t value) const; // Encoded value. |
| 3019 void set_kind_tag(uint32_t value) const; | 3048 void set_kind_tag(uint32_t value) const; |
| 3020 void set_data(const Object& value) const; | 3049 void set_data(const Object& value) const; |
| 3021 | 3050 |
| 3022 static RawFunction* New(Heap::Space space = Heap::kOld); | 3051 static RawFunction* New(Heap::Space space = Heap::kOld); |
| 3023 | 3052 |
| (...skipping 2061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5085 // only be created using the Code::FinalizeCode method. This method creates | 5114 // only be created using the Code::FinalizeCode method. This method creates |
| 5086 // the RawInstruction and RawCode objects, sets up the pointer offsets | 5115 // the RawInstruction and RawCode objects, sets up the pointer offsets |
| 5087 // and links the two in a GC safe manner. | 5116 // and links the two in a GC safe manner. |
| 5088 static RawCode* New(intptr_t pointer_offsets_length); | 5117 static RawCode* New(intptr_t pointer_offsets_length); |
| 5089 | 5118 |
| 5090 FINAL_HEAP_OBJECT_IMPLEMENTATION(Code, Object); | 5119 FINAL_HEAP_OBJECT_IMPLEMENTATION(Code, Object); |
| 5091 friend class Class; | 5120 friend class Class; |
| 5092 friend class SnapshotWriter; | 5121 friend class SnapshotWriter; |
| 5093 friend class FunctionSerializationCluster; | 5122 friend class FunctionSerializationCluster; |
| 5094 friend class CodeSerializationCluster; | 5123 friend class CodeSerializationCluster; |
| 5095 friend class CodePatcher; // for set_instructions | 5124 friend class CodePatcher; // for set_instructions |
| 5096 friend class ProgramVisitor; // for set_instructions | 5125 friend class ProgramVisitor; // for set_instructions |
| 5097 // So that the RawFunction pointer visitor can determine whether code the | 5126 // So that the RawFunction pointer visitor can determine whether code the |
| 5098 // function points to is optimized. | 5127 // function points to is optimized. |
| 5099 friend class RawFunction; | 5128 friend class RawFunction; |
| 5100 }; | 5129 }; |
| 5101 | 5130 |
| 5102 | 5131 |
| 5103 class Context : public Object { | 5132 class Context : public Object { |
| 5104 public: | 5133 public: |
| 5105 RawContext* parent() const { return raw_ptr()->parent_; } | 5134 RawContext* parent() const { return raw_ptr()->parent_; } |
| (...skipping 3947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9053 | 9082 |
| 9054 inline void TypeArguments::SetHash(intptr_t value) const { | 9083 inline void TypeArguments::SetHash(intptr_t value) const { |
| 9055 // This is only safe because we create a new Smi, which does not cause | 9084 // This is only safe because we create a new Smi, which does not cause |
| 9056 // heap allocation. | 9085 // heap allocation. |
| 9057 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); | 9086 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); |
| 9058 } | 9087 } |
| 9059 | 9088 |
| 9060 } // namespace dart | 9089 } // namespace dart |
| 9061 | 9090 |
| 9062 #endif // RUNTIME_VM_OBJECT_H_ | 9091 #endif // RUNTIME_VM_OBJECT_H_ |
| OLD | NEW |