Chromium Code Reviews| Index: src/objects-inl.h |
| diff --git a/src/objects-inl.h b/src/objects-inl.h |
| index ed266436f190d18637170c15226fa180cf314fe2..2c2f728cebc0ba90dc988e1c4f2703d887412f07 100644 |
| --- a/src/objects-inl.h |
| +++ b/src/objects-inl.h |
| @@ -133,7 +133,7 @@ PropertyDetails PropertyDetails::AsDeleted() { |
| bool Object::IsFixedArrayBase() { |
| - return IsFixedArray() || IsFixedDoubleArray(); |
| + return IsFixedArray() || IsFixedDoubleArray() || IsConstantPoolArray(); |
| } |
| @@ -572,6 +572,7 @@ TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE) |
| TYPE_CHECKER(Map, MAP_TYPE) |
| TYPE_CHECKER(FixedArray, FIXED_ARRAY_TYPE) |
| TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE) |
| +TYPE_CHECKER(ConstantPoolArray, CONSTANT_POOL_ARRAY_TYPE) |
| bool Object::IsJSWeakCollection() { |
| @@ -1028,6 +1029,12 @@ MaybeObject* Object::GetProperty(Name* key, PropertyAttributes* attributes) { |
| #define WRITE_UINT32_FIELD(p, offset, value) \ |
| (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)) = value) |
| +#define READ_INT32_FIELD(p, offset) \ |
| + (*reinterpret_cast<int32_t*>(FIELD_ADDR(p, offset))) |
| + |
| +#define WRITE_INT32_FIELD(p, offset, value) \ |
| + (*reinterpret_cast<int32_t*>(FIELD_ADDR(p, offset)) = value) |
| + |
| #define READ_INT64_FIELD(p, offset) \ |
| (*reinterpret_cast<int64_t*>(FIELD_ADDR(p, offset))) |
| @@ -1929,7 +1936,8 @@ void Object::VerifyApiCallResultType() { |
| FixedArrayBase* FixedArrayBase::cast(Object* object) { |
| - ASSERT(object->IsFixedArray() || object->IsFixedDoubleArray()); |
| + ASSERT(object->IsFixedArray() || object->IsFixedDoubleArray() || |
| + object->IsConstantPoolArray()); |
| return reinterpret_cast<FixedArrayBase*>(object); |
| } |
| @@ -2028,6 +2036,73 @@ bool FixedDoubleArray::is_the_hole(int index) { |
| } |
| +SMI_ACCESSORS(ConstantPoolArray, first_int32_index, kFirstInt32IndexOffset) |
| + |
| + |
| +int64_t ConstantPoolArray::get_int64_entry(int index) { |
| + 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.
|
| + map() != HEAP->fixed_array_map()); |
| + ASSERT(index >= 0 && index < this->first_int32_index()); |
| + return READ_INT64_FIELD(this, kFirstOffset + index * kInt64Size); |
| +} |
| + |
| + |
| +double ConstantPoolArray::get_int64_entry_as_double(int index) { |
| + STATIC_ASSERT(kDoubleSize == kInt64Size); |
| + ASSERT(map() != HEAP->fixed_cow_array_map() && |
| + map() != HEAP->fixed_array_map()); |
| + ASSERT(index >= 0 && index < this->first_int32_index()); |
| + return READ_DOUBLE_FIELD(this, kFirstOffset + index * kInt64Size); |
| +} |
| + |
| + |
| +int32_t ConstantPoolArray::get_int32_entry(int index) { |
| + ASSERT(map() != HEAP->fixed_cow_array_map() && |
| + map() != HEAP->fixed_array_map()); |
| + ASSERT(index >= this->first_int32_index() && index < this->length()); |
| + int offset = kFirstOffset + this->first_int32_index() * kInt64Size |
| + + index * kInt32Size; |
| + return READ_INT32_FIELD(this, offset); |
| +} |
| + |
| + |
| +MaybeObject* ConstantPoolArray::get(int index) { |
| + if (index < first_int32_index()) { |
| + return GetHeap()->NumberFromDouble(get_int64_entry_as_double(index)); |
| + } else { |
| + return GetHeap()->NumberFromInt32(get_int32_entry(index)); |
| + } |
| +} |
| + |
| + |
| +void ConstantPoolArray::set(int index, int64_t value) { |
| + ASSERT(map() != HEAP->fixed_cow_array_map() && |
| + map() != HEAP->fixed_array_map()); |
| + ASSERT(index >= 0 && index < this->first_int32_index()); |
| + int offset = kFirstOffset + index * kInt64Size; |
| + WRITE_INT64_FIELD(this, offset, value); |
| +} |
| + |
| +void ConstantPoolArray::set(int index, double value) { |
| + STATIC_ASSERT(kDoubleSize == kInt64Size); |
| + ASSERT(map() != HEAP->fixed_cow_array_map() && |
| + map() != HEAP->fixed_array_map()); |
| + ASSERT(index >= 0 && index < this->first_int32_index()); |
| + int offset = kFirstOffset + index * kDoubleSize; |
| + WRITE_DOUBLE_FIELD(this, offset, value); |
| +} |
| + |
| + |
| +void ConstantPoolArray::set(int index, int32_t value) { |
| + ASSERT(map() != HEAP->fixed_cow_array_map() && |
| + map() != HEAP->fixed_array_map()); |
| + ASSERT(index >= this->first_int32_index() && index < this->length()); |
| + int offset = kFirstOffset + this->first_int32_index() * kInt64Size + |
| + index * kInt32Size; |
| + WRITE_INT32_FIELD(this, offset, value); |
| +} |
| + |
| + |
| WriteBarrierMode HeapObject::GetWriteBarrierMode( |
| const DisallowHeapAllocation& promise) { |
| Heap* heap = GetHeap(); |
| @@ -2526,6 +2601,7 @@ void SeededNumberDictionary::set_requires_slow_elements() { |
| CAST_ACCESSOR(FixedArray) |
| CAST_ACCESSOR(FixedDoubleArray) |
| +CAST_ACCESSOR(ConstantPoolArray) |
| CAST_ACCESSOR(DescriptorArray) |
| CAST_ACCESSOR(DeoptimizationInputData) |
| CAST_ACCESSOR(DeoptimizationOutputData) |
| @@ -3421,6 +3497,11 @@ int HeapObject::SizeFromMap(Map* map) { |
| return FixedDoubleArray::SizeFor( |
| reinterpret_cast<FixedDoubleArray*>(this)->length()); |
| } |
| + if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { |
| + return ConstantPoolArray::SizeFor( |
| + reinterpret_cast<ConstantPoolArray*>(this)->length(), |
| + reinterpret_cast<ConstantPoolArray*>(this)->first_int32_index()); |
| + } |
| ASSERT(instance_type == CODE_TYPE); |
| return reinterpret_cast<Code*>(this)->CodeSize(); |
| } |
| @@ -6031,6 +6112,12 @@ MaybeObject* FixedDoubleArray::Copy() { |
| } |
| +MaybeObject* ConstantPoolArray::Copy() { |
| + if (length() == 0) return this; |
| + return GetHeap()->CopyConstantPoolArray(this); |
| +} |
| + |
| + |
| void TypeFeedbackCells::SetAstId(int index, TypeFeedbackId id) { |
| set(1 + index * 2, Smi::FromInt(id.ToInt())); |
| } |