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 // |
11 | 11 |
12 #ifndef V8_OBJECTS_INL_H_ | 12 #ifndef V8_OBJECTS_INL_H_ |
13 #define V8_OBJECTS_INL_H_ | 13 #define V8_OBJECTS_INL_H_ |
14 | 14 |
15 #include "src/base/atomicops.h" | 15 #include "src/base/atomicops.h" |
16 #include "src/base/bits.h" | 16 #include "src/base/bits.h" |
17 #include "src/contexts-inl.h" | 17 #include "src/contexts-inl.h" |
18 #include "src/conversions-inl.h" | 18 #include "src/conversions-inl.h" |
19 #include "src/factory.h" | 19 #include "src/factory.h" |
20 #include "src/field-index-inl.h" | 20 #include "src/field-index-inl.h" |
21 #include "src/handles-inl.h" | 21 #include "src/handles-inl.h" |
22 #include "src/heap/heap-inl.h" | 22 #include "src/heap/heap-inl.h" |
23 #include "src/heap/heap.h" | 23 #include "src/heap/heap.h" |
| 24 #include "src/isolate.h" |
24 #include "src/isolate-inl.h" | 25 #include "src/isolate-inl.h" |
25 #include "src/isolate.h" | |
26 #include "src/keys.h" | |
27 #include "src/layout-descriptor-inl.h" | 26 #include "src/layout-descriptor-inl.h" |
28 #include "src/lookup.h" | 27 #include "src/lookup.h" |
29 #include "src/objects.h" | 28 #include "src/objects.h" |
30 #include "src/property.h" | 29 #include "src/property.h" |
31 #include "src/prototype.h" | 30 #include "src/prototype.h" |
32 #include "src/transitions-inl.h" | 31 #include "src/transitions-inl.h" |
33 #include "src/type-feedback-vector-inl.h" | 32 #include "src/type-feedback-vector-inl.h" |
34 #include "src/v8memory.h" | 33 #include "src/v8memory.h" |
35 | 34 |
36 namespace v8 { | 35 namespace v8 { |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 return PrototypeIterator::GetCurrent(iter); | 1103 return PrototypeIterator::GetCurrent(iter); |
1105 } | 1104 } |
1106 | 1105 |
1107 MaybeHandle<Object> JSReceiver::GetProperty(Isolate* isolate, | 1106 MaybeHandle<Object> JSReceiver::GetProperty(Isolate* isolate, |
1108 Handle<JSReceiver> receiver, | 1107 Handle<JSReceiver> receiver, |
1109 const char* name) { | 1108 const char* name) { |
1110 Handle<String> str = isolate->factory()->InternalizeUtf8String(name); | 1109 Handle<String> str = isolate->factory()->InternalizeUtf8String(name); |
1111 return GetProperty(receiver, str); | 1110 return GetProperty(receiver, str); |
1112 } | 1111 } |
1113 | 1112 |
1114 // static | |
1115 MUST_USE_RESULT MaybeHandle<FixedArray> JSReceiver::OwnPropertyKeys( | |
1116 Handle<JSReceiver> object) { | |
1117 return KeyAccumulator::GetKeys(object, OWN_ONLY, ALL_PROPERTIES, | |
1118 CONVERT_TO_STRING); | |
1119 } | |
1120 | 1113 |
1121 #define FIELD_ADDR(p, offset) \ | 1114 #define FIELD_ADDR(p, offset) \ |
1122 (reinterpret_cast<byte*>(p) + offset - kHeapObjectTag) | 1115 (reinterpret_cast<byte*>(p) + offset - kHeapObjectTag) |
1123 | 1116 |
1124 #define FIELD_ADDR_CONST(p, offset) \ | 1117 #define FIELD_ADDR_CONST(p, offset) \ |
1125 (reinterpret_cast<const byte*>(p) + offset - kHeapObjectTag) | 1118 (reinterpret_cast<const byte*>(p) + offset - kHeapObjectTag) |
1126 | 1119 |
1127 #define READ_FIELD(p, offset) \ | 1120 #define READ_FIELD(p, offset) \ |
1128 (*reinterpret_cast<Object* const*>(FIELD_ADDR_CONST(p, offset))) | 1121 (*reinterpret_cast<Object* const*>(FIELD_ADDR_CONST(p, offset))) |
1129 | 1122 |
(...skipping 5515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6645 ElementsKind JSObject::GetElementsKind() { | 6638 ElementsKind JSObject::GetElementsKind() { |
6646 ElementsKind kind = map()->elements_kind(); | 6639 ElementsKind kind = map()->elements_kind(); |
6647 #if VERIFY_HEAP && DEBUG | 6640 #if VERIFY_HEAP && DEBUG |
6648 FixedArrayBase* fixed_array = | 6641 FixedArrayBase* fixed_array = |
6649 reinterpret_cast<FixedArrayBase*>(READ_FIELD(this, kElementsOffset)); | 6642 reinterpret_cast<FixedArrayBase*>(READ_FIELD(this, kElementsOffset)); |
6650 | 6643 |
6651 // If a GC was caused while constructing this object, the elements | 6644 // If a GC was caused while constructing this object, the elements |
6652 // pointer may point to a one pointer filler map. | 6645 // pointer may point to a one pointer filler map. |
6653 if (ElementsAreSafeToExamine()) { | 6646 if (ElementsAreSafeToExamine()) { |
6654 Map* map = fixed_array->map(); | 6647 Map* map = fixed_array->map(); |
6655 if (IsFastSmiOrObjectElementsKind(kind)) { | 6648 DCHECK((IsFastSmiOrObjectElementsKind(kind) && |
6656 DCHECK(map == GetHeap()->fixed_array_map() || | 6649 (map == GetHeap()->fixed_array_map() || |
6657 map == GetHeap()->fixed_cow_array_map()); | 6650 map == GetHeap()->fixed_cow_array_map())) || |
6658 } else if (IsFastDoubleElementsKind(kind)) { | 6651 (IsFastDoubleElementsKind(kind) && |
6659 DCHECK(fixed_array->IsFixedDoubleArray() || | 6652 (fixed_array->IsFixedDoubleArray() || |
6660 fixed_array == GetHeap()->empty_fixed_array()); | 6653 fixed_array == GetHeap()->empty_fixed_array())) || |
6661 } else if (kind == DICTIONARY_ELEMENTS) { | 6654 (kind == DICTIONARY_ELEMENTS && |
6662 DCHECK(fixed_array->IsFixedArray()); | 6655 fixed_array->IsFixedArray() && |
6663 DCHECK(fixed_array->IsDictionary()); | 6656 fixed_array->IsDictionary()) || |
6664 } else { | 6657 (kind > DICTIONARY_ELEMENTS)); |
6665 DCHECK(kind > DICTIONARY_ELEMENTS); | |
6666 } | |
6667 DCHECK(!IsSloppyArgumentsElements(kind) || | 6658 DCHECK(!IsSloppyArgumentsElements(kind) || |
6668 (elements()->IsFixedArray() && elements()->length() >= 2)); | 6659 (elements()->IsFixedArray() && elements()->length() >= 2)); |
6669 } | 6660 } |
6670 #endif | 6661 #endif |
6671 return kind; | 6662 return kind; |
6672 } | 6663 } |
6673 | 6664 |
6674 | 6665 |
6675 bool JSObject::HasFastObjectElements() { | 6666 bool JSObject::HasFastObjectElements() { |
6676 return IsFastObjectElementsKind(GetElementsKind()); | 6667 return IsFastObjectElementsKind(GetElementsKind()); |
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7851 #undef WRITE_INT64_FIELD | 7842 #undef WRITE_INT64_FIELD |
7852 #undef READ_BYTE_FIELD | 7843 #undef READ_BYTE_FIELD |
7853 #undef WRITE_BYTE_FIELD | 7844 #undef WRITE_BYTE_FIELD |
7854 #undef NOBARRIER_READ_BYTE_FIELD | 7845 #undef NOBARRIER_READ_BYTE_FIELD |
7855 #undef NOBARRIER_WRITE_BYTE_FIELD | 7846 #undef NOBARRIER_WRITE_BYTE_FIELD |
7856 | 7847 |
7857 } // namespace internal | 7848 } // namespace internal |
7858 } // namespace v8 | 7849 } // namespace v8 |
7859 | 7850 |
7860 #endif // V8_OBJECTS_INL_H_ | 7851 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |