| OLD | NEW | 
|      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/bigint_operations.h" |     10 #include "vm/bigint_operations.h" | 
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|    508   fields = Array::New(1); |    508   fields = Array::New(1); | 
|    509   name = Symbols::New("@parent_"); |    509   name = Symbols::New("@parent_"); | 
|    510   fld = Field::New(name, false, false, false, cls, 0); |    510   fld = Field::New(name, false, false, false, cls, 0); | 
|    511   fields.SetAt(0, fld); |    511   fields.SetAt(0, fld); | 
|    512   cls.SetFields(fields); |    512   cls.SetFields(fields); | 
|    513 } |    513 } | 
|    514  |    514  | 
|    515  |    515  | 
|    516 // Make unused space in an object whose type has been transformed safe |    516 // Make unused space in an object whose type has been transformed safe | 
|    517 // for traversing during GC. |    517 // for traversing during GC. | 
|    518 // The unused part of the transformed object is marked as an Array |    518 // The unused part of the transformed object is marked as an Int8Array | 
|    519 // object or a regular Object so that it can be traversed during garbage |    519 // object. | 
|    520 // collection. |  | 
|    521 void Object::MakeUnusedSpaceTraversable(const Object& obj, |    520 void Object::MakeUnusedSpaceTraversable(const Object& obj, | 
|    522                                         intptr_t original_size, |    521                                         intptr_t original_size, | 
|    523                                         intptr_t used_size) { |    522                                         intptr_t used_size) { | 
|    524   ASSERT(Isolate::Current()->no_gc_scope_depth() > 0); |    523   ASSERT(Isolate::Current()->no_gc_scope_depth() > 0); | 
|    525   ASSERT(!obj.IsNull()); |    524   ASSERT(!obj.IsNull()); | 
|    526   ASSERT(original_size >= used_size); |    525   ASSERT(original_size >= used_size); | 
|    527   if (original_size > used_size) { |    526   if (original_size > used_size) { | 
|    528     intptr_t leftover_size = original_size - used_size; |    527     intptr_t leftover_size = original_size - used_size; | 
|    529  |    528  | 
|    530     uword addr = RawObject::ToAddr(obj.raw()) + used_size; |    529     uword addr = RawObject::ToAddr(obj.raw()) + used_size; | 
|    531     if (leftover_size >= Array::InstanceSize(0)) { |    530     ASSERT(Int8Array::InstanceSize(0) == Object::InstanceSize()); | 
|    532       // As we have enough space to use an array object, update the leftover |    531     // Update the leftover space as an Int8Array object. | 
|    533       // space as an Array object. |    532     RawInt8Array* raw = | 
|    534       RawArray* raw = reinterpret_cast<RawArray*>(RawObject::FromAddr(addr)); |    533         reinterpret_cast<RawInt8Array*>(RawObject::FromAddr(addr)); | 
|    535       uword tags = 0; |    534     uword tags = 0; | 
|    536       tags = RawObject::SizeTag::update(leftover_size, tags); |    535     tags = RawObject::SizeTag::update(leftover_size, tags); | 
|    537       tags = RawObject::ClassIdTag::update(kArrayCid, tags); |    536     tags = RawObject::ClassIdTag::update(kInt8ArrayCid, tags); | 
|    538       raw->ptr()->tags_ = tags; |    537     raw->ptr()->tags_ = tags; | 
|    539       intptr_t leftover_len = |    538     intptr_t leftover_len = (leftover_size - Int8Array::InstanceSize(0)); | 
|    540           ((leftover_size - Array::InstanceSize(0)) / kWordSize); |    539     ASSERT(Int8Array::InstanceSize(leftover_len) == leftover_size); | 
|    541       ASSERT(Array::InstanceSize(leftover_len) == leftover_size); |    540     raw->ptr()->length_ = Smi::New(leftover_len); | 
|    542       raw->ptr()->tags_ = tags; |  | 
|    543       raw->ptr()->length_ = Smi::New(leftover_len); |  | 
|    544     } else { |  | 
|    545       // Update the leftover space as a basic object. |  | 
|    546       ASSERT(leftover_size == Object::InstanceSize()); |  | 
|    547       RawObject* raw = |  | 
|    548           reinterpret_cast<RawObject*>(RawObject::FromAddr(addr)); |  | 
|    549       uword tags = 0; |  | 
|    550       tags = RawObject::SizeTag::update(leftover_size, tags); |  | 
|    551       tags = RawObject::ClassIdTag::update(kInstanceCid, tags); |  | 
|    552       raw->ptr()->tags_ = tags; |  | 
|    553     } |  | 
|    554   } |    541   } | 
|    555 } |    542 } | 
|    556  |    543  | 
|    557  |    544  | 
|    558 void Object::RegisterClass(const Class& cls, |    545 void Object::RegisterClass(const Class& cls, | 
|    559                            const String& name, |    546                            const String& name, | 
|    560                            const Library& lib) { |    547                            const Library& lib) { | 
|    561   ASSERT(name.Length() > 0); |    548   ASSERT(name.Length() > 0); | 
|    562   ASSERT(name.CharAt(0) != '_'); |    549   ASSERT(name.CharAt(0) != '_'); | 
|    563   cls.set_name(name); |    550   cls.set_name(name); | 
| (...skipping 11979 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  12543   } |  12530   } | 
|  12544   return result.raw(); |  12531   return result.raw(); | 
|  12545 } |  12532 } | 
|  12546  |  12533  | 
|  12547  |  12534  | 
|  12548 const char* WeakProperty::ToCString() const { |  12535 const char* WeakProperty::ToCString() const { | 
|  12549   return "_WeakProperty"; |  12536   return "_WeakProperty"; | 
|  12550 } |  12537 } | 
|  12551  |  12538  | 
|  12552 }  // namespace dart |  12539 }  // namespace dart | 
| OLD | NEW |