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