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 #include "src/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 3849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3860 while (!tmpl_info->IsTemplateFor(iter.GetCurrent())) { | 3860 while (!tmpl_info->IsTemplateFor(iter.GetCurrent())) { |
3861 iter.Advance(); | 3861 iter.Advance(); |
3862 if (iter.IsAtEnd()) { | 3862 if (iter.IsAtEnd()) { |
3863 return Local<Object>(); | 3863 return Local<Object>(); |
3864 } | 3864 } |
3865 } | 3865 } |
3866 // IsTemplateFor() ensures that iter.GetCurrent() can't be a Proxy here. | 3866 // IsTemplateFor() ensures that iter.GetCurrent() can't be a Proxy here. |
3867 return Utils::ToLocal(i::handle(iter.GetCurrent<i::JSObject>(), isolate)); | 3867 return Utils::ToLocal(i::handle(iter.GetCurrent<i::JSObject>(), isolate)); |
3868 } | 3868 } |
3869 | 3869 |
| 3870 MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context) { |
| 3871 return GetPropertyNames( |
| 3872 context, v8::KeyCollectionMode::kIncludePrototypes, |
| 3873 static_cast<v8::PropertyFilter>(ONLY_ENUMERABLE | SKIP_SYMBOLS), |
| 3874 v8::IndexFilter::kIncludeIndices); |
| 3875 } |
3870 | 3876 |
3871 MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context) { | 3877 MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context, |
| 3878 KeyCollectionMode mode, |
| 3879 PropertyFilter property_filter, |
| 3880 IndexFilter index_filter) { |
3872 PREPARE_FOR_EXECUTION(context, Object, GetPropertyNames, Array); | 3881 PREPARE_FOR_EXECUTION(context, Object, GetPropertyNames, Array); |
3873 auto self = Utils::OpenHandle(this); | 3882 auto self = Utils::OpenHandle(this); |
3874 i::Handle<i::FixedArray> value; | 3883 i::Handle<i::FixedArray> value; |
3875 has_pending_exception = !i::KeyAccumulator::GetKeys(self, i::INCLUDE_PROTOS, | 3884 i::KeyAccumulator accumulator( |
3876 i::ENUMERABLE_STRINGS) | 3885 isolate, static_cast<i::KeyCollectionMode>(mode), |
3877 .ToHandle(&value); | 3886 static_cast<i::PropertyFilter>(property_filter)); |
| 3887 accumulator.set_skip_indices(index_filter == IndexFilter::kSkipIndices); |
| 3888 has_pending_exception = accumulator.CollectKeys(self, self).IsNothing(); |
3878 RETURN_ON_FAILED_EXECUTION(Array); | 3889 RETURN_ON_FAILED_EXECUTION(Array); |
| 3890 value = accumulator.GetKeys(i::GetKeysConversion::kKeepNumbers); |
3879 DCHECK(self->map()->EnumLength() == i::kInvalidEnumCacheSentinel || | 3891 DCHECK(self->map()->EnumLength() == i::kInvalidEnumCacheSentinel || |
3880 self->map()->EnumLength() == 0 || | 3892 self->map()->EnumLength() == 0 || |
3881 self->map()->instance_descriptors()->GetEnumCache() != *value); | 3893 self->map()->instance_descriptors()->GetEnumCache() != *value); |
3882 auto result = isolate->factory()->NewJSArrayWithElements(value); | 3894 auto result = isolate->factory()->NewJSArrayWithElements(value); |
3883 RETURN_ESCAPED(Utils::ToLocal(result)); | 3895 RETURN_ESCAPED(Utils::ToLocal(result)); |
3884 } | 3896 } |
3885 | 3897 |
3886 | 3898 |
3887 Local<Array> v8::Object::GetPropertyNames() { | 3899 Local<Array> v8::Object::GetPropertyNames() { |
3888 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3900 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3889 RETURN_TO_LOCAL_UNCHECKED(GetPropertyNames(context), Array); | 3901 RETURN_TO_LOCAL_UNCHECKED(GetPropertyNames(context), Array); |
3890 } | 3902 } |
3891 | 3903 |
3892 MaybeLocal<Array> v8::Object::GetOwnPropertyNames(Local<Context> context) { | 3904 MaybeLocal<Array> v8::Object::GetOwnPropertyNames(Local<Context> context) { |
3893 return GetOwnPropertyNames( | 3905 return GetOwnPropertyNames( |
3894 context, static_cast<v8::PropertyFilter>(ONLY_ENUMERABLE | SKIP_SYMBOLS)); | 3906 context, static_cast<v8::PropertyFilter>(ONLY_ENUMERABLE | SKIP_SYMBOLS)); |
3895 } | 3907 } |
3896 | 3908 |
3897 Local<Array> v8::Object::GetOwnPropertyNames() { | 3909 Local<Array> v8::Object::GetOwnPropertyNames() { |
3898 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3910 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3899 RETURN_TO_LOCAL_UNCHECKED(GetOwnPropertyNames(context), Array); | 3911 RETURN_TO_LOCAL_UNCHECKED(GetOwnPropertyNames(context), Array); |
3900 } | 3912 } |
3901 | 3913 |
3902 MaybeLocal<Array> v8::Object::GetOwnPropertyNames(Local<Context> context, | 3914 MaybeLocal<Array> v8::Object::GetOwnPropertyNames(Local<Context> context, |
3903 PropertyFilter filter) { | 3915 PropertyFilter filter) { |
3904 PREPARE_FOR_EXECUTION(context, Object, GetOwnPropertyNames, Array); | 3916 return GetPropertyNames(context, KeyCollectionMode::kOwnOnly, filter, |
3905 auto self = Utils::OpenHandle(this); | 3917 v8::IndexFilter::kIncludeIndices); |
3906 i::Handle<i::FixedArray> value; | |
3907 has_pending_exception = | |
3908 !i::KeyAccumulator::GetKeys(self, i::OWN_ONLY, | |
3909 static_cast<i::PropertyFilter>(filter)) | |
3910 .ToHandle(&value); | |
3911 RETURN_ON_FAILED_EXECUTION(Array); | |
3912 DCHECK(self->map()->EnumLength() == i::kInvalidEnumCacheSentinel || | |
3913 self->map()->EnumLength() == 0 || | |
3914 self->map()->instance_descriptors()->GetEnumCache() != *value); | |
3915 auto result = isolate->factory()->NewJSArrayWithElements(value); | |
3916 RETURN_ESCAPED(Utils::ToLocal(result)); | |
3917 } | 3918 } |
3918 | 3919 |
3919 MaybeLocal<String> v8::Object::ObjectProtoToString(Local<Context> context) { | 3920 MaybeLocal<String> v8::Object::ObjectProtoToString(Local<Context> context) { |
3920 PREPARE_FOR_EXECUTION(context, Object, ObjectProtoToString, String); | 3921 PREPARE_FOR_EXECUTION(context, Object, ObjectProtoToString, String); |
3921 auto obj = Utils::OpenHandle(this); | 3922 auto obj = Utils::OpenHandle(this); |
3922 Local<String> result; | 3923 Local<String> result; |
3923 has_pending_exception = | 3924 has_pending_exception = |
3924 !ToLocal<String>(i::JSObject::ObjectProtoToString(isolate, obj), &result); | 3925 !ToLocal<String>(i::JSObject::ObjectProtoToString(isolate, obj), &result); |
3925 RETURN_ON_FAILED_EXECUTION(String); | 3926 RETURN_ON_FAILED_EXECUTION(String); |
3926 RETURN_ESCAPED(result); | 3927 RETURN_ESCAPED(result); |
(...skipping 4883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8810 Address callback_address = | 8811 Address callback_address = |
8811 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8812 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8812 VMState<EXTERNAL> state(isolate); | 8813 VMState<EXTERNAL> state(isolate); |
8813 ExternalCallbackScope call_scope(isolate, callback_address); | 8814 ExternalCallbackScope call_scope(isolate, callback_address); |
8814 callback(info); | 8815 callback(info); |
8815 } | 8816 } |
8816 | 8817 |
8817 | 8818 |
8818 } // namespace internal | 8819 } // namespace internal |
8819 } // namespace v8 | 8820 } // namespace v8 |
OLD | NEW |