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 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1948 return JSBuiltinsObject::kSize; | 1964 return JSBuiltinsObject::kSize; |
1949 case JS_FUNCTION_TYPE: | 1965 case JS_FUNCTION_TYPE: |
1950 return JSFunction::kSize; | 1966 return JSFunction::kSize; |
1951 case JS_VALUE_TYPE: | 1967 case JS_VALUE_TYPE: |
1952 return JSValue::kSize; | 1968 return JSValue::kSize; |
1953 case JS_DATE_TYPE: | 1969 case JS_DATE_TYPE: |
1954 return JSDate::kSize; | 1970 return JSDate::kSize; |
1955 case JS_ARRAY_TYPE: | 1971 case JS_ARRAY_TYPE: |
1956 return JSArray::kSize; | 1972 return JSArray::kSize; |
1957 case JS_ARRAY_BUFFER_TYPE: | 1973 case JS_ARRAY_BUFFER_TYPE: |
| 1974 case JS_SHARED_ARRAY_BUFFER_TYPE: |
1958 return JSArrayBuffer::kSize; | 1975 return JSArrayBuffer::kSize; |
1959 case JS_TYPED_ARRAY_TYPE: | 1976 case JS_TYPED_ARRAY_TYPE: |
| 1977 case JS_SHARED_TYPED_ARRAY_TYPE: |
1960 return JSTypedArray::kSize; | 1978 return JSTypedArray::kSize; |
1961 case JS_DATA_VIEW_TYPE: | 1979 case JS_DATA_VIEW_TYPE: |
1962 return JSDataView::kSize; | 1980 return JSDataView::kSize; |
1963 case JS_SET_TYPE: | 1981 case JS_SET_TYPE: |
1964 return JSSet::kSize; | 1982 return JSSet::kSize; |
1965 case JS_MAP_TYPE: | 1983 case JS_MAP_TYPE: |
1966 return JSMap::kSize; | 1984 return JSMap::kSize; |
1967 case JS_SET_ITERATOR_TYPE: | 1985 case JS_SET_ITERATOR_TYPE: |
1968 return JSSetIterator::kSize; | 1986 return JSSetIterator::kSize; |
1969 case JS_MAP_ITERATOR_TYPE: | 1987 case JS_MAP_ITERATOR_TYPE: |
(...skipping 4490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6460 bool JSArrayBuffer::was_neutered() { | 6478 bool JSArrayBuffer::was_neutered() { |
6461 return BooleanBit::get(flag(), kWasNeuteredBit); | 6479 return BooleanBit::get(flag(), kWasNeuteredBit); |
6462 } | 6480 } |
6463 | 6481 |
6464 | 6482 |
6465 void JSArrayBuffer::set_was_neutered(bool value) { | 6483 void JSArrayBuffer::set_was_neutered(bool value) { |
6466 set_flag(BooleanBit::set(flag(), kWasNeuteredBit, value)); | 6484 set_flag(BooleanBit::set(flag(), kWasNeuteredBit, value)); |
6467 } | 6485 } |
6468 | 6486 |
6469 | 6487 |
| 6488 SharedFlag JSArrayBuffer::is_shared() { |
| 6489 return map()->instance_type() == JS_SHARED_ARRAY_BUFFER_TYPE ? SHARED |
| 6490 : NOT_SHARED; |
| 6491 } |
| 6492 |
| 6493 |
6470 ACCESSORS(JSArrayBuffer, weak_next, Object, kWeakNextOffset) | 6494 ACCESSORS(JSArrayBuffer, weak_next, Object, kWeakNextOffset) |
6471 | 6495 |
6472 | 6496 |
6473 Object* JSArrayBufferView::byte_offset() const { | 6497 Object* JSArrayBufferView::byte_offset() const { |
6474 if (WasNeutered()) return Smi::FromInt(0); | 6498 if (WasNeutered()) return Smi::FromInt(0); |
6475 return Object::cast(READ_FIELD(this, kByteOffsetOffset)); | 6499 return Object::cast(READ_FIELD(this, kByteOffsetOffset)); |
6476 } | 6500 } |
6477 | 6501 |
6478 | 6502 |
6479 void JSArrayBufferView::set_byte_offset(Object* value, WriteBarrierMode mode) { | 6503 void JSArrayBufferView::set_byte_offset(Object* value, WriteBarrierMode mode) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6516 WRITE_FIELD(this, kLengthOffset, value); | 6540 WRITE_FIELD(this, kLengthOffset, value); |
6517 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kLengthOffset, value, mode); | 6541 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kLengthOffset, value, mode); |
6518 } | 6542 } |
6519 | 6543 |
6520 | 6544 |
6521 #ifdef VERIFY_HEAP | 6545 #ifdef VERIFY_HEAP |
6522 ACCESSORS(JSTypedArray, raw_length, Object, kLengthOffset) | 6546 ACCESSORS(JSTypedArray, raw_length, Object, kLengthOffset) |
6523 #endif | 6547 #endif |
6524 | 6548 |
6525 | 6549 |
| 6550 SharedFlag JSTypedArray::is_shared() const { |
| 6551 return map()->instance_type() == JS_SHARED_TYPED_ARRAY_TYPE ? SHARED |
| 6552 : NOT_SHARED; |
| 6553 } |
| 6554 |
| 6555 |
6526 ACCESSORS(JSRegExp, data, Object, kDataOffset) | 6556 ACCESSORS(JSRegExp, data, Object, kDataOffset) |
6527 | 6557 |
6528 | 6558 |
6529 JSRegExp::Type JSRegExp::TypeTag() { | 6559 JSRegExp::Type JSRegExp::TypeTag() { |
6530 Object* data = this->data(); | 6560 Object* data = this->data(); |
6531 if (data->IsUndefined()) return JSRegExp::NOT_COMPILED; | 6561 if (data->IsUndefined()) return JSRegExp::NOT_COMPILED; |
6532 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex)); | 6562 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex)); |
6533 return static_cast<JSRegExp::Type>(smi->value()); | 6563 return static_cast<JSRegExp::Type>(smi->value()); |
6534 } | 6564 } |
6535 | 6565 |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7603 #undef READ_SHORT_FIELD | 7633 #undef READ_SHORT_FIELD |
7604 #undef WRITE_SHORT_FIELD | 7634 #undef WRITE_SHORT_FIELD |
7605 #undef READ_BYTE_FIELD | 7635 #undef READ_BYTE_FIELD |
7606 #undef WRITE_BYTE_FIELD | 7636 #undef WRITE_BYTE_FIELD |
7607 #undef NOBARRIER_READ_BYTE_FIELD | 7637 #undef NOBARRIER_READ_BYTE_FIELD |
7608 #undef NOBARRIER_WRITE_BYTE_FIELD | 7638 #undef NOBARRIER_WRITE_BYTE_FIELD |
7609 | 7639 |
7610 } } // namespace v8::internal | 7640 } } // namespace v8::internal |
7611 | 7641 |
7612 #endif // V8_OBJECTS_INL_H_ | 7642 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |