From 023e8803f8a392e63820179db5af02e68ae977c7 Mon Sep 17 00:00:00 2001 From: Darshan Sen Date: Mon, 29 May 2023 06:56:22 +0530 Subject: [PATCH] doc,vm: clarify usage of cachedData in vm.compileFunction() Fixes: https://github.com/nodejs/node/issues/48175 Signed-off-by: Darshan Sen PR-URL: https://github.com/nodejs/node/pull/48193 Reviewed-By: Debadree Chatterjee Reviewed-By: Luigi Pinca --- doc/api/vm.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/api/vm.md b/doc/api/vm.md index 7631b39353b7d2..19d39c77a01720 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -1005,7 +1005,8 @@ changes: is displayed in stack traces produced by this script. **Default:** `0`. * `cachedData` {Buffer|TypedArray|DataView} Provides an optional `Buffer` or `TypedArray`, or `DataView` with V8's code cache data for the supplied - source. + source. This must be produced by a prior call to [`vm.compileFunction()`][] + with the same `code` and `params`. * `produceCachedData` {boolean} Specifies whether to produce new cache data. **Default:** `false`. * `parsingContext` {Object} The [contextified][] object in which the said @@ -1593,6 +1594,7 @@ are not controllable through the timeout either. [`script.runInContext()`]: #scriptrunincontextcontextifiedobject-options [`script.runInThisContext()`]: #scriptruninthiscontextoptions [`url.origin`]: url.md#urlorigin +[`vm.compileFunction()`]: #vmcompilefunctioncode-params-options [`vm.createContext()`]: #vmcreatecontextcontextobject-options [`vm.runInContext()`]: #vmrunincontextcode-contextifiedobject-options [`vm.runInThisContext()`]: #vmruninthiscontextcode-options