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

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: Created 7 years, 4 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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 565
566 TYPE_CHECKER(JSFunctionProxy, JS_FUNCTION_PROXY_TYPE) 566 TYPE_CHECKER(JSFunctionProxy, JS_FUNCTION_PROXY_TYPE)
567 TYPE_CHECKER(JSSet, JS_SET_TYPE) 567 TYPE_CHECKER(JSSet, JS_SET_TYPE)
568 TYPE_CHECKER(JSMap, JS_MAP_TYPE) 568 TYPE_CHECKER(JSMap, JS_MAP_TYPE)
569 TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE) 569 TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE)
570 TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE) 570 TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE)
571 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE) 571 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE)
572 TYPE_CHECKER(Map, MAP_TYPE) 572 TYPE_CHECKER(Map, MAP_TYPE)
573 TYPE_CHECKER(FixedArray, FIXED_ARRAY_TYPE) 573 TYPE_CHECKER(FixedArray, FIXED_ARRAY_TYPE)
574 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE) 574 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE)
575 TYPE_CHECKER(ConstantPoolArray, CONSTANT_POOL_ARRAY_TYPE)
575 576
576 577
577 bool Object::IsJSWeakCollection() { 578 bool Object::IsJSWeakCollection() {
578 return IsJSWeakMap() || IsJSWeakSet(); 579 return IsJSWeakMap() || IsJSWeakSet();
579 } 580 }
580 581
581 582
582 bool Object::IsDescriptorArray() { 583 bool Object::IsDescriptorArray() {
583 return IsFixedArray(); 584 return IsFixedArray();
584 } 585 }
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 1022
1022 #define WRITE_INTPTR_FIELD(p, offset, value) \ 1023 #define WRITE_INTPTR_FIELD(p, offset, value) \
1023 (*reinterpret_cast<intptr_t*>(FIELD_ADDR(p, offset)) = value) 1024 (*reinterpret_cast<intptr_t*>(FIELD_ADDR(p, offset)) = value)
1024 1025
1025 #define READ_UINT32_FIELD(p, offset) \ 1026 #define READ_UINT32_FIELD(p, offset) \
1026 (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset))) 1027 (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)))
1027 1028
1028 #define WRITE_UINT32_FIELD(p, offset, value) \ 1029 #define WRITE_UINT32_FIELD(p, offset, value) \
1029 (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)) = value) 1030 (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)) = value)
1030 1031
1032 #define READ_INT32_FIELD(p, offset) \
1033 (*reinterpret_cast<int32_t*>(FIELD_ADDR(p, offset)))
1034
1035 #define WRITE_INT32_FIELD(p, offset, value) \
1036 (*reinterpret_cast<int32_t*>(FIELD_ADDR(p, offset)) = value)
1037
1031 #define READ_INT64_FIELD(p, offset) \ 1038 #define READ_INT64_FIELD(p, offset) \
1032 (*reinterpret_cast<int64_t*>(FIELD_ADDR(p, offset))) 1039 (*reinterpret_cast<int64_t*>(FIELD_ADDR(p, offset)))
1033 1040
1034 #define WRITE_INT64_FIELD(p, offset, value) \ 1041 #define WRITE_INT64_FIELD(p, offset, value) \
1035 (*reinterpret_cast<int64_t*>(FIELD_ADDR(p, offset)) = value) 1042 (*reinterpret_cast<int64_t*>(FIELD_ADDR(p, offset)) = value)
1036 1043
1037 #define READ_SHORT_FIELD(p, offset) \ 1044 #define READ_SHORT_FIELD(p, offset) \
1038 (*reinterpret_cast<uint16_t*>(FIELD_ADDR(p, offset))) 1045 (*reinterpret_cast<uint16_t*>(FIELD_ADDR(p, offset)))
1039 1046
1040 #define WRITE_SHORT_FIELD(p, offset, value) \ 1047 #define WRITE_SHORT_FIELD(p, offset, value) \
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 IsTrue() || 1929 IsTrue() ||
1923 IsFalse() || 1930 IsFalse() ||
1924 IsNull())) { 1931 IsNull())) {
1925 FATAL("API call returned invalid object"); 1932 FATAL("API call returned invalid object");
1926 } 1933 }
1927 #endif // ENABLE_EXTRA_CHECKS 1934 #endif // ENABLE_EXTRA_CHECKS
1928 } 1935 }
1929 1936
1930 1937
1931 FixedArrayBase* FixedArrayBase::cast(Object* object) { 1938 FixedArrayBase* FixedArrayBase::cast(Object* object) {
1932 ASSERT(object->IsFixedArray() || object->IsFixedDoubleArray()); 1939 ASSERT(object->IsFixedArray() || object->IsFixedDoubleArray() ||
1940 object->IsConstantPoolArray());
1933 return reinterpret_cast<FixedArrayBase*>(object); 1941 return reinterpret_cast<FixedArrayBase*>(object);
1934 } 1942 }
1935 1943
1936 1944
1937 Object* FixedArray::get(int index) { 1945 Object* FixedArray::get(int index) {
1938 ASSERT(index >= 0 && index < this->length()); 1946 ASSERT(index >= 0 && index < this->length());
1939 return READ_FIELD(this, kHeaderSize + index * kPointerSize); 1947 return READ_FIELD(this, kHeaderSize + index * kPointerSize);
1940 } 1948 }
1941 1949
1942 1950
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2021 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); 2029 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double());
2022 } 2030 }
2023 2031
2024 2032
2025 bool FixedDoubleArray::is_the_hole(int index) { 2033 bool FixedDoubleArray::is_the_hole(int index) {
2026 int offset = kHeaderSize + index * kDoubleSize; 2034 int offset = kHeaderSize + index * kDoubleSize;
2027 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset)); 2035 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset));
2028 } 2036 }
2029 2037
2030 2038
2039 SMI_ACCESSORS(ConstantPoolArray, first_int32_index, kFirstInt32IndexOffset)
2040
2041
2042 int64_t ConstantPoolArray::get_int64_entry(int index) {
2043 ASSERT(map() != HEAP->fixed_cow_array_map() &&
ulan 2013/08/09 08:52:54 Why not use map() == HEAP->constant_pool_array_map
rmcilroy 2013/08/16 10:27:37 Done.
2044 map() != HEAP->fixed_array_map());
2045 ASSERT(index >= 0 && index < this->first_int32_index());
2046 return READ_INT64_FIELD(this, kFirstOffset + index * kInt64Size);
2047 }
2048
2049
2050 double ConstantPoolArray::get_int64_entry_as_double(int index) {
2051 STATIC_ASSERT(kDoubleSize == kInt64Size);
2052 ASSERT(map() != HEAP->fixed_cow_array_map() &&
2053 map() != HEAP->fixed_array_map());
2054 ASSERT(index >= 0 && index < this->first_int32_index());
2055 return READ_DOUBLE_FIELD(this, kFirstOffset + index * kInt64Size);
2056 }
2057
2058
2059 int32_t ConstantPoolArray::get_int32_entry(int index) {
2060 ASSERT(map() != HEAP->fixed_cow_array_map() &&
2061 map() != HEAP->fixed_array_map());
2062 ASSERT(index >= this->first_int32_index() && index < this->length());
2063 int offset = kFirstOffset + this->first_int32_index() * kInt64Size
2064 + index * kInt32Size;
2065 return READ_INT32_FIELD(this, offset);
2066 }
2067
2068
2069 MaybeObject* ConstantPoolArray::get(int index) {
2070 if (index < first_int32_index()) {
2071 return GetHeap()->NumberFromDouble(get_int64_entry_as_double(index));
2072 } else {
2073 return GetHeap()->NumberFromInt32(get_int32_entry(index));
2074 }
2075 }
2076
2077
2078 void ConstantPoolArray::set(int index, int64_t value) {
2079 ASSERT(map() != HEAP->fixed_cow_array_map() &&
2080 map() != HEAP->fixed_array_map());
2081 ASSERT(index >= 0 && index < this->first_int32_index());
2082 int offset = kFirstOffset + index * kInt64Size;
2083 WRITE_INT64_FIELD(this, offset, value);
2084 }
2085
2086 void ConstantPoolArray::set(int index, double value) {
2087 STATIC_ASSERT(kDoubleSize == kInt64Size);
2088 ASSERT(map() != HEAP->fixed_cow_array_map() &&
2089 map() != HEAP->fixed_array_map());
2090 ASSERT(index >= 0 && index < this->first_int32_index());
2091 int offset = kFirstOffset + index * kDoubleSize;
2092 WRITE_DOUBLE_FIELD(this, offset, value);
2093 }
2094
2095
2096 void ConstantPoolArray::set(int index, int32_t value) {
2097 ASSERT(map() != HEAP->fixed_cow_array_map() &&
2098 map() != HEAP->fixed_array_map());
2099 ASSERT(index >= this->first_int32_index() && index < this->length());
2100 int offset = kFirstOffset + this->first_int32_index() * kInt64Size +
2101 index * kInt32Size;
2102 WRITE_INT32_FIELD(this, offset, value);
2103 }
2104
2105
2031 WriteBarrierMode HeapObject::GetWriteBarrierMode( 2106 WriteBarrierMode HeapObject::GetWriteBarrierMode(
2032 const DisallowHeapAllocation& promise) { 2107 const DisallowHeapAllocation& promise) {
2033 Heap* heap = GetHeap(); 2108 Heap* heap = GetHeap();
2034 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; 2109 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER;
2035 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; 2110 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER;
2036 return UPDATE_WRITE_BARRIER; 2111 return UPDATE_WRITE_BARRIER;
2037 } 2112 }
2038 2113
2039 2114
2040 void FixedArray::set(int index, 2115 void FixedArray::set(int index,
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
2519 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); 2594 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask));
2520 } 2595 }
2521 2596
2522 2597
2523 // ------------------------------------ 2598 // ------------------------------------
2524 // Cast operations 2599 // Cast operations
2525 2600
2526 2601
2527 CAST_ACCESSOR(FixedArray) 2602 CAST_ACCESSOR(FixedArray)
2528 CAST_ACCESSOR(FixedDoubleArray) 2603 CAST_ACCESSOR(FixedDoubleArray)
2604 CAST_ACCESSOR(ConstantPoolArray)
2529 CAST_ACCESSOR(DescriptorArray) 2605 CAST_ACCESSOR(DescriptorArray)
2530 CAST_ACCESSOR(DeoptimizationInputData) 2606 CAST_ACCESSOR(DeoptimizationInputData)
2531 CAST_ACCESSOR(DeoptimizationOutputData) 2607 CAST_ACCESSOR(DeoptimizationOutputData)
2532 CAST_ACCESSOR(DependentCode) 2608 CAST_ACCESSOR(DependentCode)
2533 CAST_ACCESSOR(TypeFeedbackCells) 2609 CAST_ACCESSOR(TypeFeedbackCells)
2534 CAST_ACCESSOR(StringTable) 2610 CAST_ACCESSOR(StringTable)
2535 CAST_ACCESSOR(JSFunctionResultCache) 2611 CAST_ACCESSOR(JSFunctionResultCache)
2536 CAST_ACCESSOR(NormalizedMapCache) 2612 CAST_ACCESSOR(NormalizedMapCache)
2537 CAST_ACCESSOR(ScopeInfo) 2613 CAST_ACCESSOR(ScopeInfo)
2538 CAST_ACCESSOR(CompilationCacheTable) 2614 CAST_ACCESSOR(CompilationCacheTable)
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
3414 } 3490 }
3415 if (instance_type == STRING_TYPE || 3491 if (instance_type == STRING_TYPE ||
3416 instance_type == INTERNALIZED_STRING_TYPE) { 3492 instance_type == INTERNALIZED_STRING_TYPE) {
3417 return SeqTwoByteString::SizeFor( 3493 return SeqTwoByteString::SizeFor(
3418 reinterpret_cast<SeqTwoByteString*>(this)->length()); 3494 reinterpret_cast<SeqTwoByteString*>(this)->length());
3419 } 3495 }
3420 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { 3496 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) {
3421 return FixedDoubleArray::SizeFor( 3497 return FixedDoubleArray::SizeFor(
3422 reinterpret_cast<FixedDoubleArray*>(this)->length()); 3498 reinterpret_cast<FixedDoubleArray*>(this)->length());
3423 } 3499 }
3500 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) {
3501 return ConstantPoolArray::SizeFor(
3502 reinterpret_cast<ConstantPoolArray*>(this)->length(),
3503 reinterpret_cast<ConstantPoolArray*>(this)->first_int32_index());
3504 }
3424 ASSERT(instance_type == CODE_TYPE); 3505 ASSERT(instance_type == CODE_TYPE);
3425 return reinterpret_cast<Code*>(this)->CodeSize(); 3506 return reinterpret_cast<Code*>(this)->CodeSize();
3426 } 3507 }
3427 3508
3428 3509
3429 void Map::set_instance_size(int value) { 3510 void Map::set_instance_size(int value) {
3430 ASSERT_EQ(0, value & (kPointerSize - 1)); 3511 ASSERT_EQ(0, value & (kPointerSize - 1));
3431 value >>= kPointerSizeLog2; 3512 value >>= kPointerSizeLog2;
3432 ASSERT(0 <= value && value < 256); 3513 ASSERT(0 <= value && value < 256);
3433 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value)); 3514 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value));
(...skipping 2590 matching lines...) Expand 10 before | Expand all | Expand 10 after
6024 return GetHeap()->CopyFixedArray(this); 6105 return GetHeap()->CopyFixedArray(this);
6025 } 6106 }
6026 6107
6027 6108
6028 MaybeObject* FixedDoubleArray::Copy() { 6109 MaybeObject* FixedDoubleArray::Copy() {
6029 if (length() == 0) return this; 6110 if (length() == 0) return this;
6030 return GetHeap()->CopyFixedDoubleArray(this); 6111 return GetHeap()->CopyFixedDoubleArray(this);
6031 } 6112 }
6032 6113
6033 6114
6115 MaybeObject* ConstantPoolArray::Copy() {
6116 if (length() == 0) return this;
6117 return GetHeap()->CopyConstantPoolArray(this);
6118 }
6119
6120
6034 void TypeFeedbackCells::SetAstId(int index, TypeFeedbackId id) { 6121 void TypeFeedbackCells::SetAstId(int index, TypeFeedbackId id) {
6035 set(1 + index * 2, Smi::FromInt(id.ToInt())); 6122 set(1 + index * 2, Smi::FromInt(id.ToInt()));
6036 } 6123 }
6037 6124
6038 6125
6039 TypeFeedbackId TypeFeedbackCells::AstId(int index) { 6126 TypeFeedbackId TypeFeedbackCells::AstId(int index) {
6040 return TypeFeedbackId(Smi::cast(get(1 + index * 2))->value()); 6127 return TypeFeedbackId(Smi::cast(get(1 + index * 2))->value());
6041 } 6128 }
6042 6129
6043 6130
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
6261 #undef WRITE_UINT32_FIELD 6348 #undef WRITE_UINT32_FIELD
6262 #undef READ_SHORT_FIELD 6349 #undef READ_SHORT_FIELD
6263 #undef WRITE_SHORT_FIELD 6350 #undef WRITE_SHORT_FIELD
6264 #undef READ_BYTE_FIELD 6351 #undef READ_BYTE_FIELD
6265 #undef WRITE_BYTE_FIELD 6352 #undef WRITE_BYTE_FIELD
6266 6353
6267 6354
6268 } } // namespace v8::internal 6355 } } // namespace v8::internal
6269 6356
6270 #endif // V8_OBJECTS_INL_H_ 6357 #endif // V8_OBJECTS_INL_H_
OLDNEW
« src/heap.cc ('K') | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698