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

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

Issue 1691163002: Fix background compilation crashes due to allocation of types in new space. Remove default argument… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: e Created 4 years, 10 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') | no next file » | 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 6015 matching lines...) Expand 10 before | Expand all | Expand 10 after
6026 ((num_fixed_params - num_ignored_params + num_opt_pos_params) < 6026 ((num_fixed_params - num_ignored_params + num_opt_pos_params) <
6027 (other_num_fixed_params - other_num_ignored_params + 6027 (other_num_fixed_params - other_num_ignored_params +
6028 other_num_opt_pos_params)) || 6028 other_num_opt_pos_params)) ||
6029 (num_opt_named_params < other_num_opt_named_params)) { 6029 (num_opt_named_params < other_num_opt_named_params)) {
6030 return false; 6030 return false;
6031 } 6031 }
6032 // Check the result type. 6032 // Check the result type.
6033 AbstractType& other_res_type = AbstractType::Handle(other.result_type()); 6033 AbstractType& other_res_type = AbstractType::Handle(other.result_type());
6034 if (!other_res_type.IsInstantiated()) { 6034 if (!other_res_type.IsInstantiated()) {
6035 other_res_type = other_res_type.InstantiateFrom(other_type_arguments, 6035 other_res_type = other_res_type.InstantiateFrom(other_type_arguments,
6036 bound_error); 6036 bound_error,
6037 NULL, NULL, space);
6037 ASSERT((bound_error == NULL) || bound_error->IsNull()); 6038 ASSERT((bound_error == NULL) || bound_error->IsNull());
6038 } 6039 }
6039 if (!other_res_type.IsDynamicType() && !other_res_type.IsVoidType()) { 6040 if (!other_res_type.IsDynamicType() && !other_res_type.IsVoidType()) {
6040 AbstractType& res_type = AbstractType::Handle(result_type()); 6041 AbstractType& res_type = AbstractType::Handle(result_type());
6041 if (!res_type.IsInstantiated()) { 6042 if (!res_type.IsInstantiated()) {
6042 res_type = res_type.InstantiateFrom(type_arguments, bound_error); 6043 res_type = res_type.InstantiateFrom(type_arguments, bound_error,
6044 NULL, NULL, space);
6043 ASSERT((bound_error == NULL) || bound_error->IsNull()); 6045 ASSERT((bound_error == NULL) || bound_error->IsNull());
6044 } 6046 }
6045 if (res_type.IsVoidType()) { 6047 if (res_type.IsVoidType()) {
6046 return false; 6048 return false;
6047 } 6049 }
6048 if (test_kind == kIsSubtypeOf) { 6050 if (test_kind == kIsSubtypeOf) {
6049 if (!res_type.IsSubtypeOf(other_res_type, bound_error) && 6051 if (!res_type.IsSubtypeOf(other_res_type, bound_error, NULL, space) &&
6050 !other_res_type.IsSubtypeOf(res_type, bound_error)) { 6052 !other_res_type.IsSubtypeOf(res_type, bound_error, NULL, space)) {
6051 return false; 6053 return false;
6052 } 6054 }
6053 } else { 6055 } else {
6054 ASSERT(test_kind == kIsMoreSpecificThan); 6056 ASSERT(test_kind == kIsMoreSpecificThan);
6055 if (!res_type.IsMoreSpecificThan(other_res_type, bound_error)) { 6057 if (!res_type.IsMoreSpecificThan(other_res_type, bound_error,
6058 NULL, space)) {
6056 return false; 6059 return false;
6057 } 6060 }
6058 } 6061 }
6059 } 6062 }
6060 // Check the types of fixed and optional positional parameters. 6063 // Check the types of fixed and optional positional parameters.
6061 for (intptr_t i = 0; i < (other_num_fixed_params - other_num_ignored_params + 6064 for (intptr_t i = 0; i < (other_num_fixed_params - other_num_ignored_params +
6062 other_num_opt_pos_params); i++) { 6065 other_num_opt_pos_params); i++) {
6063 if (!TestParameterType(test_kind, 6066 if (!TestParameterType(test_kind,
6064 i + num_ignored_params, i + other_num_ignored_params, 6067 i + num_ignored_params, i + other_num_ignored_params,
6065 type_arguments, other, other_type_arguments, 6068 type_arguments, other, other_type_arguments,
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
6414 // Hide implicit parameters. 6417 // Hide implicit parameters.
6415 i = NumImplicitParameters(); 6418 i = NumImplicitParameters();
6416 } 6419 }
6417 String& name = String::Handle(zone); 6420 String& name = String::Handle(zone);
6418 while (i < num_fixed_params) { 6421 while (i < num_fixed_params) {
6419 param_type = ParameterTypeAt(i); 6422 param_type = ParameterTypeAt(i);
6420 ASSERT(!param_type.IsNull()); 6423 ASSERT(!param_type.IsNull());
6421 if (instantiate && 6424 if (instantiate &&
6422 param_type.IsFinalized() && 6425 param_type.IsFinalized() &&
6423 !param_type.IsInstantiated()) { 6426 !param_type.IsInstantiated()) {
6424 param_type = param_type.InstantiateFrom(instantiator, NULL); 6427 param_type = param_type.InstantiateFrom(instantiator, NULL,
6428 NULL, NULL, Heap::kNew);
6425 } 6429 }
6426 name = param_type.BuildName(name_visibility); 6430 name = param_type.BuildName(name_visibility);
6427 pieces->Add(name); 6431 pieces->Add(name);
6428 if (i != (num_params - 1)) { 6432 if (i != (num_params - 1)) {
6429 pieces->Add(Symbols::CommaSpace()); 6433 pieces->Add(Symbols::CommaSpace());
6430 } 6434 }
6431 i++; 6435 i++;
6432 } 6436 }
6433 if (num_opt_params > 0) { 6437 if (num_opt_params > 0) {
6434 if (num_opt_pos_params > 0) { 6438 if (num_opt_pos_params > 0) {
6435 pieces->Add(Symbols::LBracket()); 6439 pieces->Add(Symbols::LBracket());
6436 } else { 6440 } else {
6437 pieces->Add(Symbols::LBrace()); 6441 pieces->Add(Symbols::LBrace());
6438 } 6442 }
6439 for (intptr_t i = num_fixed_params; i < num_params; i++) { 6443 for (intptr_t i = num_fixed_params; i < num_params; i++) {
6440 // The parameter name of an optional positional parameter does not need 6444 // The parameter name of an optional positional parameter does not need
6441 // to be part of the signature, since it is not used. 6445 // to be part of the signature, since it is not used.
6442 if (num_opt_named_params > 0) { 6446 if (num_opt_named_params > 0) {
6443 name = ParameterNameAt(i); 6447 name = ParameterNameAt(i);
6444 pieces->Add(name); 6448 pieces->Add(name);
6445 pieces->Add(Symbols::ColonSpace()); 6449 pieces->Add(Symbols::ColonSpace());
6446 } 6450 }
6447 param_type = ParameterTypeAt(i); 6451 param_type = ParameterTypeAt(i);
6448 if (instantiate && 6452 if (instantiate &&
6449 param_type.IsFinalized() && 6453 param_type.IsFinalized() &&
6450 !param_type.IsInstantiated()) { 6454 !param_type.IsInstantiated()) {
6451 param_type = param_type.InstantiateFrom(instantiator, NULL); 6455 param_type = param_type.InstantiateFrom(instantiator, NULL,
6456 NULL, NULL, Heap::kNew);
6452 } 6457 }
6453 ASSERT(!param_type.IsNull()); 6458 ASSERT(!param_type.IsNull());
6454 name = param_type.BuildName(name_visibility); 6459 name = param_type.BuildName(name_visibility);
6455 pieces->Add(name); 6460 pieces->Add(name);
6456 if (i != (num_params - 1)) { 6461 if (i != (num_params - 1)) {
6457 pieces->Add(Symbols::CommaSpace()); 6462 pieces->Add(Symbols::CommaSpace());
6458 } 6463 }
6459 } 6464 }
6460 if (num_opt_pos_params > 0) { 6465 if (num_opt_pos_params > 0) {
6461 pieces->Add(Symbols::RBracket()); 6466 pieces->Add(Symbols::RBracket());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
6539 } 6544 }
6540 } 6545 }
6541 pieces.Add(Symbols::LParen()); 6546 pieces.Add(Symbols::LParen());
6542 BuildSignatureParameters(instantiate, 6547 BuildSignatureParameters(instantiate,
6543 name_visibility, 6548 name_visibility,
6544 instantiator, 6549 instantiator,
6545 &pieces); 6550 &pieces);
6546 pieces.Add(Symbols::RParenArrow()); 6551 pieces.Add(Symbols::RParenArrow());
6547 AbstractType& res_type = AbstractType::Handle(zone, result_type()); 6552 AbstractType& res_type = AbstractType::Handle(zone, result_type());
6548 if (instantiate && res_type.IsFinalized() && !res_type.IsInstantiated()) { 6553 if (instantiate && res_type.IsFinalized() && !res_type.IsInstantiated()) {
6549 res_type = res_type.InstantiateFrom(instantiator, NULL); 6554 res_type = res_type.InstantiateFrom(instantiator, NULL,
6555 NULL, NULL, Heap::kNew);
6550 } 6556 }
6551 name = res_type.BuildName(name_visibility); 6557 name = res_type.BuildName(name_visibility);
6552 pieces.Add(name); 6558 pieces.Add(name);
6553 return Symbols::FromConcatAll(pieces); 6559 return Symbols::FromConcatAll(pieces);
6554 } 6560 }
6555 6561
6556 6562
6557 bool Function::HasInstantiatedSignature() const { 6563 bool Function::HasInstantiatedSignature() const {
6558 AbstractType& type = AbstractType::Handle(result_type()); 6564 AbstractType& type = AbstractType::Handle(result_type());
6559 if (!type.IsInstantiated()) { 6565 if (!type.IsInstantiated()) {
(...skipping 7628 matching lines...) Expand 10 before | Expand all | Expand 10 after
14188 const Class& cls = Class::Handle(zone, clazz()); 14194 const Class& cls = Class::Handle(zone, clazz());
14189 if (cls.IsClosureClass()) { 14195 if (cls.IsClosureClass()) {
14190 if (other.IsObjectType() || other.IsDartFunctionType()) { 14196 if (other.IsObjectType() || other.IsDartFunctionType()) {
14191 return true; 14197 return true;
14192 } 14198 }
14193 Function& other_signature = Function::Handle(zone); 14199 Function& other_signature = Function::Handle(zone);
14194 TypeArguments& other_type_arguments = TypeArguments::Handle(zone); 14200 TypeArguments& other_type_arguments = TypeArguments::Handle(zone);
14195 // Note that we may encounter a bound error in checked mode. 14201 // Note that we may encounter a bound error in checked mode.
14196 if (!other.IsInstantiated()) { 14202 if (!other.IsInstantiated()) {
14197 const AbstractType& instantiated_other = AbstractType::Handle( 14203 const AbstractType& instantiated_other = AbstractType::Handle(
14198 zone, other.InstantiateFrom(other_instantiator, bound_error)); 14204 zone, other.InstantiateFrom(other_instantiator, bound_error,
14205 NULL, NULL, Heap::kOld));
14199 if ((bound_error != NULL) && !bound_error->IsNull()) { 14206 if ((bound_error != NULL) && !bound_error->IsNull()) {
14200 ASSERT(Isolate::Current()->flags().type_checks()); 14207 ASSERT(Isolate::Current()->flags().type_checks());
14201 return false; 14208 return false;
14202 } 14209 }
14203 if (instantiated_other.IsDynamicType() || 14210 if (instantiated_other.IsDynamicType() ||
14204 instantiated_other.IsObjectType() || 14211 instantiated_other.IsObjectType() ||
14205 instantiated_other.IsDartFunctionType()) { 14212 instantiated_other.IsDartFunctionType()) {
14206 return true; 14213 return true;
14207 } 14214 }
14208 if (!instantiated_other.IsFunctionType()) { 14215 if (!instantiated_other.IsFunctionType()) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
14240 // Also, an optimization reuses the type argument vector of the instantiator 14247 // Also, an optimization reuses the type argument vector of the instantiator
14241 // of generic instances when its layout is compatible. 14248 // of generic instances when its layout is compatible.
14242 ASSERT(type_arguments.IsNull() || 14249 ASSERT(type_arguments.IsNull() ||
14243 (type_arguments.Length() >= cls.NumTypeArguments())); 14250 (type_arguments.Length() >= cls.NumTypeArguments()));
14244 } 14251 }
14245 Class& other_class = Class::Handle(zone); 14252 Class& other_class = Class::Handle(zone);
14246 TypeArguments& other_type_arguments = TypeArguments::Handle(zone); 14253 TypeArguments& other_type_arguments = TypeArguments::Handle(zone);
14247 AbstractType& instantiated_other = AbstractType::Handle(zone, other.raw()); 14254 AbstractType& instantiated_other = AbstractType::Handle(zone, other.raw());
14248 // Note that we may encounter a bound error in checked mode. 14255 // Note that we may encounter a bound error in checked mode.
14249 if (!other.IsInstantiated()) { 14256 if (!other.IsInstantiated()) {
14250 instantiated_other = other.InstantiateFrom(other_instantiator, bound_error); 14257 instantiated_other = other.InstantiateFrom(other_instantiator, bound_error,
14258 NULL, NULL, Heap::kOld);
14251 if ((bound_error != NULL) && !bound_error->IsNull()) { 14259 if ((bound_error != NULL) && !bound_error->IsNull()) {
14252 ASSERT(Isolate::Current()->flags().type_checks()); 14260 ASSERT(Isolate::Current()->flags().type_checks());
14253 return false; 14261 return false;
14254 } 14262 }
14255 if (instantiated_other.IsTypeRef()) { 14263 if (instantiated_other.IsTypeRef()) {
14256 instantiated_other = TypeRef::Cast(instantiated_other).type(); 14264 instantiated_other = TypeRef::Cast(instantiated_other).type();
14257 } 14265 }
14258 if (instantiated_other.IsDynamicType()) { 14266 if (instantiated_other.IsDynamicType()) {
14259 return true; 14267 return true;
14260 } 14268 }
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
14994 } 15002 }
14995 } 15003 }
14996 const AbstractType& bound = AbstractType::Handle(zone, type_param.bound()); 15004 const AbstractType& bound = AbstractType::Handle(zone, type_param.bound());
14997 // We may be checking bounds at finalization time and can encounter 15005 // We may be checking bounds at finalization time and can encounter
14998 // a still unfinalized bound. Finalizing the bound here may lead to cycles. 15006 // a still unfinalized bound. Finalizing the bound here may lead to cycles.
14999 if (!bound.IsFinalized()) { 15007 if (!bound.IsFinalized()) {
15000 return false; // TODO(regis): Return "maybe after instantiation". 15008 return false; // TODO(regis): Return "maybe after instantiation".
15001 } 15009 }
15002 // The current bound_trail cannot be used, because operands are swapped and 15010 // The current bound_trail cannot be used, because operands are swapped and
15003 // the test is different anyway (more specific vs. subtype). 15011 // the test is different anyway (more specific vs. subtype).
15004 if (bound.IsMoreSpecificThan(other, bound_error, NULL)) { 15012 if (bound.IsMoreSpecificThan(other, bound_error, NULL, space)) {
15005 return true; 15013 return true;
15006 } 15014 }
15007 return false; // TODO(regis): We should return "maybe after instantiation". 15015 return false; // TODO(regis): We should return "maybe after instantiation".
15008 } 15016 }
15009 if (other.IsTypeParameter()) { 15017 if (other.IsTypeParameter()) {
15010 return false; // TODO(regis): We should return "maybe after instantiation". 15018 return false; // TODO(regis): We should return "maybe after instantiation".
15011 } 15019 }
15012 const Class& type_cls = Class::Handle(zone, type_class()); 15020 const Class& type_cls = Class::Handle(zone, type_class());
15013 // Function types cannot be handled by Class::TypeTest(). 15021 // Function types cannot be handled by Class::TypeTest().
15014 const bool other_is_dart_function_type = other.IsDartFunctionType(); 15022 const bool other_is_dart_function_type = other.IsDartFunctionType();
(...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after
16695 if (instantiated_bounded_type.Equals(bounded_type) && 16703 if (instantiated_bounded_type.Equals(bounded_type) &&
16696 instantiated_upper_bound.Equals(upper_bound)) { 16704 instantiated_upper_bound.Equals(upper_bound)) {
16697 return bounded_type.raw(); 16705 return bounded_type.raw();
16698 } 16706 }
16699 const TypeParameter& type_param = TypeParameter::Handle(type_parameter()); 16707 const TypeParameter& type_param = TypeParameter::Handle(type_parameter());
16700 if (instantiated_bounded_type.IsBeingFinalized() || 16708 if (instantiated_bounded_type.IsBeingFinalized() ||
16701 instantiated_upper_bound.IsBeingFinalized() || 16709 instantiated_upper_bound.IsBeingFinalized() ||
16702 (!type_param.CheckBound(instantiated_bounded_type, 16710 (!type_param.CheckBound(instantiated_bounded_type,
16703 instantiated_upper_bound, 16711 instantiated_upper_bound,
16704 bound_error, 16712 bound_error,
16705 bound_trail) && 16713 bound_trail,
16714 space) &&
16706 bound_error->IsNull())) { 16715 bound_error->IsNull())) {
16707 // We cannot determine yet whether the bounded_type is below the 16716 // We cannot determine yet whether the bounded_type is below the
16708 // upper_bound, because one or both of them is still being finalized or 16717 // upper_bound, because one or both of them is still being finalized or
16709 // uninstantiated. 16718 // uninstantiated.
16710 ASSERT(instantiated_bounded_type.IsBeingFinalized() || 16719 ASSERT(instantiated_bounded_type.IsBeingFinalized() ||
16711 instantiated_upper_bound.IsBeingFinalized() || 16720 instantiated_upper_bound.IsBeingFinalized() ||
16712 !instantiated_bounded_type.IsInstantiated() || 16721 !instantiated_bounded_type.IsInstantiated() ||
16713 !instantiated_upper_bound.IsInstantiated()); 16722 !instantiated_upper_bound.IsInstantiated());
16714 // Postpone bound check by returning a new BoundedType with unfinalized 16723 // Postpone bound check by returning a new BoundedType with unfinalized
16715 // or partially instantiated bounded_type and upper_bound, but keeping 16724 // or partially instantiated bounded_type and upper_bound, but keeping
(...skipping 4692 matching lines...) Expand 10 before | Expand all | Expand 10 after
21408 return UserTag::null(); 21417 return UserTag::null();
21409 } 21418 }
21410 21419
21411 21420
21412 const char* UserTag::ToCString() const { 21421 const char* UserTag::ToCString() const {
21413 const String& tag_label = String::Handle(label()); 21422 const String& tag_label = String::Handle(label());
21414 return tag_label.ToCString(); 21423 return tag_label.ToCString();
21415 } 21424 }
21416 21425
21417 } // namespace dart 21426 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698