Skip to content

Commit 570db99

Browse files
ManishearthV8-internal LUCI CQ
authored andcommitted
[temporal] Use callMethod instead of getProperty for from()
Supersedes https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/8549326 Bug: 439921647 Change-Id: I6a6a696451e9c6dcc52dca701c390d046d42d30d Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/8558119 Commit-Queue: Manish Goregaokar <manishearth@google.com> Reviewed-by: Matthias Liedtke <mliedtke@google.com>
1 parent 0379546 commit 570db99

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

Sources/Fuzzilli/CodeGen/CodeGenerators.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,9 @@ public let CodeGenerators: [CodeGenerator] = [
150150
b.construct(constructor, withArgs: [nanoseconds])
151151

152152
} else {
153-
let from = b.getProperty("from", of: constructor)
154153
// TODO(manishearth, 439921647) Generate Temporal-like strings
155154
let string = b.randomVariable(forUseAs: .string)
156-
b.callFunction(from, withArgs: [string])
155+
b.callMethod("from", on: constructor, withArgs: [string])
157156
}
158157

159158
}
@@ -165,7 +164,6 @@ public let CodeGenerators: [CodeGenerator] = [
165164
let args = (0...numArgs).map { _ in b.randomVariable(forUseAs: .number) }
166165
b.construct(constructor, withArgs: args)
167166
} else {
168-
let from = b.getProperty("from", of: constructor)
169167
// Whether to pass a Temporal-like object or a string
170168
if Bool.random() {
171169
// Durations are simple, they accept an object with optional integer fields for each duration field
@@ -175,11 +173,11 @@ public let CodeGenerators: [CodeGenerator] = [
175173
dict[field] = b.randomVariable(forUseAs: .number)
176174
}
177175
}
178-
b.callFunction(from, withArgs: [ b.createObject(with: dict) ] )
176+
b.callMethod("from", on: constructor, withArgs: [ b.createObject(with: dict) ] )
179177
} else {
180178
// TODO(manishearth, 439921647) Generate Temporal-like strings
181179
let string = b.randomVariable(forUseAs: .string)
182-
b.callFunction(from, withArgs: [string])
180+
b.callMethod("from", on: constructor, withArgs: [string])
183181

184182
}
185183
}

Tests/FuzzilliTests/JSTyperTests.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,13 @@ class JSTyperTests: XCTestCase {
16871687
XCTAssert(b.type(of: instantBuiltin).Is(.object(ofGroup: "TemporalInstantConstructor")))
16881688
let instantProto = b.getProperty("prototype", of: instantBuiltin)
16891689
XCTAssert(b.type(of: instantProto).Is(.object(ofGroup: "Temporal.Instant.prototype")))
1690+
let instantFrom = b.getProperty("from", of: instantBuiltin)
1691+
XCTAssert(b.type(of: instantFrom).Is(.unboundFunction([.plain(.string | .object())] => ILType.jsTemporalInstant, receiver: .jsTemporalInstantConstructor)))
1692+
let randomString = b.randomVariable(forUseAs: .string)
1693+
let fromCall = b.callMethod("from", on: instantBuiltin, withArgs: [randomString])
1694+
XCTAssert(b.type(of: fromCall).Is(.jsTemporalInstant))
1695+
1696+
16901697
// We don't test Instant's prototype, since Instant only has nontrivial methods that
16911698
// use options bag types that are still in flux.
16921699

0 commit comments

Comments
 (0)