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 #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 5337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5348 // This is only safe because we create a new Smi, which does not cause | 5348 // This is only safe because we create a new Smi, which does not cause |
5349 // heap allocation. | 5349 // heap allocation. |
5350 raw_ptr()->data_length_ = Smi::New(value); | 5350 raw_ptr()->data_length_ = Smi::New(value); |
5351 } | 5351 } |
5352 | 5352 |
5353 HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance); | 5353 HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance); |
5354 friend class Class; | 5354 friend class Class; |
5355 }; | 5355 }; |
5356 | 5356 |
5357 | 5357 |
5358 class WeakProperty : public Instance { | |
5359 public: | |
5360 RawObject* key() const { | |
5361 return raw_ptr()->key_; | |
5362 } | |
5363 | |
5364 void set_key(const Object& key) { | |
5365 StorePointer(&raw_ptr()->key_, key.raw()); | |
5366 } | |
5367 | |
5368 RawObject* value() const { | |
5369 return raw_ptr()->value_; | |
5370 } | |
5371 | |
5372 void set_value(const Object& value) { | |
5373 StorePointer(&raw_ptr()->value_, value.raw()); | |
5374 } | |
5375 | |
5376 static RawWeakProperty* New(Heap::Space space = Heap::kNew); | |
5377 | |
5378 static intptr_t InstanceSize() { | |
5379 return RoundedAllocationSize(sizeof(RawWeakProperty)); | |
5380 } | |
5381 | |
5382 static void Clear(RawWeakProperty* raw_weak) { | |
turnidge
2012/08/09 18:34:34
These static functions (Clear/Pop/Push) all are ex
cshapiro
2012/08/14 04:58:18
Removed. Done.
| |
5383 raw_weak->ptr()->key_ = Object::null(); | |
5384 raw_weak->ptr()->value_ = Object::null(); | |
5385 } | |
5386 | |
5387 static RawWeakProperty* Pop(RawWeakProperty** queue) { | |
turnidge
2012/08/09 18:34:34
Not sure if this is technically a 'queue'. Seems
cshapiro
2012/08/14 04:58:18
True. This method has been removed. Done.
| |
5388 ASSERT(queue != NULL); | |
5389 RawWeakProperty* result = WeakProperty::null(); | |
5390 if (*queue != WeakProperty::null()) { | |
5391 result = *queue; | |
5392 RawWeakProperty* next = result->ptr()->next_; | |
5393 result->ptr()->next_ = WeakProperty::null(); | |
5394 *queue = next; | |
5395 } | |
5396 return result; | |
5397 } | |
5398 | |
5399 static void Push(RawWeakProperty* raw_weak, RawWeakProperty** queue) { | |
5400 ASSERT(queue != NULL); | |
5401 RawWeakProperty* next = *queue; | |
5402 raw_weak->ptr()->next_ = next; | |
5403 *queue = raw_weak; | |
5404 } | |
5405 | |
5406 private: | |
5407 HEAP_OBJECT_IMPLEMENTATION(WeakProperty, Instance); | |
5408 friend class Class; | |
5409 }; | |
5410 | |
5411 | |
5358 // Breaking cycles and loops. | 5412 // Breaking cycles and loops. |
5359 RawClass* Object::clazz() const { | 5413 RawClass* Object::clazz() const { |
5360 uword raw_value = reinterpret_cast<uword>(raw_); | 5414 uword raw_value = reinterpret_cast<uword>(raw_); |
5361 if ((raw_value & kSmiTagMask) == kSmiTag) { | 5415 if ((raw_value & kSmiTagMask) == kSmiTag) { |
5362 return Smi::Class(); | 5416 return Smi::Class(); |
5363 } | 5417 } |
5364 return Isolate::Current()->class_table()->At(raw()->GetClassId()); | 5418 return Isolate::Current()->class_table()->At(raw()->GetClassId()); |
5365 } | 5419 } |
5366 | 5420 |
5367 | 5421 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5459 if (this->CharAt(i) != str.CharAt(begin_index + i)) { | 5513 if (this->CharAt(i) != str.CharAt(begin_index + i)) { |
5460 return false; | 5514 return false; |
5461 } | 5515 } |
5462 } | 5516 } |
5463 return true; | 5517 return true; |
5464 } | 5518 } |
5465 | 5519 |
5466 } // namespace dart | 5520 } // namespace dart |
5467 | 5521 |
5468 #endif // VM_OBJECT_H_ | 5522 #endif // VM_OBJECT_H_ |
OLD | NEW |