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 7478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7489 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } | 7489 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } |
7490 void set_is_simple() const { set_type(kSimple); } | 7490 void set_is_simple() const { set_type(kSimple); } |
7491 void set_is_complex() const { set_type(kComplex); } | 7491 void set_is_complex() const { set_type(kComplex); } |
7492 | 7492 |
7493 void* GetDataStartAddress() const; | 7493 void* GetDataStartAddress() const; |
7494 static RawJSRegExp* FromDataStartAddress(void* data); | 7494 static RawJSRegExp* FromDataStartAddress(void* data); |
7495 const char* Flags() const; | 7495 const char* Flags() const; |
7496 | 7496 |
7497 virtual bool CanonicalizeEquals(const Instance& other) const; | 7497 virtual bool CanonicalizeEquals(const Instance& other) const; |
7498 | 7498 |
7499 static const intptr_t kBytesPerElement = 1; | |
7500 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | |
7501 | |
7502 static intptr_t InstanceSize() { | 7499 static intptr_t InstanceSize() { |
7503 ASSERT(sizeof(RawJSRegExp) == OFFSET_OF_RETURNED_VALUE(RawJSRegExp, data)); | |
7504 if (FLAG_use_jscre) { | |
7505 return 0; | |
7506 } | |
7507 return RoundedAllocationSize(sizeof(RawJSRegExp)); | 7500 return RoundedAllocationSize(sizeof(RawJSRegExp)); |
7508 } | 7501 } |
7509 | 7502 |
7510 static intptr_t InstanceSize(intptr_t len) { | 7503 static RawJSRegExp* New(Heap::Space space = Heap::kNew); |
7511 ASSERT(0 <= len && len <= kMaxElements); | |
7512 return RoundedAllocationSize( | |
7513 sizeof(RawJSRegExp) + (len * kBytesPerElement)); | |
7514 } | |
7515 | |
7516 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew); | |
7517 | 7504 |
7518 private: | 7505 private: |
7519 void set_type(RegExType type) const { | 7506 void set_type(RegExType type) const { |
7520 StoreNonPointer(&raw_ptr()->type_flags_, | 7507 StoreNonPointer(&raw_ptr()->type_flags_, |
7521 TypeBits::update(type, raw_ptr()->type_flags_)); | 7508 TypeBits::update(type, raw_ptr()->type_flags_)); |
7522 } | 7509 } |
7523 void set_flags(intptr_t value) const { | 7510 void set_flags(intptr_t value) const { |
7524 StoreNonPointer(&raw_ptr()->type_flags_, | 7511 StoreNonPointer(&raw_ptr()->type_flags_, |
7525 FlagsBits::update(value, raw_ptr()->type_flags_)); | 7512 FlagsBits::update(value, raw_ptr()->type_flags_)); |
7526 } | 7513 } |
7527 | 7514 |
7528 RegExType type() const { | 7515 RegExType type() const { |
7529 return TypeBits::decode(raw_ptr()->type_flags_); | 7516 return TypeBits::decode(raw_ptr()->type_flags_); |
7530 } | 7517 } |
7531 intptr_t flags() const { | 7518 intptr_t flags() const { |
7532 return FlagsBits::decode(raw_ptr()->type_flags_); | 7519 return FlagsBits::decode(raw_ptr()->type_flags_); |
7533 } | 7520 } |
7534 | 7521 |
7535 void SetLength(intptr_t value) const { | |
7536 // This is only safe because we create a new Smi, which does not cause | |
7537 // heap allocation. | |
7538 StoreSmi(&raw_ptr()->data_length_, Smi::New(value)); | |
7539 } | |
7540 | |
7541 FINAL_HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance); | 7522 FINAL_HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance); |
7542 friend class Class; | 7523 friend class Class; |
7543 }; | 7524 }; |
7544 | 7525 |
7545 | 7526 |
7546 class WeakProperty : public Instance { | 7527 class WeakProperty : public Instance { |
7547 public: | 7528 public: |
7548 RawObject* key() const { | 7529 RawObject* key() const { |
7549 return raw_ptr()->key_; | 7530 return raw_ptr()->key_; |
7550 } | 7531 } |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7794 | 7775 |
7795 | 7776 |
7796 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 7777 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
7797 intptr_t index) { | 7778 intptr_t index) { |
7798 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 7779 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
7799 } | 7780 } |
7800 | 7781 |
7801 } // namespace dart | 7782 } // namespace dart |
7802 | 7783 |
7803 #endif // VM_OBJECT_H_ | 7784 #endif // VM_OBJECT_H_ |
OLD | NEW |