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 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 TYPE_CHECKER(Foreign, FOREIGN_TYPE) | 836 TYPE_CHECKER(Foreign, FOREIGN_TYPE) |
837 | 837 |
838 | 838 |
839 bool Object::IsBoolean() const { | 839 bool Object::IsBoolean() const { |
840 return IsOddball() && | 840 return IsOddball() && |
841 ((Oddball::cast(this)->kind() & Oddball::kNotBooleanMask) == 0); | 841 ((Oddball::cast(this)->kind() & Oddball::kNotBooleanMask) == 0); |
842 } | 842 } |
843 | 843 |
844 | 844 |
845 TYPE_CHECKER(JSArray, JS_ARRAY_TYPE) | 845 TYPE_CHECKER(JSArray, JS_ARRAY_TYPE) |
846 TYPE_CHECKER(JSArrayBuffer, JS_ARRAY_BUFFER_TYPE) | 846 |
847 TYPE_CHECKER(JSTypedArray, JS_TYPED_ARRAY_TYPE) | 847 |
| 848 bool Object::IsJSArrayBuffer() const { |
| 849 if (!IsHeapObject()) return false; |
| 850 |
| 851 InstanceType type = HeapObject::cast(this)->map()->instance_type(); |
| 852 return type == JS_ARRAY_BUFFER_TYPE || type == JS_SHARED_ARRAY_BUFFER_TYPE; |
| 853 } |
| 854 |
| 855 |
| 856 bool Object::IsJSTypedArray() const { |
| 857 if (!IsHeapObject()) return false; |
| 858 |
| 859 InstanceType type = HeapObject::cast(this)->map()->instance_type(); |
| 860 return type == JS_TYPED_ARRAY_TYPE || type == JS_SHARED_TYPED_ARRAY_TYPE; |
| 861 } |
| 862 |
| 863 |
848 TYPE_CHECKER(JSDataView, JS_DATA_VIEW_TYPE) | 864 TYPE_CHECKER(JSDataView, JS_DATA_VIEW_TYPE) |
849 | 865 |
850 | 866 |
851 bool Object::IsJSArrayBufferView() const { | 867 bool Object::IsJSArrayBufferView() const { |
852 return IsJSDataView() || IsJSTypedArray(); | 868 return IsJSDataView() || IsJSTypedArray(); |
853 } | 869 } |
854 | 870 |
855 | 871 |
856 TYPE_CHECKER(JSRegExp, JS_REGEXP_TYPE) | 872 TYPE_CHECKER(JSRegExp, JS_REGEXP_TYPE) |
857 | 873 |
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1960 return JSBuiltinsObject::kSize; | 1976 return JSBuiltinsObject::kSize; |
1961 case JS_FUNCTION_TYPE: | 1977 case JS_FUNCTION_TYPE: |
1962 return JSFunction::kSize; | 1978 return JSFunction::kSize; |
1963 case JS_VALUE_TYPE: | 1979 case JS_VALUE_TYPE: |
1964 return JSValue::kSize; | 1980 return JSValue::kSize; |
1965 case JS_DATE_TYPE: | 1981 case JS_DATE_TYPE: |
1966 return JSDate::kSize; | 1982 return JSDate::kSize; |
1967 case JS_ARRAY_TYPE: | 1983 case JS_ARRAY_TYPE: |
1968 return JSArray::kSize; | 1984 return JSArray::kSize; |
1969 case JS_ARRAY_BUFFER_TYPE: | 1985 case JS_ARRAY_BUFFER_TYPE: |
| 1986 case JS_SHARED_ARRAY_BUFFER_TYPE: |
1970 return JSArrayBuffer::kSize; | 1987 return JSArrayBuffer::kSize; |
1971 case JS_TYPED_ARRAY_TYPE: | 1988 case JS_TYPED_ARRAY_TYPE: |
| 1989 case JS_SHARED_TYPED_ARRAY_TYPE: |
1972 return JSTypedArray::kSize; | 1990 return JSTypedArray::kSize; |
1973 case JS_DATA_VIEW_TYPE: | 1991 case JS_DATA_VIEW_TYPE: |
1974 return JSDataView::kSize; | 1992 return JSDataView::kSize; |
1975 case JS_SET_TYPE: | 1993 case JS_SET_TYPE: |
1976 return JSSet::kSize; | 1994 return JSSet::kSize; |
1977 case JS_MAP_TYPE: | 1995 case JS_MAP_TYPE: |
1978 return JSMap::kSize; | 1996 return JSMap::kSize; |
1979 case JS_SET_ITERATOR_TYPE: | 1997 case JS_SET_ITERATOR_TYPE: |
1980 return JSSetIterator::kSize; | 1998 return JSSetIterator::kSize; |
1981 case JS_MAP_ITERATOR_TYPE: | 1999 case JS_MAP_ITERATOR_TYPE: |
(...skipping 4495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6477 | 6495 |
6478 | 6496 |
6479 bool JSArrayBuffer::was_neutered() { return WasNeutered::decode(bit_field()); } | 6497 bool JSArrayBuffer::was_neutered() { return WasNeutered::decode(bit_field()); } |
6480 | 6498 |
6481 | 6499 |
6482 void JSArrayBuffer::set_was_neutered(bool value) { | 6500 void JSArrayBuffer::set_was_neutered(bool value) { |
6483 set_bit_field(WasNeutered::update(bit_field(), value)); | 6501 set_bit_field(WasNeutered::update(bit_field(), value)); |
6484 } | 6502 } |
6485 | 6503 |
6486 | 6504 |
| 6505 bool JSArrayBuffer::is_shared() { |
| 6506 return map()->instance_type() == JS_SHARED_ARRAY_BUFFER_TYPE; |
| 6507 } |
| 6508 |
| 6509 |
6487 Object* JSArrayBufferView::byte_offset() const { | 6510 Object* JSArrayBufferView::byte_offset() const { |
6488 if (WasNeutered()) return Smi::FromInt(0); | 6511 if (WasNeutered()) return Smi::FromInt(0); |
6489 return Object::cast(READ_FIELD(this, kByteOffsetOffset)); | 6512 return Object::cast(READ_FIELD(this, kByteOffsetOffset)); |
6490 } | 6513 } |
6491 | 6514 |
6492 | 6515 |
6493 void JSArrayBufferView::set_byte_offset(Object* value, WriteBarrierMode mode) { | 6516 void JSArrayBufferView::set_byte_offset(Object* value, WriteBarrierMode mode) { |
6494 WRITE_FIELD(this, kByteOffsetOffset, value); | 6517 WRITE_FIELD(this, kByteOffsetOffset, value); |
6495 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kByteOffsetOffset, value, mode); | 6518 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kByteOffsetOffset, value, mode); |
6496 } | 6519 } |
(...skipping 16 matching lines...) Expand all Loading... |
6513 ACCESSORS(JSArrayBufferView, raw_byte_offset, Object, kByteOffsetOffset) | 6536 ACCESSORS(JSArrayBufferView, raw_byte_offset, Object, kByteOffsetOffset) |
6514 ACCESSORS(JSArrayBufferView, raw_byte_length, Object, kByteLengthOffset) | 6537 ACCESSORS(JSArrayBufferView, raw_byte_length, Object, kByteLengthOffset) |
6515 #endif | 6538 #endif |
6516 | 6539 |
6517 | 6540 |
6518 bool JSArrayBufferView::WasNeutered() const { | 6541 bool JSArrayBufferView::WasNeutered() const { |
6519 return JSArrayBuffer::cast(buffer())->was_neutered(); | 6542 return JSArrayBuffer::cast(buffer())->was_neutered(); |
6520 } | 6543 } |
6521 | 6544 |
6522 | 6545 |
| 6546 bool JSArrayBufferView::is_shared() const { |
| 6547 return map()->instance_type() == JS_SHARED_TYPED_ARRAY_TYPE; |
| 6548 } |
| 6549 |
| 6550 |
6523 Object* JSTypedArray::length() const { | 6551 Object* JSTypedArray::length() const { |
6524 if (WasNeutered()) return Smi::FromInt(0); | 6552 if (WasNeutered()) return Smi::FromInt(0); |
6525 return Object::cast(READ_FIELD(this, kLengthOffset)); | 6553 return Object::cast(READ_FIELD(this, kLengthOffset)); |
6526 } | 6554 } |
6527 | 6555 |
6528 | 6556 |
6529 void JSTypedArray::set_length(Object* value, WriteBarrierMode mode) { | 6557 void JSTypedArray::set_length(Object* value, WriteBarrierMode mode) { |
6530 WRITE_FIELD(this, kLengthOffset, value); | 6558 WRITE_FIELD(this, kLengthOffset, value); |
6531 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kLengthOffset, value, mode); | 6559 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kLengthOffset, value, mode); |
6532 } | 6560 } |
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7627 #undef READ_SHORT_FIELD | 7655 #undef READ_SHORT_FIELD |
7628 #undef WRITE_SHORT_FIELD | 7656 #undef WRITE_SHORT_FIELD |
7629 #undef READ_BYTE_FIELD | 7657 #undef READ_BYTE_FIELD |
7630 #undef WRITE_BYTE_FIELD | 7658 #undef WRITE_BYTE_FIELD |
7631 #undef NOBARRIER_READ_BYTE_FIELD | 7659 #undef NOBARRIER_READ_BYTE_FIELD |
7632 #undef NOBARRIER_WRITE_BYTE_FIELD | 7660 #undef NOBARRIER_WRITE_BYTE_FIELD |
7633 | 7661 |
7634 } } // namespace v8::internal | 7662 } } // namespace v8::internal |
7635 | 7663 |
7636 #endif // V8_OBJECTS_INL_H_ | 7664 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |