Skip to content

Commit 4aee239

Browse files
LiedtkeV8-internal LUCI CQ
authored andcommitted
[environment] Register Iterator.zip
and support iterables in OptionsBags. Iterator.zip was added to V8 with https://crrev.com/c/7605659. Bug: 465357675 Change-Id: Ia5e5c49831f8ad10c166bb32a264ee90a1aadead Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/9090936 Auto-Submit: Matthias Liedtke <mliedtke@google.com> Reviewed-by: Olivier Flückiger <olivf@google.com> Commit-Queue: Nikos Papaspyrou <nikolaos@google.com> Reviewed-by: Nikos Papaspyrou <nikolaos@google.com>
1 parent 44c33a4 commit 4aee239

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

Sources/Fuzzilli/Base/ProgramBuilder.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ public class ProgramBuilder {
737737
let (pattern, flags) = self.randomRegExpPatternAndFlags()
738738
return self.loadRegExp(pattern, flags)
739739
}),
740+
(.iterable, { return self.createArray(with: [self.randomJsVariable()]) }),
740741
(.function(), {
741742
// TODO: We could technically generate a full function here but then we would enter the full code generation logic which could do anything.
742743
// Because we want to avoid this, we will just pick anything that can be a function.

Sources/Fuzzilli/Environment/JavaScriptEnvironment.swift

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ public class JavaScriptEnvironment: ComponentBase {
566566
registerEnumeration(OptionsBag.jsIntlSignDisplayEnum)
567567
registerEnumeration(OptionsBag.jsIntlPluralRulesTypeEnum)
568568
registerEnumeration(OptionsBag.jsIntlSegmenterGranularityEnum)
569+
registerEnumeration(OptionsBag.jsIteratorZipModeEnum)
569570
registerEnumeration(OptionsBag.base64Alphabet)
570571
registerEnumeration(OptionsBag.base64LastChunkHandling)
571572

@@ -594,6 +595,7 @@ public class JavaScriptEnvironment: ComponentBase {
594595
registerOptionsBag(.jsIntlRelativeTimeFormatSettings)
595596
registerOptionsBag(.jsIntlSegmenterSettings)
596597
registerOptionsBag(.jsIntlLocaleMatcherSettings)
598+
registerOptionsBag(.jsIteratorZipSettings)
597599

598600
registerTemporalFieldsObject(.jsTemporalPlainTimeLikeObject, forWith: false, dateFields: false, timeFields: true, zonedFields: false)
599601
registerTemporalFieldsObject(.jsTemporalPlainDateLikeObject, forWith: false, dateFields: true, timeFields: false, zonedFields: false)
@@ -1072,7 +1074,7 @@ public struct OptionsBag {
10721074
self.properties = properties
10731075
let properties = properties.mapValues {
10741076
// This list can be expanded over time as long as createOptionsBag() supports this
1075-
assert($0.isEnumeration || $0.Is(.number | .integer | .boolean) ||
1077+
assert($0.isEnumeration || $0.Is(.number | .integer | .boolean | .iterable) ||
10761078
// Has a producing generator registered
10771079
$0.Is(.jsTemporalPlainTime) ||
10781080
// Has explicit support in createOptionsBag
@@ -1122,7 +1124,7 @@ public extension ILType {
11221124
static let jsIterator = ILType.iterable + ILType.object(ofGroup: "Iterator", withProperties: ["value", "done"], withMethods: ["next", "return", "throw", "map", "filter", "take", "drop", "flatMap", "reduce", "toArray", "forEach", "some", "every", "find"])
11231125

11241126
/// Type of the JavaScript Iterator constructor builtin.
1125-
static let jsIteratorConstructor = ILType.object(ofGroup: "IteratorConstructor", withProperties: ["prototype"], withMethods: ["from", "concat"])
1127+
static let jsIteratorConstructor = ILType.object(ofGroup: "IteratorConstructor", withProperties: ["prototype"], withMethods: ["from", "concat", "zip"])
11261128

11271129
/// Type of a JavaScript generator object.
11281130
static let jsGenerator = ILType.iterable + ILType.object(ofGroup: "Generator", withMethods: ["next", "return", "throw"])
@@ -1699,6 +1701,7 @@ public extension ObjectGroup {
16991701
methods: [
17001702
"from" : [.jsAnything] => .jsIterator,
17011703
"concat" : [.jsAnything...] => .jsIterator,
1704+
"zip" : [.iterable, .opt(OptionsBag.jsIteratorZipSettings.group.instanceType)] => .jsIterator,
17021705
]
17031706
)
17041707

@@ -4158,6 +4161,19 @@ extension OptionsBag {
41584161
)
41594162
}
41604163

4164+
// Iterator
4165+
extension OptionsBag {
4166+
fileprivate static let jsIteratorZipModeEnum = ILType.enumeration(ofName: "IteratorZipMode", withValues: ["strict", "longest", "shortest"])
4167+
4168+
static let jsIteratorZipSettings = OptionsBag(
4169+
name: "IteratorZipSettings",
4170+
properties: [
4171+
"mode": jsIteratorZipModeEnum,
4172+
"padding": .iterable,
4173+
]
4174+
)
4175+
}
4176+
41614177
// Base64
41624178
extension OptionsBag {
41634179
fileprivate static let base64Alphabet =

0 commit comments

Comments
 (0)