Commit 5f9d5901 authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[Promise.any] Make 'errors' non-enumerable

This reflects the latest changes in the Promise.any proposal.

Bug: v8:9808
Change-Id: I0f8ea2e95f430479963bf9d9597f243024de8c74
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2222344Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68164}
parent 36843395
......@@ -30,15 +30,20 @@ transitioning javascript builtin AggregateErrorConstructor(
const errors: JSAny = arguments[0];
const errorsList = iterator::IterableToListWithSymbolLookup(errors);
// 5. Perform ! CreateDataPropertyOrThrow(_O_, `"errors"`, _errorsList_).
CreateDataProperty(obj, ErrorsStringConstant(), errorsList);
// 5. Perform ! DefinePropertyOrThrow(_O_, `"errors"`, Property Descriptor {
// [[Configurable]]: *true*, [[Enumerable]]: *false*, [[Writable]]: *true*,
// [[Value]]: ! CreateArrayFromList(_errorsList_) }).
SetOwnPropertyIgnoreAttributes(
obj, ErrorsStringConstant(), errorsList,
SmiConstant(PropertyAttributes::DONT_ENUM));
// 6. Return O.
return obj;
}
extern runtime ConstructAggregateErrorHelper(
extern transitioning runtime ConstructAggregateErrorHelper(
Context, JSFunction, JSAny, Object): JSObject;
extern runtime ConstructInternalAggregateErrorHelper(Context, Object): JSObject;
extern transitioning runtime ConstructInternalAggregateErrorHelper(
Context, Object): JSObject;
}
......@@ -331,6 +331,16 @@ extern enum MessageTemplate {
...
}
extern enum PropertyAttributes extends int31 {
NONE,
READ_ONLY,
DONT_ENUM,
DONT_DELETE,
ALL_ATTRIBUTES_MASK,
FROZEN,
...
}
const kMaxArrayIndex:
constexpr uint32 generates 'JSArray::kMaxArrayIndex';
const kArrayBufferMaxByteLength:
......@@ -523,6 +533,8 @@ extern transitioning macro GetProperty(implicit context: Context)(
JSAny, JSAny): JSAny;
extern transitioning builtin SetProperty(implicit context: Context)(
JSAny, JSAny, JSAny): JSAny;
extern transitioning builtin SetPropertyIgnoreAttributes(
implicit context: Context)(JSObject, String, JSAny, Smi): JSAny;
extern transitioning builtin SetPropertyInLiteral(implicit context: Context)(
JSAny, JSAny, JSAny): JSAny;
extern transitioning builtin DeleteProperty(implicit context: Context)(
......@@ -1528,6 +1540,9 @@ macro IsFastJSArrayForReadWithNoCustomIteration(context: Context, o: Object):
extern transitioning runtime
CreateDataProperty(implicit context: Context)(JSReceiver, JSAny, JSAny);
extern transitioning runtime SetOwnPropertyIgnoreAttributes(
implicit context: Context)(JSObject, String, JSAny, Smi);
namespace runtime {
extern runtime
GetDerivedMap(Context, JSFunction, JSReceiver): Map;
......
......@@ -365,7 +365,9 @@ transitioning macro ConstructAggregateError(implicit context: Context)(
const obj: JSObject = error::ConstructInternalAggregateErrorHelper(
context, SmiConstant(MessageTemplate::kAllPromisesRejected));
const errorsJSArray = array::CreateJSArrayWithElements(errors);
CreateDataProperty(obj, ErrorsStringConstant(), errorsJSArray);
SetOwnPropertyIgnoreAttributes(
obj, ErrorsStringConstant(), errorsJSArray,
SmiConstant(PropertyAttributes::DONT_ENUM));
return obj;
}
......
......@@ -40,7 +40,6 @@ extern class AccessCheckInfo extends Struct {
data: Object;
}
type PropertyAttributes extends int32 constexpr 'PropertyAttributes';
type SideEffectType extends int32 constexpr 'SideEffectType';
bitfield struct AccessorInfoFlags extends uint31 {
......
......@@ -1188,6 +1188,19 @@ RUNTIME_FUNCTION(Runtime_CreateDataProperty) {
return *value;
}
RUNTIME_FUNCTION(Runtime_SetOwnPropertyIgnoreAttributes) {
HandleScope scope(isolate);
DCHECK_EQ(4, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSObject, o, 0);
CONVERT_ARG_HANDLE_CHECKED(String, key, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
CONVERT_ARG_HANDLE_CHECKED(Smi, attributes, 3);
RETURN_RESULT_OR_FAILURE(
isolate, JSObject::SetOwnPropertyIgnoreAttributes(
o, key, value, PropertyAttributes(attributes->value())));
}
RUNTIME_FUNCTION(Runtime_GetOwnPropertyDescriptor) {
HandleScope scope(isolate);
......
......@@ -329,6 +329,7 @@ namespace internal {
F(SetDataProperties, 2, 1) \
F(SetKeyedProperty, 3, 1) \
F(SetNamedProperty, 3, 1) \
F(SetOwnPropertyIgnoreAttributes, 4, 1) \
F(StoreDataPropertyInLiteral, 3, 1) \
F(ShrinkPropertyDictionary, 1, 1) \
F(ToFastProperties, 1, 1) \
......
......@@ -186,3 +186,11 @@
assertEquals(2, to_string_called);
assertEquals(3, errors_iterated);
})();
(function TestErrorsProperties() {
let error = new AggregateError([1, 20, 4]);
let desc = Object.getOwnPropertyDescriptor(error, 'errors');
assertEquals(true, desc.configurable);
assertEquals(false, desc.enumerable);
assertEquals(true, desc.writable);
})();
......@@ -116,3 +116,16 @@ load('test/mjsunit/test-async.js');
(e) => { assert.equals(['a', 'b'], e.errors) });
});
})();
(function TestErrorsProperties() {
testAsync(assert => {
assert.plan(3);
Promise.any([]).catch(
(error) => {
let desc = Object.getOwnPropertyDescriptor(error, 'errors');
assert.equals(true, desc.configurable);
assert.equals(false, desc.enumerable);
assert.equals(true, desc.writable);
});
});
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment