Plumb Isolate through own property enumeration functions
Currently the Isolate is gotten off of the object that the operation is being performed on. Shared objects return the shared Isolate, which is incorrect as it shouldn't be used to run JS, nor does it have HandleScopes open. Plumb the executing Isolate through. Bug: v8:12547 Change-Id: I3d960751c798ac657a6122598154e36d9d504c31 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3606489 Reviewed-by: Adam Klein <adamk@chromium.org> Commit-Queue: Shu-yu Guo <syg@chromium.org> Cr-Commit-Position: refs/heads/main@{#80163}
This commit is contained in:
parent
3eead7e32e
commit
0407423bd0
@ -280,8 +280,8 @@ Object GetOwnPropertyKeys(Isolate* isolate, BuiltinArguments args,
|
||||
Handle<FixedArray> keys;
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, keys,
|
||||
KeyAccumulator::GetKeys(receiver, KeyCollectionMode::kOwnOnly, filter,
|
||||
GetKeysConversion::kConvertToString));
|
||||
KeyAccumulator::GetKeys(isolate, receiver, KeyCollectionMode::kOwnOnly,
|
||||
filter, GetKeysConversion::kConvertToString));
|
||||
return *isolate->factory()->NewJSArrayWithElements(keys);
|
||||
}
|
||||
|
||||
@ -326,9 +326,10 @@ BUILTIN(ObjectGetOwnPropertyDescriptors) {
|
||||
|
||||
Handle<FixedArray> keys;
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, keys, KeyAccumulator::GetKeys(
|
||||
receiver, KeyCollectionMode::kOwnOnly, ALL_PROPERTIES,
|
||||
GetKeysConversion::kConvertToString));
|
||||
isolate, keys,
|
||||
KeyAccumulator::GetKeys(isolate, receiver, KeyCollectionMode::kOwnOnly,
|
||||
ALL_PROPERTIES,
|
||||
GetKeysConversion::kConvertToString));
|
||||
|
||||
Handle<JSObject> descriptors =
|
||||
isolate->factory()->NewJSObject(isolate->object_function());
|
||||
|
@ -88,7 +88,7 @@ BUILTIN(ReflectOwnKeys) {
|
||||
Handle<FixedArray> keys;
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, keys,
|
||||
KeyAccumulator::GetKeys(Handle<JSReceiver>::cast(target),
|
||||
KeyAccumulator::GetKeys(isolate, Handle<JSReceiver>::cast(target),
|
||||
KeyCollectionMode::kOwnOnly, ALL_PROPERTIES,
|
||||
GetKeysConversion::kConvertToString));
|
||||
return *isolate->factory()->NewJSArrayWithElements(keys);
|
||||
|
@ -30,7 +30,7 @@ BUILTIN(WebSnapshotSerialize) {
|
||||
block_list_js_array = args.at<JSArray>(2);
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, block_list,
|
||||
JSReceiver::GetOwnValues(block_list_js_array,
|
||||
JSReceiver::GetOwnValues(isolate, block_list_js_array,
|
||||
PropertyFilter::ENUMERABLE_STRINGS));
|
||||
}
|
||||
|
||||
@ -98,7 +98,8 @@ BUILTIN(WebSnapshotDeserialize) {
|
||||
auto js_array = args.at<JSArray>(2);
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, injected_references,
|
||||
JSReceiver::GetOwnValues(js_array, PropertyFilter::ENUMERABLE_STRINGS));
|
||||
JSReceiver::GetOwnValues(isolate, js_array,
|
||||
PropertyFilter::ENUMERABLE_STRINGS));
|
||||
}
|
||||
|
||||
WebSnapshotDeserializer deserializer(reinterpret_cast<v8::Isolate*>(isolate),
|
||||
|
@ -275,7 +275,7 @@ void DebugEvaluate::ContextBuilder::UpdateValues() {
|
||||
for (ContextChainElement& element : context_chain_) {
|
||||
if (!element.materialized_object.is_null()) {
|
||||
Handle<FixedArray> keys =
|
||||
KeyAccumulator::GetKeys(element.materialized_object,
|
||||
KeyAccumulator::GetKeys(isolate_, element.materialized_object,
|
||||
KeyCollectionMode::kOwnOnly,
|
||||
ENUMERABLE_STRINGS)
|
||||
.ToHandleChecked();
|
||||
|
@ -194,8 +194,8 @@ bool GetPrivateMembers(Local<Context> context, Local<Object> object,
|
||||
i::Handle<i::FixedArray> keys;
|
||||
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
||||
isolate, keys,
|
||||
i::KeyAccumulator::GetKeys(receiver, i::KeyCollectionMode::kOwnOnly,
|
||||
key_filter,
|
||||
i::KeyAccumulator::GetKeys(isolate, receiver,
|
||||
i::KeyCollectionMode::kOwnOnly, key_filter,
|
||||
i::GetKeysConversion::kConvertToString),
|
||||
false);
|
||||
|
||||
|
@ -184,8 +184,9 @@ bool DebugPropertyIterator::FillKeysForCurrentPrototypeAndStage() {
|
||||
}
|
||||
PropertyFilter filter =
|
||||
stage_ == kEnumerableStrings ? ENUMERABLE_STRINGS : ALL_PROPERTIES;
|
||||
if (KeyAccumulator::GetKeys(receiver, KeyCollectionMode::kOwnOnly, filter,
|
||||
GetKeysConversion::kConvertToString, false,
|
||||
if (KeyAccumulator::GetKeys(isolate_, receiver, KeyCollectionMode::kOwnOnly,
|
||||
filter, GetKeysConversion::kConvertToString,
|
||||
false,
|
||||
skip_indices_ || receiver->IsJSTypedArray())
|
||||
.ToHandle(¤t_keys_)) {
|
||||
current_keys_length_ = current_keys_->length();
|
||||
|
@ -956,8 +956,8 @@ void ScopeIterator::VisitLocalScope(const Visitor& visitor, Mode mode,
|
||||
if (context_->extension_object().is_null()) return;
|
||||
Handle<JSObject> extension(context_->extension_object(), isolate_);
|
||||
Handle<FixedArray> keys =
|
||||
KeyAccumulator::GetKeys(extension, KeyCollectionMode::kOwnOnly,
|
||||
ENUMERABLE_STRINGS)
|
||||
KeyAccumulator::GetKeys(isolate_, extension,
|
||||
KeyCollectionMode::kOwnOnly, ENUMERABLE_STRINGS)
|
||||
.ToHandleChecked();
|
||||
|
||||
for (int i = 0; i < keys->length(); i++) {
|
||||
|
@ -4766,7 +4766,7 @@ MaybeHandle<FixedArray> Isolate::GetImportAssertionsFromArgument(
|
||||
Handle<JSReceiver>::cast(import_assertions_object);
|
||||
|
||||
Handle<FixedArray> assertion_keys;
|
||||
if (!KeyAccumulator::GetKeys(import_assertions_object_receiver,
|
||||
if (!KeyAccumulator::GetKeys(this, import_assertions_object_receiver,
|
||||
KeyCollectionMode::kOwnOnly, ENUMERABLE_STRINGS,
|
||||
GetKeysConversion::kConvertToString)
|
||||
.ToHandle(&assertion_keys)) {
|
||||
|
@ -161,7 +161,7 @@ MaybeHandle<Object> JsonParseInternalizer::InternalizeJsonProperty(
|
||||
Handle<FixedArray> contents;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(
|
||||
isolate_, contents,
|
||||
KeyAccumulator::GetKeys(object, KeyCollectionMode::kOwnOnly,
|
||||
KeyAccumulator::GetKeys(isolate_, object, KeyCollectionMode::kOwnOnly,
|
||||
ENUMERABLE_STRINGS,
|
||||
GetKeysConversion::kConvertToString),
|
||||
Object);
|
||||
|
@ -869,7 +869,7 @@ JsonStringifier::Result JsonStringifier::SerializeJSReceiverSlow(
|
||||
if (contents.is_null()) {
|
||||
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
||||
isolate_, contents,
|
||||
KeyAccumulator::GetKeys(object, KeyCollectionMode::kOwnOnly,
|
||||
KeyAccumulator::GetKeys(isolate_, object, KeyCollectionMode::kOwnOnly,
|
||||
ENUMERABLE_STRINGS,
|
||||
GetKeysConversion::kConvertToString),
|
||||
EXCEPTION);
|
||||
|
@ -116,8 +116,8 @@ MaybeHandle<Object> JSReceiver::GetProperty(Isolate* isolate,
|
||||
|
||||
// static
|
||||
V8_WARN_UNUSED_RESULT MaybeHandle<FixedArray> JSReceiver::OwnPropertyKeys(
|
||||
Handle<JSReceiver> object) {
|
||||
return KeyAccumulator::GetKeys(object, KeyCollectionMode::kOwnOnly,
|
||||
Isolate* isolate, Handle<JSReceiver> object) {
|
||||
return KeyAccumulator::GetKeys(isolate, object, KeyCollectionMode::kOwnOnly,
|
||||
ALL_PROPERTIES,
|
||||
GetKeysConversion::kConvertToString);
|
||||
}
|
||||
|
@ -378,8 +378,8 @@ Maybe<bool> JSReceiver::SetOrCopyDataProperties(
|
||||
Handle<FixedArray> keys;
|
||||
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
||||
isolate, keys,
|
||||
KeyAccumulator::GetKeys(from, KeyCollectionMode::kOwnOnly, ALL_PROPERTIES,
|
||||
GetKeysConversion::kKeepNumbers),
|
||||
KeyAccumulator::GetKeys(isolate, from, KeyCollectionMode::kOwnOnly,
|
||||
ALL_PROPERTIES, GetKeysConversion::kKeepNumbers),
|
||||
Nothing<bool>());
|
||||
|
||||
if (!from->HasFastProperties() && target->HasFastProperties() &&
|
||||
@ -1026,7 +1026,7 @@ MaybeHandle<Object> JSReceiver::DefineProperties(Isolate* isolate,
|
||||
Handle<FixedArray> keys;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(
|
||||
isolate, keys,
|
||||
KeyAccumulator::GetKeys(props, KeyCollectionMode::kOwnOnly,
|
||||
KeyAccumulator::GetKeys(isolate, props, KeyCollectionMode::kOwnOnly,
|
||||
ALL_PROPERTIES),
|
||||
Object);
|
||||
// 6. Let descriptors be an empty List.
|
||||
@ -1871,7 +1871,8 @@ Maybe<bool> JSReceiver::SetIntegrityLevel(Handle<JSReceiver> receiver,
|
||||
|
||||
Handle<FixedArray> keys;
|
||||
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
||||
isolate, keys, JSReceiver::OwnPropertyKeys(receiver), Nothing<bool>());
|
||||
isolate, keys, JSReceiver::OwnPropertyKeys(isolate, receiver),
|
||||
Nothing<bool>());
|
||||
|
||||
PropertyDescriptor no_conf;
|
||||
no_conf.set_configurable(false);
|
||||
@ -1922,7 +1923,8 @@ Maybe<bool> GenericTestIntegrityLevel(Handle<JSReceiver> receiver,
|
||||
|
||||
Handle<FixedArray> keys;
|
||||
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
||||
isolate, keys, JSReceiver::OwnPropertyKeys(receiver), Nothing<bool>());
|
||||
isolate, keys, JSReceiver::OwnPropertyKeys(isolate, receiver),
|
||||
Nothing<bool>());
|
||||
|
||||
for (int i = 0; i < keys->length(); ++i) {
|
||||
Handle<Object> key(keys->get(i), isolate);
|
||||
@ -2151,8 +2153,8 @@ MaybeHandle<FixedArray> GetOwnValuesOrEntries(Isolate* isolate,
|
||||
Handle<FixedArray> keys;
|
||||
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
||||
isolate, keys,
|
||||
KeyAccumulator::GetKeys(object, KeyCollectionMode::kOwnOnly, key_filter,
|
||||
GetKeysConversion::kConvertToString),
|
||||
KeyAccumulator::GetKeys(isolate, object, KeyCollectionMode::kOwnOnly,
|
||||
key_filter, GetKeysConversion::kConvertToString),
|
||||
MaybeHandle<FixedArray>());
|
||||
|
||||
values_or_entries = isolate->factory()->NewFixedArray(keys->length());
|
||||
@ -2190,18 +2192,18 @@ MaybeHandle<FixedArray> GetOwnValuesOrEntries(Isolate* isolate,
|
||||
return FixedArray::ShrinkOrEmpty(isolate, values_or_entries, length);
|
||||
}
|
||||
|
||||
MaybeHandle<FixedArray> JSReceiver::GetOwnValues(Handle<JSReceiver> object,
|
||||
MaybeHandle<FixedArray> JSReceiver::GetOwnValues(Isolate* isolate,
|
||||
Handle<JSReceiver> object,
|
||||
PropertyFilter filter,
|
||||
bool try_fast_path) {
|
||||
return GetOwnValuesOrEntries(object->GetIsolate(), object, filter,
|
||||
try_fast_path, false);
|
||||
return GetOwnValuesOrEntries(isolate, object, filter, try_fast_path, false);
|
||||
}
|
||||
|
||||
MaybeHandle<FixedArray> JSReceiver::GetOwnEntries(Handle<JSReceiver> object,
|
||||
MaybeHandle<FixedArray> JSReceiver::GetOwnEntries(Isolate* isolate,
|
||||
Handle<JSReceiver> object,
|
||||
PropertyFilter filter,
|
||||
bool try_fast_path) {
|
||||
return GetOwnValuesOrEntries(object->GetIsolate(), object, filter,
|
||||
try_fast_path, true);
|
||||
return GetOwnValuesOrEntries(isolate, object, filter, try_fast_path, true);
|
||||
}
|
||||
|
||||
Maybe<bool> JSReceiver::SetPrototype(Isolate* isolate,
|
||||
|
@ -289,14 +289,14 @@ class JSReceiver : public TorqueGeneratedJSReceiver<JSReceiver, HeapObject> {
|
||||
|
||||
// ES6 [[OwnPropertyKeys]] (modulo return type)
|
||||
V8_WARN_UNUSED_RESULT static inline MaybeHandle<FixedArray> OwnPropertyKeys(
|
||||
Handle<JSReceiver> object);
|
||||
Isolate* isolate, Handle<JSReceiver> object);
|
||||
|
||||
V8_WARN_UNUSED_RESULT static MaybeHandle<FixedArray> GetOwnValues(
|
||||
Handle<JSReceiver> object, PropertyFilter filter,
|
||||
Isolate* isolate, Handle<JSReceiver> object, PropertyFilter filter,
|
||||
bool try_fast_path = true);
|
||||
|
||||
V8_WARN_UNUSED_RESULT static MaybeHandle<FixedArray> GetOwnEntries(
|
||||
Handle<JSReceiver> object, PropertyFilter filter,
|
||||
Isolate* isolate, Handle<JSReceiver> object, PropertyFilter filter,
|
||||
bool try_fast_path = true);
|
||||
|
||||
static const int kHashMask = PropertyArray::HashField::kMask;
|
||||
|
@ -2915,7 +2915,7 @@ MaybeHandle<JSReceiver> DefaultMergeFields(
|
||||
Handle<FixedArray> original_keys;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(
|
||||
isolate, original_keys,
|
||||
KeyAccumulator::GetKeys(fields, KeyCollectionMode::kOwnOnly,
|
||||
KeyAccumulator::GetKeys(isolate, fields, KeyCollectionMode::kOwnOnly,
|
||||
ENUMERABLE_STRINGS,
|
||||
GetKeysConversion::kConvertToString),
|
||||
JSReceiver);
|
||||
@ -2948,8 +2948,8 @@ MaybeHandle<JSReceiver> DefaultMergeFields(
|
||||
Handle<FixedArray> new_keys;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(
|
||||
isolate, new_keys,
|
||||
KeyAccumulator::GetKeys(additional_fields, KeyCollectionMode::kOwnOnly,
|
||||
ENUMERABLE_STRINGS,
|
||||
KeyAccumulator::GetKeys(isolate, additional_fields,
|
||||
KeyCollectionMode::kOwnOnly, ENUMERABLE_STRINGS,
|
||||
GetKeysConversion::kConvertToString),
|
||||
JSReceiver);
|
||||
bool new_keys_has_month_or_month_code = false;
|
||||
|
@ -88,9 +88,9 @@ static Handle<FixedArray> CombineKeys(Isolate* isolate,
|
||||
|
||||
// static
|
||||
MaybeHandle<FixedArray> KeyAccumulator::GetKeys(
|
||||
Handle<JSReceiver> object, KeyCollectionMode mode, PropertyFilter filter,
|
||||
GetKeysConversion keys_conversion, bool is_for_in, bool skip_indices) {
|
||||
Isolate* isolate = object->GetIsolate();
|
||||
Isolate* isolate, Handle<JSReceiver> object, KeyCollectionMode mode,
|
||||
PropertyFilter filter, GetKeysConversion keys_conversion, bool is_for_in,
|
||||
bool skip_indices) {
|
||||
FastKeyAccumulator accumulator(isolate, object, mode, filter, is_for_in,
|
||||
skip_indices);
|
||||
return accumulator.GetKeys(keys_conversion);
|
||||
@ -1261,9 +1261,9 @@ Maybe<bool> KeyAccumulator::CollectOwnJSProxyKeys(Handle<JSReceiver> receiver,
|
||||
bool extensible_target = maybe_extensible.FromJust();
|
||||
// 11. Let targetKeys be ? target.[[OwnPropertyKeys]]().
|
||||
Handle<FixedArray> target_keys;
|
||||
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate_, target_keys,
|
||||
JSReceiver::OwnPropertyKeys(target),
|
||||
Nothing<bool>());
|
||||
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
||||
isolate_, target_keys, JSReceiver::OwnPropertyKeys(isolate_, target),
|
||||
Nothing<bool>());
|
||||
// 12, 13. (Assert)
|
||||
// 14. Let targetConfigurableKeys be an empty List.
|
||||
// To save memory, we're re-using target_keys and will modify it in-place.
|
||||
@ -1355,7 +1355,7 @@ Maybe<bool> KeyAccumulator::CollectOwnJSProxyTargetKeys(
|
||||
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
||||
isolate_, keys,
|
||||
KeyAccumulator::GetKeys(
|
||||
target, KeyCollectionMode::kOwnOnly, ALL_PROPERTIES,
|
||||
isolate_, target, KeyCollectionMode::kOwnOnly, ALL_PROPERTIES,
|
||||
GetKeysConversion::kConvertToString, is_for_in_, skip_indices_),
|
||||
Nothing<bool>());
|
||||
Maybe<bool> result = AddKeysFromJSProxy(proxy, keys);
|
||||
|
@ -56,7 +56,8 @@ class KeyAccumulator final {
|
||||
KeyAccumulator& operator=(const KeyAccumulator&) = delete;
|
||||
|
||||
static MaybeHandle<FixedArray> GetKeys(
|
||||
Handle<JSReceiver> object, KeyCollectionMode mode, PropertyFilter filter,
|
||||
Isolate* isolate, Handle<JSReceiver> object, KeyCollectionMode mode,
|
||||
PropertyFilter filter,
|
||||
GetKeysConversion keys_conversion = GetKeysConversion::kKeepNumbers,
|
||||
bool is_for_in = false, bool skip_indices = false);
|
||||
|
||||
|
@ -663,7 +663,7 @@ Maybe<bool> ValueSerializer::WriteJSObjectSlow(Handle<JSObject> object) {
|
||||
WriteTag(SerializationTag::kBeginJSObject);
|
||||
Handle<FixedArray> keys;
|
||||
uint32_t properties_written = 0;
|
||||
if (!KeyAccumulator::GetKeys(object, KeyCollectionMode::kOwnOnly,
|
||||
if (!KeyAccumulator::GetKeys(isolate_, object, KeyCollectionMode::kOwnOnly,
|
||||
ENUMERABLE_STRINGS)
|
||||
.ToHandle(&keys) ||
|
||||
!WriteJSObjectPropertiesSlow(object, keys).To(&properties_written)) {
|
||||
@ -756,7 +756,7 @@ Maybe<bool> ValueSerializer::WriteJSArray(Handle<JSArray> array) {
|
||||
}
|
||||
|
||||
Handle<FixedArray> keys;
|
||||
if (!KeyAccumulator::GetKeys(array, KeyCollectionMode::kOwnOnly,
|
||||
if (!KeyAccumulator::GetKeys(isolate_, array, KeyCollectionMode::kOwnOnly,
|
||||
ENUMERABLE_STRINGS,
|
||||
GetKeysConversion::kKeepNumbers, false, true)
|
||||
.ToHandle(&keys)) {
|
||||
@ -775,7 +775,7 @@ Maybe<bool> ValueSerializer::WriteJSArray(Handle<JSArray> array) {
|
||||
WriteVarint<uint32_t>(length);
|
||||
Handle<FixedArray> keys;
|
||||
uint32_t properties_written = 0;
|
||||
if (!KeyAccumulator::GetKeys(array, KeyCollectionMode::kOwnOnly,
|
||||
if (!KeyAccumulator::GetKeys(isolate_, array, KeyCollectionMode::kOwnOnly,
|
||||
ENUMERABLE_STRINGS)
|
||||
.ToHandle(&keys) ||
|
||||
!WriteJSObjectPropertiesSlow(array, keys).To(&properties_written)) {
|
||||
|
@ -292,7 +292,7 @@ RUNTIME_FUNCTION(Runtime_ObjectKeys) {
|
||||
Handle<FixedArray> keys;
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, keys,
|
||||
KeyAccumulator::GetKeys(receiver, KeyCollectionMode::kOwnOnly,
|
||||
KeyAccumulator::GetKeys(isolate, receiver, KeyCollectionMode::kOwnOnly,
|
||||
ENUMERABLE_STRINGS,
|
||||
GetKeysConversion::kConvertToString));
|
||||
return *keys;
|
||||
@ -314,7 +314,7 @@ RUNTIME_FUNCTION(Runtime_ObjectGetOwnPropertyNames) {
|
||||
Handle<FixedArray> keys;
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, keys,
|
||||
KeyAccumulator::GetKeys(receiver, KeyCollectionMode::kOwnOnly,
|
||||
KeyAccumulator::GetKeys(isolate, receiver, KeyCollectionMode::kOwnOnly,
|
||||
SKIP_SYMBOLS,
|
||||
GetKeysConversion::kConvertToString));
|
||||
return *keys;
|
||||
@ -336,13 +336,13 @@ RUNTIME_FUNCTION(Runtime_ObjectGetOwnPropertyNamesTryFast) {
|
||||
if (nod != 0 && map->NumberOfEnumerableProperties() == nod) {
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, keys,
|
||||
KeyAccumulator::GetKeys(receiver, KeyCollectionMode::kOwnOnly,
|
||||
KeyAccumulator::GetKeys(isolate, receiver, KeyCollectionMode::kOwnOnly,
|
||||
ENUMERABLE_STRINGS,
|
||||
GetKeysConversion::kConvertToString));
|
||||
} else {
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, keys,
|
||||
KeyAccumulator::GetKeys(receiver, KeyCollectionMode::kOwnOnly,
|
||||
KeyAccumulator::GetKeys(isolate, receiver, KeyCollectionMode::kOwnOnly,
|
||||
SKIP_SYMBOLS,
|
||||
GetKeysConversion::kConvertToString));
|
||||
}
|
||||
@ -660,8 +660,8 @@ RUNTIME_FUNCTION(Runtime_ObjectValues) {
|
||||
Handle<FixedArray> values;
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, values,
|
||||
JSReceiver::GetOwnValues(receiver, PropertyFilter::ENUMERABLE_STRINGS,
|
||||
true));
|
||||
JSReceiver::GetOwnValues(isolate, receiver,
|
||||
PropertyFilter::ENUMERABLE_STRINGS, true));
|
||||
return *isolate->factory()->NewJSArrayWithElements(values);
|
||||
}
|
||||
|
||||
@ -674,8 +674,8 @@ RUNTIME_FUNCTION(Runtime_ObjectValuesSkipFastPath) {
|
||||
Handle<FixedArray> value;
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, value,
|
||||
JSReceiver::GetOwnValues(receiver, PropertyFilter::ENUMERABLE_STRINGS,
|
||||
false));
|
||||
JSReceiver::GetOwnValues(isolate, receiver,
|
||||
PropertyFilter::ENUMERABLE_STRINGS, false));
|
||||
return *isolate->factory()->NewJSArrayWithElements(value);
|
||||
}
|
||||
|
||||
@ -688,8 +688,8 @@ RUNTIME_FUNCTION(Runtime_ObjectEntries) {
|
||||
Handle<FixedArray> entries;
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, entries,
|
||||
JSReceiver::GetOwnEntries(receiver, PropertyFilter::ENUMERABLE_STRINGS,
|
||||
true));
|
||||
JSReceiver::GetOwnEntries(isolate, receiver,
|
||||
PropertyFilter::ENUMERABLE_STRINGS, true));
|
||||
return *isolate->factory()->NewJSArrayWithElements(entries);
|
||||
}
|
||||
|
||||
@ -702,8 +702,8 @@ RUNTIME_FUNCTION(Runtime_ObjectEntriesSkipFastPath) {
|
||||
Handle<FixedArray> entries;
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, entries,
|
||||
JSReceiver::GetOwnEntries(receiver, PropertyFilter::ENUMERABLE_STRINGS,
|
||||
false));
|
||||
JSReceiver::GetOwnEntries(isolate, receiver,
|
||||
PropertyFilter::ENUMERABLE_STRINGS, false));
|
||||
return *isolate->factory()->NewJSArrayWithElements(entries);
|
||||
}
|
||||
|
||||
@ -1027,8 +1027,8 @@ RUNTIME_FUNCTION(Runtime_GetOwnPropertyKeys) {
|
||||
Handle<FixedArray> keys;
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, keys,
|
||||
KeyAccumulator::GetKeys(object, KeyCollectionMode::kOwnOnly, filter,
|
||||
GetKeysConversion::kConvertToString));
|
||||
KeyAccumulator::GetKeys(isolate, object, KeyCollectionMode::kOwnOnly,
|
||||
filter, GetKeysConversion::kConvertToString));
|
||||
|
||||
return *isolate->factory()->NewJSArrayWithElements(keys);
|
||||
}
|
||||
|
@ -52,3 +52,24 @@ let S = new SharedStructType(['field']);
|
||||
}
|
||||
assertThrows(() => { new SharedStructType(field_names); });
|
||||
})();
|
||||
|
||||
(function TestOwnPropertyEnumeration() {
|
||||
let s = new S();
|
||||
s.field = 42;
|
||||
|
||||
assertArrayEquals(['field'], Reflect.ownKeys(s));
|
||||
|
||||
let propDescs = Object.getOwnPropertyDescriptors(s);
|
||||
let desc = propDescs['field'];
|
||||
assertEquals(true, desc.writable);
|
||||
assertEquals(false, desc.configurable);
|
||||
assertEquals(true, desc.enumerable);
|
||||
assertEquals(42, desc.value);
|
||||
|
||||
let vals = Object.values(s);
|
||||
assertArrayEquals([42], vals);
|
||||
|
||||
let entries = Object.entries(s);
|
||||
assertEquals(1, entries.length);
|
||||
assertArrayEquals(['field', 42], entries[0]);
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user