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

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

Issue 1325373004: More cleanups for background compilation. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Simpler code Created 5 years, 3 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/object.h ('k') | runtime/vm/parser.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 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 3568 matching lines...) Expand 10 before | Expand all | Expand 10 after
3579 if (direct_subclasses.IsNull()) { 3579 if (direct_subclasses.IsNull()) {
3580 direct_subclasses = GrowableObjectArray::New(4, Heap::kOld); 3580 direct_subclasses = GrowableObjectArray::New(4, Heap::kOld);
3581 StorePointer(&raw_ptr()->direct_subclasses_, direct_subclasses.raw()); 3581 StorePointer(&raw_ptr()->direct_subclasses_, direct_subclasses.raw());
3582 } 3582 }
3583 #if defined(DEBUG) 3583 #if defined(DEBUG)
3584 // Verify that the same class is not added twice. 3584 // Verify that the same class is not added twice.
3585 for (intptr_t i = 0; i < direct_subclasses.Length(); i++) { 3585 for (intptr_t i = 0; i < direct_subclasses.Length(); i++) {
3586 ASSERT(direct_subclasses.At(i) != subclass.raw()); 3586 ASSERT(direct_subclasses.At(i) != subclass.raw());
3587 } 3587 }
3588 #endif 3588 #endif
3589 direct_subclasses.Add(subclass); 3589 direct_subclasses.Add(subclass, Heap::kOld);
3590 } 3590 }
3591 3591
3592 3592
3593 RawArray* Class::constants() const { 3593 RawArray* Class::constants() const {
3594 return raw_ptr()->constants_; 3594 return raw_ptr()->constants_;
3595 } 3595 }
3596 3596
3597 void Class::set_constants(const Array& value) const { 3597 void Class::set_constants(const Array& value) const {
3598 ASSERT(!value.IsNull()); 3598 ASSERT(!value.IsNull());
3599 StorePointer(&raw_ptr()->constants_, value.raw()); 3599 StorePointer(&raw_ptr()->constants_, value.raw());
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
3728 // If test_kind == kIsMoreSpecificThan, checks if S is more specific than T. 3728 // If test_kind == kIsMoreSpecificThan, checks if S is more specific than T.
3729 // Type S is specified by this class parameterized with 'type_arguments', and 3729 // Type S is specified by this class parameterized with 'type_arguments', and
3730 // type T by class 'other' parameterized with 'other_type_arguments'. 3730 // type T by class 'other' parameterized with 'other_type_arguments'.
3731 // This class and class 'other' do not need to be finalized, however, they must 3731 // This class and class 'other' do not need to be finalized, however, they must
3732 // be resolved as well as their interfaces. 3732 // be resolved as well as their interfaces.
3733 bool Class::TypeTestNonRecursive(const Class& cls, 3733 bool Class::TypeTestNonRecursive(const Class& cls,
3734 Class::TypeTestKind test_kind, 3734 Class::TypeTestKind test_kind,
3735 const TypeArguments& type_arguments, 3735 const TypeArguments& type_arguments,
3736 const Class& other, 3736 const Class& other,
3737 const TypeArguments& other_type_arguments, 3737 const TypeArguments& other_type_arguments,
3738 Error* bound_error) { 3738 Error* bound_error,
3739 Heap::Space space) {
3739 // Use the thsi object as if it was the receiver of this method, but instead 3740 // Use the thsi object as if it was the receiver of this method, but instead
3740 // of recursing reset it to the super class and loop. 3741 // of recursing reset it to the super class and loop.
3741 Isolate* isolate = Isolate::Current(); 3742 Isolate* isolate = Isolate::Current();
3742 Class& thsi = Class::Handle(isolate, cls.raw()); 3743 Class& thsi = Class::Handle(isolate, cls.raw());
3743 while (true) { 3744 while (true) {
3744 ASSERT(!thsi.IsVoidClass()); 3745 ASSERT(!thsi.IsVoidClass());
3745 // Check for DynamicType. 3746 // Check for DynamicType.
3746 // Each occurrence of DynamicType in type T is interpreted as the dynamic 3747 // Each occurrence of DynamicType in type T is interpreted as the dynamic
3747 // type, a supertype of all types. 3748 // type, a supertype of all types.
3748 if (other.IsDynamicClass()) { 3749 if (other.IsDynamicClass()) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3785 type_arguments.IsRaw(from_index, num_type_params)) { 3786 type_arguments.IsRaw(from_index, num_type_params)) {
3786 // Other type can't be more specific than this one because for that 3787 // Other type can't be more specific than this one because for that
3787 // it would have to have all dynamic type arguments which is checked 3788 // it would have to have all dynamic type arguments which is checked
3788 // above. 3789 // above.
3789 return test_kind == Class::kIsSubtypeOf; 3790 return test_kind == Class::kIsSubtypeOf;
3790 } 3791 }
3791 return type_arguments.TypeTest(test_kind, 3792 return type_arguments.TypeTest(test_kind,
3792 other_type_arguments, 3793 other_type_arguments,
3793 from_index, 3794 from_index,
3794 num_type_params, 3795 num_type_params,
3795 bound_error); 3796 bound_error,
3797 space);
3796 } 3798 }
3797 const bool other_is_function_class = other.IsFunctionClass(); 3799 const bool other_is_function_class = other.IsFunctionClass();
3798 if (other.IsSignatureClass() || other_is_function_class) { 3800 if (other.IsSignatureClass() || other_is_function_class) {
3799 const Function& other_fun = Function::Handle(isolate, 3801 const Function& other_fun = Function::Handle(isolate,
3800 other.signature_function()); 3802 other.signature_function());
3801 if (thsi.IsSignatureClass()) { 3803 if (thsi.IsSignatureClass()) {
3802 if (other_is_function_class) { 3804 if (other_is_function_class) {
3803 return true; 3805 return true;
3804 } 3806 }
3805 // Check for two function types. 3807 // Check for two function types.
3806 const Function& fun = 3808 const Function& fun =
3807 Function::Handle(isolate, thsi.signature_function()); 3809 Function::Handle(isolate, thsi.signature_function());
3808 return fun.TypeTest(test_kind, 3810 return fun.TypeTest(test_kind,
3809 type_arguments, 3811 type_arguments,
3810 other_fun, 3812 other_fun,
3811 other_type_arguments, 3813 other_type_arguments,
3812 bound_error); 3814 bound_error,
3815 space);
3813 } 3816 }
3814 // Check if type S has a call() method of function type T. 3817 // Check if type S has a call() method of function type T.
3815 Function& function = 3818 Function& function =
3816 Function::Handle(isolate, 3819 Function::Handle(isolate,
3817 thsi.LookupDynamicFunction(Symbols::Call())); 3820 thsi.LookupDynamicFunction(Symbols::Call()));
3818 if (function.IsNull()) { 3821 if (function.IsNull()) {
3819 // Walk up the super_class chain. 3822 // Walk up the super_class chain.
3820 Class& cls = Class::Handle(isolate, thsi.SuperClass()); 3823 Class& cls = Class::Handle(isolate, thsi.SuperClass());
3821 while (!cls.IsNull() && function.IsNull()) { 3824 while (!cls.IsNull() && function.IsNull()) {
3822 function = cls.LookupDynamicFunction(Symbols::Call()); 3825 function = cls.LookupDynamicFunction(Symbols::Call());
3823 cls = cls.SuperClass(); 3826 cls = cls.SuperClass();
3824 } 3827 }
3825 } 3828 }
3826 if (!function.IsNull()) { 3829 if (!function.IsNull()) {
3827 if (other_is_function_class || 3830 if (other_is_function_class ||
3828 function.TypeTest(test_kind, 3831 function.TypeTest(test_kind,
3829 type_arguments, 3832 type_arguments,
3830 other_fun, 3833 other_fun,
3831 other_type_arguments, 3834 other_type_arguments,
3832 bound_error)) { 3835 bound_error,
3836 space)) {
3833 return true; 3837 return true;
3834 } 3838 }
3835 } 3839 }
3836 } 3840 }
3837 // Check for 'direct super type' specified in the implements clause 3841 // Check for 'direct super type' specified in the implements clause
3838 // and check for transitivity at the same time. 3842 // and check for transitivity at the same time.
3839 Array& interfaces = Array::Handle(isolate, thsi.interfaces()); 3843 Array& interfaces = Array::Handle(isolate, thsi.interfaces());
3840 AbstractType& interface = AbstractType::Handle(isolate); 3844 AbstractType& interface = AbstractType::Handle(isolate);
3841 Class& interface_class = Class::Handle(isolate); 3845 Class& interface_class = Class::Handle(isolate);
3842 TypeArguments& interface_args = TypeArguments::Handle(isolate); 3846 TypeArguments& interface_args = TypeArguments::Handle(isolate);
(...skipping 19 matching lines...) Expand all
3862 if (!interface_args.IsNull() && !interface_args.IsInstantiated()) { 3866 if (!interface_args.IsNull() && !interface_args.IsInstantiated()) {
3863 // This type class implements an interface that is parameterized with 3867 // This type class implements an interface that is parameterized with
3864 // generic type(s), e.g. it implements List<T>. 3868 // generic type(s), e.g. it implements List<T>.
3865 // The uninstantiated type T must be instantiated using the type 3869 // The uninstantiated type T must be instantiated using the type
3866 // parameters of this type before performing the type test. 3870 // parameters of this type before performing the type test.
3867 // The type arguments of this type that are referred to by the type 3871 // The type arguments of this type that are referred to by the type
3868 // parameters of the interface are at the end of the type vector, 3872 // parameters of the interface are at the end of the type vector,
3869 // after the type arguments of the super type of this type. 3873 // after the type arguments of the super type of this type.
3870 // The index of the type parameters is adjusted upon finalization. 3874 // The index of the type parameters is adjusted upon finalization.
3871 error = Error::null(); 3875 error = Error::null();
3872 interface_args = interface_args.InstantiateFrom(type_arguments, &error); 3876 interface_args =
3877 interface_args.InstantiateFrom(type_arguments, &error, NULL, space);
3873 if (!error.IsNull()) { 3878 if (!error.IsNull()) {
3874 // Return the first bound error to the caller if it requests it. 3879 // Return the first bound error to the caller if it requests it.
3875 if ((bound_error != NULL) && bound_error->IsNull()) { 3880 if ((bound_error != NULL) && bound_error->IsNull()) {
3876 *bound_error = error.raw(); 3881 *bound_error = error.raw();
3877 } 3882 }
3878 continue; // Another interface may work better. 3883 continue; // Another interface may work better.
3879 } 3884 }
3880 } 3885 }
3881 if (interface_class.TypeTest(test_kind, 3886 if (interface_class.TypeTest(test_kind,
3882 interface_args, 3887 interface_args,
3883 other, 3888 other,
3884 other_type_arguments, 3889 other_type_arguments,
3885 bound_error)) { 3890 bound_error,
3891 space)) {
3886 return true; 3892 return true;
3887 } 3893 }
3888 } 3894 }
3889 // "Recurse" up the class hierarchy until we have reached the top. 3895 // "Recurse" up the class hierarchy until we have reached the top.
3890 thsi = thsi.SuperClass(); 3896 thsi = thsi.SuperClass();
3891 if (thsi.IsNull()) { 3897 if (thsi.IsNull()) {
3892 return false; 3898 return false;
3893 } 3899 }
3894 } 3900 }
3895 UNREACHABLE(); 3901 UNREACHABLE();
3896 return false; 3902 return false;
3897 } 3903 }
3898 3904
3899 3905
3900 // If test_kind == kIsSubtypeOf, checks if type S is a subtype of type T. 3906 // If test_kind == kIsSubtypeOf, checks if type S is a subtype of type T.
3901 // If test_kind == kIsMoreSpecificThan, checks if S is more specific than T. 3907 // If test_kind == kIsMoreSpecificThan, checks if S is more specific than T.
3902 // Type S is specified by this class parameterized with 'type_arguments', and 3908 // Type S is specified by this class parameterized with 'type_arguments', and
3903 // type T by class 'other' parameterized with 'other_type_arguments'. 3909 // type T by class 'other' parameterized with 'other_type_arguments'.
3904 // This class and class 'other' do not need to be finalized, however, they must 3910 // This class and class 'other' do not need to be finalized, however, they must
3905 // be resolved as well as their interfaces. 3911 // be resolved as well as their interfaces.
3906 bool Class::TypeTest(TypeTestKind test_kind, 3912 bool Class::TypeTest(TypeTestKind test_kind,
3907 const TypeArguments& type_arguments, 3913 const TypeArguments& type_arguments,
3908 const Class& other, 3914 const Class& other,
3909 const TypeArguments& other_type_arguments, 3915 const TypeArguments& other_type_arguments,
3910 Error* bound_error) const { 3916 Error* bound_error,
3917 Heap::Space space) const {
3911 return TypeTestNonRecursive(*this, 3918 return TypeTestNonRecursive(*this,
3912 test_kind, 3919 test_kind,
3913 type_arguments, 3920 type_arguments,
3914 other, 3921 other,
3915 other_type_arguments, 3922 other_type_arguments,
3916 bound_error); 3923 bound_error,
3924 space);
3917 } 3925 }
3918 3926
3919 3927
3920 bool Class::IsTopLevel() const { 3928 bool Class::IsTopLevel() const {
3921 return Name() == Symbols::TopLevel().raw(); 3929 return Name() == Symbols::TopLevel().raw();
3922 } 3930 }
3923 3931
3924 3932
3925 bool Class::IsPrivate() const { 3933 bool Class::IsPrivate() const {
3926 return Library::IsPrivate(String::Handle(Name())); 3934 return Library::IsPrivate(String::Handle(Name()));
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
4544 } 4552 }
4545 } 4553 }
4546 return true; 4554 return true;
4547 } 4555 }
4548 4556
4549 4557
4550 bool TypeArguments::TypeTest(TypeTestKind test_kind, 4558 bool TypeArguments::TypeTest(TypeTestKind test_kind,
4551 const TypeArguments& other, 4559 const TypeArguments& other,
4552 intptr_t from_index, 4560 intptr_t from_index,
4553 intptr_t len, 4561 intptr_t len,
4554 Error* bound_error) const { 4562 Error* bound_error,
4563 Heap::Space space) const {
4555 ASSERT(Length() >= (from_index + len)); 4564 ASSERT(Length() >= (from_index + len));
4556 ASSERT(!other.IsNull()); 4565 ASSERT(!other.IsNull());
4557 ASSERT(other.Length() >= (from_index + len)); 4566 ASSERT(other.Length() >= (from_index + len));
4558 AbstractType& type = AbstractType::Handle(); 4567 AbstractType& type = AbstractType::Handle();
4559 AbstractType& other_type = AbstractType::Handle(); 4568 AbstractType& other_type = AbstractType::Handle();
4560 for (intptr_t i = 0; i < len; i++) { 4569 for (intptr_t i = 0; i < len; i++) {
4561 type = TypeAt(from_index + i); 4570 type = TypeAt(from_index + i);
4562 ASSERT(!type.IsNull()); 4571 ASSERT(!type.IsNull());
4563 other_type = other.TypeAt(from_index + i); 4572 other_type = other.TypeAt(from_index + i);
4564 ASSERT(!other_type.IsNull()); 4573 ASSERT(!other_type.IsNull());
4565 if (!type.TypeTest(test_kind, other_type, bound_error)) { 4574 if (!type.TypeTest(test_kind, other_type, bound_error, space)) {
4566 return false; 4575 return false;
4567 } 4576 }
4568 } 4577 }
4569 return true; 4578 return true;
4570 } 4579 }
4571 4580
4572 4581
4573 void TypeArguments::PrintJSONImpl(JSONStream* stream, bool ref) const { 4582 void TypeArguments::PrintJSONImpl(JSONStream* stream, bool ref) const {
4574 JSONObject jsobj(stream); 4583 JSONObject jsobj(stream);
4575 // The index in the canonical_type_arguments table cannot be used as part of 4584 // The index in the canonical_type_arguments table cannot be used as part of
(...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after
6040 } 6049 }
6041 6050
6042 6051
6043 bool Function::HasCompatibleParametersWith(const Function& other, 6052 bool Function::HasCompatibleParametersWith(const Function& other,
6044 Error* bound_error) const { 6053 Error* bound_error) const {
6045 ASSERT(Isolate::Current()->flags().error_on_bad_override()); 6054 ASSERT(Isolate::Current()->flags().error_on_bad_override());
6046 ASSERT((bound_error != NULL) && bound_error->IsNull()); 6055 ASSERT((bound_error != NULL) && bound_error->IsNull());
6047 // Check that this function's signature type is a subtype of the other 6056 // Check that this function's signature type is a subtype of the other
6048 // function's signature type. 6057 // function's signature type.
6049 if (!TypeTest(kIsSubtypeOf, Object::null_type_arguments(), 6058 if (!TypeTest(kIsSubtypeOf, Object::null_type_arguments(),
6050 other, Object::null_type_arguments(), bound_error)) { 6059 other, Object::null_type_arguments(), bound_error,
6060 Heap::kOld)) {
6051 // For more informative error reporting, use the location of the other 6061 // For more informative error reporting, use the location of the other
6052 // function here, since the caller will use the location of this function. 6062 // function here, since the caller will use the location of this function.
6053 *bound_error = LanguageError::NewFormatted( 6063 *bound_error = LanguageError::NewFormatted(
6054 *bound_error, // A bound error if non null. 6064 *bound_error, // A bound error if non null.
6055 Script::Handle(other.script()), 6065 Script::Handle(other.script()),
6056 other.token_pos(), 6066 other.token_pos(),
6057 Report::kError, 6067 Report::kError,
6058 Heap::kNew, 6068 Heap::kNew,
6059 "signature type '%s' of function '%s' is not a subtype of signature " 6069 "signature type '%s' of function '%s' is not a subtype of signature "
6060 "type '%s' of function '%s'", 6070 "type '%s' of function '%s'",
(...skipping 21 matching lines...) Expand all
6082 // parameter of the other function. 6092 // parameter of the other function.
6083 // Note that we do not apply contravariance of parameter types, but covariance 6093 // Note that we do not apply contravariance of parameter types, but covariance
6084 // of both parameter types and result type. 6094 // of both parameter types and result type.
6085 bool Function::TestParameterType( 6095 bool Function::TestParameterType(
6086 TypeTestKind test_kind, 6096 TypeTestKind test_kind,
6087 intptr_t parameter_position, 6097 intptr_t parameter_position,
6088 intptr_t other_parameter_position, 6098 intptr_t other_parameter_position,
6089 const TypeArguments& type_arguments, 6099 const TypeArguments& type_arguments,
6090 const Function& other, 6100 const Function& other,
6091 const TypeArguments& other_type_arguments, 6101 const TypeArguments& other_type_arguments,
6092 Error* bound_error) const { 6102 Error* bound_error,
6103 Heap::Space space) const {
6093 AbstractType& other_param_type = 6104 AbstractType& other_param_type =
6094 AbstractType::Handle(other.ParameterTypeAt(other_parameter_position)); 6105 AbstractType::Handle(other.ParameterTypeAt(other_parameter_position));
6095 if (!other_param_type.IsInstantiated()) { 6106 if (!other_param_type.IsInstantiated()) {
6096 other_param_type = other_param_type.InstantiateFrom(other_type_arguments, 6107 other_param_type = other_param_type.InstantiateFrom(other_type_arguments,
6097 bound_error); 6108 bound_error,
6109 NULL, // trail
6110 space);
6098 ASSERT((bound_error == NULL) || bound_error->IsNull()); 6111 ASSERT((bound_error == NULL) || bound_error->IsNull());
6099 } 6112 }
6100 if (other_param_type.IsDynamicType()) { 6113 if (other_param_type.IsDynamicType()) {
6101 return true; 6114 return true;
6102 } 6115 }
6103 AbstractType& param_type = 6116 AbstractType& param_type =
6104 AbstractType::Handle(ParameterTypeAt(parameter_position)); 6117 AbstractType::Handle(ParameterTypeAt(parameter_position));
6105 if (!param_type.IsInstantiated()) { 6118 if (!param_type.IsInstantiated()) {
6106 param_type = param_type.InstantiateFrom(type_arguments, bound_error); 6119 param_type = param_type.InstantiateFrom(
6120 type_arguments, bound_error, NULL /*trail*/, space);
6107 ASSERT((bound_error == NULL) || bound_error->IsNull()); 6121 ASSERT((bound_error == NULL) || bound_error->IsNull());
6108 } 6122 }
6109 if (param_type.IsDynamicType()) { 6123 if (param_type.IsDynamicType()) {
6110 return test_kind == kIsSubtypeOf; 6124 return test_kind == kIsSubtypeOf;
6111 } 6125 }
6112 if (test_kind == kIsSubtypeOf) { 6126 if (test_kind == kIsSubtypeOf) {
6113 if (!param_type.IsSubtypeOf(other_param_type, bound_error) && 6127 if (!param_type.IsSubtypeOf(other_param_type, bound_error, space) &&
6114 !other_param_type.IsSubtypeOf(param_type, bound_error)) { 6128 !other_param_type.IsSubtypeOf(param_type, bound_error, space)) {
6115 return false; 6129 return false;
6116 } 6130 }
6117 } else { 6131 } else {
6118 ASSERT(test_kind == kIsMoreSpecificThan); 6132 ASSERT(test_kind == kIsMoreSpecificThan);
6119 if (!param_type.IsMoreSpecificThan(other_param_type, bound_error)) { 6133 if (!param_type.IsMoreSpecificThan(other_param_type, bound_error, space)) {
6120 return false; 6134 return false;
6121 } 6135 }
6122 } 6136 }
6123 return true; 6137 return true;
6124 } 6138 }
6125 6139
6126 6140
6127 bool Function::TypeTest(TypeTestKind test_kind, 6141 bool Function::TypeTest(TypeTestKind test_kind,
6128 const TypeArguments& type_arguments, 6142 const TypeArguments& type_arguments,
6129 const Function& other, 6143 const Function& other,
6130 const TypeArguments& other_type_arguments, 6144 const TypeArguments& other_type_arguments,
6131 Error* bound_error) const { 6145 Error* bound_error,
6146 Heap::Space space) const {
6132 const intptr_t num_fixed_params = num_fixed_parameters(); 6147 const intptr_t num_fixed_params = num_fixed_parameters();
6133 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters(); 6148 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters();
6134 const intptr_t num_opt_named_params = NumOptionalNamedParameters(); 6149 const intptr_t num_opt_named_params = NumOptionalNamedParameters();
6135 const intptr_t other_num_fixed_params = other.num_fixed_parameters(); 6150 const intptr_t other_num_fixed_params = other.num_fixed_parameters();
6136 const intptr_t other_num_opt_pos_params = 6151 const intptr_t other_num_opt_pos_params =
6137 other.NumOptionalPositionalParameters(); 6152 other.NumOptionalPositionalParameters();
6138 const intptr_t other_num_opt_named_params = 6153 const intptr_t other_num_opt_named_params =
6139 other.NumOptionalNamedParameters(); 6154 other.NumOptionalNamedParameters();
6140 // This function requires the same arguments or less and accepts the same 6155 // This function requires the same arguments or less and accepts the same
6141 // arguments or more. 6156 // arguments or more.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
6179 return false; 6194 return false;
6180 } 6195 }
6181 } 6196 }
6182 } 6197 }
6183 // Check the types of fixed and optional positional parameters. 6198 // Check the types of fixed and optional positional parameters.
6184 for (intptr_t i = 0; i < (other_num_fixed_params - other_num_ignored_params + 6199 for (intptr_t i = 0; i < (other_num_fixed_params - other_num_ignored_params +
6185 other_num_opt_pos_params); i++) { 6200 other_num_opt_pos_params); i++) {
6186 if (!TestParameterType(test_kind, 6201 if (!TestParameterType(test_kind,
6187 i + num_ignored_params, i + other_num_ignored_params, 6202 i + num_ignored_params, i + other_num_ignored_params,
6188 type_arguments, other, other_type_arguments, 6203 type_arguments, other, other_type_arguments,
6189 bound_error)) { 6204 bound_error,
6205 space)) {
6190 return false; 6206 return false;
6191 } 6207 }
6192 } 6208 }
6193 // Check the names and types of optional named parameters. 6209 // Check the names and types of optional named parameters.
6194 if (other_num_opt_named_params == 0) { 6210 if (other_num_opt_named_params == 0) {
6195 return true; 6211 return true;
6196 } 6212 }
6197 // Check that for each optional named parameter of type T of the other 6213 // Check that for each optional named parameter of type T of the other
6198 // function type, there exists an optional named parameter of this function 6214 // function type, there exists an optional named parameter of this function
6199 // type with an identical name and with a type S that is a either a subtype 6215 // type with an identical name and with a type S that is a either a subtype
(...skipping 10 matching lines...) Expand all
6210 other_param_name = other.ParameterNameAt(i); 6226 other_param_name = other.ParameterNameAt(i);
6211 ASSERT(other_param_name.IsSymbol()); 6227 ASSERT(other_param_name.IsSymbol());
6212 found_param_name = false; 6228 found_param_name = false;
6213 for (intptr_t j = num_fixed_params; j < num_params; j++) { 6229 for (intptr_t j = num_fixed_params; j < num_params; j++) {
6214 ASSERT(String::Handle(ParameterNameAt(j)).IsSymbol()); 6230 ASSERT(String::Handle(ParameterNameAt(j)).IsSymbol());
6215 if (ParameterNameAt(j) == other_param_name.raw()) { 6231 if (ParameterNameAt(j) == other_param_name.raw()) {
6216 found_param_name = true; 6232 found_param_name = true;
6217 if (!TestParameterType(test_kind, 6233 if (!TestParameterType(test_kind,
6218 j, i, 6234 j, i,
6219 type_arguments, other, other_type_arguments, 6235 type_arguments, other, other_type_arguments,
6220 bound_error)) { 6236 bound_error,
6237 space)) {
6221 return false; 6238 return false;
6222 } 6239 }
6223 break; 6240 break;
6224 } 6241 }
6225 } 6242 }
6226 if (!found_param_name) { 6243 if (!found_param_name) {
6227 return false; 6244 return false;
6228 } 6245 }
6229 } 6246 }
6230 return true; 6247 return true;
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
6756 } else { 6773 } else {
6757 return PrettyName(); 6774 return PrettyName();
6758 } 6775 }
6759 } else { 6776 } else {
6760 if (cls.IsTopLevel()) { 6777 if (cls.IsTopLevel()) {
6761 return PrettyName(); 6778 return PrettyName();
6762 } else { 6779 } else {
6763 tmp = cls.PrettyName(); 6780 tmp = cls.PrettyName();
6764 } 6781 }
6765 } 6782 }
6766 tmp = String::Concat(tmp, Symbols::Dot()); 6783 tmp = String::Concat(tmp, Symbols::Dot(), Heap::kOld);
6767 const String& suffix = String::Handle(PrettyName()); 6784 const String& suffix = String::Handle(PrettyName());
6768 return String::Concat(tmp, suffix); 6785 return String::Concat(tmp, suffix, Heap::kOld);
6769 } 6786 }
6770 6787
6771 6788
6772 RawString* Function::QualifiedUserVisibleName() const { 6789 RawString* Function::QualifiedUserVisibleName() const {
6773 String& tmp = String::Handle(); 6790 String& tmp = String::Handle();
6774 const Class& cls = Class::Handle(Owner()); 6791 const Class& cls = Class::Handle(Owner());
6775 6792
6776 if (IsClosureFunction()) { 6793 if (IsClosureFunction()) {
6777 if (IsLocalFunction() && !IsImplicitClosureFunction()) { 6794 if (IsLocalFunction() && !IsImplicitClosureFunction()) {
6778 const Function& parent = Function::Handle(parent_function()); 6795 const Function& parent = Function::Handle(parent_function());
(...skipping 2282 matching lines...) Expand 10 before | Expand all | Expand 10 after
9061 error = lib.TransitiveLoadError(); 9078 error = lib.TransitiveLoadError();
9062 if (!error.IsNull()) { 9079 if (!error.IsNull()) {
9063 break; 9080 break;
9064 } 9081 }
9065 } 9082 }
9066 return error.raw(); 9083 return error.raw();
9067 } 9084 }
9068 9085
9069 9086
9070 static RawString* MakeClassMetaName(const Class& cls) { 9087 static RawString* MakeClassMetaName(const Class& cls) {
9071 String& cname = String::Handle(cls.Name()); 9088 return Symbols::FromConcat(Symbols::At(), String::Handle(cls.Name()));
9072 return String::Concat(Symbols::At(), cname);
9073 } 9089 }
9074 9090
9075 9091
9076 static RawString* MakeFieldMetaName(const Field& field) { 9092 static RawString* MakeFieldMetaName(const Field& field) {
9077 const String& cname = 9093 const String& cname =
9078 String::Handle(MakeClassMetaName(Class::Handle(field.origin()))); 9094 String::Handle(MakeClassMetaName(Class::Handle(field.origin())));
9079 String& fname = String::Handle(field.name()); 9095 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3);
9080 fname = String::Concat(Symbols::At(), fname); 9096 pieces.Add(cname);
9081 return String::Concat(cname, fname); 9097 pieces.Add(Symbols::At());
9098 pieces.Add(String::Handle(field.name()));
9099 return Symbols::FromConcatAll(pieces);
9082 } 9100 }
9083 9101
9084 9102
9085 static RawString* MakeFunctionMetaName(const Function& func) { 9103 static RawString* MakeFunctionMetaName(const Function& func) {
9086 const String& cname = 9104 const String& cname =
9087 String::Handle(MakeClassMetaName(Class::Handle(func.origin()))); 9105 String::Handle(MakeClassMetaName(Class::Handle(func.origin())));
9088 String& fname = String::Handle(func.QualifiedPrettyName()); 9106 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3);
9089 fname = String::Concat(Symbols::At(), fname); 9107 pieces.Add(cname);
9090 return String::Concat(cname, fname); 9108 pieces.Add(Symbols::At());
9109 pieces.Add(String::Handle(func.QualifiedPrettyName()));
9110 return Symbols::FromConcatAll(pieces);
9091 } 9111 }
9092 9112
9093 9113
9094 static RawString* MakeTypeParameterMetaName(const TypeParameter& param) { 9114 static RawString* MakeTypeParameterMetaName(const TypeParameter& param) {
9095 const String& cname = String::Handle( 9115 const String& cname = String::Handle(
9096 MakeClassMetaName(Class::Handle(param.parameterized_class()))); 9116 MakeClassMetaName(Class::Handle(param.parameterized_class())));
9097 String& pname = String::Handle(param.name()); 9117 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3);
9098 pname = String::Concat(Symbols::At(), pname); 9118 pieces.Add(cname);
9099 return String::Concat(cname, pname); 9119 pieces.Add(Symbols::At());
9120 pieces.Add(String::Handle(param.name()));
9121 return Symbols::FromConcatAll(pieces);
9100 } 9122 }
9101 9123
9102 9124
9103 void Library::AddMetadata(const Class& cls, 9125 void Library::AddMetadata(const Class& cls,
9104 const String& name, 9126 const String& name,
9105 intptr_t token_pos) const { 9127 intptr_t token_pos) const {
9106 const String& metaname = String::Handle(Symbols::New(name)); 9128 const String& metaname = String::Handle(Symbols::New(name));
9107 Field& field = Field::Handle(Field::New(metaname, 9129 Field& field = Field::Handle(Field::New(metaname,
9108 true, // is_static 9130 true, // is_static
9109 false, // is_final 9131 false, // is_final
(...skipping 5425 matching lines...) Expand 10 before | Expand all | Expand 10 after
14535 ASSERT(Isolate::Current()->flags().type_checks()); 14557 ASSERT(Isolate::Current()->flags().type_checks());
14536 return false; 14558 return false;
14537 } 14559 }
14538 other_class = instantiated_other.type_class(); 14560 other_class = instantiated_other.type_class();
14539 other_type_arguments = instantiated_other.arguments(); 14561 other_type_arguments = instantiated_other.arguments();
14540 } else { 14562 } else {
14541 other_class = other.type_class(); 14563 other_class = other.type_class();
14542 other_type_arguments = other.arguments(); 14564 other_type_arguments = other.arguments();
14543 } 14565 }
14544 return cls.IsSubtypeOf(type_arguments, other_class, other_type_arguments, 14566 return cls.IsSubtypeOf(type_arguments, other_class, other_type_arguments,
14545 bound_error); 14567 bound_error, Heap::kOld);
14546 } 14568 }
14547 14569
14548 14570
14549 bool Instance::OperatorEquals(const Instance& other) const { 14571 bool Instance::OperatorEquals(const Instance& other) const {
14550 // TODO(koda): Optimize for all builtin classes and all classes 14572 // TODO(koda): Optimize for all builtin classes and all classes
14551 // that do not override operator==. 14573 // that do not override operator==.
14552 return DartLibraryCalls::Equals(*this, other) == Object::bool_true().raw(); 14574 return DartLibraryCalls::Equals(*this, other) == Object::bool_true().raw();
14553 } 14575 }
14554 14576
14555 14577
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
15196 15218
15197 15219
15198 bool AbstractType::IsFunctionType() const { 15220 bool AbstractType::IsFunctionType() const {
15199 return HasResolvedTypeClass() && 15221 return HasResolvedTypeClass() &&
15200 (type_class() == Type::Handle(Type::Function()).type_class()); 15222 (type_class() == Type::Handle(Type::Function()).type_class());
15201 } 15223 }
15202 15224
15203 15225
15204 bool AbstractType::TypeTest(TypeTestKind test_kind, 15226 bool AbstractType::TypeTest(TypeTestKind test_kind,
15205 const AbstractType& other, 15227 const AbstractType& other,
15206 Error* bound_error) const { 15228 Error* bound_error,
15229 Heap::Space space) const {
15207 ASSERT(IsResolved()); 15230 ASSERT(IsResolved());
15208 ASSERT(other.IsResolved()); 15231 ASSERT(other.IsResolved());
15209 if (IsMalformed() || other.IsMalformed()) { 15232 if (IsMalformed() || other.IsMalformed()) {
15210 // Malformed types involved in subtype tests should be handled specially 15233 // Malformed types involved in subtype tests should be handled specially
15211 // by the caller. Malformed types should only be encountered here in a 15234 // by the caller. Malformed types should only be encountered here in a
15212 // more specific than test. 15235 // more specific than test.
15213 ASSERT(test_kind == kIsMoreSpecificThan); 15236 ASSERT(test_kind == kIsMoreSpecificThan);
15214 return false; 15237 return false;
15215 } 15238 }
15216 // In case the type checked in a type test is malbounded, the code generator 15239 // In case the type checked in a type test is malbounded, the code generator
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
15265 return false; // TODO(regis): We should return "maybe after instantiation". 15288 return false; // TODO(regis): We should return "maybe after instantiation".
15266 } 15289 }
15267 if (other.IsTypeParameter()) { 15290 if (other.IsTypeParameter()) {
15268 return false; // TODO(regis): We should return "maybe after instantiation". 15291 return false; // TODO(regis): We should return "maybe after instantiation".
15269 } 15292 }
15270 const Class& cls = Class::Handle(type_class()); 15293 const Class& cls = Class::Handle(type_class());
15271 return cls.TypeTest(test_kind, 15294 return cls.TypeTest(test_kind,
15272 TypeArguments::Handle(arguments()), 15295 TypeArguments::Handle(arguments()),
15273 Class::Handle(other.type_class()), 15296 Class::Handle(other.type_class()),
15274 TypeArguments::Handle(other.arguments()), 15297 TypeArguments::Handle(other.arguments()),
15275 bound_error); 15298 bound_error,
15299 space);
15276 } 15300 }
15277 15301
15278 15302
15279 intptr_t AbstractType::Hash() const { 15303 intptr_t AbstractType::Hash() const {
15280 // AbstractType is an abstract class. 15304 // AbstractType is an abstract class.
15281 UNREACHABLE(); 15305 UNREACHABLE();
15282 return 0; 15306 return 0;
15283 } 15307 }
15284 15308
15285 15309
(...skipping 6235 matching lines...) Expand 10 before | Expand all | Expand 10 after
21521 return tag_label.ToCString(); 21545 return tag_label.ToCString();
21522 } 21546 }
21523 21547
21524 21548
21525 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21549 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21526 Instance::PrintJSONImpl(stream, ref); 21550 Instance::PrintJSONImpl(stream, ref);
21527 } 21551 }
21528 21552
21529 21553
21530 } // namespace dart 21554 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698