Skip to content

Commit f5a31f0

Browse files
marjakhCommit Bot
authored andcommitted
[Promise.any] Add AggregateError
Spec: https://github.com/tc39/proposal-promise-any Bug: v8:9808 Change-Id: I568b2444df9f00f615f2cda1268e4ecc5b36667e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2139571 Commit-Queue: Marja Hölttä <marja@chromium.org> Reviewed-by: Toon Verwaest <verwaest@chromium.org> Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Shu-yu Guo <syg@chromium.org> Reviewed-by: Igor Sheludko <ishell@chromium.org> Cr-Commit-Position: refs/heads/master@{#67224}
1 parent 8e8a06f commit f5a31f0

31 files changed

Lines changed: 546 additions & 121 deletions

BUILD.gn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,7 @@ torque_files = [
11141114
"src/objects/heap-number.tq",
11151115
"src/objects/heap-object.tq",
11161116
"src/objects/intl-objects.tq",
1117+
"src/objects/js-aggregate-error.tq",
11171118
"src/objects/js-array-buffer.tq",
11181119
"src/objects/js-array.tq",
11191120
"src/objects/js-collection-iterator.tq",
@@ -2628,6 +2629,8 @@ v8_source_set("v8_base_without_compiler") {
26282629
"src/objects/internal-index.h",
26292630
"src/objects/intl-objects.cc",
26302631
"src/objects/intl-objects.h",
2632+
"src/objects/js-aggregate-error-inl.h",
2633+
"src/objects/js-aggregate-error.h",
26312634
"src/objects/js-array-buffer-inl.h",
26322635
"src/objects/js-array-buffer.cc",
26332636
"src/objects/js-array-buffer.h",

src/builtins/base.tq

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ extern enum MessageTemplate {
257257
kInvalidArrayLength,
258258
kInvalidIndex,
259259
kNotConstructor,
260+
kNotGeneric,
260261
kCalledNonCallable,
261262
kCalledOnNullOrUndefined,
262263
kProtoObjectOrNull,
@@ -373,6 +374,7 @@ extern macro Int32TrueConstant(): bool;
373374
extern macro Int32FalseConstant(): bool;
374375
extern macro EmptyStringConstant(): EmptyString;
375376
extern macro LengthStringConstant(): String;
377+
extern macro MessageStringConstant(): String;
376378
extern macro NanConstant(): NaN;
377379
extern macro IteratorSymbolConstant(): PublicSymbol;
378380
extern macro MatchSymbolConstant(): Symbol;
@@ -385,6 +387,7 @@ const True: True = TrueConstant();
385387
const False: False = FalseConstant();
386388
const kEmptyString: EmptyString = EmptyStringConstant();
387389
const kLengthString: String = LengthStringConstant();
390+
const kMessageString: String = MessageStringConstant();
388391
const kReturnString: String = ReturnStringConstant();
389392

390393
const kNaN: NaN = NanConstant();

src/builtins/builtins-error.cc

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,9 @@ namespace internal {
1818
// ES6 section 19.5.1.1 Error ( message )
1919
BUILTIN(ErrorConstructor) {
2020
HandleScope scope(isolate);
21-
22-
FrameSkipMode mode = SKIP_FIRST;
23-
Handle<Object> caller;
24-
25-
// When we're passed a JSFunction as new target, we can skip frames until that
26-
// specific function is seen instead of unconditionally skipping the first
27-
// frame.
28-
if (args.new_target()->IsJSFunction()) {
29-
mode = SKIP_UNTIL_SEEN;
30-
caller = args.new_target();
31-
}
32-
3321
RETURN_RESULT_OR_FAILURE(
34-
isolate,
35-
ErrorUtils::Construct(isolate, args.target(),
36-
Handle<Object>::cast(args.new_target()),
37-
args.atOrUndefined(isolate, 1), mode, caller,
38-
ErrorUtils::StackTraceCollection::kDetailed));
22+
isolate, ErrorUtils::Construct(isolate, args.target(), args.new_target(),
23+
args.atOrUndefined(isolate, 1)));
3924
}
4025

4126
// static

src/builtins/cast.tq

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
extern macro IsConstructor(HeapObject): bool;
66
extern macro IsFeedbackVector(HeapObject): bool;
7+
extern macro IsJSAggregateError(HeapObject): bool;
78
extern macro IsJSArray(HeapObject): bool;
89
extern macro IsJSProxy(HeapObject): bool;
910
extern macro IsJSRegExp(HeapObject): bool;
@@ -56,6 +57,8 @@ extern macro TaggedToPositiveSmi(Object): PositiveSmi
5657
labels CastError;
5758
extern macro TaggedToDirectString(Object): DirectString
5859
labels CastError;
60+
extern macro HeapObjectToJSAggregateError(HeapObject): JSAggregateError
61+
labels CastError;
5962
extern macro HeapObjectToJSArray(HeapObject): JSArray
6063
labels CastError;
6164
extern macro HeapObjectToCallable(HeapObject): Callable
@@ -364,6 +367,11 @@ Cast<Undefined|Callable>(o: HeapObject): Undefined|Callable
364367
return HeapObjectToCallable(o) otherwise CastError;
365368
}
366369

370+
Cast<JSAggregateError>(o: HeapObject): JSAggregateError
371+
labels CastError {
372+
return HeapObjectToJSAggregateError(o) otherwise CastError;
373+
}
374+
367375
Cast<JSArray>(o: HeapObject): JSArray
368376
labels CastError {
369377
return HeapObjectToJSArray(o) otherwise CastError;

src/builtins/iterator.tq

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace iterator {
4949
extern builtin IterableToListMayPreserveHoles(implicit context:
5050
Context)(JSAny, JSAny);
5151
extern builtin IterableToListWithSymbolLookup(implicit context:
52-
Context)(JSAny);
52+
Context)(JSAny): JSArray;
5353

5454
transitioning builtin GetIteratorWithFeedback(
5555
context: Context, receiver: JSAny, loadSlot: TaggedIndex,

src/codegen/code-stub-assembler.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "src/objects/descriptor-array.h"
2020
#include "src/objects/function-kind.h"
2121
#include "src/objects/heap-number.h"
22+
#include "src/objects/js-aggregate-error.h"
2223
#include "src/objects/js-generator.h"
2324
#include "src/objects/oddball.h"
2425
#include "src/objects/ordered-hash-table-inl.h"
@@ -4900,6 +4901,12 @@ void CodeStubAssembler::CopyFixedArrayElements(
49004901
Comment("] CopyFixedArrayElements");
49014902
}
49024903

4904+
TNode<JSAggregateError> CodeStubAssembler::HeapObjectToJSAggregateError(
4905+
TNode<HeapObject> heap_object, Label* fail) {
4906+
GotoIfNot(IsJSAggregateError(heap_object), fail);
4907+
return UncheckedCast<JSAggregateError>(heap_object);
4908+
}
4909+
49034910
TNode<FixedArray> CodeStubAssembler::HeapObjectToFixedArray(
49044911
TNode<HeapObject> base, Label* cast_fail) {
49054912
Label fixed_array(this);
@@ -6039,6 +6046,10 @@ TNode<BoolT> CodeStubAssembler::IsJSPrimitiveWrapperMap(SloppyTNode<Map> map) {
60396046
return IsJSPrimitiveWrapperInstanceType(LoadMapInstanceType(map));
60406047
}
60416048

6049+
TNode<BoolT> CodeStubAssembler::IsJSAggregateError(TNode<HeapObject> object) {
6050+
return HasInstanceType(object, JS_AGGREGATE_ERROR_TYPE);
6051+
}
6052+
60426053
TNode<BoolT> CodeStubAssembler::IsJSArrayInstanceType(
60436054
SloppyTNode<Int32T> instance_type) {
60446055
return InstanceTypeEqual(instance_type, JS_ARRAY_TYPE);

src/codegen/code-stub-assembler.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "src/objects/smi.h"
2121
#include "src/objects/tagged-index.h"
2222
#include "src/roots/roots.h"
23-
2423
#include "torque-generated/exported-macros-assembler-tq.h"
2524

2625
namespace v8 {
@@ -103,6 +102,7 @@ enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol };
103102
V(ManyClosuresCellMap, many_closures_cell_map, ManyClosuresCellMap) \
104103
V(match_symbol, match_symbol, MatchSymbol) \
105104
V(megamorphic_symbol, megamorphic_symbol, MegamorphicSymbol) \
105+
V(message_string, message_string, MessageString) \
106106
V(MetaMap, meta_map, MetaMap) \
107107
V(minus_Infinity_string, minus_Infinity_string, MinusInfinityString) \
108108
V(MinusZeroValue, minus_zero_value, MinusZero) \
@@ -426,6 +426,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
426426
return UncheckedCast<HeapObject>(value);
427427
}
428428

429+
TNode<JSAggregateError> HeapObjectToJSAggregateError(
430+
TNode<HeapObject> heap_object, Label* fail);
431+
429432
TNode<JSArray> HeapObjectToJSArray(TNode<HeapObject> heap_object,
430433
Label* fail) {
431434
GotoIfNot(IsJSArray(heap_object), fail);
@@ -2542,6 +2545,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
25422545
TNode<BoolT> IsOddball(SloppyTNode<HeapObject> object);
25432546
TNode<BoolT> IsOddballInstanceType(SloppyTNode<Int32T> instance_type);
25442547
TNode<BoolT> IsIndirectStringInstanceType(SloppyTNode<Int32T> instance_type);
2548+
TNode<BoolT> IsJSAggregateError(TNode<HeapObject> object);
25452549
TNode<BoolT> IsJSArrayBuffer(SloppyTNode<HeapObject> object);
25462550
TNode<BoolT> IsJSDataView(TNode<HeapObject> object);
25472551
TNode<BoolT> IsJSArrayInstanceType(SloppyTNode<Int32T> instance_type);

src/compiler/types.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ Type::bitset BitsetType::Lub(const MapRefLike& map) {
224224
case JS_ASYNC_FUNCTION_OBJECT_TYPE:
225225
case JS_ASYNC_GENERATOR_OBJECT_TYPE:
226226
case JS_MODULE_NAMESPACE_TYPE:
227+
case JS_AGGREGATE_ERROR_TYPE:
227228
case JS_ARRAY_BUFFER_TYPE:
228229
case JS_ARRAY_ITERATOR_TYPE:
229230
case JS_REG_EXP_TYPE:

src/diagnostics/objects-debug.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "src/objects/free-space-inl.h"
3030
#include "src/objects/function-kind.h"
3131
#include "src/objects/hash-table-inl.h"
32+
#include "src/objects/js-aggregate-error-inl.h"
3233
#include "src/objects/js-array-inl.h"
3334
#include "src/objects/layout-descriptor.h"
3435
#include "src/objects/objects-inl.h"

src/diagnostics/objects-printer.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "src/objects/free-space-inl.h"
2525
#include "src/objects/hash-table-inl.h"
2626
#include "src/objects/heap-number-inl.h"
27+
#include "src/objects/js-aggregate-error-inl.h"
2728
#include "src/objects/js-array-buffer-inl.h"
2829
#include "src/objects/js-array-inl.h"
2930
#include "src/objects/objects-inl.h"
@@ -639,6 +640,12 @@ void JSGeneratorObject::JSGeneratorObjectPrint(std::ostream& os) { // NOLINT
639640
JSObjectPrintBody(os, *this);
640641
}
641642

643+
void JSAggregateError::JSAggregateErrorPrint(std::ostream& os) {
644+
JSObjectPrintHeader(os, *this, "JSAggregateError");
645+
os << "\n - errors: " << Brief(errors());
646+
JSObjectPrintBody(os, *this);
647+
}
648+
642649
void JSArray::JSArrayPrint(std::ostream& os) { // NOLINT
643650
JSObjectPrintHeader(os, *this, "JSArray");
644651
os << "\n - length: " << Brief(this->length());

0 commit comments

Comments
 (0)