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

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

Issue 22601003: Out-of-line constant pool on Arm: Stage 2 - Introduce ConstantPoolArray object. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 7 years, 2 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 #define BOOL_ACCESSORS(holder, field, name, offset) \ 126 #define BOOL_ACCESSORS(holder, field, name, offset) \
127 bool holder::name() { \ 127 bool holder::name() { \
128 return BooleanBit::get(field(), offset); \ 128 return BooleanBit::get(field(), offset); \
129 } \ 129 } \
130 void holder::set_##name(bool value) { \ 130 void holder::set_##name(bool value) { \
131 set_##field(BooleanBit::set(field(), offset, value)); \ 131 set_##field(BooleanBit::set(field(), offset, value)); \
132 } 132 }
133 133
134 134
135 bool Object::IsFixedArrayBase() { 135 bool Object::IsFixedArrayBase() {
136 return IsFixedArray() || IsFixedDoubleArray(); 136 return IsFixedArray() || IsFixedDoubleArray() || IsConstantPoolArray();
137 } 137 }
138 138
139 139
140 // External objects are not extensible, so the map check is enough. 140 // External objects are not extensible, so the map check is enough.
141 bool Object::IsExternal() { 141 bool Object::IsExternal() {
142 return Object::IsHeapObject() && 142 return Object::IsHeapObject() &&
143 HeapObject::cast(this)->map() == 143 HeapObject::cast(this)->map() ==
144 HeapObject::cast(this)->GetHeap()->external_map(); 144 HeapObject::cast(this)->GetHeap()->external_map();
145 } 145 }
146 146
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 564
565 TYPE_CHECKER(JSFunctionProxy, JS_FUNCTION_PROXY_TYPE) 565 TYPE_CHECKER(JSFunctionProxy, JS_FUNCTION_PROXY_TYPE)
566 TYPE_CHECKER(JSSet, JS_SET_TYPE) 566 TYPE_CHECKER(JSSet, JS_SET_TYPE)
567 TYPE_CHECKER(JSMap, JS_MAP_TYPE) 567 TYPE_CHECKER(JSMap, JS_MAP_TYPE)
568 TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE) 568 TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE)
569 TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE) 569 TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE)
570 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE) 570 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE)
571 TYPE_CHECKER(Map, MAP_TYPE) 571 TYPE_CHECKER(Map, MAP_TYPE)
572 TYPE_CHECKER(FixedArray, FIXED_ARRAY_TYPE) 572 TYPE_CHECKER(FixedArray, FIXED_ARRAY_TYPE)
573 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE) 573 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE)
574 TYPE_CHECKER(ConstantPoolArray, CONSTANT_POOL_ARRAY_TYPE)
574 575
575 576
576 bool Object::IsJSWeakCollection() { 577 bool Object::IsJSWeakCollection() {
577 return IsJSWeakMap() || IsJSWeakSet(); 578 return IsJSWeakMap() || IsJSWeakSet();
578 } 579 }
579 580
580 581
581 bool Object::IsDescriptorArray() { 582 bool Object::IsDescriptorArray() {
582 return IsFixedArray(); 583 return IsFixedArray();
583 } 584 }
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 1021
1021 #define WRITE_INTPTR_FIELD(p, offset, value) \ 1022 #define WRITE_INTPTR_FIELD(p, offset, value) \
1022 (*reinterpret_cast<intptr_t*>(FIELD_ADDR(p, offset)) = value) 1023 (*reinterpret_cast<intptr_t*>(FIELD_ADDR(p, offset)) = value)
1023 1024
1024 #define READ_UINT32_FIELD(p, offset) \ 1025 #define READ_UINT32_FIELD(p, offset) \
1025 (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset))) 1026 (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)))
1026 1027
1027 #define WRITE_UINT32_FIELD(p, offset, value) \ 1028 #define WRITE_UINT32_FIELD(p, offset, value) \
1028 (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)) = value) 1029 (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)) = value)
1029 1030
1031 #define READ_INT32_FIELD(p, offset) \
1032 (*reinterpret_cast<int32_t*>(FIELD_ADDR(p, offset)))
1033
1034 #define WRITE_INT32_FIELD(p, offset, value) \
1035 (*reinterpret_cast<int32_t*>(FIELD_ADDR(p, offset)) = value)
1036
1030 #define READ_INT64_FIELD(p, offset) \ 1037 #define READ_INT64_FIELD(p, offset) \
1031 (*reinterpret_cast<int64_t*>(FIELD_ADDR(p, offset))) 1038 (*reinterpret_cast<int64_t*>(FIELD_ADDR(p, offset)))
1032 1039
1033 #define WRITE_INT64_FIELD(p, offset, value) \ 1040 #define WRITE_INT64_FIELD(p, offset, value) \
1034 (*reinterpret_cast<int64_t*>(FIELD_ADDR(p, offset)) = value) 1041 (*reinterpret_cast<int64_t*>(FIELD_ADDR(p, offset)) = value)
1035 1042
1036 #define READ_SHORT_FIELD(p, offset) \ 1043 #define READ_SHORT_FIELD(p, offset) \
1037 (*reinterpret_cast<uint16_t*>(FIELD_ADDR(p, offset))) 1044 (*reinterpret_cast<uint16_t*>(FIELD_ADDR(p, offset)))
1038 1045
1039 #define WRITE_SHORT_FIELD(p, offset, value) \ 1046 #define WRITE_SHORT_FIELD(p, offset, value) \
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1880 IsTrue() || 1887 IsTrue() ||
1881 IsFalse() || 1888 IsFalse() ||
1882 IsNull())) { 1889 IsNull())) {
1883 FATAL("API call returned invalid object"); 1890 FATAL("API call returned invalid object");
1884 } 1891 }
1885 #endif // ENABLE_EXTRA_CHECKS 1892 #endif // ENABLE_EXTRA_CHECKS
1886 } 1893 }
1887 1894
1888 1895
1889 FixedArrayBase* FixedArrayBase::cast(Object* object) { 1896 FixedArrayBase* FixedArrayBase::cast(Object* object) {
1890 ASSERT(object->IsFixedArray() || object->IsFixedDoubleArray()); 1897 ASSERT(object->IsFixedArray() || object->IsFixedDoubleArray() ||
1898 object->IsConstantPoolArray());
1891 return reinterpret_cast<FixedArrayBase*>(object); 1899 return reinterpret_cast<FixedArrayBase*>(object);
1892 } 1900 }
1893 1901
1894 1902
1895 Object* FixedArray::get(int index) { 1903 Object* FixedArray::get(int index) {
1896 ASSERT(index >= 0 && index < this->length()); 1904 ASSERT(index >= 0 && index < this->length());
1897 return READ_FIELD(this, kHeaderSize + index * kPointerSize); 1905 return READ_FIELD(this, kHeaderSize + index * kPointerSize);
1898 } 1906 }
1899 1907
1900 1908
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); 1987 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double());
1980 } 1988 }
1981 1989
1982 1990
1983 bool FixedDoubleArray::is_the_hole(int index) { 1991 bool FixedDoubleArray::is_the_hole(int index) {
1984 int offset = kHeaderSize + index * kDoubleSize; 1992 int offset = kHeaderSize + index * kDoubleSize;
1985 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset)); 1993 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset));
1986 } 1994 }
1987 1995
1988 1996
1997 SMI_ACCESSORS(ConstantPoolArray, first_ptr_index, kFirstPointerIndexOffset)
1998 SMI_ACCESSORS(ConstantPoolArray, first_int32_index, kFirstInt32IndexOffset)
1999
2000
2001 int ConstantPoolArray::first_int64_index() {
2002 return 0;
2003 }
2004
2005
2006 int ConstantPoolArray::count_of_int64_entries() {
2007 return first_ptr_index();
2008 }
2009
2010
2011 int ConstantPoolArray::count_of_ptr_entries() {
2012 return first_int32_index() - first_ptr_index();
2013 }
2014
2015
2016 int ConstantPoolArray::count_of_int32_entries() {
2017 return length() - first_int32_index();
2018 }
2019
2020
2021 void ConstantPoolArray::SetEntryCounts(int number_of_int64_entries,
2022 int number_of_ptr_entries,
2023 int number_of_int32_entries) {
2024 set_first_ptr_index(number_of_int64_entries);
2025 set_first_int32_index(number_of_int64_entries + number_of_ptr_entries);
2026 set_length(number_of_int64_entries + number_of_ptr_entries +
2027 number_of_int32_entries);
2028 }
2029
2030
2031 int64_t ConstantPoolArray::get_int64_entry(int index) {
2032 ASSERT(map() == GetHeap()->constant_pool_array_map());
2033 ASSERT(index >= 0 && index < first_ptr_index());
2034 return READ_INT64_FIELD(this, OffsetOfElementAt(index));
2035 }
2036
2037 double ConstantPoolArray::get_int64_entry_as_double(int index) {
2038 STATIC_ASSERT(kDoubleSize == kInt64Size);
2039 ASSERT(map() == GetHeap()->constant_pool_array_map());
2040 ASSERT(index >= 0 && index < first_ptr_index());
2041 return READ_DOUBLE_FIELD(this, OffsetOfElementAt(index));
2042 }
2043
2044
2045 Object* ConstantPoolArray::get_ptr_entry(int index) {
2046 ASSERT(map() == GetHeap()->constant_pool_array_map());
2047 ASSERT(index >= first_ptr_index() && index < first_int32_index());
2048 return READ_FIELD(this, OffsetOfElementAt(index));
2049 }
2050
2051
2052 int32_t ConstantPoolArray::get_int32_entry(int index) {
2053 ASSERT(map() == GetHeap()->constant_pool_array_map());
2054 ASSERT(index >= first_int32_index() && index < length());
2055 return READ_INT32_FIELD(this, OffsetOfElementAt(index));
2056 }
2057
2058
2059 void ConstantPoolArray::set(int index, Object* value) {
2060 ASSERT(map() == GetHeap()->constant_pool_array_map());
2061 ASSERT(index >= first_ptr_index() && index < first_int32_index());
2062 WRITE_FIELD(this, OffsetOfElementAt(index), value);
2063 WRITE_BARRIER(GetHeap(), this, OffsetOfElementAt(index), value);
2064 }
2065
2066
2067 void ConstantPoolArray::set(int index, int64_t value) {
2068 ASSERT(map() == GetHeap()->constant_pool_array_map());
2069 ASSERT(index >= first_int64_index() && index < first_ptr_index());
2070 WRITE_INT64_FIELD(this, OffsetOfElementAt(index), value);
2071 }
2072
2073
2074 void ConstantPoolArray::set(int index, double value) {
2075 STATIC_ASSERT(kDoubleSize == kInt64Size);
2076 ASSERT(map() == GetHeap()->constant_pool_array_map());
2077 ASSERT(index >= first_int64_index() && index < first_ptr_index());
2078 WRITE_DOUBLE_FIELD(this, OffsetOfElementAt(index), value);
2079 }
2080
2081
2082 void ConstantPoolArray::set(int index, int32_t value) {
2083 ASSERT(map() == GetHeap()->constant_pool_array_map());
2084 ASSERT(index >= this->first_int32_index() && index < length());
2085 WRITE_INT32_FIELD(this, OffsetOfElementAt(index), value);
2086 }
2087
2088
1989 WriteBarrierMode HeapObject::GetWriteBarrierMode( 2089 WriteBarrierMode HeapObject::GetWriteBarrierMode(
1990 const DisallowHeapAllocation& promise) { 2090 const DisallowHeapAllocation& promise) {
1991 Heap* heap = GetHeap(); 2091 Heap* heap = GetHeap();
1992 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; 2092 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER;
1993 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; 2093 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER;
1994 return UPDATE_WRITE_BARRIER; 2094 return UPDATE_WRITE_BARRIER;
1995 } 2095 }
1996 2096
1997 2097
1998 void FixedArray::set(int index, 2098 void FixedArray::set(int index,
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
2471 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); 2571 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask));
2472 } 2572 }
2473 2573
2474 2574
2475 // ------------------------------------ 2575 // ------------------------------------
2476 // Cast operations 2576 // Cast operations
2477 2577
2478 2578
2479 CAST_ACCESSOR(FixedArray) 2579 CAST_ACCESSOR(FixedArray)
2480 CAST_ACCESSOR(FixedDoubleArray) 2580 CAST_ACCESSOR(FixedDoubleArray)
2581 CAST_ACCESSOR(ConstantPoolArray)
2481 CAST_ACCESSOR(DescriptorArray) 2582 CAST_ACCESSOR(DescriptorArray)
2482 CAST_ACCESSOR(DeoptimizationInputData) 2583 CAST_ACCESSOR(DeoptimizationInputData)
2483 CAST_ACCESSOR(DeoptimizationOutputData) 2584 CAST_ACCESSOR(DeoptimizationOutputData)
2484 CAST_ACCESSOR(DependentCode) 2585 CAST_ACCESSOR(DependentCode)
2485 CAST_ACCESSOR(TypeFeedbackCells) 2586 CAST_ACCESSOR(TypeFeedbackCells)
2486 CAST_ACCESSOR(StringTable) 2587 CAST_ACCESSOR(StringTable)
2487 CAST_ACCESSOR(JSFunctionResultCache) 2588 CAST_ACCESSOR(JSFunctionResultCache)
2488 CAST_ACCESSOR(NormalizedMapCache) 2589 CAST_ACCESSOR(NormalizedMapCache)
2489 CAST_ACCESSOR(ScopeInfo) 2590 CAST_ACCESSOR(ScopeInfo)
2490 CAST_ACCESSOR(CompilationCacheTable) 2591 CAST_ACCESSOR(CompilationCacheTable)
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
3366 } 3467 }
3367 if (instance_type == STRING_TYPE || 3468 if (instance_type == STRING_TYPE ||
3368 instance_type == INTERNALIZED_STRING_TYPE) { 3469 instance_type == INTERNALIZED_STRING_TYPE) {
3369 return SeqTwoByteString::SizeFor( 3470 return SeqTwoByteString::SizeFor(
3370 reinterpret_cast<SeqTwoByteString*>(this)->length()); 3471 reinterpret_cast<SeqTwoByteString*>(this)->length());
3371 } 3472 }
3372 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { 3473 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) {
3373 return FixedDoubleArray::SizeFor( 3474 return FixedDoubleArray::SizeFor(
3374 reinterpret_cast<FixedDoubleArray*>(this)->length()); 3475 reinterpret_cast<FixedDoubleArray*>(this)->length());
3375 } 3476 }
3477 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) {
3478 return ConstantPoolArray::SizeFor(
3479 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int64_entries(),
3480 reinterpret_cast<ConstantPoolArray*>(this)->count_of_ptr_entries(),
3481 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int32_entries());
3482 }
3376 ASSERT(instance_type == CODE_TYPE); 3483 ASSERT(instance_type == CODE_TYPE);
3377 return reinterpret_cast<Code*>(this)->CodeSize(); 3484 return reinterpret_cast<Code*>(this)->CodeSize();
3378 } 3485 }
3379 3486
3380 3487
3381 void Map::set_instance_size(int value) { 3488 void Map::set_instance_size(int value) {
3382 ASSERT_EQ(0, value & (kPointerSize - 1)); 3489 ASSERT_EQ(0, value & (kPointerSize - 1));
3383 value >>= kPointerSizeLog2; 3490 value >>= kPointerSizeLog2;
3384 ASSERT(0 <= value && value < 256); 3491 ASSERT(0 <= value && value < 256);
3385 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value)); 3492 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value));
(...skipping 2659 matching lines...) Expand 10 before | Expand all | Expand 10 after
6045 return GetHeap()->CopyFixedArray(this); 6152 return GetHeap()->CopyFixedArray(this);
6046 } 6153 }
6047 6154
6048 6155
6049 MaybeObject* FixedDoubleArray::Copy() { 6156 MaybeObject* FixedDoubleArray::Copy() {
6050 if (length() == 0) return this; 6157 if (length() == 0) return this;
6051 return GetHeap()->CopyFixedDoubleArray(this); 6158 return GetHeap()->CopyFixedDoubleArray(this);
6052 } 6159 }
6053 6160
6054 6161
6162 MaybeObject* ConstantPoolArray::Copy() {
6163 if (length() == 0) return this;
6164 return GetHeap()->CopyConstantPoolArray(this);
6165 }
6166
6167
6055 void TypeFeedbackCells::SetAstId(int index, TypeFeedbackId id) { 6168 void TypeFeedbackCells::SetAstId(int index, TypeFeedbackId id) {
6056 set(1 + index * 2, Smi::FromInt(id.ToInt())); 6169 set(1 + index * 2, Smi::FromInt(id.ToInt()));
6057 } 6170 }
6058 6171
6059 6172
6060 TypeFeedbackId TypeFeedbackCells::AstId(int index) { 6173 TypeFeedbackId TypeFeedbackCells::AstId(int index) {
6061 return TypeFeedbackId(Smi::cast(get(1 + index * 2))->value()); 6174 return TypeFeedbackId(Smi::cast(get(1 + index * 2))->value());
6062 } 6175 }
6063 6176
6064 6177
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
6280 #undef WRITE_UINT32_FIELD 6393 #undef WRITE_UINT32_FIELD
6281 #undef READ_SHORT_FIELD 6394 #undef READ_SHORT_FIELD
6282 #undef WRITE_SHORT_FIELD 6395 #undef WRITE_SHORT_FIELD
6283 #undef READ_BYTE_FIELD 6396 #undef READ_BYTE_FIELD
6284 #undef WRITE_BYTE_FIELD 6397 #undef WRITE_BYTE_FIELD
6285 6398
6286 6399
6287 } } // namespace v8::internal 6400 } } // namespace v8::internal
6288 6401
6289 #endif // V8_OBJECTS_INL_H_ 6402 #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