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

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

Issue 1153373003: Add new Float32x4 type for SIMD.js. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix int type mismatches. Created 5 years, 6 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
« 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 163 }
164 164
165 165
166 bool Object::IsHeapObject() const { 166 bool Object::IsHeapObject() const {
167 return Internals::HasHeapObjectTag(this); 167 return Internals::HasHeapObjectTag(this);
168 } 168 }
169 169
170 170
171 TYPE_CHECKER(HeapNumber, HEAP_NUMBER_TYPE) 171 TYPE_CHECKER(HeapNumber, HEAP_NUMBER_TYPE)
172 TYPE_CHECKER(MutableHeapNumber, MUTABLE_HEAP_NUMBER_TYPE) 172 TYPE_CHECKER(MutableHeapNumber, MUTABLE_HEAP_NUMBER_TYPE)
173 TYPE_CHECKER(Float32x4, FLOAT32X4_TYPE)
173 TYPE_CHECKER(Symbol, SYMBOL_TYPE) 174 TYPE_CHECKER(Symbol, SYMBOL_TYPE)
174 175
175 176
176 bool Object::IsString() const { 177 bool Object::IsString() const {
177 return Object::IsHeapObject() 178 return Object::IsHeapObject()
178 && HeapObject::cast(this)->map()->instance_type() < FIRST_NONSTRING_TYPE; 179 && HeapObject::cast(this)->map()->instance_type() < FIRST_NONSTRING_TYPE;
179 } 180 }
180 181
181 182
182 bool Object::IsName() const { 183 bool Object::IsName() const {
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 1315
1315 #define WRITE_UINT32_FIELD(p, offset, value) \ 1316 #define WRITE_UINT32_FIELD(p, offset, value) \
1316 (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)) = value) 1317 (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)) = value)
1317 1318
1318 #define READ_INT32_FIELD(p, offset) \ 1319 #define READ_INT32_FIELD(p, offset) \
1319 (*reinterpret_cast<const int32_t*>(FIELD_ADDR_CONST(p, offset))) 1320 (*reinterpret_cast<const int32_t*>(FIELD_ADDR_CONST(p, offset)))
1320 1321
1321 #define WRITE_INT32_FIELD(p, offset, value) \ 1322 #define WRITE_INT32_FIELD(p, offset, value) \
1322 (*reinterpret_cast<int32_t*>(FIELD_ADDR(p, offset)) = value) 1323 (*reinterpret_cast<int32_t*>(FIELD_ADDR(p, offset)) = value)
1323 1324
1325 #define READ_FLOAT_FIELD(p, offset) \
1326 (*reinterpret_cast<const float*>(FIELD_ADDR_CONST(p, offset)))
1327
1328 #define WRITE_FLOAT_FIELD(p, offset, value) \
1329 (*reinterpret_cast<float*>(FIELD_ADDR(p, offset)) = value)
1330
1324 #define READ_UINT64_FIELD(p, offset) \ 1331 #define READ_UINT64_FIELD(p, offset) \
1325 (*reinterpret_cast<const uint64_t*>(FIELD_ADDR_CONST(p, offset))) 1332 (*reinterpret_cast<const uint64_t*>(FIELD_ADDR_CONST(p, offset)))
1326 1333
1327 #define WRITE_UINT64_FIELD(p, offset, value) \ 1334 #define WRITE_UINT64_FIELD(p, offset, value) \
1328 (*reinterpret_cast<uint64_t*>(FIELD_ADDR(p, offset)) = value) 1335 (*reinterpret_cast<uint64_t*>(FIELD_ADDR(p, offset)) = value)
1329 1336
1330 #define READ_INT64_FIELD(p, offset) \ 1337 #define READ_INT64_FIELD(p, offset) \
1331 (*reinterpret_cast<const int64_t*>(FIELD_ADDR_CONST(p, offset))) 1338 (*reinterpret_cast<const int64_t*>(FIELD_ADDR_CONST(p, offset)))
1332 1339
1333 #define WRITE_INT64_FIELD(p, offset, value) \ 1340 #define WRITE_INT64_FIELD(p, offset, value) \
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 return ((READ_INT_FIELD(this, kExponentOffset) & kExponentMask) >> 1579 return ((READ_INT_FIELD(this, kExponentOffset) & kExponentMask) >>
1573 kExponentShift) - kExponentBias; 1580 kExponentShift) - kExponentBias;
1574 } 1581 }
1575 1582
1576 1583
1577 int HeapNumber::get_sign() { 1584 int HeapNumber::get_sign() {
1578 return READ_INT_FIELD(this, kExponentOffset) & kSignMask; 1585 return READ_INT_FIELD(this, kExponentOffset) & kSignMask;
1579 } 1586 }
1580 1587
1581 1588
1589 float Float32x4::get_lane(int lane) const {
1590 DCHECK(lane < 4 && lane >= 0);
1591 #if defined(V8_TARGET_LITTLE_ENDIAN)
1592 return READ_FLOAT_FIELD(this, kValueOffset + lane * kFloatSize);
1593 #elif defined(V8_TARGET_BIG_ENDIAN)
1594 return READ_FLOAT_FIELD(this, kValueOffset + (3 - lane) * kFloatSize);
1595 #else
1596 #error Unknown byte ordering
1597 #endif
1598 }
1599
1600
1601 void Float32x4::set_lane(int lane, float value) {
1602 DCHECK(lane < 4 && lane >= 0);
1603 #if defined(V8_TARGET_LITTLE_ENDIAN)
1604 WRITE_FLOAT_FIELD(this, kValueOffset + lane * kFloatSize, value);
1605 #elif defined(V8_TARGET_BIG_ENDIAN)
1606 WRITE_FLOAT_FIELD(this, kValueOffset + (3 - lane) * kFloatSize, value);
1607 #else
1608 #error Unknown byte ordering
1609 #endif
1610 }
1611
1612
1582 ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset) 1613 ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset)
1583 1614
1584 1615
1585 Object** FixedArray::GetFirstElementAddress() { 1616 Object** FixedArray::GetFirstElementAddress() {
1586 return reinterpret_cast<Object**>(FIELD_ADDR(this, OffsetOfElementAt(0))); 1617 return reinterpret_cast<Object**>(FIELD_ADDR(this, OffsetOfElementAt(0)));
1587 } 1618 }
1588 1619
1589 1620
1590 bool FixedArray::ContainsOnlySmisOrHoles() { 1621 bool FixedArray::ContainsOnlySmisOrHoles() {
1591 Object* the_hole = GetHeap()->the_hole_value(); 1622 Object* the_hole = GetHeap()->the_hole_value();
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after
2811 2842
2812 2843
2813 AllocationAlignment HeapObject::RequiredAlignment() { 2844 AllocationAlignment HeapObject::RequiredAlignment() {
2814 #ifdef V8_HOST_ARCH_32_BIT 2845 #ifdef V8_HOST_ARCH_32_BIT
2815 if ((IsFixedFloat64Array() || IsFixedDoubleArray() || 2846 if ((IsFixedFloat64Array() || IsFixedDoubleArray() ||
2816 IsConstantPoolArray()) && 2847 IsConstantPoolArray()) &&
2817 FixedArrayBase::cast(this)->length() != 0) { 2848 FixedArrayBase::cast(this)->length() != 0) {
2818 return kDoubleAligned; 2849 return kDoubleAligned;
2819 } 2850 }
2820 if (IsHeapNumber()) return kDoubleUnaligned; 2851 if (IsHeapNumber()) return kDoubleUnaligned;
2852 if (IsFloat32x4()) return kSimd128Unaligned;
2821 #endif // V8_HOST_ARCH_32_BIT 2853 #endif // V8_HOST_ARCH_32_BIT
2822 return kWordAligned; 2854 return kWordAligned;
2823 } 2855 }
2824 2856
2825 2857
2826 void FixedArray::set(int index, 2858 void FixedArray::set(int index,
2827 Object* value, 2859 Object* value,
2828 WriteBarrierMode mode) { 2860 WriteBarrierMode mode) {
2829 DCHECK(map() != GetHeap()->fixed_cow_array_map()); 2861 DCHECK(map() != GetHeap()->fixed_cow_array_map());
2830 DCHECK(index >= 0 && index < this->length()); 2862 DCHECK(index >= 0 && index < this->length());
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
3352 CAST_ACCESSOR(ExternalString) 3384 CAST_ACCESSOR(ExternalString)
3353 CAST_ACCESSOR(ExternalTwoByteString) 3385 CAST_ACCESSOR(ExternalTwoByteString)
3354 CAST_ACCESSOR(ExternalUint16Array) 3386 CAST_ACCESSOR(ExternalUint16Array)
3355 CAST_ACCESSOR(ExternalUint32Array) 3387 CAST_ACCESSOR(ExternalUint32Array)
3356 CAST_ACCESSOR(ExternalUint8Array) 3388 CAST_ACCESSOR(ExternalUint8Array)
3357 CAST_ACCESSOR(ExternalUint8ClampedArray) 3389 CAST_ACCESSOR(ExternalUint8ClampedArray)
3358 CAST_ACCESSOR(FixedArray) 3390 CAST_ACCESSOR(FixedArray)
3359 CAST_ACCESSOR(FixedArrayBase) 3391 CAST_ACCESSOR(FixedArrayBase)
3360 CAST_ACCESSOR(FixedDoubleArray) 3392 CAST_ACCESSOR(FixedDoubleArray)
3361 CAST_ACCESSOR(FixedTypedArrayBase) 3393 CAST_ACCESSOR(FixedTypedArrayBase)
3394 CAST_ACCESSOR(Float32x4)
3362 CAST_ACCESSOR(Foreign) 3395 CAST_ACCESSOR(Foreign)
3363 CAST_ACCESSOR(GlobalDictionary) 3396 CAST_ACCESSOR(GlobalDictionary)
3364 CAST_ACCESSOR(GlobalObject) 3397 CAST_ACCESSOR(GlobalObject)
3365 CAST_ACCESSOR(HandlerTable) 3398 CAST_ACCESSOR(HandlerTable)
3366 CAST_ACCESSOR(HeapObject) 3399 CAST_ACCESSOR(HeapObject)
3367 CAST_ACCESSOR(JSArray) 3400 CAST_ACCESSOR(JSArray)
3368 CAST_ACCESSOR(JSArrayBuffer) 3401 CAST_ACCESSOR(JSArrayBuffer)
3369 CAST_ACCESSOR(JSArrayBufferView) 3402 CAST_ACCESSOR(JSArrayBufferView)
3370 CAST_ACCESSOR(JSBuiltinsObject) 3403 CAST_ACCESSOR(JSBuiltinsObject)
3371 CAST_ACCESSOR(JSDataView) 3404 CAST_ACCESSOR(JSDataView)
(...skipping 4343 matching lines...) Expand 10 before | Expand all | Expand 10 after
7715 #undef READ_SHORT_FIELD 7748 #undef READ_SHORT_FIELD
7716 #undef WRITE_SHORT_FIELD 7749 #undef WRITE_SHORT_FIELD
7717 #undef READ_BYTE_FIELD 7750 #undef READ_BYTE_FIELD
7718 #undef WRITE_BYTE_FIELD 7751 #undef WRITE_BYTE_FIELD
7719 #undef NOBARRIER_READ_BYTE_FIELD 7752 #undef NOBARRIER_READ_BYTE_FIELD
7720 #undef NOBARRIER_WRITE_BYTE_FIELD 7753 #undef NOBARRIER_WRITE_BYTE_FIELD
7721 7754
7722 } } // namespace v8::internal 7755 } } // namespace v8::internal
7723 7756
7724 #endif // V8_OBJECTS_INL_H_ 7757 #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