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

Side by Side Diff: src/objects-inl.h

Issue 183883011: Differentate between code target pointers and heap pointers in constant pools. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2186 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); 2186 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double());
2187 } 2187 }
2188 2188
2189 2189
2190 bool FixedDoubleArray::is_the_hole(int index) { 2190 bool FixedDoubleArray::is_the_hole(int index) {
2191 int offset = kHeaderSize + index * kDoubleSize; 2191 int offset = kHeaderSize + index * kDoubleSize;
2192 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset)); 2192 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset));
2193 } 2193 }
2194 2194
2195 2195
2196 SMI_ACCESSORS(ConstantPoolArray, first_ptr_index, kFirstPointerIndexOffset) 2196 SMI_ACCESSORS(
2197 SMI_ACCESSORS(ConstantPoolArray, first_int32_index, kFirstInt32IndexOffset) 2197 ConstantPoolArray, first_code_ptr_index, kFirstCodePointerIndexOffset)
2198 SMI_ACCESSORS(
2199 ConstantPoolArray, first_heap_ptr_index, kFirstHeapPointerIndexOffset)
2200 SMI_ACCESSORS(
2201 ConstantPoolArray, first_int32_index, kFirstInt32IndexOffset)
2198 2202
2199 2203
2200 int ConstantPoolArray::first_int64_index() { 2204 int ConstantPoolArray::first_int64_index() {
2201 return 0; 2205 return 0;
2202 } 2206 }
2203 2207
2204 2208
2205 int ConstantPoolArray::count_of_int64_entries() { 2209 int ConstantPoolArray::count_of_int64_entries() {
2206 return first_ptr_index(); 2210 return first_code_ptr_index();
2207 } 2211 }
2208 2212
2209 2213
2210 int ConstantPoolArray::count_of_ptr_entries() { 2214 int ConstantPoolArray::count_of_code_ptr_entries() {
2211 return first_int32_index() - first_ptr_index(); 2215 return first_heap_ptr_index() - first_code_ptr_index();
2212 } 2216 }
2213 2217
2214 2218
2219 int ConstantPoolArray::count_of_heap_ptr_entries() {
2220 return first_int32_index() - first_heap_ptr_index();
2221 }
2222
2223
2215 int ConstantPoolArray::count_of_int32_entries() { 2224 int ConstantPoolArray::count_of_int32_entries() {
2216 return length() - first_int32_index(); 2225 return length() - first_int32_index();
2217 } 2226 }
2218 2227
2219 2228
2220 void ConstantPoolArray::SetEntryCounts(int number_of_int64_entries, 2229 void ConstantPoolArray::SetEntryCounts(int number_of_int64_entries,
2221 int number_of_ptr_entries, 2230 int number_of_code_ptr_entries,
2231 int number_of_heap_ptr_entries,
2222 int number_of_int32_entries) { 2232 int number_of_int32_entries) {
2223 set_first_ptr_index(number_of_int64_entries); 2233 int current_index = number_of_int64_entries;
2224 set_first_int32_index(number_of_int64_entries + number_of_ptr_entries); 2234 set_first_code_ptr_index(current_index);
2225 set_length(number_of_int64_entries + number_of_ptr_entries + 2235 current_index += number_of_code_ptr_entries;
2226 number_of_int32_entries); 2236 set_first_heap_ptr_index(current_index);
2237 current_index += number_of_heap_ptr_entries;
2238 set_first_int32_index(current_index);
2239 current_index += number_of_int32_entries;
2240 set_length(current_index);
2227 } 2241 }
2228 2242
2229 2243
2230 int64_t ConstantPoolArray::get_int64_entry(int index) { 2244 int64_t ConstantPoolArray::get_int64_entry(int index) {
2231 ASSERT(map() == GetHeap()->constant_pool_array_map()); 2245 ASSERT(map() == GetHeap()->constant_pool_array_map());
2232 ASSERT(index >= 0 && index < first_ptr_index()); 2246 ASSERT(index >= 0 && index < first_code_ptr_index());
2233 return READ_INT64_FIELD(this, OffsetOfElementAt(index)); 2247 return READ_INT64_FIELD(this, OffsetOfElementAt(index));
2234 } 2248 }
2235 2249
2236 double ConstantPoolArray::get_int64_entry_as_double(int index) { 2250 double ConstantPoolArray::get_int64_entry_as_double(int index) {
2237 STATIC_ASSERT(kDoubleSize == kInt64Size); 2251 STATIC_ASSERT(kDoubleSize == kInt64Size);
2238 ASSERT(map() == GetHeap()->constant_pool_array_map()); 2252 ASSERT(map() == GetHeap()->constant_pool_array_map());
2239 ASSERT(index >= 0 && index < first_ptr_index()); 2253 ASSERT(index >= 0 && index < first_code_ptr_index());
2240 return READ_DOUBLE_FIELD(this, OffsetOfElementAt(index)); 2254 return READ_DOUBLE_FIELD(this, OffsetOfElementAt(index));
2241 } 2255 }
2242 2256
2243 2257
2244 Object* ConstantPoolArray::get_ptr_entry(int index) { 2258 Address ConstantPoolArray::get_code_ptr_entry(int index) {
2245 ASSERT(map() == GetHeap()->constant_pool_array_map()); 2259 ASSERT(map() == GetHeap()->constant_pool_array_map());
2246 ASSERT(index >= first_ptr_index() && index < first_int32_index()); 2260 ASSERT(index >= first_code_ptr_index() && index < first_heap_ptr_index());
2261 return reinterpret_cast<Address>(READ_FIELD(this, OffsetOfElementAt(index)));
2262 }
2263
2264
2265 Object* ConstantPoolArray::get_heap_ptr_entry(int index) {
2266 ASSERT(map() == GetHeap()->constant_pool_array_map());
2267 ASSERT(index >= first_heap_ptr_index() && index < first_int32_index());
2247 return READ_FIELD(this, OffsetOfElementAt(index)); 2268 return READ_FIELD(this, OffsetOfElementAt(index));
2248 } 2269 }
2249 2270
2250 2271
2251 int32_t ConstantPoolArray::get_int32_entry(int index) { 2272 int32_t ConstantPoolArray::get_int32_entry(int index) {
2252 ASSERT(map() == GetHeap()->constant_pool_array_map()); 2273 ASSERT(map() == GetHeap()->constant_pool_array_map());
2253 ASSERT(index >= first_int32_index() && index < length()); 2274 ASSERT(index >= first_int32_index() && index < length());
2254 return READ_INT32_FIELD(this, OffsetOfElementAt(index)); 2275 return READ_INT32_FIELD(this, OffsetOfElementAt(index));
2255 } 2276 }
2256 2277
2257 2278
2279 void ConstantPoolArray::set(int index, Address value) {
2280 ASSERT(map() == GetHeap()->constant_pool_array_map());
2281 ASSERT(index >= first_code_ptr_index() && index < first_heap_ptr_index());
2282 WRITE_FIELD(this, OffsetOfElementAt(index), reinterpret_cast<Object*>(value));
2283 }
2284
2285
2258 void ConstantPoolArray::set(int index, Object* value) { 2286 void ConstantPoolArray::set(int index, Object* value) {
2259 ASSERT(map() == GetHeap()->constant_pool_array_map()); 2287 ASSERT(map() == GetHeap()->constant_pool_array_map());
2260 ASSERT(index >= first_ptr_index() && index < first_int32_index()); 2288 ASSERT(index >= first_code_ptr_index() && index < first_int32_index());
2261 WRITE_FIELD(this, OffsetOfElementAt(index), value); 2289 WRITE_FIELD(this, OffsetOfElementAt(index), value);
2262 WRITE_BARRIER(GetHeap(), this, OffsetOfElementAt(index), value); 2290 WRITE_BARRIER(GetHeap(), this, OffsetOfElementAt(index), value);
2263 } 2291 }
2264 2292
2265 2293
2266 void ConstantPoolArray::set(int index, int64_t value) { 2294 void ConstantPoolArray::set(int index, int64_t value) {
2267 ASSERT(map() == GetHeap()->constant_pool_array_map()); 2295 ASSERT(map() == GetHeap()->constant_pool_array_map());
2268 ASSERT(index >= first_int64_index() && index < first_ptr_index()); 2296 ASSERT(index >= first_int64_index() && index < first_code_ptr_index());
2269 WRITE_INT64_FIELD(this, OffsetOfElementAt(index), value); 2297 WRITE_INT64_FIELD(this, OffsetOfElementAt(index), value);
2270 } 2298 }
2271 2299
2272 2300
2273 void ConstantPoolArray::set(int index, double value) { 2301 void ConstantPoolArray::set(int index, double value) {
2274 STATIC_ASSERT(kDoubleSize == kInt64Size); 2302 STATIC_ASSERT(kDoubleSize == kInt64Size);
2275 ASSERT(map() == GetHeap()->constant_pool_array_map()); 2303 ASSERT(map() == GetHeap()->constant_pool_array_map());
2276 ASSERT(index >= first_int64_index() && index < first_ptr_index()); 2304 ASSERT(index >= first_int64_index() && index < first_code_ptr_index());
2277 WRITE_DOUBLE_FIELD(this, OffsetOfElementAt(index), value); 2305 WRITE_DOUBLE_FIELD(this, OffsetOfElementAt(index), value);
2278 } 2306 }
2279 2307
2280 2308
2281 void ConstantPoolArray::set(int index, int32_t value) { 2309 void ConstantPoolArray::set(int index, int32_t value) {
2282 ASSERT(map() == GetHeap()->constant_pool_array_map()); 2310 ASSERT(map() == GetHeap()->constant_pool_array_map());
2283 ASSERT(index >= this->first_int32_index() && index < length()); 2311 ASSERT(index >= this->first_int32_index() && index < length());
2284 WRITE_INT32_FIELD(this, OffsetOfElementAt(index), value); 2312 WRITE_INT32_FIELD(this, OffsetOfElementAt(index), value);
2285 } 2313 }
2286 2314
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after
3834 return SeqTwoByteString::SizeFor( 3862 return SeqTwoByteString::SizeFor(
3835 reinterpret_cast<SeqTwoByteString*>(this)->length()); 3863 reinterpret_cast<SeqTwoByteString*>(this)->length());
3836 } 3864 }
3837 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { 3865 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) {
3838 return FixedDoubleArray::SizeFor( 3866 return FixedDoubleArray::SizeFor(
3839 reinterpret_cast<FixedDoubleArray*>(this)->length()); 3867 reinterpret_cast<FixedDoubleArray*>(this)->length());
3840 } 3868 }
3841 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { 3869 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) {
3842 return ConstantPoolArray::SizeFor( 3870 return ConstantPoolArray::SizeFor(
3843 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int64_entries(), 3871 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int64_entries(),
3844 reinterpret_cast<ConstantPoolArray*>(this)->count_of_ptr_entries(), 3872 reinterpret_cast<ConstantPoolArray*>(this)->count_of_code_ptr_entries(),
3873 reinterpret_cast<ConstantPoolArray*>(this)->count_of_heap_ptr_entries(),
3845 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int32_entries()); 3874 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int32_entries());
3846 } 3875 }
3847 if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && 3876 if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE &&
3848 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) { 3877 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) {
3849 return reinterpret_cast<FixedTypedArrayBase*>(this)->size(); 3878 return reinterpret_cast<FixedTypedArrayBase*>(this)->size();
3850 } 3879 }
3851 ASSERT(instance_type == CODE_TYPE); 3880 ASSERT(instance_type == CODE_TYPE);
3852 return reinterpret_cast<Code*>(this)->CodeSize(); 3881 return reinterpret_cast<Code*>(this)->CodeSize();
3853 } 3882 }
3854 3883
(...skipping 2893 matching lines...) Expand 10 before | Expand all | Expand 10 after
6748 #undef READ_UINT32_FIELD 6777 #undef READ_UINT32_FIELD
6749 #undef WRITE_UINT32_FIELD 6778 #undef WRITE_UINT32_FIELD
6750 #undef READ_SHORT_FIELD 6779 #undef READ_SHORT_FIELD
6751 #undef WRITE_SHORT_FIELD 6780 #undef WRITE_SHORT_FIELD
6752 #undef READ_BYTE_FIELD 6781 #undef READ_BYTE_FIELD
6753 #undef WRITE_BYTE_FIELD 6782 #undef WRITE_BYTE_FIELD
6754 6783
6755 } } // namespace v8::internal 6784 } } // namespace v8::internal
6756 6785
6757 #endif // V8_OBJECTS_INL_H_ 6786 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698