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

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

Issue 10034019: Add missing calls to class finalizer in various tests. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart_entry_test.cc ('k') | runtime/vm/unit_test.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 "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 284
285 // Allocate and initialize the null class. 285 // Allocate and initialize the null class.
286 cls = Class::New<Instance>(); 286 cls = Class::New<Instance>();
287 cls.set_is_finalized(); 287 cls.set_is_finalized();
288 null_class_ = cls.raw(); 288 null_class_ = cls.raw();
289 289
290 // Complete initialization of null_ instance, i.e. initialize its class_ 290 // Complete initialization of null_ instance, i.e. initialize its class_
291 // field. 291 // field.
292 null_->ptr()->class_ = null_class_; 292 null_->ptr()->class_ = null_class_;
293 293
294 // Allocate and initialize the sentinel values of an instance class. 294 // Allocate and initialize the sentinel values of Null class.
295 { 295 {
296 cls = Class::New<Instance>(); 296 cls = null_class_;
297 Instance& sentinel = Instance::Handle(); 297 Instance& sentinel = Instance::Handle();
298 sentinel ^= Object::Allocate(cls, Instance::InstanceSize(), Heap::kOld); 298 sentinel ^= Object::Allocate(cls, Instance::InstanceSize(), Heap::kOld);
299 sentinel_ = sentinel.raw(); 299 sentinel_ = sentinel.raw();
300 300
301 Instance& transition_sentinel = Instance::Handle(); 301 Instance& transition_sentinel = Instance::Handle();
302 transition_sentinel ^= 302 transition_sentinel ^=
303 Object::Allocate(cls, Instance::InstanceSize(), Heap::kOld); 303 Object::Allocate(cls, Instance::InstanceSize(), Heap::kOld);
304 transition_sentinel_ = transition_sentinel.raw(); 304 transition_sentinel_ = transition_sentinel.raw();
305 } 305 }
306 306
(...skipping 6205 matching lines...) Expand 10 before | Expand all | Expand 10 after
6512 const AbstractType& instantiated_other = 6512 const AbstractType& instantiated_other =
6513 AbstractType::Handle(other_instantiator.TypeAt(other.Index())); 6513 AbstractType::Handle(other_instantiator.TypeAt(other.Index()));
6514 ASSERT(instantiated_other.IsInstantiated()); 6514 ASSERT(instantiated_other.IsInstantiated());
6515 other_class = instantiated_other.type_class(); 6515 other_class = instantiated_other.type_class();
6516 } else { 6516 } else {
6517 other_class = other.type_class(); 6517 other_class = other.type_class();
6518 } 6518 }
6519 return other_class.IsObjectClass() || other_class.IsDynamicClass(); 6519 return other_class.IsObjectClass() || other_class.IsDynamicClass();
6520 } 6520 }
6521 const Class& cls = Class::Handle(clazz()); 6521 const Class& cls = Class::Handle(clazz());
6522 // We must not encounter Object::sentinel() or Object::transition_sentinel(),
6523 // both instances of class NullClass, but not instance Object::null().
6524 ASSERT(!cls.IsNullClass());
6522 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); 6525 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle();
6523 const intptr_t num_type_arguments = cls.NumTypeArguments(); 6526 const intptr_t num_type_arguments = cls.NumTypeArguments();
6524 if (num_type_arguments > 0) { 6527 if (num_type_arguments > 0) {
6525 type_arguments = GetTypeArguments(); 6528 type_arguments = GetTypeArguments();
6526 // Verify that the number of type arguments in the instance matches the 6529 // Verify that the number of type arguments in the instance matches the
6527 // number of type arguments expected by the instance class. 6530 // number of type arguments expected by the instance class.
6528 // A discrepancy is allowed for closures, which borrow the type argument 6531 // A discrepancy is allowed for closures, which borrow the type argument
6529 // vector of their instantiator, which may be of a super class of the class 6532 // vector of their instantiator, which may be of a super class of the class
6530 // defining the closure. Truncating the vector to the correct length on 6533 // defining the closure. Truncating the vector to the correct length on
6531 // instantiation is unnecessary. The vector may therefore be longer. 6534 // instantiation is unnecessary. The vector may therefore be longer.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
6595 6598
6596 bool Instance::IsValidFieldOffset(int offset) const { 6599 bool Instance::IsValidFieldOffset(int offset) const {
6597 const Class& cls = Class::Handle(clazz()); 6600 const Class& cls = Class::Handle(clazz());
6598 return (offset >= 0 && offset <= (cls.instance_size() - kWordSize)); 6601 return (offset >= 0 && offset <= (cls.instance_size() - kWordSize));
6599 } 6602 }
6600 6603
6601 6604
6602 const char* Instance::ToCString() const { 6605 const char* Instance::ToCString() const {
6603 if (IsNull()) { 6606 if (IsNull()) {
6604 return "null"; 6607 return "null";
6608 } else if (raw() == Object::sentinel()) {
6609 return "sentinel";
6610 } else if (raw() == Object::transition_sentinel()) {
6611 return "transition_sentinel";
6605 } else if (Isolate::Current()->no_gc_scope_depth() > 0) { 6612 } else if (Isolate::Current()->no_gc_scope_depth() > 0) {
6606 // Can occur when running disassembler. 6613 // Can occur when running disassembler.
6607 return "Instance"; 6614 return "Instance";
6608 } else { 6615 } else {
6609 const char* kFormat = "Instance of '%s'"; 6616 const char* kFormat = "Instance of '%s'";
6610 Class& cls = Class::Handle(clazz()); 6617 Class& cls = Class::Handle(clazz());
6611 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); 6618 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle();
6612 const intptr_t num_type_arguments = cls.NumTypeArguments(); 6619 const intptr_t num_type_arguments = cls.NumTypeArguments();
6613 if (num_type_arguments > 0) { 6620 if (num_type_arguments > 0) {
6614 type_arguments = GetTypeArguments(); 6621 type_arguments = GetTypeArguments();
(...skipping 2515 matching lines...) Expand 10 before | Expand all | Expand 10 after
9130 const String& str = String::Handle(pattern()); 9137 const String& str = String::Handle(pattern());
9131 const char* format = "JSRegExp: pattern=%s flags=%s"; 9138 const char* format = "JSRegExp: pattern=%s flags=%s";
9132 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 9139 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
9133 char* chars = reinterpret_cast<char*>( 9140 char* chars = reinterpret_cast<char*>(
9134 Isolate::Current()->current_zone()->Allocate(len + 1)); 9141 Isolate::Current()->current_zone()->Allocate(len + 1));
9135 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 9142 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
9136 return chars; 9143 return chars;
9137 } 9144 }
9138 9145
9139 } // namespace dart 9146 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_entry_test.cc ('k') | runtime/vm/unit_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698