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

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

Issue 2509013002: Allocate generic types in new-space before canonicalizing. (Closed)
Patch Set: formatting Created 4 years, 1 month 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/become.h" 10 #include "vm/become.h"
(...skipping 15389 matching lines...) Expand 10 before | Expand all | Expand 10 after
15400 Isolate* isolate = thread->isolate(); 15400 Isolate* isolate = thread->isolate();
15401 Instance& result = Instance::Handle(zone); 15401 Instance& result = Instance::Handle(zone);
15402 const Class& cls = Class::Handle(zone, this->clazz()); 15402 const Class& cls = Class::Handle(zone, this->clazz());
15403 SafepointMutexLocker ml(isolate->constant_canonicalization_mutex()); 15403 SafepointMutexLocker ml(isolate->constant_canonicalization_mutex());
15404 result ^= cls.LookupCanonicalInstance(zone, *this); 15404 result ^= cls.LookupCanonicalInstance(zone, *this);
15405 return (result.raw() == this->raw()); 15405 return (result.raw() == this->raw());
15406 } 15406 }
15407 #endif // DEBUG 15407 #endif // DEBUG
15408 15408
15409 15409
15410 RawAbstractType* Instance::GetType() const { 15410 RawAbstractType* Instance::GetType(Heap::Space space) const {
15411 if (IsNull()) { 15411 if (IsNull()) {
15412 return Type::NullType(); 15412 return Type::NullType();
15413 } 15413 }
15414 const Class& cls = Class::Handle(clazz()); 15414 const Class& cls = Class::Handle(clazz());
15415 if (cls.IsClosureClass()) { 15415 if (cls.IsClosureClass()) {
15416 const Function& signature = 15416 const Function& signature =
15417 Function::Handle(Closure::Cast(*this).function()); 15417 Function::Handle(Closure::Cast(*this).function());
15418 Type& type = Type::Handle(signature.SignatureType()); 15418 Type& type = Type::Handle(signature.SignatureType());
15419 if (type.type_class() == cls.raw()) { 15419 if (type.type_class() == cls.raw()) {
15420 // Type is not parameterized. 15420 // Type is not parameterized.
15421 if (!type.IsCanonical()) { 15421 if (!type.IsCanonical()) {
15422 type ^= type.Canonicalize(); 15422 type ^= type.Canonicalize();
15423 signature.SetSignatureType(type); 15423 signature.SetSignatureType(type);
15424 } 15424 }
15425 return type.raw(); 15425 return type.raw();
15426 } 15426 }
15427 const Class& scope_cls = Class::Handle(type.type_class()); 15427 const Class& scope_cls = Class::Handle(type.type_class());
15428 ASSERT(scope_cls.NumTypeArguments() > 0); 15428 ASSERT(scope_cls.NumTypeArguments() > 0);
15429 TypeArguments& type_arguments = TypeArguments::Handle(GetTypeArguments()); 15429 TypeArguments& type_arguments = TypeArguments::Handle(GetTypeArguments());
15430 type = Type::New(scope_cls, type_arguments, TokenPosition::kNoSource, 15430 type =
15431 Heap::kNew); 15431 Type::New(scope_cls, type_arguments, TokenPosition::kNoSource, space);
15432 type.set_signature(signature); 15432 type.set_signature(signature);
15433 type.SetIsFinalized(); 15433 type.SetIsFinalized();
15434 type ^= type.Canonicalize(); 15434 type ^= type.Canonicalize();
15435 return type.raw(); 15435 return type.raw();
15436 } 15436 }
15437 Type& type = Type::Handle(); 15437 Type& type = Type::Handle();
15438 if (!cls.IsGeneric()) { 15438 if (!cls.IsGeneric()) {
15439 type = cls.CanonicalType(); 15439 type = cls.CanonicalType();
15440 } 15440 }
15441 if (type.IsNull()) { 15441 if (type.IsNull()) {
15442 TypeArguments& type_arguments = TypeArguments::Handle(); 15442 TypeArguments& type_arguments = TypeArguments::Handle();
15443 if (cls.NumTypeArguments() > 0) { 15443 if (cls.NumTypeArguments() > 0) {
15444 type_arguments = GetTypeArguments(); 15444 type_arguments = GetTypeArguments();
15445 } 15445 }
15446 type = Type::New(cls, type_arguments, TokenPosition::kNoSource); 15446 type = Type::New(cls, type_arguments, TokenPosition::kNoSource, space);
15447 type.SetIsFinalized(); 15447 type.SetIsFinalized();
15448 type ^= type.Canonicalize(); 15448 type ^= type.Canonicalize();
15449 } 15449 }
15450 return type.raw(); 15450 return type.raw();
15451 } 15451 }
15452 15452
15453 15453
15454 RawTypeArguments* Instance::GetTypeArguments() const { 15454 RawTypeArguments* Instance::GetTypeArguments() const {
15455 const Class& cls = Class::Handle(clazz()); 15455 const Class& cls = Class::Handle(clazz());
15456 intptr_t field_offset = cls.type_arguments_field_offset(); 15456 intptr_t field_offset = cls.type_arguments_field_offset();
(...skipping 7232 matching lines...) Expand 10 before | Expand all | Expand 10 after
22689 return UserTag::null(); 22689 return UserTag::null();
22690 } 22690 }
22691 22691
22692 22692
22693 const char* UserTag::ToCString() const { 22693 const char* UserTag::ToCString() const {
22694 const String& tag_label = String::Handle(label()); 22694 const String& tag_label = String::Handle(label());
22695 return tag_label.ToCString(); 22695 return tag_label.ToCString();
22696 } 22696 }
22697 22697
22698 } // namespace dart 22698 } // 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