OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/assert-scope.h" | 9 #include "src/assert-scope.h" |
10 #include "src/builtins.h" | 10 #include "src/builtins.h" |
(...skipping 3097 matching lines...) Loading... |
3108 LAST_TYPE = INT32 | 3108 LAST_TYPE = INT32 |
3109 }; | 3109 }; |
3110 | 3110 |
3111 enum LayoutSection { | 3111 enum LayoutSection { |
3112 SMALL_SECTION = 0, | 3112 SMALL_SECTION = 0, |
3113 EXTENDED_SECTION | 3113 EXTENDED_SECTION |
3114 }; | 3114 }; |
3115 | 3115 |
3116 class NumberOfEntries BASE_EMBEDDED { | 3116 class NumberOfEntries BASE_EMBEDDED { |
3117 public: | 3117 public: |
| 3118 inline NumberOfEntries() { |
| 3119 for (int i = 0; i < NUMBER_OF_TYPES; i++) { |
| 3120 element_counts_[i] = 0; |
| 3121 } |
| 3122 } |
| 3123 |
3118 inline NumberOfEntries(int int64_count, int code_ptr_count, | 3124 inline NumberOfEntries(int int64_count, int code_ptr_count, |
3119 int heap_ptr_count, int int32_count) { | 3125 int heap_ptr_count, int int32_count) { |
3120 element_counts_[INT64] = int64_count; | 3126 element_counts_[INT64] = int64_count; |
3121 element_counts_[CODE_PTR] = code_ptr_count; | 3127 element_counts_[CODE_PTR] = code_ptr_count; |
3122 element_counts_[HEAP_PTR] = heap_ptr_count; | 3128 element_counts_[HEAP_PTR] = heap_ptr_count; |
3123 element_counts_[INT32] = int32_count; | 3129 element_counts_[INT32] = int32_count; |
3124 } | 3130 } |
3125 | 3131 |
3126 inline NumberOfEntries(ConstantPoolArray* array, LayoutSection section) { | 3132 inline NumberOfEntries(ConstantPoolArray* array, LayoutSection section) { |
3127 element_counts_[INT64] = array->number_of_entries(INT64, section); | 3133 element_counts_[INT64] = array->number_of_entries(INT64, section); |
3128 element_counts_[CODE_PTR] = array->number_of_entries(CODE_PTR, section); | 3134 element_counts_[CODE_PTR] = array->number_of_entries(CODE_PTR, section); |
3129 element_counts_[HEAP_PTR] = array->number_of_entries(HEAP_PTR, section); | 3135 element_counts_[HEAP_PTR] = array->number_of_entries(HEAP_PTR, section); |
3130 element_counts_[INT32] = array->number_of_entries(INT32, section); | 3136 element_counts_[INT32] = array->number_of_entries(INT32, section); |
3131 } | 3137 } |
3132 | 3138 |
3133 inline int count_of(Type type) const { | 3139 inline void increment(Type type); |
3134 ASSERT(type < NUMBER_OF_TYPES); | 3140 inline int equals(const NumberOfEntries& other) const; |
3135 return element_counts_[type]; | 3141 inline bool is_empty() const; |
3136 } | 3142 inline int count_of(Type type) const; |
3137 | 3143 inline int base_of(Type type) const; |
3138 inline int total_count() const { | 3144 inline int total_count() const; |
3139 int count = 0; | 3145 inline int are_in_range(int min, int max) const; |
3140 for (int i = 0; i < NUMBER_OF_TYPES; i++) { | |
3141 count += element_counts_[i]; | |
3142 } | |
3143 return count; | |
3144 } | |
3145 | |
3146 inline int are_in_range(int min, int max) const { | |
3147 for (int i = FIRST_TYPE; i < NUMBER_OF_TYPES; i++) { | |
3148 if (element_counts_[i] < min || element_counts_[i] > max) { | |
3149 return false; | |
3150 } | |
3151 } | |
3152 return true; | |
3153 } | |
3154 | 3146 |
3155 private: | 3147 private: |
3156 int element_counts_[NUMBER_OF_TYPES]; | 3148 int element_counts_[NUMBER_OF_TYPES]; |
3157 }; | 3149 }; |
3158 | 3150 |
3159 class Iterator BASE_EMBEDDED { | 3151 class Iterator BASE_EMBEDDED { |
3160 public: | 3152 public: |
3161 inline Iterator(ConstantPoolArray* array, Type type) | 3153 inline Iterator(ConstantPoolArray* array, Type type) |
3162 : array_(array), type_(type), final_section_(array->final_section()) { | 3154 : array_(array), |
3163 current_section_ = SMALL_SECTION; | 3155 type_(type), |
3164 next_index_ = array->first_index(type, SMALL_SECTION); | 3156 final_section_(array->final_section()), |
| 3157 current_section_(SMALL_SECTION), |
| 3158 next_index_(array->first_index(type, SMALL_SECTION)) { |
| 3159 update_section(); |
| 3160 } |
| 3161 |
| 3162 inline Iterator(ConstantPoolArray* array, Type type, LayoutSection section) |
| 3163 : array_(array), |
| 3164 type_(type), |
| 3165 final_section_(section), |
| 3166 current_section_(section), |
| 3167 next_index_(array->first_index(type, section)) { |
3165 update_section(); | 3168 update_section(); |
3166 } | 3169 } |
3167 | 3170 |
3168 inline int next_index(); | 3171 inline int next_index(); |
3169 inline bool is_finished(); | 3172 inline bool is_finished(); |
| 3173 |
3170 private: | 3174 private: |
3171 inline void update_section(); | 3175 inline void update_section(); |
3172 ConstantPoolArray* array_; | 3176 ConstantPoolArray* array_; |
3173 const Type type_; | 3177 const Type type_; |
3174 const LayoutSection final_section_; | 3178 const LayoutSection final_section_; |
3175 | 3179 |
3176 LayoutSection current_section_; | 3180 LayoutSection current_section_; |
3177 int next_index_; | 3181 int next_index_; |
3178 }; | 3182 }; |
3179 | 3183 |
(...skipping 39 matching lines...) Loading... |
3219 | 3223 |
3220 // Clears the pointer entries with GC safe values. | 3224 // Clears the pointer entries with GC safe values. |
3221 void ClearPtrEntries(Isolate* isolate); | 3225 void ClearPtrEntries(Isolate* isolate); |
3222 | 3226 |
3223 // returns the total number of entries in the constant pool array. | 3227 // returns the total number of entries in the constant pool array. |
3224 inline int length(); | 3228 inline int length(); |
3225 | 3229 |
3226 // Garbage collection support. | 3230 // Garbage collection support. |
3227 inline int size(); | 3231 inline int size(); |
3228 | 3232 |
| 3233 |
| 3234 inline static int MaxInt64Offset(int number_of_int64) { |
| 3235 return kFirstEntryOffset + (number_of_int64 * kInt64Size); |
| 3236 } |
| 3237 |
3229 inline static int SizeFor(const NumberOfEntries& small) { | 3238 inline static int SizeFor(const NumberOfEntries& small) { |
3230 int size = kFirstEntryOffset + | 3239 int size = kFirstEntryOffset + |
3231 (small.count_of(INT64) * kInt64Size) + | 3240 (small.count_of(INT64) * kInt64Size) + |
3232 (small.count_of(CODE_PTR) * kPointerSize) + | 3241 (small.count_of(CODE_PTR) * kPointerSize) + |
3233 (small.count_of(HEAP_PTR) * kPointerSize) + | 3242 (small.count_of(HEAP_PTR) * kPointerSize) + |
3234 (small.count_of(INT32) * kInt32Size); | 3243 (small.count_of(INT32) * kInt32Size); |
3235 return RoundUp(size, kPointerSize); | 3244 return RoundUp(size, kPointerSize); |
3236 } | 3245 } |
3237 | 3246 |
3238 inline static int SizeForExtended(const NumberOfEntries& small, | 3247 inline static int SizeForExtended(const NumberOfEntries& small, |
(...skipping 7928 matching lines...) Loading... |
11167 } else { | 11176 } else { |
11168 value &= ~(1 << bit_position); | 11177 value &= ~(1 << bit_position); |
11169 } | 11178 } |
11170 return value; | 11179 return value; |
11171 } | 11180 } |
11172 }; | 11181 }; |
11173 | 11182 |
11174 } } // namespace v8::internal | 11183 } } // namespace v8::internal |
11175 | 11184 |
11176 #endif // V8_OBJECTS_H_ | 11185 #endif // V8_OBJECTS_H_ |
OLD | NEW |