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

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

Issue 2891053003: Add support for converted closures with explicit contexts to VM (Closed)
Patch Set: Temporarily disable Run step in closures test suite Created 3 years, 5 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
« no previous file with comments | « runtime/vm/kernel_to_il.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 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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 return *vm_isolate_snapshot_object_table_; 490 return *vm_isolate_snapshot_object_table_;
491 } 491 }
492 static const Type& dynamic_type() { 492 static const Type& dynamic_type() {
493 ASSERT(dynamic_type_ != NULL); 493 ASSERT(dynamic_type_ != NULL);
494 return *dynamic_type_; 494 return *dynamic_type_;
495 } 495 }
496 static const Type& void_type() { 496 static const Type& void_type() {
497 ASSERT(void_type_ != NULL); 497 ASSERT(void_type_ != NULL);
498 return *void_type_; 498 return *void_type_;
499 } 499 }
500 static const Type& vector_type() {
501 ASSERT(vector_type_ != NULL);
502 return *vector_type_;
503 }
500 504
501 static void set_vm_isolate_snapshot_object_table(const Array& table); 505 static void set_vm_isolate_snapshot_object_table(const Array& table);
502 506
503 static RawClass* class_class() { return class_class_; } 507 static RawClass* class_class() { return class_class_; }
504 static RawClass* dynamic_class() { return dynamic_class_; } 508 static RawClass* dynamic_class() { return dynamic_class_; }
505 static RawClass* void_class() { return void_class_; } 509 static RawClass* void_class() { return void_class_; }
506 static RawClass* unresolved_class_class() { return unresolved_class_class_; } 510 static RawClass* unresolved_class_class() { return unresolved_class_class_; }
507 static RawClass* type_arguments_class() { return type_arguments_class_; } 511 static RawClass* type_arguments_class() { return type_arguments_class_; }
508 static RawClass* patch_class_class() { return patch_class_class_; } 512 static RawClass* patch_class_class() { return patch_class_class_; }
509 static RawClass* function_class() { return function_class_; } 513 static RawClass* function_class() { return function_class_; }
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 static cpp_vtable handle_vtable_; 758 static cpp_vtable handle_vtable_;
755 static cpp_vtable builtin_vtables_[kNumPredefinedCids]; 759 static cpp_vtable builtin_vtables_[kNumPredefinedCids];
756 760
757 // The static values below are singletons shared between the different 761 // The static values below are singletons shared between the different
758 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_. 762 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_.
759 static RawObject* null_; 763 static RawObject* null_;
760 764
761 static RawClass* class_class_; // Class of the Class vm object. 765 static RawClass* class_class_; // Class of the Class vm object.
762 static RawClass* dynamic_class_; // Class of the 'dynamic' type. 766 static RawClass* dynamic_class_; // Class of the 'dynamic' type.
763 static RawClass* void_class_; // Class of the 'void' type. 767 static RawClass* void_class_; // Class of the 'void' type.
768 static RawClass* vector_class_; // Class of the 'vector' type.
764 static RawClass* unresolved_class_class_; // Class of UnresolvedClass. 769 static RawClass* unresolved_class_class_; // Class of UnresolvedClass.
765 static RawClass* type_arguments_class_; // Class of TypeArguments vm object. 770 static RawClass* type_arguments_class_; // Class of TypeArguments vm object.
766 static RawClass* patch_class_class_; // Class of the PatchClass vm object. 771 static RawClass* patch_class_class_; // Class of the PatchClass vm object.
767 static RawClass* function_class_; // Class of the Function vm object. 772 static RawClass* function_class_; // Class of the Function vm object.
768 static RawClass* closure_data_class_; // Class of ClosureData vm obj. 773 static RawClass* closure_data_class_; // Class of ClosureData vm obj.
769 static RawClass* signature_data_class_; // Class of SignatureData vm obj. 774 static RawClass* signature_data_class_; // Class of SignatureData vm obj.
770 static RawClass* redirection_data_class_; // Class of RedirectionData vm obj. 775 static RawClass* redirection_data_class_; // Class of RedirectionData vm obj.
771 static RawClass* field_class_; // Class of the Field vm object. 776 static RawClass* field_class_; // Class of the Field vm object.
772 static RawClass* literal_token_class_; // Class of LiteralToken vm object. 777 static RawClass* literal_token_class_; // Class of LiteralToken vm object.
773 static RawClass* token_stream_class_; // Class of the TokenStream vm object. 778 static RawClass* token_stream_class_; // Class of the TokenStream vm object.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 static Bool* bool_true_; 825 static Bool* bool_true_;
821 static Bool* bool_false_; 826 static Bool* bool_false_;
822 static Smi* smi_illegal_cid_; 827 static Smi* smi_illegal_cid_;
823 static LanguageError* snapshot_writer_error_; 828 static LanguageError* snapshot_writer_error_;
824 static LanguageError* branch_offset_error_; 829 static LanguageError* branch_offset_error_;
825 static LanguageError* speculative_inlining_error_; 830 static LanguageError* speculative_inlining_error_;
826 static LanguageError* background_compilation_error_; 831 static LanguageError* background_compilation_error_;
827 static Array* vm_isolate_snapshot_object_table_; 832 static Array* vm_isolate_snapshot_object_table_;
828 static Type* dynamic_type_; 833 static Type* dynamic_type_;
829 static Type* void_type_; 834 static Type* void_type_;
835 static Type* vector_type_;
830 836
831 friend void ClassTable::Register(const Class& cls); 837 friend void ClassTable::Register(const Class& cls);
832 friend void RawObject::Validate(Isolate* isolate) const; 838 friend void RawObject::Validate(Isolate* isolate) const;
833 friend class Closure; 839 friend class Closure;
834 friend class SnapshotReader; 840 friend class SnapshotReader;
835 friend class InstanceDeserializationCluster; 841 friend class InstanceDeserializationCluster;
836 friend class OneByteString; 842 friend class OneByteString;
837 friend class TwoByteString; 843 friend class TwoByteString;
838 friend class ExternalOneByteString; 844 friend class ExternalOneByteString;
839 friend class ExternalTwoByteString; 845 friend class ExternalTwoByteString;
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after
2392 bool IsInvokeFieldDispatcher() const { 2398 bool IsInvokeFieldDispatcher() const {
2393 return kind() == RawFunction::kInvokeFieldDispatcher; 2399 return kind() == RawFunction::kInvokeFieldDispatcher;
2394 } 2400 }
2395 2401
2396 // Returns true iff an implicit closure function has been created 2402 // Returns true iff an implicit closure function has been created
2397 // for this function. 2403 // for this function.
2398 bool HasImplicitClosureFunction() const { 2404 bool HasImplicitClosureFunction() const {
2399 return implicit_closure_function() != null(); 2405 return implicit_closure_function() != null();
2400 } 2406 }
2401 2407
2402 // Return the closure function implicitly created for this function. 2408 // Returns true iff a converted closure function has been created
2403 // If none exists yet, create one and remember it. 2409 // for this function.
2410 bool HasConvertedClosureFunction() const {
2411 return converted_closure_function() != null();
2412 }
2413
2414 // Returns the closure function implicitly created for this function. If none
2415 // exists yet, create one and remember it. Implicit closure functions are
2416 // used in VM Closure instances that represent results of tear-off operations.
2404 RawFunction* ImplicitClosureFunction() const; 2417 RawFunction* ImplicitClosureFunction() const;
2405 void DropUncompiledImplicitClosureFunction() const; 2418 void DropUncompiledImplicitClosureFunction() const;
2406 2419
2420 // Returns the converted closure function created for this function.
2421 // If none exists yet, create one and remember it. See the comment on
2422 // ConvertedClosureFunction definition in runtime/vm/object.cc for elaborate
2423 // explanation.
2424 RawFunction* ConvertedClosureFunction() const;
2425 void DropUncompiledConvertedClosureFunction() const;
2426
2407 // Return the closure implicitly created for this function. 2427 // Return the closure implicitly created for this function.
2408 // If none exists yet, create one and remember it. 2428 // If none exists yet, create one and remember it.
2409 RawInstance* ImplicitStaticClosure() const; 2429 RawInstance* ImplicitStaticClosure() const;
2410 2430
2411 RawInstance* ImplicitInstanceClosure(const Instance& receiver) const; 2431 RawInstance* ImplicitInstanceClosure(const Instance& receiver) const;
2412 2432
2413 intptr_t ComputeClosureHash() const; 2433 intptr_t ComputeClosureHash() const;
2414 2434
2415 // Redirection information for a redirecting factory. 2435 // Redirection information for a redirecting factory.
2416 bool IsRedirectingFactory() const; 2436 bool IsRedirectingFactory() const;
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
2757 } 2777 }
2758 2778
2759 // Returns true if this function represents a generated irregexp function. 2779 // Returns true if this function represents a generated irregexp function.
2760 bool IsIrregexpFunction() const { 2780 bool IsIrregexpFunction() const {
2761 return kind() == RawFunction::kIrregexpFunction; 2781 return kind() == RawFunction::kIrregexpFunction;
2762 } 2782 }
2763 2783
2764 // Returns true if this function represents an implicit closure function. 2784 // Returns true if this function represents an implicit closure function.
2765 bool IsImplicitClosureFunction() const; 2785 bool IsImplicitClosureFunction() const;
2766 2786
2787 // Returns true if this function represents a converted closure function.
2788 bool IsConvertedClosureFunction() const {
2789 return kind() == RawFunction::kConvertedClosureFunction;
2790 }
2791
2767 // Returns true if this function represents a non implicit closure function. 2792 // Returns true if this function represents a non implicit closure function.
2768 bool IsNonImplicitClosureFunction() const { 2793 bool IsNonImplicitClosureFunction() const {
2769 return IsClosureFunction() && !IsImplicitClosureFunction(); 2794 return IsClosureFunction() && !IsImplicitClosureFunction();
2770 } 2795 }
2771 2796
2772 // Returns true if this function represents an implicit static closure 2797 // Returns true if this function represents an implicit static closure
2773 // function. 2798 // function.
2774 bool IsImplicitStaticClosureFunction() const { 2799 bool IsImplicitStaticClosureFunction() const {
2775 return is_static() && IsImplicitClosureFunction(); 2800 return is_static() && IsImplicitClosureFunction();
2776 } 2801 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2849 bool is_native, 2874 bool is_native,
2850 const Object& owner, 2875 const Object& owner,
2851 TokenPosition token_pos, 2876 TokenPosition token_pos,
2852 Heap::Space space = Heap::kOld); 2877 Heap::Space space = Heap::kOld);
2853 2878
2854 // Allocates a new Function object representing a closure function. 2879 // Allocates a new Function object representing a closure function.
2855 static RawFunction* NewClosureFunction(const String& name, 2880 static RawFunction* NewClosureFunction(const String& name,
2856 const Function& parent, 2881 const Function& parent,
2857 TokenPosition token_pos); 2882 TokenPosition token_pos);
2858 2883
2884 // Allocates a new Function object representing a converted closure function.
2885 static RawFunction* NewConvertedClosureFunction(const String& name,
2886 const Function& parent,
2887 TokenPosition token_pos);
2888
2859 // Allocates a new Function object representing a signature function. 2889 // Allocates a new Function object representing a signature function.
2860 // The owner is the scope class of the function type. 2890 // The owner is the scope class of the function type.
2861 // The parent is the enclosing function or null if none. 2891 // The parent is the enclosing function or null if none.
2862 static RawFunction* NewSignatureFunction(const Object& owner, 2892 static RawFunction* NewSignatureFunction(const Object& owner,
2863 const Function& parent, 2893 const Function& parent,
2864 TokenPosition token_pos, 2894 TokenPosition token_pos,
2865 Heap::Space space = Heap::kOld); 2895 Heap::Space space = Heap::kOld);
2866 2896
2867 static RawFunction* NewEvalFunction(const Class& owner, 2897 static RawFunction* NewEvalFunction(const Class& owner,
2868 const Script& script, 2898 const Script& script,
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
3012 class name##Bit : public BitField<uint32_t, bool, k##name##Bit, 1> {}; 3042 class name##Bit : public BitField<uint32_t, bool, k##name##Bit, 1> {};
3013 FOR_EACH_FUNCTION_KIND_BIT(DEFINE_BIT) 3043 FOR_EACH_FUNCTION_KIND_BIT(DEFINE_BIT)
3014 #undef DEFINE_BIT 3044 #undef DEFINE_BIT
3015 3045
3016 void set_name(const String& value) const; 3046 void set_name(const String& value) const;
3017 void set_kind(RawFunction::Kind value) const; 3047 void set_kind(RawFunction::Kind value) const;
3018 void set_parent_function(const Function& value) const; 3048 void set_parent_function(const Function& value) const;
3019 void set_owner(const Object& value) const; 3049 void set_owner(const Object& value) const;
3020 RawFunction* implicit_closure_function() const; 3050 RawFunction* implicit_closure_function() const;
3021 void set_implicit_closure_function(const Function& value) const; 3051 void set_implicit_closure_function(const Function& value) const;
3052 RawFunction* converted_closure_function() const;
3053 void set_converted_closure_function(const Function& value) const;
3022 RawInstance* implicit_static_closure() const; 3054 RawInstance* implicit_static_closure() const;
3023 void set_implicit_static_closure(const Instance& closure) const; 3055 void set_implicit_static_closure(const Instance& closure) const;
3024 RawScript* eval_script() const; 3056 RawScript* eval_script() const;
3025 void set_eval_script(const Script& value) const; 3057 void set_eval_script(const Script& value) const;
3026 void set_num_optional_parameters(intptr_t value) const; // Encoded value. 3058 void set_num_optional_parameters(intptr_t value) const; // Encoded value.
3027 void set_kind_tag(uint32_t value) const; 3059 void set_kind_tag(uint32_t value) const;
3028 void set_data(const Object& value) const; 3060 void set_data(const Object& value) const;
3029 3061
3030 static RawFunction* New(Heap::Space space = Heap::kOld); 3062 static RawFunction* New(Heap::Space space = Heap::kOld);
3031 3063
(...skipping 5902 matching lines...) Expand 10 before | Expand all | Expand 10 after
8934 8966
8935 inline void TypeArguments::SetHash(intptr_t value) const { 8967 inline void TypeArguments::SetHash(intptr_t value) const {
8936 // This is only safe because we create a new Smi, which does not cause 8968 // This is only safe because we create a new Smi, which does not cause
8937 // heap allocation. 8969 // heap allocation.
8938 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); 8970 StoreSmi(&raw_ptr()->hash_, Smi::New(value));
8939 } 8971 }
8940 8972
8941 } // namespace dart 8973 } // namespace dart
8942 8974
8943 #endif // RUNTIME_VM_OBJECT_H_ 8975 #endif // RUNTIME_VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/kernel_to_il.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698