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

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: Enable pointers to be stored in ConstantPoolArray and add tests 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
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 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 IsTrue() || 1894 IsTrue() ||
1888 IsFalse() || 1895 IsFalse() ||
1889 IsNull())) { 1896 IsNull())) {
1890 FATAL("API call returned invalid object"); 1897 FATAL("API call returned invalid object");
1891 } 1898 }
1892 #endif // ENABLE_EXTRA_CHECKS 1899 #endif // ENABLE_EXTRA_CHECKS
1893 } 1900 }
1894 1901
1895 1902
1896 FixedArrayBase* FixedArrayBase::cast(Object* object) { 1903 FixedArrayBase* FixedArrayBase::cast(Object* object) {
1897 ASSERT(object->IsFixedArray() || object->IsFixedDoubleArray()); 1904 ASSERT(object->IsFixedArray() || object->IsFixedDoubleArray() ||
1905 object->IsConstantPoolArray());
1898 return reinterpret_cast<FixedArrayBase*>(object); 1906 return reinterpret_cast<FixedArrayBase*>(object);
1899 } 1907 }
1900 1908
1901 1909
1902 Object* FixedArray::get(int index) { 1910 Object* FixedArray::get(int index) {
1903 ASSERT(index >= 0 && index < this->length()); 1911 ASSERT(index >= 0 && index < this->length());
1904 return READ_FIELD(this, kHeaderSize + index * kPointerSize); 1912 return READ_FIELD(this, kHeaderSize + index * kPointerSize);
1905 } 1913 }
1906 1914
1907 1915
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); 1994 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double());
1987 } 1995 }
1988 1996
1989 1997
1990 bool FixedDoubleArray::is_the_hole(int index) { 1998 bool FixedDoubleArray::is_the_hole(int index) {
1991 int offset = kHeaderSize + index * kDoubleSize; 1999 int offset = kHeaderSize + index * kDoubleSize;
1992 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset)); 2000 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset));
1993 } 2001 }
1994 2002
1995 2003
2004 SMI_ACCESSORS(ConstantPoolArray, first_ptr_index, kFirstPointerIndexOffset)
2005 SMI_ACCESSORS(ConstantPoolArray, first_int32_index, kFirstInt32IndexOffset)
2006
2007
2008 int ConstantPoolArray::first_int64_index() {
2009 return 0;
2010 }
2011
2012
2013 int ConstantPoolArray::count_of_int64_entries() {
2014 return first_ptr_index();
2015 }
2016
2017
2018 int ConstantPoolArray::count_of_ptr_entries() {
2019 return first_int32_index() - first_ptr_index();
2020 }
2021
2022
2023 int ConstantPoolArray::count_of_int32_entries() {
2024 return length() - first_int32_index();
2025 }
2026
2027
2028 void ConstantPoolArray::SetEntryCounts(int number_of_int64_entries,
2029 int number_of_ptr_entries,
2030 int number_of_int32_entries) {
2031 set_first_ptr_index(number_of_int64_entries);
2032 set_first_int32_index(number_of_int64_entries + number_of_ptr_entries);
2033 set_length(number_of_int64_entries + number_of_ptr_entries +
2034 number_of_int32_entries);
2035 }
2036
2037
2038 int64_t ConstantPoolArray::get_int64_entry(int index) {
2039 ASSERT(map() == GetHeap()->constant_pool_array_map());
2040 ASSERT(index >= 0 && index < first_ptr_index());
2041 return READ_INT64_FIELD(this, OffsetOfElementAt(index));
2042 }
2043
2044 double ConstantPoolArray::get_int64_entry_as_double(int index) {
2045 STATIC_ASSERT(kDoubleSize == kInt64Size);
2046 ASSERT(map() == GetHeap()->constant_pool_array_map());
2047 ASSERT(index >= 0 && index < first_ptr_index());
2048 return READ_DOUBLE_FIELD(this, OffsetOfElementAt(index));
2049 }
2050
2051
2052 Object* ConstantPoolArray::get_ptr_entry(int index) {
2053 ASSERT(map() == GetHeap()->constant_pool_array_map());
2054 ASSERT(index >= first_ptr_index() && index < first_int32_index());
2055 return READ_FIELD(this, OffsetOfElementAt(index));
2056 }
2057
2058
2059 int32_t ConstantPoolArray::get_int32_entry(int index) {
2060 ASSERT(map() == GetHeap()->constant_pool_array_map());
2061 ASSERT(index >= first_int32_index() && index < length());
2062 return READ_INT32_FIELD(this, OffsetOfElementAt(index));
2063 }
2064
2065
2066 MaybeObject* ConstantPoolArray::get(int index) {
ulan 2013/09/27 12:39:10 Let's either call this function Get to indicate th
rmcilroy 2013/10/01 11:21:52 Removed the function instead.
2067 if (index < first_ptr_index()) {
2068 return GetHeap()->NumberFromDouble(get_int64_entry_as_double(index));
2069 } else if (index < first_int32_index()) {
2070 return get_ptr_entry(index);
2071 } else {
2072 return GetHeap()->NumberFromInt32(get_int32_entry(index));
2073 }
2074 }
2075
2076
2077 void ConstantPoolArray::set(int index, Object* value) {
2078 ASSERT(map() == GetHeap()->constant_pool_array_map());
2079 ASSERT(index >= first_ptr_index() && index < first_int32_index());
2080 WRITE_FIELD(this, OffsetOfElementAt(index), value);
2081 WRITE_BARRIER(GetHeap(), this, OffsetOfElementAt(index), value);
2082 }
2083
2084
2085 void ConstantPoolArray::set(int index, int64_t value) {
2086 ASSERT(map() == GetHeap()->constant_pool_array_map());
2087 ASSERT(index >= first_int64_index() && index < first_ptr_index());
2088 WRITE_INT64_FIELD(this, OffsetOfElementAt(index), value);
2089 }
2090
2091
2092 void ConstantPoolArray::set(int index, double value) {
2093 STATIC_ASSERT(kDoubleSize == kInt64Size);
2094 ASSERT(map() == GetHeap()->constant_pool_array_map());
2095 ASSERT(index >= first_int64_index() && index < first_ptr_index());
2096 WRITE_DOUBLE_FIELD(this, OffsetOfElementAt(index), value);
2097 }
2098
2099
2100 void ConstantPoolArray::set(int index, int32_t value) {
2101 ASSERT(map() == GetHeap()->constant_pool_array_map());
2102 ASSERT(index >= this->first_int32_index() && index < length());
2103 WRITE_INT32_FIELD(this, OffsetOfElementAt(index), value);
2104 }
2105
2106
1996 WriteBarrierMode HeapObject::GetWriteBarrierMode( 2107 WriteBarrierMode HeapObject::GetWriteBarrierMode(
1997 const DisallowHeapAllocation& promise) { 2108 const DisallowHeapAllocation& promise) {
1998 Heap* heap = GetHeap(); 2109 Heap* heap = GetHeap();
1999 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; 2110 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER;
2000 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; 2111 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER;
2001 return UPDATE_WRITE_BARRIER; 2112 return UPDATE_WRITE_BARRIER;
2002 } 2113 }
2003 2114
2004 2115
2005 void FixedArray::set(int index, 2116 void FixedArray::set(int index,
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
2478 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); 2589 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask));
2479 } 2590 }
2480 2591
2481 2592
2482 // ------------------------------------ 2593 // ------------------------------------
2483 // Cast operations 2594 // Cast operations
2484 2595
2485 2596
2486 CAST_ACCESSOR(FixedArray) 2597 CAST_ACCESSOR(FixedArray)
2487 CAST_ACCESSOR(FixedDoubleArray) 2598 CAST_ACCESSOR(FixedDoubleArray)
2599 CAST_ACCESSOR(ConstantPoolArray)
2488 CAST_ACCESSOR(DescriptorArray) 2600 CAST_ACCESSOR(DescriptorArray)
2489 CAST_ACCESSOR(DeoptimizationInputData) 2601 CAST_ACCESSOR(DeoptimizationInputData)
2490 CAST_ACCESSOR(DeoptimizationOutputData) 2602 CAST_ACCESSOR(DeoptimizationOutputData)
2491 CAST_ACCESSOR(DependentCode) 2603 CAST_ACCESSOR(DependentCode)
2492 CAST_ACCESSOR(TypeFeedbackCells) 2604 CAST_ACCESSOR(TypeFeedbackCells)
2493 CAST_ACCESSOR(StringTable) 2605 CAST_ACCESSOR(StringTable)
2494 CAST_ACCESSOR(JSFunctionResultCache) 2606 CAST_ACCESSOR(JSFunctionResultCache)
2495 CAST_ACCESSOR(NormalizedMapCache) 2607 CAST_ACCESSOR(NormalizedMapCache)
2496 CAST_ACCESSOR(ScopeInfo) 2608 CAST_ACCESSOR(ScopeInfo)
2497 CAST_ACCESSOR(CompilationCacheTable) 2609 CAST_ACCESSOR(CompilationCacheTable)
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
3373 } 3485 }
3374 if (instance_type == STRING_TYPE || 3486 if (instance_type == STRING_TYPE ||
3375 instance_type == INTERNALIZED_STRING_TYPE) { 3487 instance_type == INTERNALIZED_STRING_TYPE) {
3376 return SeqTwoByteString::SizeFor( 3488 return SeqTwoByteString::SizeFor(
3377 reinterpret_cast<SeqTwoByteString*>(this)->length()); 3489 reinterpret_cast<SeqTwoByteString*>(this)->length());
3378 } 3490 }
3379 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { 3491 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) {
3380 return FixedDoubleArray::SizeFor( 3492 return FixedDoubleArray::SizeFor(
3381 reinterpret_cast<FixedDoubleArray*>(this)->length()); 3493 reinterpret_cast<FixedDoubleArray*>(this)->length());
3382 } 3494 }
3495 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) {
3496 return ConstantPoolArray::SizeFor(
3497 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int64_entries(),
3498 reinterpret_cast<ConstantPoolArray*>(this)->count_of_ptr_entries(),
3499 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int32_entries());
3500 }
3383 ASSERT(instance_type == CODE_TYPE); 3501 ASSERT(instance_type == CODE_TYPE);
3384 return reinterpret_cast<Code*>(this)->CodeSize(); 3502 return reinterpret_cast<Code*>(this)->CodeSize();
3385 } 3503 }
3386 3504
3387 3505
3388 void Map::set_instance_size(int value) { 3506 void Map::set_instance_size(int value) {
3389 ASSERT_EQ(0, value & (kPointerSize - 1)); 3507 ASSERT_EQ(0, value & (kPointerSize - 1));
3390 value >>= kPointerSizeLog2; 3508 value >>= kPointerSizeLog2;
3391 ASSERT(0 <= value && value < 256); 3509 ASSERT(0 <= value && value < 256);
3392 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value)); 3510 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value));
(...skipping 2622 matching lines...) Expand 10 before | Expand all | Expand 10 after
6015 return GetHeap()->CopyFixedArray(this); 6133 return GetHeap()->CopyFixedArray(this);
6016 } 6134 }
6017 6135
6018 6136
6019 MaybeObject* FixedDoubleArray::Copy() { 6137 MaybeObject* FixedDoubleArray::Copy() {
6020 if (length() == 0) return this; 6138 if (length() == 0) return this;
6021 return GetHeap()->CopyFixedDoubleArray(this); 6139 return GetHeap()->CopyFixedDoubleArray(this);
6022 } 6140 }
6023 6141
6024 6142
6143 MaybeObject* ConstantPoolArray::Copy() {
6144 if (length() == 0) return this;
6145 return GetHeap()->CopyConstantPoolArray(this);
6146 }
6147
6148
6025 void TypeFeedbackCells::SetAstId(int index, TypeFeedbackId id) { 6149 void TypeFeedbackCells::SetAstId(int index, TypeFeedbackId id) {
6026 set(1 + index * 2, Smi::FromInt(id.ToInt())); 6150 set(1 + index * 2, Smi::FromInt(id.ToInt()));
6027 } 6151 }
6028 6152
6029 6153
6030 TypeFeedbackId TypeFeedbackCells::AstId(int index) { 6154 TypeFeedbackId TypeFeedbackCells::AstId(int index) {
6031 return TypeFeedbackId(Smi::cast(get(1 + index * 2))->value()); 6155 return TypeFeedbackId(Smi::cast(get(1 + index * 2))->value());
6032 } 6156 }
6033 6157
6034 6158
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
6250 #undef WRITE_UINT32_FIELD 6374 #undef WRITE_UINT32_FIELD
6251 #undef READ_SHORT_FIELD 6375 #undef READ_SHORT_FIELD
6252 #undef WRITE_SHORT_FIELD 6376 #undef WRITE_SHORT_FIELD
6253 #undef READ_BYTE_FIELD 6377 #undef READ_BYTE_FIELD
6254 #undef WRITE_BYTE_FIELD 6378 #undef WRITE_BYTE_FIELD
6255 6379
6256 6380
6257 } } // namespace v8::internal 6381 } } // namespace v8::internal
6258 6382
6259 #endif // V8_OBJECTS_INL_H_ 6383 #endif // V8_OBJECTS_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698