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

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

Issue 11968020: Fix for 7941 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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 | « no previous file | runtime/vm/object_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 "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
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 or a regular Object so that it can be traversed during garbage
520 // collection. 520 // collection.
521 void Object::MakeUnusedSpaceTraversable(const Object& obj, 521 void Object::MakeUnusedSpaceTraversable(const Object& obj,
522 intptr_t original_size, 522 intptr_t original_size,
523 intptr_t used_size) { 523 intptr_t used_size) {
524 ASSERT(Isolate::Current()->no_gc_scope_depth() > 0); 524 ASSERT(Isolate::Current()->no_gc_scope_depth() > 0);
525 ASSERT(!obj.IsNull()); 525 ASSERT(!obj.IsNull());
526 ASSERT(original_size >= used_size); 526 ASSERT(original_size >= used_size);
527 if (original_size > used_size) { 527 if (original_size > used_size) {
528 intptr_t leftover_size = original_size - used_size; 528 intptr_t leftover_size = original_size - used_size;
529 529
530 uword addr = RawObject::ToAddr(obj.raw()) + used_size; 530 uword addr = RawObject::ToAddr(obj.raw()) + used_size;
Ivan Posva 2013/01/16 21:30:06 How about adding ASSERT(Object::InstanceSize() + k
siva 2013/01/16 21:43:08 Changed code a bit as discussed offline. ASSERT(ob
531 if (leftover_size >= Array::InstanceSize(0)) { 531 if (leftover_size >= Int8Array::InstanceSize(0)) {
532 // As we have enough space to use an array object, update the leftover 532 // As we have enough space to use an Int8Array object, update the
533 // space as an Array object. 533 // leftover space as an Int8Array object.
534 RawArray* raw = reinterpret_cast<RawArray*>(RawObject::FromAddr(addr)); 534 RawInt8Array* raw =
535 reinterpret_cast<RawInt8Array*>(RawObject::FromAddr(addr));
535 uword tags = 0; 536 uword tags = 0;
536 tags = RawObject::SizeTag::update(leftover_size, tags); 537 tags = RawObject::SizeTag::update(leftover_size, tags);
537 tags = RawObject::ClassIdTag::update(kArrayCid, tags); 538 tags = RawObject::ClassIdTag::update(kInt8ArrayCid, tags);
538 raw->ptr()->tags_ = tags; 539 raw->ptr()->tags_ = tags;
539 intptr_t leftover_len = 540 intptr_t leftover_len = (leftover_size - Int8Array::InstanceSize(0));
540 ((leftover_size - Array::InstanceSize(0)) / kWordSize); 541 ASSERT(Int8Array::InstanceSize(leftover_len) == leftover_size);
541 ASSERT(Array::InstanceSize(leftover_len) == leftover_size);
542 raw->ptr()->tags_ = tags;
543 raw->ptr()->length_ = Smi::New(leftover_len); 542 raw->ptr()->length_ = Smi::New(leftover_len);
544 } else { 543 } else {
545 // Update the leftover space as a basic object. 544 // Update the leftover space as a basic object.
546 ASSERT(leftover_size == Object::InstanceSize()); 545 ASSERT(leftover_size == Object::InstanceSize());
547 RawObject* raw = 546 RawObject* raw =
548 reinterpret_cast<RawObject*>(RawObject::FromAddr(addr)); 547 reinterpret_cast<RawObject*>(RawObject::FromAddr(addr));
549 uword tags = 0; 548 uword tags = 0;
550 tags = RawObject::SizeTag::update(leftover_size, tags); 549 tags = RawObject::SizeTag::update(leftover_size, tags);
551 tags = RawObject::ClassIdTag::update(kInstanceCid, tags); 550 tags = RawObject::ClassIdTag::update(kInstanceCid, tags);
552 raw->ptr()->tags_ = tags; 551 raw->ptr()->tags_ = tags;
(...skipping 11990 matching lines...) Expand 10 before | Expand all | Expand 10 after
12543 } 12542 }
12544 return result.raw(); 12543 return result.raw();
12545 } 12544 }
12546 12545
12547 12546
12548 const char* WeakProperty::ToCString() const { 12547 const char* WeakProperty::ToCString() const {
12549 return "_WeakProperty"; 12548 return "_WeakProperty";
12550 } 12549 }
12551 12550
12552 } // namespace dart 12551 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698