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

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

Issue 106793007: Convert InstantiatedTypeArguments to TypeArguments upon canonicalization. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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 | Annotate | Revision Log
« 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 3993 matching lines...) Expand 10 before | Expand all | Expand 10 after
4004 4004
4005 4005
4006 void InstantiatedTypeArguments::SetTypeAt(intptr_t index, 4006 void InstantiatedTypeArguments::SetTypeAt(intptr_t index,
4007 const AbstractType& value) const { 4007 const AbstractType& value) const {
4008 // We only replace individual argument types during resolution at compile 4008 // We only replace individual argument types during resolution at compile
4009 // time, when no type parameters are instantiated yet. 4009 // time, when no type parameters are instantiated yet.
4010 UNREACHABLE(); 4010 UNREACHABLE();
4011 } 4011 }
4012 4012
4013 4013
4014 RawAbstractTypeArguments* InstantiatedTypeArguments::Canonicalize() const {
4015 const intptr_t num_types = Length();
4016 const TypeArguments& type_args = TypeArguments::Handle(
4017 TypeArguments::New(num_types, Heap::kOld));
4018 AbstractType& type = AbstractType::Handle();
4019 for (intptr_t i = 0; i < num_types; i++) {
4020 type = TypeAt(i);
4021 type_args.SetTypeAt(i, type);
4022 }
4023 return type_args.Canonicalize();
4024 }
4025
4026
4014 void InstantiatedTypeArguments::set_uninstantiated_type_arguments( 4027 void InstantiatedTypeArguments::set_uninstantiated_type_arguments(
4015 const AbstractTypeArguments& value) const { 4028 const AbstractTypeArguments& value) const {
4016 StorePointer(&raw_ptr()->uninstantiated_type_arguments_, value.raw()); 4029 StorePointer(&raw_ptr()->uninstantiated_type_arguments_, value.raw());
4017 } 4030 }
4018 4031
4019 4032
4020 void InstantiatedTypeArguments::set_instantiator_type_arguments( 4033 void InstantiatedTypeArguments::set_instantiator_type_arguments(
4021 const AbstractTypeArguments& value) const { 4034 const AbstractTypeArguments& value) const {
4022 StorePointer(&raw_ptr()->instantiator_type_arguments_, value.raw()); 4035 StorePointer(&raw_ptr()->instantiator_type_arguments_, value.raw());
4023 } 4036 }
(...skipping 8289 matching lines...) Expand 10 before | Expand all | Expand 10 after
12313 TypeParameter& type_arg = TypeParameter::Handle(isolate); 12326 TypeParameter& type_arg = TypeParameter::Handle(isolate);
12314 TypeParameter& type_param = TypeParameter::Handle(isolate); 12327 TypeParameter& type_param = TypeParameter::Handle(isolate);
12315 for (intptr_t i = 0; i < num_type_params; i++) { 12328 for (intptr_t i = 0; i < num_type_params; i++) {
12316 type_arg ^= type_args.TypeAt(num_type_args - num_type_params + i); 12329 type_arg ^= type_args.TypeAt(num_type_args - num_type_params + i);
12317 type_param ^= type_params.TypeAt(i); 12330 type_param ^= type_params.TypeAt(i);
12318 ASSERT(type_arg.Equals(type_param)); 12331 ASSERT(type_arg.Equals(type_param));
12319 } 12332 }
12320 } 12333 }
12321 #endif 12334 #endif
12322 ASSERT(IsOld()); 12335 ASSERT(IsOld());
12336 ASSERT(type_args.IsNull() || type_args.IsOld());
12323 SetCanonical(); 12337 SetCanonical();
12324 return this->raw(); 12338 return this->raw();
12325 } 12339 }
12326 12340
12327 12341
12328 intptr_t Type::Hash() const { 12342 intptr_t Type::Hash() const {
12329 ASSERT(IsFinalized()); 12343 ASSERT(IsFinalized());
12330 uword result = 1; 12344 uword result = 1;
12331 if (IsMalformed()) return result; 12345 if (IsMalformed()) return result;
12332 result += Class::Handle(type_class()).id(); 12346 result += Class::Handle(type_class()).id();
(...skipping 4179 matching lines...) Expand 10 before | Expand all | Expand 10 after
16512 return "_MirrorReference"; 16526 return "_MirrorReference";
16513 } 16527 }
16514 16528
16515 16529
16516 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 16530 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
16517 Instance::PrintToJSONStream(stream, ref); 16531 Instance::PrintToJSONStream(stream, ref);
16518 } 16532 }
16519 16533
16520 16534
16521 } // namespace dart 16535 } // 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