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 5515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6638 ElementsKind JSObject::GetElementsKind() { | 6645 ElementsKind JSObject::GetElementsKind() { |
6639 ElementsKind kind = map()->elements_kind(); | 6646 ElementsKind kind = map()->elements_kind(); |
6640 #if VERIFY_HEAP && DEBUG | 6647 #if VERIFY_HEAP && DEBUG |
6641 FixedArrayBase* fixed_array = | 6648 FixedArrayBase* fixed_array = |
6642 reinterpret_cast<FixedArrayBase*>(READ_FIELD(this, kElementsOffset)); | 6649 reinterpret_cast<FixedArrayBase*>(READ_FIELD(this, kElementsOffset)); |
6643 | 6650 |
6644 // If a GC was caused while constructing this object, the elements | 6651 // If a GC was caused while constructing this object, the elements |
6645 // pointer may point to a one pointer filler map. | 6652 // pointer may point to a one pointer filler map. |
6646 if (ElementsAreSafeToExamine()) { | 6653 if (ElementsAreSafeToExamine()) { |
6647 Map* map = fixed_array->map(); | 6654 Map* map = fixed_array->map(); |
6648 DCHECK((IsFastSmiOrObjectElementsKind(kind) && | 6655 if (IsFastSmiOrObjectElementsKind(kind)) { |
6649 (map == GetHeap()->fixed_array_map() || | 6656 DCHECK(map == GetHeap()->fixed_array_map() || |
6650 map == GetHeap()->fixed_cow_array_map())) || | 6657 map == GetHeap()->fixed_cow_array_map()); |
6651 (IsFastDoubleElementsKind(kind) && | 6658 } else if (IsFastDoubleElementsKind(kind)) { |
6652 (fixed_array->IsFixedDoubleArray() || | 6659 DCHECK(fixed_array->IsFixedDoubleArray() || |
6653 fixed_array == GetHeap()->empty_fixed_array())) || | 6660 fixed_array == GetHeap()->empty_fixed_array()); |
6654 (kind == DICTIONARY_ELEMENTS && | 6661 } else if (kind == DICTIONARY_ELEMENTS) { |
6655 fixed_array->IsFixedArray() && | 6662 DCHECK(fixed_array->IsFixedArray()); |
6656 fixed_array->IsDictionary()) || | 6663 DCHECK(fixed_array->IsDictionary()); |
6657 (kind > DICTIONARY_ELEMENTS)); | 6664 } else { |
| 6665 DCHECK(kind > DICTIONARY_ELEMENTS); |
| 6666 } |
6658 DCHECK(!IsSloppyArgumentsElements(kind) || | 6667 DCHECK(!IsSloppyArgumentsElements(kind) || |
6659 (elements()->IsFixedArray() && elements()->length() >= 2)); | 6668 (elements()->IsFixedArray() && elements()->length() >= 2)); |
6660 } | 6669 } |
6661 #endif | 6670 #endif |
6662 return kind; | 6671 return kind; |
6663 } | 6672 } |
6664 | 6673 |
6665 | 6674 |
6666 bool JSObject::HasFastObjectElements() { | 6675 bool JSObject::HasFastObjectElements() { |
6667 return IsFastObjectElementsKind(GetElementsKind()); | 6676 return IsFastObjectElementsKind(GetElementsKind()); |
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7842 #undef WRITE_INT64_FIELD | 7851 #undef WRITE_INT64_FIELD |
7843 #undef READ_BYTE_FIELD | 7852 #undef READ_BYTE_FIELD |
7844 #undef WRITE_BYTE_FIELD | 7853 #undef WRITE_BYTE_FIELD |
7845 #undef NOBARRIER_READ_BYTE_FIELD | 7854 #undef NOBARRIER_READ_BYTE_FIELD |
7846 #undef NOBARRIER_WRITE_BYTE_FIELD | 7855 #undef NOBARRIER_WRITE_BYTE_FIELD |
7847 | 7856 |
7848 } // namespace internal | 7857 } // namespace internal |
7849 } // namespace v8 | 7858 } // namespace v8 |
7850 | 7859 |
7851 #endif // V8_OBJECTS_INL_H_ | 7860 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |