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( ...@@ -30,15 +30,20 @@ transitioning javascript builtin AggregateErrorConstructor(
const errors: JSAny = arguments[0]; const errors: JSAny = arguments[0];
const errorsList = iterator::IterableToListWithSymbolLookup(errors); const errorsList = iterator::IterableToListWithSymbolLookup(errors);
// 5. Perform ! CreateDataPropertyOrThrow(_O_, `"errors"`, _errorsList_). // 5. Perform ! DefinePropertyOrThrow(_O_, `"errors"`, Property Descriptor {
CreateDataProperty(obj, ErrorsStringConstant(), errorsList); // [[Configurable]]: *true*, [[Enumerable]]: *false*, [[Writable]]: *true*,
// [[Value]]: ! CreateArrayFromList(_errorsList_) }).
SetOwnPropertyIgnoreAttributes(
obj, ErrorsStringConstant(), errorsList,
SmiConstant(PropertyAttributes::DONT_ENUM));
// 6. Return O. // 6. Return O.
return obj; return obj;
} }
extern runtime ConstructAggregateErrorHelper( extern transitioning runtime ConstructAggregateErrorHelper(
Context, JSFunction, JSAny, Object): JSObject; 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 { ...@@ -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: const kMaxArrayIndex:
constexpr uint32 generates 'JSArray::kMaxArrayIndex'; constexpr uint32 generates 'JSArray::kMaxArrayIndex';
const kArrayBufferMaxByteLength: const kArrayBufferMaxByteLength:
...@@ -523,6 +533,8 @@ extern transitioning macro GetProperty(implicit context: Context)( ...@@ -523,6 +533,8 @@ extern transitioning macro GetProperty(implicit context: Context)(
JSAny, JSAny): JSAny; JSAny, JSAny): JSAny;
extern transitioning builtin SetProperty(implicit context: Context)( extern transitioning builtin SetProperty(implicit context: Context)(
JSAny, JSAny, JSAny): JSAny; JSAny, JSAny, JSAny): JSAny;
extern transitioning builtin SetPropertyIgnoreAttributes(
implicit context: Context)(JSObject, String, JSAny, Smi): JSAny;
extern transitioning builtin SetPropertyInLiteral(implicit context: Context)( extern transitioning builtin SetPropertyInLiteral(implicit context: Context)(
JSAny, JSAny, JSAny): JSAny; JSAny, JSAny, JSAny): JSAny;
extern transitioning builtin DeleteProperty(implicit context: Context)( extern transitioning builtin DeleteProperty(implicit context: Context)(
...@@ -1528,6 +1540,9 @@ macro IsFastJSArrayForReadWithNoCustomIteration(context: Context, o: Object): ...@@ -1528,6 +1540,9 @@ macro IsFastJSArrayForReadWithNoCustomIteration(context: Context, o: Object):
extern transitioning runtime extern transitioning runtime
CreateDataProperty(implicit context: Context)(JSReceiver, JSAny, JSAny); CreateDataProperty(implicit context: Context)(JSReceiver, JSAny, JSAny);
extern transitioning runtime SetOwnPropertyIgnoreAttributes(
implicit context: Context)(JSObject, String, JSAny, Smi);
namespace runtime { namespace runtime {
extern runtime extern runtime
GetDerivedMap(Context, JSFunction, JSReceiver): Map; GetDerivedMap(Context, JSFunction, JSReceiver): Map;
......
...@@ -365,7 +365,9 @@ transitioning macro ConstructAggregateError(implicit context: Context)( ...@@ -365,7 +365,9 @@ transitioning macro ConstructAggregateError(implicit context: Context)(
const obj: JSObject = error::ConstructInternalAggregateErrorHelper( const obj: JSObject = error::ConstructInternalAggregateErrorHelper(
context, SmiConstant(MessageTemplate::kAllPromisesRejected)); context, SmiConstant(MessageTemplate::kAllPromisesRejected));
const errorsJSArray = array::CreateJSArrayWithElements(errors); const errorsJSArray = array::CreateJSArrayWithElements(errors);
CreateDataProperty(obj, ErrorsStringConstant(), errorsJSArray); SetOwnPropertyIgnoreAttributes(
obj, ErrorsStringConstant(), errorsJSArray,
SmiConstant(PropertyAttributes::DONT_ENUM));
return obj; return obj;
} }
......
...@@ -40,7 +40,6 @@ extern class AccessCheckInfo extends Struct { ...@@ -40,7 +40,6 @@ extern class AccessCheckInfo extends Struct {
data: Object; data: Object;
} }
type PropertyAttributes extends int32 constexpr 'PropertyAttributes';
type SideEffectType extends int32 constexpr 'SideEffectType'; type SideEffectType extends int32 constexpr 'SideEffectType';
bitfield struct AccessorInfoFlags extends uint31 { bitfield struct AccessorInfoFlags extends uint31 {
......
...@@ -1188,6 +1188,19 @@ RUNTIME_FUNCTION(Runtime_CreateDataProperty) { ...@@ -1188,6 +1188,19 @@ RUNTIME_FUNCTION(Runtime_CreateDataProperty) {
return *value; 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) { RUNTIME_FUNCTION(Runtime_GetOwnPropertyDescriptor) {
HandleScope scope(isolate); HandleScope scope(isolate);
......
...@@ -329,6 +329,7 @@ namespace internal { ...@@ -329,6 +329,7 @@ namespace internal {
F(SetDataProperties, 2, 1) \ F(SetDataProperties, 2, 1) \
F(SetKeyedProperty, 3, 1) \ F(SetKeyedProperty, 3, 1) \
F(SetNamedProperty, 3, 1) \ F(SetNamedProperty, 3, 1) \
F(SetOwnPropertyIgnoreAttributes, 4, 1) \
F(StoreDataPropertyInLiteral, 3, 1) \ F(StoreDataPropertyInLiteral, 3, 1) \
F(ShrinkPropertyDictionary, 1, 1) \ F(ShrinkPropertyDictionary, 1, 1) \
F(ToFastProperties, 1, 1) \ F(ToFastProperties, 1, 1) \
......
...@@ -186,3 +186,11 @@ ...@@ -186,3 +186,11 @@
assertEquals(2, to_string_called); assertEquals(2, to_string_called);
assertEquals(3, errors_iterated); 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'); ...@@ -116,3 +116,16 @@ load('test/mjsunit/test-async.js');
(e) => { assert.equals(['a', 'b'], e.errors) }); (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