Skip to content

Commit

Permalink
Merge pull request #9749 from quarto-dev/bugfix/9737
Browse files Browse the repository at this point in the history
v8 - enable linear-time regex matching engine
  • Loading branch information
cscheid authored May 22, 2024
2 parents 40e23f0 + f0abd35 commit e7bbd43
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 11 deletions.
6 changes: 4 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"--unstable-ffi",
"--importmap=${workspaceFolder}/src/import_map.json",
"--inspect-brk",
"--allow-all"
"--allow-all",
"--v8-flags=--enable-experimental-regexp-engine,--max-old-space-size=8192,--max-heap-size=8192"
],
"env": {
"QUARTO_BIN_PATH": "${workspaceFolder}/package/dist/bin",
Expand All @@ -43,7 +44,8 @@
"--allow-all",
"--check",
"--importmap=${workspaceFolder}/src/import_map.json",
"--inspect-brk"
"--inspect-brk",
"--v8-flags=--enable-experimental-regexp-engine,--max-old-space-size=8192,--max-heap-size=8192"
],
"env": {
"QUARTO_ROOT": "${workspaceFolder}",
Expand Down
8 changes: 6 additions & 2 deletions package/launcher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,15 @@ fn main() {
String::from("--allow-ffi"),
];

// # --enable-experimental-regexp-engine is required for /regex/l, https://github.com/quarto-dev/quarto-cli/issues/9737
if let Ok(v8_options) = env::var("QUARTO_DENO_V8_OPTIONS") {
deno_options.push(format!("{}{}", String::from("--v8-flags=--enable-experimental-regexp-engine,--max-old-space-size=8192,--max-heap-size=8192,"), String::from(v8_options)));
} else {
deno_options.push(String::from("--v8-flags=--enable-experimental-regexp-engine,--max-old-space-size=8192,--max-heap-size=8192"));
}
// If there are extra args, include those
if let Ok(extra_options) = env::var("QUARTO_DENO_EXTRA_OPTIONS") {
deno_options.push(extra_options);
} else {
deno_options.push(String::from("--v8-flags=--max-old-space-size=8192,--max-heap-size=8192"));
};

// run deno
Expand Down
11 changes: 10 additions & 1 deletion package/scripts/common/quarto
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,17 @@ export DENO_NO_UPDATE_CHECK=1
# Be sure to include any already defined QUARTO_DENO_OPTIONS
QUARTO_DENO_OPTIONS="--unstable-ffi --no-config ${QUARTO_CACHE_OPTIONS} --allow-read --allow-write --allow-run --allow-env --allow-net --allow-ffi ${QUARTO_DENO_OPTIONS}"

# --enable-experimental-regexp-engine is required for /regex/l, https://github.com/quarto-dev/quarto-cli/issues/9737
if [ "$QUARTO_DENO_V8_OPTIONS" != "" ]; then
QUARTO_DENO_V8_OPTIONS="--enable-experimental-regexp-engine,--max-old-space-size=8192,--max-heap-size=8192,${QUARTO_DENO_V8_OPTIONS}"
else
QUARTO_DENO_V8_OPTIONS="--enable-experimental-regexp-engine,--max-old-space-size=8192,--max-heap-size=8192"
fi

if [ "$QUARTO_DENO_EXTRA_OPTIONS" == "" ]; then
QUARTO_DENO_EXTRA_OPTIONS="--v8-flags=--max-old-space-size=8192,--max-heap-size=8192"
QUARTO_DENO_EXTRA_OPTIONS="--v8-flags=${QUARTO_DENO_V8_OPTIONS}"
else
QUARTO_DENO_EXTRA_OPTIONS="--v8-flags=${QUARTO_DENO_V8_OPTIONS} ${QUARTO_DENO_EXTRA_OPTIONS}"
fi

if [ "$QUARTO_TS_PROFILE" != "" ]; then
Expand Down
11 changes: 10 additions & 1 deletion package/scripts/windows/quarto.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,17 @@ SET "DENO_TLS_CA_STORE=system,mozilla"
SET "DENO_NO_UPDATE_CHECK=1"
SET "QUARTO_DENO_OPTIONS=--unstable-ffi --no-config --cached-only --allow-read --allow-write --allow-run --allow-env --allow-net --allow-ffi"

REM --enable-experimental-regexp-engine is required for /regex/l, https://github.com/quarto-dev/quarto-cli/issues/9737
IF DEFINED QUARTO_DENO_V8_OPTIONS (
SET "QUARTO_DENO_V8_OPTIONS=--enable-experimental-regexp-engine,--max-old-space-size=8192,--max-heap-size=8192,!QUARTO_DENO_V8_OPTIONS!"
) ELSE (
SET "QUARTO_DENO_V8_OPTIONS=--enable-experimental-regexp-engine,--max-old-space-size=8192,--max-heap-size=8192"
)

IF NOT DEFINED QUARTO_DENO_EXTRA_OPTIONS (
set "QUARTO_DENO_EXTRA_OPTIONS=--v8-flags=--max-old-space-size=8192,--max-heap-size=8192"
SET "QUARTO_DENO_EXTRA_OPTIONS=--v8-flags=!QUARTO_DENO_V8_OPTIONS!"
) ELSE (
SET "QUARTO_DENO_EXTRA_OPTIONS=--v8-flags=!QUARTO_DENO_V8_OPTIONS! !QUARTO_DENO_EXTRA_OPTIONS!"
)

!QUARTO_DENO! !QUARTO_ACTION! !QUARTO_DENO_OPTIONS! !QUARTO_DENO_EXTRA_OPTIONS! !QUARTO_IMPORT_MAP_ARG! !QUARTO_TARGET! %*
Expand Down
6 changes: 3 additions & 3 deletions src/project/types/website/util/discover-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ const kPreviewClassPattern =
const kMdNamedImagePattern =
`!\\[[^\\]]*\\]\\(${kNamedFilePattern}(?:\\".*\\")?\\)(?:\\{[^\\|]*\.*[\\s\\}]+)?`;

const kNamedFileRegex = RegExp(kNamedFilePattern);
const kMdPreviewClassRegex = RegExp(kPreviewClassPattern);
const kMdNamedImageRegex = RegExp(kMdNamedImagePattern);
const kNamedFileRegex = RegExp(kNamedFilePattern, "l");
const kMdPreviewClassRegex = RegExp(kPreviewClassPattern, "l");
const kMdNamedImageRegex = RegExp(kMdNamedImagePattern, "l");
const kMarkdownImg = /!\[[^\]]*\]\((.*?)(?:\".*\")?\)(?:\{(?:[^\|]*)\})?/;

export function findDescription(doc: Document): string | undefined {
Expand Down
2 changes: 1 addition & 1 deletion tests/run-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ $Env:QUARTO_DEBUG = "true"
# Preparing running Deno with default arguments

$QUARTO_IMPORT_MAP_ARG="--importmap=$(Join-Path $QUARTO_SRC_DIR "dev_import_map.json")"
$QUARTO_DENO_OPTIONS="--config test-conf.json --unstable-ffi --allow-read --allow-write --allow-run --allow-env --allow-net --check"
$QUARTO_DENO_OPTIONS="--config test-conf.json --v8-flags=--enable-experimental-regexp-engine,--max-old-space-size=8192,--max-heap-size=8192 --unstable-ffi --allow-read --allow-write --allow-run --allow-env --allow-net --check"

# Parsing argument passed to the script

Expand Down
2 changes: 1 addition & 1 deletion tests/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export QUARTO_BIN_PATH=$DENO_DIR
export QUARTO_SHARE_PATH="`cd "$QUARTO_ROOT/src/resources/";pwd`"
export QUARTO_DEBUG=true

QUARTO_DENO_OPTIONS="--config test-conf.json --unstable-ffi --allow-read --allow-write --allow-run --allow-env --allow-net --check"
QUARTO_DENO_OPTIONS="--config test-conf.json --v8-flags=--enable-experimental-regexp-engine,--max-old-space-size=8192,--max-heap-size=8192 --unstable-ffi --allow-read --allow-write --allow-run --allow-env --allow-net --check"


if [[ -z $GITHUB_ACTION ]] && [[ -z $QUARTO_TESTS_NO_CONFIG ]]
Expand Down

0 comments on commit e7bbd43

Please sign in to comment.