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 2994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3005 } | 3005 } |
3006 RawArray* object_pool() const { return raw_ptr()->object_pool_; } | 3006 RawArray* object_pool() const { return raw_ptr()->object_pool_; } |
3007 static intptr_t object_pool_offset() { | 3007 static intptr_t object_pool_offset() { |
3008 return OFFSET_OF(RawInstructions, object_pool_); | 3008 return OFFSET_OF(RawInstructions, object_pool_); |
3009 } | 3009 } |
3010 | 3010 |
3011 uword EntryPoint() const { | 3011 uword EntryPoint() const { |
3012 return reinterpret_cast<uword>(raw_ptr()) + HeaderSize(); | 3012 return reinterpret_cast<uword>(raw_ptr()) + HeaderSize(); |
3013 } | 3013 } |
3014 | 3014 |
3015 static const intptr_t kMaxElements = (kIntptrMax - | 3015 static const intptr_t kMaxElements = (kMaxInt32 - |
3016 (sizeof(RawInstructions) + | 3016 (sizeof(RawInstructions) + |
3017 sizeof(RawObject) + | 3017 sizeof(RawObject) + |
3018 (2 * OS::kMaxPreferredCodeAlignment))); | 3018 (2 * OS::kMaxPreferredCodeAlignment))); |
3019 | 3019 |
3020 static intptr_t InstanceSize() { | 3020 static intptr_t InstanceSize() { |
3021 ASSERT(sizeof(RawInstructions) == | 3021 ASSERT(sizeof(RawInstructions) == |
3022 OFFSET_OF_RETURNED_VALUE(RawInstructions, data)); | 3022 OFFSET_OF_RETURNED_VALUE(RawInstructions, data)); |
3023 return 0; | 3023 return 0; |
3024 } | 3024 } |
3025 | 3025 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3071 RawString* GetName(intptr_t var_index) const; | 3071 RawString* GetName(intptr_t var_index) const; |
3072 | 3072 |
3073 void SetVar(intptr_t var_index, | 3073 void SetVar(intptr_t var_index, |
3074 const String& name, | 3074 const String& name, |
3075 RawLocalVarDescriptors::VarInfo* info) const; | 3075 RawLocalVarDescriptors::VarInfo* info) const; |
3076 | 3076 |
3077 void GetInfo(intptr_t var_index, RawLocalVarDescriptors::VarInfo* info) const; | 3077 void GetInfo(intptr_t var_index, RawLocalVarDescriptors::VarInfo* info) const; |
3078 | 3078 |
3079 static const intptr_t kBytesPerElement = | 3079 static const intptr_t kBytesPerElement = |
3080 sizeof(RawLocalVarDescriptors::VarInfo); | 3080 sizeof(RawLocalVarDescriptors::VarInfo); |
3081 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 3081 static const intptr_t kMaxElements = RawLocalVarDescriptors::kMaxIndex; |
3082 | 3082 |
3083 static intptr_t InstanceSize() { | 3083 static intptr_t InstanceSize() { |
3084 ASSERT(sizeof(RawLocalVarDescriptors) == | 3084 ASSERT(sizeof(RawLocalVarDescriptors) == |
3085 OFFSET_OF_RETURNED_VALUE(RawLocalVarDescriptors, data)); | 3085 OFFSET_OF_RETURNED_VALUE(RawLocalVarDescriptors, data)); |
3086 return 0; | 3086 return 0; |
3087 } | 3087 } |
3088 static intptr_t InstanceSize(intptr_t len) { | 3088 static intptr_t InstanceSize(intptr_t len) { |
3089 ASSERT(0 <= len && len <= kMaxElements); | 3089 ASSERT(0 <= len && len <= kMaxElements); |
3090 return RoundedAllocationSize( | 3090 return RoundedAllocationSize( |
3091 sizeof(RawLocalVarDescriptors) + (len * kBytesPerElement)); | 3091 sizeof(RawLocalVarDescriptors) + (len * kBytesPerElement)); |
(...skipping 24 matching lines...) Expand all Loading... | |
3116 rec->set_token_pos(static_cast<int32_t>(token_pos), | 3116 rec->set_token_pos(static_cast<int32_t>(token_pos), |
3117 RecordSizeInBytes() == RawPcDescriptors::kCompressedRecSize); | 3117 RecordSizeInBytes() == RawPcDescriptors::kCompressedRecSize); |
3118 ASSERT(Utils::IsInt(16, try_index)); | 3118 ASSERT(Utils::IsInt(16, try_index)); |
3119 rec->set_try_index(try_index); | 3119 rec->set_try_index(try_index); |
3120 ASSERT(rec->try_index() == try_index); | 3120 ASSERT(rec->try_index() == try_index); |
3121 ASSERT(rec->token_pos() == token_pos); | 3121 ASSERT(rec->token_pos() == token_pos); |
3122 } | 3122 } |
3123 | 3123 |
3124 static const intptr_t kMaxBytesPerElement = | 3124 static const intptr_t kMaxBytesPerElement = |
3125 sizeof(RawPcDescriptors::PcDescriptorRec); | 3125 sizeof(RawPcDescriptors::PcDescriptorRec); |
3126 static const intptr_t kMaxElements = kSmiMax / kMaxBytesPerElement; | 3126 static const intptr_t kMaxElements = kSmi32Max / kMaxBytesPerElement; |
siva
2014/09/09 16:47:24
Does this need to be kSmi32Max why not just kMaxIn
zra
2014/09/09 17:42:38
Done.
| |
3127 | 3127 |
3128 static intptr_t InstanceSize() { | 3128 static intptr_t InstanceSize() { |
3129 ASSERT(sizeof(RawPcDescriptors) == | 3129 ASSERT(sizeof(RawPcDescriptors) == |
3130 OFFSET_OF_RETURNED_VALUE(RawPcDescriptors, data)); | 3130 OFFSET_OF_RETURNED_VALUE(RawPcDescriptors, data)); |
3131 return 0; | 3131 return 0; |
3132 } | 3132 } |
3133 static intptr_t InstanceSize(intptr_t len, intptr_t record_size_in_bytes) { | 3133 static intptr_t InstanceSize(intptr_t len, intptr_t record_size_in_bytes) { |
3134 ASSERT(0 <= len && len <= kMaxElements); | 3134 ASSERT(0 <= len && len <= kMaxElements); |
3135 return RoundedAllocationSize( | 3135 return RoundedAllocationSize( |
3136 sizeof(RawPcDescriptors) + (len * record_size_in_bytes)); | 3136 sizeof(RawPcDescriptors) + (len * record_size_in_bytes)); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3244 static const intptr_t kNoMaximum = -1; | 3244 static const intptr_t kNoMaximum = -1; |
3245 static const intptr_t kNoMinimum = -1; | 3245 static const intptr_t kNoMinimum = -1; |
3246 | 3246 |
3247 bool IsObject(intptr_t index) const { | 3247 bool IsObject(intptr_t index) const { |
3248 ASSERT(InRange(index)); | 3248 ASSERT(InRange(index)); |
3249 return GetBit(index); | 3249 return GetBit(index); |
3250 } | 3250 } |
3251 | 3251 |
3252 intptr_t Length() const { return raw_ptr()->length_; } | 3252 intptr_t Length() const { return raw_ptr()->length_; } |
3253 | 3253 |
3254 uword PC() const { return raw_ptr()->pc_; } | 3254 uint32_t PcOffset() const { return raw_ptr()->pc_offset_; } |
3255 void SetPC(uword value) const { raw_ptr()->pc_ = value; } | 3255 void SetPcOffset(uint32_t value) const { |
3256 ASSERT(value <= kMaxUint32); | |
3257 raw_ptr()->pc_offset_ = value; | |
3258 } | |
3256 | 3259 |
3257 intptr_t RegisterBitCount() const { return raw_ptr()->register_bit_count_; } | 3260 intptr_t RegisterBitCount() const { return raw_ptr()->register_bit_count_; } |
3258 void SetRegisterBitCount(intptr_t register_bit_count) const { | 3261 void SetRegisterBitCount(intptr_t register_bit_count) const { |
3262 ASSERT(register_bit_count < kMaxInt32); | |
3259 raw_ptr()->register_bit_count_ = register_bit_count; | 3263 raw_ptr()->register_bit_count_ = register_bit_count; |
3260 } | 3264 } |
3261 | 3265 |
3262 static const intptr_t kMaxLengthInBytes = kSmiMax; | 3266 static const intptr_t kMaxLengthInBytes = kSmiMax; |
3263 | 3267 |
3264 static intptr_t InstanceSize() { | 3268 static intptr_t InstanceSize() { |
3265 ASSERT(sizeof(RawStackmap) == OFFSET_OF_RETURNED_VALUE(RawStackmap, data)); | 3269 ASSERT(sizeof(RawStackmap) == OFFSET_OF_RETURNED_VALUE(RawStackmap, data)); |
3266 return 0; | 3270 return 0; |
3267 } | 3271 } |
3268 static intptr_t InstanceSize(intptr_t length) { | 3272 static intptr_t InstanceSize(intptr_t length) { |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3657 }; | 3661 }; |
3658 | 3662 |
3659 | 3663 |
3660 class Code : public Object { | 3664 class Code : public Object { |
3661 public: | 3665 public: |
3662 RawInstructions* instructions() const { return raw_ptr()->instructions_; } | 3666 RawInstructions* instructions() const { return raw_ptr()->instructions_; } |
3663 static intptr_t instructions_offset() { | 3667 static intptr_t instructions_offset() { |
3664 return OFFSET_OF(RawCode, instructions_); | 3668 return OFFSET_OF(RawCode, instructions_); |
3665 } | 3669 } |
3666 intptr_t pointer_offsets_length() const { | 3670 intptr_t pointer_offsets_length() const { |
3667 return raw_ptr()->pointer_offsets_length_; | 3671 return PtrOffBits::decode(raw_ptr()->state_bits_); |
3668 } | 3672 } |
3669 | 3673 |
3670 bool is_optimized() const { | 3674 bool is_optimized() const { |
3671 return OptimizedBit::decode(raw_ptr()->state_bits_); | 3675 return OptimizedBit::decode(raw_ptr()->state_bits_); |
3672 } | 3676 } |
3673 void set_is_optimized(bool value) const; | 3677 void set_is_optimized(bool value) const; |
3674 bool is_alive() const { | 3678 bool is_alive() const { |
3675 return AliveBit::decode(raw_ptr()->state_bits_); | 3679 return AliveBit::decode(raw_ptr()->state_bits_); |
3676 } | 3680 } |
3677 void set_is_alive(bool value) const; | 3681 void set_is_alive(bool value) const; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3713 | 3717 |
3714 RawArray* object_table() const { | 3718 RawArray* object_table() const { |
3715 return raw_ptr()->object_table_; | 3719 return raw_ptr()->object_table_; |
3716 } | 3720 } |
3717 void set_object_table(const Array& array) const; | 3721 void set_object_table(const Array& array) const; |
3718 | 3722 |
3719 RawArray* stackmaps() const { | 3723 RawArray* stackmaps() const { |
3720 return raw_ptr()->stackmaps_; | 3724 return raw_ptr()->stackmaps_; |
3721 } | 3725 } |
3722 void set_stackmaps(const Array& maps) const; | 3726 void set_stackmaps(const Array& maps) const; |
3723 RawStackmap* GetStackmap(uword pc, Array* stackmaps, Stackmap* map) const; | 3727 RawStackmap* GetStackmap( |
3728 uint32_t pc_offset, Array* stackmaps, Stackmap* map) const; | |
3724 | 3729 |
3725 enum { | 3730 enum { |
3726 kSCallTableOffsetEntry = 0, | 3731 kSCallTableOffsetEntry = 0, |
3727 kSCallTableFunctionEntry = 1, | 3732 kSCallTableFunctionEntry = 1, |
3728 kSCallTableCodeEntry = 2, | 3733 kSCallTableCodeEntry = 2, |
3729 kSCallTableEntryLength = 3, | 3734 kSCallTableEntryLength = 3, |
3730 }; | 3735 }; |
3731 | 3736 |
3732 void set_static_calls_target_table(const Array& value) const; | 3737 void set_static_calls_target_table(const Array& value) const; |
3733 RawArray* static_calls_target_table() const { | 3738 RawArray* static_calls_target_table() const { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3887 intptr_t lazy_deopt_pc_offset() const { | 3892 intptr_t lazy_deopt_pc_offset() const { |
3888 return raw_ptr()->lazy_deopt_pc_offset_; | 3893 return raw_ptr()->lazy_deopt_pc_offset_; |
3889 } | 3894 } |
3890 void set_lazy_deopt_pc_offset(intptr_t pc) const { | 3895 void set_lazy_deopt_pc_offset(intptr_t pc) const { |
3891 raw_ptr()->lazy_deopt_pc_offset_ = pc; | 3896 raw_ptr()->lazy_deopt_pc_offset_ = pc; |
3892 } | 3897 } |
3893 | 3898 |
3894 private: | 3899 private: |
3895 void set_state_bits(intptr_t bits) const; | 3900 void set_state_bits(intptr_t bits) const; |
3896 | 3901 |
3902 friend class RawObject; // For RawObject::SizeFromClass(). | |
3897 friend class RawCode; | 3903 friend class RawCode; |
3898 enum { | 3904 enum { |
3899 kOptimizedBit = 0, | 3905 kOptimizedBit = 0, |
3900 kAliveBit = 1, | 3906 kAliveBit = 1, |
3907 kPtrOffBit = 2, | |
3908 kPtrOffSize = 30, | |
3901 }; | 3909 }; |
3902 | 3910 |
3903 class OptimizedBit : public BitField<bool, kOptimizedBit, 1> {}; | 3911 class OptimizedBit : public BitField<bool, kOptimizedBit, 1> {}; |
3904 class AliveBit : public BitField<bool, kAliveBit, 1> {}; | 3912 class AliveBit : public BitField<bool, kAliveBit, 1> {}; |
3913 class PtrOffBits : public BitField<intptr_t, kPtrOffBit, kPtrOffSize> {}; | |
3905 | 3914 |
3906 // An object finder visitor interface. | 3915 // An object finder visitor interface. |
3907 class FindRawCodeVisitor : public FindObjectVisitor { | 3916 class FindRawCodeVisitor : public FindObjectVisitor { |
3908 public: | 3917 public: |
3909 explicit FindRawCodeVisitor(uword pc) | 3918 explicit FindRawCodeVisitor(uword pc) |
3910 : FindObjectVisitor(Isolate::Current()), pc_(pc) { } | 3919 : FindObjectVisitor(Isolate::Current()), pc_(pc) { } |
3911 virtual ~FindRawCodeVisitor() { } | 3920 virtual ~FindRawCodeVisitor() { } |
3912 | 3921 |
3913 virtual uword filter_addr() const { return pc_; } | 3922 virtual uword filter_addr() const { return pc_; } |
3914 | 3923 |
(...skipping 10 matching lines...) Expand all Loading... | |
3925 | 3934 |
3926 void set_compile_timestamp(int64_t timestamp) const { | 3935 void set_compile_timestamp(int64_t timestamp) const { |
3927 raw_ptr()->compile_timestamp_ = timestamp; | 3936 raw_ptr()->compile_timestamp_ = timestamp; |
3928 } | 3937 } |
3929 | 3938 |
3930 void set_instructions(RawInstructions* instructions) { | 3939 void set_instructions(RawInstructions* instructions) { |
3931 // RawInstructions are never allocated in New space and hence a | 3940 // RawInstructions are never allocated in New space and hence a |
3932 // store buffer update is not needed here. | 3941 // store buffer update is not needed here. |
3933 raw_ptr()->instructions_ = instructions; | 3942 raw_ptr()->instructions_ = instructions; |
3934 } | 3943 } |
3944 | |
3935 void set_pointer_offsets_length(intptr_t value) { | 3945 void set_pointer_offsets_length(intptr_t value) { |
3936 ASSERT(value >= 0); | 3946 // The number of fixups is limited to 1-billion. |
3937 raw_ptr()->pointer_offsets_length_ = value; | 3947 ASSERT(Utils::IsUint(30, value)); |
3948 set_state_bits(PtrOffBits::update(value, raw_ptr()->state_bits_)); | |
3938 } | 3949 } |
3939 int32_t* PointerOffsetAddrAt(int index) const { | 3950 int32_t* PointerOffsetAddrAt(int index) const { |
3940 ASSERT(index >= 0); | 3951 ASSERT(index >= 0); |
3941 ASSERT(index < pointer_offsets_length()); | 3952 ASSERT(index < pointer_offsets_length()); |
3942 // TODO(iposva): Unit test is missing for this functionality. | 3953 // TODO(iposva): Unit test is missing for this functionality. |
3943 return &raw_ptr()->data()[index]; | 3954 return &raw_ptr()->data()[index]; |
3944 } | 3955 } |
3945 void SetPointerOffsetAt(int index, int32_t offset_in_instructions) { | 3956 void SetPointerOffsetAt(int index, int32_t offset_in_instructions) { |
3946 *PointerOffsetAddrAt(index) = offset_in_instructions; | 3957 *PointerOffsetAddrAt(index) = offset_in_instructions; |
3947 } | 3958 } |
(...skipping 3147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7095 | 7106 |
7096 // Internal JavaScript regular expression object. | 7107 // Internal JavaScript regular expression object. |
7097 class JSRegExp : public Instance { | 7108 class JSRegExp : public Instance { |
7098 public: | 7109 public: |
7099 // Meaning of RegExType: | 7110 // Meaning of RegExType: |
7100 // kUninitialized: the type of th regexp has not been initialized yet. | 7111 // kUninitialized: the type of th regexp has not been initialized yet. |
7101 // kSimple: A simple pattern to match against, using string indexOf operation. | 7112 // kSimple: A simple pattern to match against, using string indexOf operation. |
7102 // kComplex: A complex pattern to match. | 7113 // kComplex: A complex pattern to match. |
7103 enum RegExType { | 7114 enum RegExType { |
7104 kUnitialized = 0, | 7115 kUnitialized = 0, |
7105 kSimple, | 7116 kSimple = 1, |
7106 kComplex, | 7117 kComplex = 2, |
7107 }; | 7118 }; |
7108 | 7119 |
7109 // Flags are passed to a regex object as follows: | 7120 // Flags are passed to a regex object as follows: |
7110 // 'i': ignore case, 'g': do global matches, 'm': pattern is multi line. | 7121 // 'i': ignore case, 'g': do global matches, 'm': pattern is multi line. |
7111 enum Flags { | 7122 enum Flags { |
7112 kNone = 0, | 7123 kNone = 0, |
7113 kGlobal = 1, | 7124 kGlobal = 1, |
7114 kIgnoreCase = 2, | 7125 kIgnoreCase = 2, |
7115 kMultiLine = 4, | 7126 kMultiLine = 4, |
7116 }; | 7127 }; |
7117 | 7128 |
7118 bool is_initialized() const { return (raw_ptr()->type_ != kUnitialized); } | 7129 enum { |
7119 bool is_simple() const { return (raw_ptr()->type_ == kSimple); } | 7130 kTypePos = 0, |
7120 bool is_complex() const { return (raw_ptr()->type_ == kComplex); } | 7131 kTypeSize = 2, |
7132 kFlagsPos = 2, | |
7133 kFlagsSize = 4, | |
7134 }; | |
7121 | 7135 |
7122 bool is_global() const { return (raw_ptr()->flags_ & kGlobal); } | 7136 class TypeBits : public BitField<RegExType, kTypePos, kTypeSize> {}; |
7123 bool is_ignore_case() const { return (raw_ptr()->flags_ & kIgnoreCase); } | 7137 class FlagsBits : public BitField<intptr_t, kFlagsPos, kFlagsSize> {}; |
7124 bool is_multi_line() const { return (raw_ptr()->flags_ & kMultiLine); } | 7138 |
7139 bool is_initialized() const { return (type() != kUnitialized); } | |
7140 bool is_simple() const { return (type() == kSimple); } | |
7141 bool is_complex() const { return (type() == kComplex); } | |
7142 | |
7143 bool is_global() const { return (flags() & kGlobal); } | |
7144 bool is_ignore_case() const { return (flags() & kIgnoreCase); } | |
7145 bool is_multi_line() const { return (flags() & kMultiLine); } | |
7125 | 7146 |
7126 RawString* pattern() const { return raw_ptr()->pattern_; } | 7147 RawString* pattern() const { return raw_ptr()->pattern_; } |
7127 RawSmi* num_bracket_expressions() const { | 7148 RawSmi* num_bracket_expressions() const { |
7128 return raw_ptr()->num_bracket_expressions_; | 7149 return raw_ptr()->num_bracket_expressions_; |
7129 } | 7150 } |
7130 | 7151 |
7131 void set_pattern(const String& pattern) const; | 7152 void set_pattern(const String& pattern) const; |
7132 void set_num_bracket_expressions(intptr_t value) const; | 7153 void set_num_bracket_expressions(intptr_t value) const; |
7133 void set_is_global() const { raw_ptr()->flags_ |= kGlobal; } | 7154 void set_is_global() const { set_flags(flags() | kGlobal); } |
7134 void set_is_ignore_case() const { raw_ptr()->flags_ |= kIgnoreCase; } | 7155 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } |
7135 void set_is_multi_line() const { raw_ptr()->flags_ |= kMultiLine; } | 7156 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } |
7136 void set_is_simple() const { raw_ptr()->type_ = kSimple; } | 7157 void set_is_simple() const { set_type(kSimple); } |
7137 void set_is_complex() const { raw_ptr()->type_ = kComplex; } | 7158 void set_is_complex() const { set_type(kComplex); } |
7138 | 7159 |
7139 void* GetDataStartAddress() const; | 7160 void* GetDataStartAddress() const; |
7140 static RawJSRegExp* FromDataStartAddress(void* data); | 7161 static RawJSRegExp* FromDataStartAddress(void* data); |
7141 const char* Flags() const; | 7162 const char* Flags() const; |
7142 | 7163 |
7143 virtual bool CanonicalizeEquals(const Instance& other) const; | 7164 virtual bool CanonicalizeEquals(const Instance& other) const; |
7144 | 7165 |
7145 static const intptr_t kBytesPerElement = 1; | 7166 static const intptr_t kBytesPerElement = 1; |
7146 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 7167 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
7147 | 7168 |
7148 static intptr_t InstanceSize() { | 7169 static intptr_t InstanceSize() { |
7149 ASSERT(sizeof(RawJSRegExp) == OFFSET_OF_RETURNED_VALUE(RawJSRegExp, data)); | 7170 ASSERT(sizeof(RawJSRegExp) == OFFSET_OF_RETURNED_VALUE(RawJSRegExp, data)); |
7150 return 0; | 7171 return 0; |
7151 } | 7172 } |
7152 | 7173 |
7153 static intptr_t InstanceSize(intptr_t len) { | 7174 static intptr_t InstanceSize(intptr_t len) { |
7154 ASSERT(0 <= len && len <= kMaxElements); | 7175 ASSERT(0 <= len && len <= kMaxElements); |
7155 return RoundedAllocationSize( | 7176 return RoundedAllocationSize( |
7156 sizeof(RawJSRegExp) + (len * kBytesPerElement)); | 7177 sizeof(RawJSRegExp) + (len * kBytesPerElement)); |
7157 } | 7178 } |
7158 | 7179 |
7159 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew); | 7180 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew); |
7160 | 7181 |
7161 private: | 7182 private: |
7162 void set_type(RegExType type) const { raw_ptr()->type_ = type; } | 7183 void set_type(RegExType type) const { |
7163 void set_flags(intptr_t value) const { raw_ptr()->flags_ = value; } | 7184 raw_ptr()->type_flags_ = TypeBits::update(type, raw_ptr()->type_flags_); |
7185 } | |
7186 void set_flags(intptr_t value) const { | |
7187 raw_ptr()->type_flags_ = FlagsBits::update(value, raw_ptr()->type_flags_); | |
7188 } | |
7189 | |
7190 RegExType type() const { | |
7191 return TypeBits::decode(raw_ptr()->type_flags_); | |
7192 } | |
7193 intptr_t flags() const { | |
7194 return FlagsBits::decode(raw_ptr()->type_flags_); | |
7195 } | |
7164 | 7196 |
7165 void SetLength(intptr_t value) const { | 7197 void SetLength(intptr_t value) const { |
7166 // This is only safe because we create a new Smi, which does not cause | 7198 // This is only safe because we create a new Smi, which does not cause |
7167 // heap allocation. | 7199 // heap allocation. |
7168 raw_ptr()->data_length_ = Smi::New(value); | 7200 raw_ptr()->data_length_ = Smi::New(value); |
7169 } | 7201 } |
7170 | 7202 |
7171 FINAL_HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance); | 7203 FINAL_HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance); |
7172 friend class Class; | 7204 friend class Class; |
7173 }; | 7205 }; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7416 | 7448 |
7417 | 7449 |
7418 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 7450 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
7419 intptr_t index) { | 7451 intptr_t index) { |
7420 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 7452 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
7421 } | 7453 } |
7422 | 7454 |
7423 } // namespace dart | 7455 } // namespace dart |
7424 | 7456 |
7425 #endif // VM_OBJECT_H_ | 7457 #endif // VM_OBJECT_H_ |
OLD | NEW |