Skip to content

Commit b1881f2

Browse files
mi-acV8-internal LUCI CQ
authored andcommitted
Revert "Reland "Simplify constrained string generation in code generators""
This reverts commit c1a33c1. Reason for revert: https://crbug.com/454201777 Original change's description: > Reland "Simplify constrained string generation in code generators" > > This is a reland of commit 80ad045 > CQ and GitHub actions now use newer versions that shouldn't crash > any more when compiling this for release builds. > > Original change's description: > > Simplify constrained string generation in code generators > > > > Change-Id: I0ed4abed4a3ef0c7e150971ec58f0aae7e5b0982 > > Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/8591236 > > Auto-Submit: Matthias Liedtke <mliedtke@google.com> > > Reviewed-by: Carl Smith <cffsmith@google.com> > > Commit-Queue: Matthias Liedtke <mliedtke@google.com> > > Change-Id: I98d5ee50de6057e239d1fae2b0ce4a3dfb1af1bd > Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/8687236 > Reviewed-by: Carl Smith <cffsmith@google.com> > Commit-Queue: Matthias Liedtke <mliedtke@google.com> Bug: 454201777 No-Presubmit: true No-Tree-Checks: true No-Try: true Change-Id: I9f3fc81d632842c357b999a6b7c93602660a3f25 Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/8693758 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Michael Achenbach <machenbach@google.com>
1 parent c1a33c1 commit b1881f2

File tree

2 files changed

+198
-70
lines changed

2 files changed

+198
-70
lines changed

Sources/Fuzzilli/Base/ProgramBuilder.swift

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -483,36 +483,6 @@ public class ProgramBuilder {
483483
return probability(0.5) ? randomBuiltinMethodName() : randomCustomMethodName()
484484
}
485485

486-
private static func generateConstrained<T: Equatable>(
487-
_ generator: () -> T,
488-
notIn: any Collection<T>,
489-
fallback: () -> T) -> T {
490-
var result: T
491-
var attempts = 0
492-
repeat {
493-
if attempts >= 10 {
494-
return fallback()
495-
}
496-
result = generator()
497-
attempts += 1
498-
} while notIn.contains(result)
499-
return result
500-
}
501-
502-
// Generate a string not already contained in `notIn` using the provided `generator`. If it fails
503-
// repeatedly, return a random string instead.
504-
public func generateString(_ generator: () -> String, notIn: any Collection<String>) -> String {
505-
Self.generateConstrained(generator, notIn: notIn,
506-
fallback: {String.random(ofLength: Int.random(in: 1...5))})
507-
}
508-
509-
// Find a random variable to use as a string that isn't contained in `notIn`. If it fails
510-
// repeatedly, create a random string literal instead.
511-
public func findOrGenerateStringLikeVariable(notIn: any Collection<Variable>) -> Variable {
512-
return Self.generateConstrained(randomJsVariable, notIn: notIn,
513-
fallback: {loadString(String.random(ofLength: Int.random(in: 1...5)))})
514-
}
515-
516486
// Settings and constants controlling the behavior of randomParameters() below.
517487
// This determines how many variables of a given type need to be visible before
518488
// that type is considered a candidate for a parameter type. For example, if this

0 commit comments

Comments
 (0)