OLD | NEW |
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 Loading... |
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 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 | 1314 |
1314 #define WRITE_UINT32_FIELD(p, offset, value) \ | 1315 #define WRITE_UINT32_FIELD(p, offset, value) \ |
1315 (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)) = value) | 1316 (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)) = value) |
1316 | 1317 |
1317 #define READ_INT32_FIELD(p, offset) \ | 1318 #define READ_INT32_FIELD(p, offset) \ |
1318 (*reinterpret_cast<const int32_t*>(FIELD_ADDR_CONST(p, offset))) | 1319 (*reinterpret_cast<const int32_t*>(FIELD_ADDR_CONST(p, offset))) |
1319 | 1320 |
1320 #define WRITE_INT32_FIELD(p, offset, value) \ | 1321 #define WRITE_INT32_FIELD(p, offset, value) \ |
1321 (*reinterpret_cast<int32_t*>(FIELD_ADDR(p, offset)) = value) | 1322 (*reinterpret_cast<int32_t*>(FIELD_ADDR(p, offset)) = value) |
1322 | 1323 |
| 1324 #define READ_FLOAT_FIELD(p, offset) \ |
| 1325 (*reinterpret_cast<const float*>(FIELD_ADDR_CONST(p, offset))) |
| 1326 |
| 1327 #define WRITE_FLOAT_FIELD(p, offset, value) \ |
| 1328 (*reinterpret_cast<float*>(FIELD_ADDR(p, offset)) = value) |
| 1329 |
1323 #define READ_UINT64_FIELD(p, offset) \ | 1330 #define READ_UINT64_FIELD(p, offset) \ |
1324 (*reinterpret_cast<const uint64_t*>(FIELD_ADDR_CONST(p, offset))) | 1331 (*reinterpret_cast<const uint64_t*>(FIELD_ADDR_CONST(p, offset))) |
1325 | 1332 |
1326 #define WRITE_UINT64_FIELD(p, offset, value) \ | 1333 #define WRITE_UINT64_FIELD(p, offset, value) \ |
1327 (*reinterpret_cast<uint64_t*>(FIELD_ADDR(p, offset)) = value) | 1334 (*reinterpret_cast<uint64_t*>(FIELD_ADDR(p, offset)) = value) |
1328 | 1335 |
1329 #define READ_INT64_FIELD(p, offset) \ | 1336 #define READ_INT64_FIELD(p, offset) \ |
1330 (*reinterpret_cast<const int64_t*>(FIELD_ADDR_CONST(p, offset))) | 1337 (*reinterpret_cast<const int64_t*>(FIELD_ADDR_CONST(p, offset))) |
1331 | 1338 |
1332 #define WRITE_INT64_FIELD(p, offset, value) \ | 1339 #define WRITE_INT64_FIELD(p, offset, value) \ |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1569 return ((READ_INT_FIELD(this, kExponentOffset) & kExponentMask) >> | 1576 return ((READ_INT_FIELD(this, kExponentOffset) & kExponentMask) >> |
1570 kExponentShift) - kExponentBias; | 1577 kExponentShift) - kExponentBias; |
1571 } | 1578 } |
1572 | 1579 |
1573 | 1580 |
1574 int HeapNumber::get_sign() { | 1581 int HeapNumber::get_sign() { |
1575 return READ_INT_FIELD(this, kExponentOffset) & kSignMask; | 1582 return READ_INT_FIELD(this, kExponentOffset) & kSignMask; |
1576 } | 1583 } |
1577 | 1584 |
1578 | 1585 |
| 1586 float Float32x4::get_lane(int lane) const { |
| 1587 DCHECK(lane < 4 && lane >= 0); |
| 1588 #if defined(V8_TARGET_LITTLE_ENDIAN) |
| 1589 return READ_FLOAT_FIELD(this, kValueOffset + lane * kFloatSize); |
| 1590 #elif defined(V8_TARGET_BIG_ENDIAN) |
| 1591 return READ_FLOAT_FIELD(this, kValueOffset + (3 - lane) * kFloatSize); |
| 1592 #else |
| 1593 #error Unknown byte ordering |
| 1594 #endif |
| 1595 } |
| 1596 |
| 1597 |
| 1598 void Float32x4::set_lane(int lane, float value) { |
| 1599 DCHECK(lane < 4 && lane >= 0); |
| 1600 #if defined(V8_TARGET_LITTLE_ENDIAN) |
| 1601 WRITE_FLOAT_FIELD(this, kValueOffset + lane * kFloatSize, value); |
| 1602 #elif defined(V8_TARGET_BIG_ENDIAN) |
| 1603 WRITE_FLOAT_FIELD(this, kValueOffset + (3 - lane) * kFloatSize, value); |
| 1604 #else |
| 1605 #error Unknown byte ordering |
| 1606 #endif |
| 1607 } |
| 1608 |
| 1609 |
1579 ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset) | 1610 ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset) |
1580 | 1611 |
1581 | 1612 |
1582 Object** FixedArray::GetFirstElementAddress() { | 1613 Object** FixedArray::GetFirstElementAddress() { |
1583 return reinterpret_cast<Object**>(FIELD_ADDR(this, OffsetOfElementAt(0))); | 1614 return reinterpret_cast<Object**>(FIELD_ADDR(this, OffsetOfElementAt(0))); |
1584 } | 1615 } |
1585 | 1616 |
1586 | 1617 |
1587 bool FixedArray::ContainsOnlySmisOrHoles() { | 1618 bool FixedArray::ContainsOnlySmisOrHoles() { |
1588 Object* the_hole = GetHeap()->the_hole_value(); | 1619 Object* the_hole = GetHeap()->the_hole_value(); |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2426 } | 2457 } |
2427 | 2458 |
2428 | 2459 |
2429 AllocationAlignment HeapObject::RequiredAlignment() { | 2460 AllocationAlignment HeapObject::RequiredAlignment() { |
2430 #ifdef V8_HOST_ARCH_32_BIT | 2461 #ifdef V8_HOST_ARCH_32_BIT |
2431 if ((IsFixedFloat64Array() || IsFixedDoubleArray()) && | 2462 if ((IsFixedFloat64Array() || IsFixedDoubleArray()) && |
2432 FixedArrayBase::cast(this)->length() != 0) { | 2463 FixedArrayBase::cast(this)->length() != 0) { |
2433 return kDoubleAligned; | 2464 return kDoubleAligned; |
2434 } | 2465 } |
2435 if (IsHeapNumber()) return kDoubleUnaligned; | 2466 if (IsHeapNumber()) return kDoubleUnaligned; |
| 2467 if (IsFloat32x4()) return kSimd128Unaligned; |
2436 #endif // V8_HOST_ARCH_32_BIT | 2468 #endif // V8_HOST_ARCH_32_BIT |
2437 return kWordAligned; | 2469 return kWordAligned; |
2438 } | 2470 } |
2439 | 2471 |
2440 | 2472 |
2441 void FixedArray::set(int index, | 2473 void FixedArray::set(int index, |
2442 Object* value, | 2474 Object* value, |
2443 WriteBarrierMode mode) { | 2475 WriteBarrierMode mode) { |
2444 DCHECK(map() != GetHeap()->fixed_cow_array_map()); | 2476 DCHECK(map() != GetHeap()->fixed_cow_array_map()); |
2445 DCHECK(index >= 0 && index < this->length()); | 2477 DCHECK(index >= 0 && index < this->length()); |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2966 CAST_ACCESSOR(ExternalString) | 2998 CAST_ACCESSOR(ExternalString) |
2967 CAST_ACCESSOR(ExternalTwoByteString) | 2999 CAST_ACCESSOR(ExternalTwoByteString) |
2968 CAST_ACCESSOR(ExternalUint16Array) | 3000 CAST_ACCESSOR(ExternalUint16Array) |
2969 CAST_ACCESSOR(ExternalUint32Array) | 3001 CAST_ACCESSOR(ExternalUint32Array) |
2970 CAST_ACCESSOR(ExternalUint8Array) | 3002 CAST_ACCESSOR(ExternalUint8Array) |
2971 CAST_ACCESSOR(ExternalUint8ClampedArray) | 3003 CAST_ACCESSOR(ExternalUint8ClampedArray) |
2972 CAST_ACCESSOR(FixedArray) | 3004 CAST_ACCESSOR(FixedArray) |
2973 CAST_ACCESSOR(FixedArrayBase) | 3005 CAST_ACCESSOR(FixedArrayBase) |
2974 CAST_ACCESSOR(FixedDoubleArray) | 3006 CAST_ACCESSOR(FixedDoubleArray) |
2975 CAST_ACCESSOR(FixedTypedArrayBase) | 3007 CAST_ACCESSOR(FixedTypedArrayBase) |
| 3008 CAST_ACCESSOR(Float32x4) |
2976 CAST_ACCESSOR(Foreign) | 3009 CAST_ACCESSOR(Foreign) |
2977 CAST_ACCESSOR(GlobalDictionary) | 3010 CAST_ACCESSOR(GlobalDictionary) |
2978 CAST_ACCESSOR(GlobalObject) | 3011 CAST_ACCESSOR(GlobalObject) |
2979 CAST_ACCESSOR(HandlerTable) | 3012 CAST_ACCESSOR(HandlerTable) |
2980 CAST_ACCESSOR(HeapObject) | 3013 CAST_ACCESSOR(HeapObject) |
2981 CAST_ACCESSOR(JSArray) | 3014 CAST_ACCESSOR(JSArray) |
2982 CAST_ACCESSOR(JSArrayBuffer) | 3015 CAST_ACCESSOR(JSArrayBuffer) |
2983 CAST_ACCESSOR(JSArrayBufferView) | 3016 CAST_ACCESSOR(JSArrayBufferView) |
2984 CAST_ACCESSOR(JSBuiltinsObject) | 3017 CAST_ACCESSOR(JSBuiltinsObject) |
2985 CAST_ACCESSOR(JSDataView) | 3018 CAST_ACCESSOR(JSDataView) |
(...skipping 4340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7326 #undef READ_SHORT_FIELD | 7359 #undef READ_SHORT_FIELD |
7327 #undef WRITE_SHORT_FIELD | 7360 #undef WRITE_SHORT_FIELD |
7328 #undef READ_BYTE_FIELD | 7361 #undef READ_BYTE_FIELD |
7329 #undef WRITE_BYTE_FIELD | 7362 #undef WRITE_BYTE_FIELD |
7330 #undef NOBARRIER_READ_BYTE_FIELD | 7363 #undef NOBARRIER_READ_BYTE_FIELD |
7331 #undef NOBARRIER_WRITE_BYTE_FIELD | 7364 #undef NOBARRIER_WRITE_BYTE_FIELD |
7332 | 7365 |
7333 } } // namespace v8::internal | 7366 } } // namespace v8::internal |
7334 | 7367 |
7335 #endif // V8_OBJECTS_INL_H_ | 7368 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |