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

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

Issue 10832199: Add a weak property type to the virtual machine. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 8 years, 4 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
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 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 5330 matching lines...) Expand 10 before | Expand all | Expand 10 after
5341 // This is only safe because we create a new Smi, which does not cause 5341 // This is only safe because we create a new Smi, which does not cause
5342 // heap allocation. 5342 // heap allocation.
5343 raw_ptr()->data_length_ = Smi::New(value); 5343 raw_ptr()->data_length_ = Smi::New(value);
5344 } 5344 }
5345 5345
5346 HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance); 5346 HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance);
5347 friend class Class; 5347 friend class Class;
5348 }; 5348 };
5349 5349
5350 5350
5351 class WeakProperty : public Instance {
5352 public:
5353 RawObject* key() const {
5354 return raw_ptr()->key_;
5355 }
5356
5357 void set_key(const Object& key) {
5358 StorePointer(&raw_ptr()->key_, key.raw());
5359 }
5360
5361 RawObject* value() const {
5362 return raw_ptr()->value_;
5363 }
5364
5365 void set_value(const Object& value) {
5366 StorePointer(&raw_ptr()->value_, value.raw());
5367 }
5368
5369 static RawWeakProperty* New(Heap::Space space = Heap::kNew);
5370
5371 static intptr_t InstanceSize() {
5372 return RoundedAllocationSize(sizeof(RawWeakProperty));
5373 }
5374
5375 static void Clear(RawWeakProperty* raw_weak) {
5376 raw_weak->ptr()->key_ = Object::null();
5377 raw_weak->ptr()->value_ = Object::null();
5378 }
5379
5380 private:
5381 HEAP_OBJECT_IMPLEMENTATION(WeakProperty, Instance);
5382 friend class Class;
5383 };
5384
5385
5351 // Breaking cycles and loops. 5386 // Breaking cycles and loops.
5352 RawClass* Object::clazz() const { 5387 RawClass* Object::clazz() const {
5353 uword raw_value = reinterpret_cast<uword>(raw_); 5388 uword raw_value = reinterpret_cast<uword>(raw_);
5354 if ((raw_value & kSmiTagMask) == kSmiTag) { 5389 if ((raw_value & kSmiTagMask) == kSmiTag) {
5355 return Smi::Class(); 5390 return Smi::Class();
5356 } 5391 }
5357 return Isolate::Current()->class_table()->At(raw()->GetClassId()); 5392 return Isolate::Current()->class_table()->At(raw()->GetClassId());
5358 } 5393 }
5359 5394
5360 5395
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
5452 if (this->CharAt(i) != str.CharAt(begin_index + i)) { 5487 if (this->CharAt(i) != str.CharAt(begin_index + i)) {
5453 return false; 5488 return false;
5454 } 5489 }
5455 } 5490 }
5456 return true; 5491 return true;
5457 } 5492 }
5458 5493
5459 } // namespace dart 5494 } // namespace dart
5460 5495
5461 #endif // VM_OBJECT_H_ 5496 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/gc_marker.cc ('k') | runtime/vm/object.cc » ('j') | runtime/vm/scavenger.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698