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

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

Issue 1654273003: Fix typedef cycle check (fixes #25620). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 | « no previous file | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/class_finalizer.h" 5 #include "vm/class_finalizer.h"
6 6
7 #include "vm/code_generator.h" 7 #include "vm/code_generator.h"
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/heap.h" 9 #include "vm/heap.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 2552 matching lines...) Expand 10 before | Expand all | Expand 10 after
2563 const AbstractType& type, 2563 const AbstractType& type,
2564 GrowableArray<intptr_t>* visited) { 2564 GrowableArray<intptr_t>* visited) {
2565 ASSERT(visited != NULL); 2565 ASSERT(visited != NULL);
2566 AbstractType& resolved_type = AbstractType::Handle(ResolveType(cls, type)); 2566 AbstractType& resolved_type = AbstractType::Handle(ResolveType(cls, type));
2567 bool checking_typedef = false; 2567 bool checking_typedef = false;
2568 if ((resolved_type.IsType() || resolved_type.IsFunctionType()) && 2568 if ((resolved_type.IsType() || resolved_type.IsFunctionType()) &&
2569 !resolved_type.IsMalformed()) { 2569 !resolved_type.IsMalformed()) {
2570 AbstractType& other_type = AbstractType::Handle(); 2570 AbstractType& other_type = AbstractType::Handle();
2571 if (resolved_type.IsFunctionType()) { 2571 if (resolved_type.IsFunctionType()) {
2572 const Class& scope_class = Class::Handle(resolved_type.type_class()); 2572 const Class& scope_class = Class::Handle(resolved_type.type_class());
2573 if (!scope_class.is_type_finalized() && scope_class.IsTypedefClass()) { 2573 const Function& signature_function =
2574 Function::Handle(FunctionType::Cast(resolved_type).signature());
2575 // The signature function of this function type may be a local signature
2576 // function used in a formal parameter type of the typedef signature, but
2577 // not the typedef signature function itself, thus not qualifying as an
2578 // illegal self reference.
2579 if (!scope_class.is_type_finalized() &&
2580 scope_class.IsTypedefClass() &&
2581 (scope_class.signature_function() == signature_function.raw())) {
2574 checking_typedef = true; 2582 checking_typedef = true;
2575 const intptr_t scope_class_id = scope_class.id(); 2583 const intptr_t scope_class_id = scope_class.id();
2576 ASSERT(visited != NULL); 2584 ASSERT(visited != NULL);
2577 for (intptr_t i = 0; i < visited->length(); i++) { 2585 for (intptr_t i = 0; i < visited->length(); i++) {
2578 if ((*visited)[i] == scope_class_id) { 2586 if ((*visited)[i] == scope_class_id) {
2579 // We have already visited alias 'scope_class'. We found a cycle. 2587 // We have already visited alias 'scope_class'. We found a cycle.
2580 return false; 2588 return false;
2581 } 2589 }
2582 } 2590 }
2583 visited->Add(scope_class_id); 2591 visited->Add(scope_class_id);
2584 } 2592 }
2585 // Check the bounds of this function type. 2593 // Check the bounds of this function type.
2586 const intptr_t num_type_params = scope_class.NumTypeParameters(); 2594 const intptr_t num_type_params = scope_class.NumTypeParameters();
2587 TypeParameter& type_param = TypeParameter::Handle(); 2595 TypeParameter& type_param = TypeParameter::Handle();
2588 const TypeArguments& type_params = 2596 const TypeArguments& type_params =
2589 TypeArguments::Handle(scope_class.type_parameters()); 2597 TypeArguments::Handle(scope_class.type_parameters());
2590 ASSERT((type_params.IsNull() && (num_type_params == 0)) || 2598 ASSERT((type_params.IsNull() && (num_type_params == 0)) ||
2591 (type_params.Length() == num_type_params)); 2599 (type_params.Length() == num_type_params));
2592 for (intptr_t i = 0; i < num_type_params; i++) { 2600 for (intptr_t i = 0; i < num_type_params; i++) {
2593 type_param ^= type_params.TypeAt(i); 2601 type_param ^= type_params.TypeAt(i);
2594 other_type = type_param.bound(); 2602 other_type = type_param.bound();
2595 if (!IsTypedefCycleFree(cls, other_type, visited)) { 2603 if (!IsTypedefCycleFree(cls, other_type, visited)) {
2596 return false; 2604 return false;
2597 } 2605 }
2598 } 2606 }
2599 // Check the result type of the signature of this function type. 2607 // Check the result type of the signature of this function type.
2600 const Function& function = 2608 other_type = signature_function.result_type();
2601 Function::Handle(FunctionType::Cast(resolved_type).signature());
2602 other_type = function.result_type();
2603 if (!IsTypedefCycleFree(cls, other_type, visited)) { 2609 if (!IsTypedefCycleFree(cls, other_type, visited)) {
2604 return false; 2610 return false;
2605 } 2611 }
2606 // Check the parameter types of the signature of this function type. 2612 // Check the parameter types of the signature of this function type.
2607 const intptr_t num_parameters = function.NumParameters(); 2613 const intptr_t num_parameters = signature_function.NumParameters();
2608 for (intptr_t i = 0; i < num_parameters; i++) { 2614 for (intptr_t i = 0; i < num_parameters; i++) {
2609 other_type = function.ParameterTypeAt(i); 2615 other_type = signature_function.ParameterTypeAt(i);
2610 if (!IsTypedefCycleFree(cls, other_type, visited)) { 2616 if (!IsTypedefCycleFree(cls, other_type, visited)) {
2611 return false; 2617 return false;
2612 } 2618 }
2613 } 2619 }
2614 } 2620 }
2615 const TypeArguments& type_args = 2621 const TypeArguments& type_args =
2616 TypeArguments::Handle(resolved_type.arguments()); 2622 TypeArguments::Handle(resolved_type.arguments());
2617 if (!type_args.IsNull()) { 2623 if (!type_args.IsNull()) {
2618 for (intptr_t i = 0; i < type_args.Length(); i++) { 2624 for (intptr_t i = 0; i < type_args.Length(); i++) {
2619 other_type = type_args.TypeAt(i); 2625 other_type = type_args.TypeAt(i);
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
3288 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); 3294 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields());
3289 field ^= fields_array.At(0); 3295 field ^= fields_array.At(0);
3290 ASSERT(field.Offset() == ByteBuffer::data_offset()); 3296 ASSERT(field.Offset() == ByteBuffer::data_offset());
3291 name ^= field.name(); 3297 name ^= field.name();
3292 expected_name ^= String::New("_data"); 3298 expected_name ^= String::New("_data");
3293 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); 3299 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name));
3294 #endif 3300 #endif
3295 } 3301 }
3296 3302
3297 } // namespace dart 3303 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698