Skip to content

Commit

Permalink
updates for 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JerrySievert committed Mar 28, 2022
1 parent 627be2e commit d7c8345
Show file tree
Hide file tree
Showing 13 changed files with 929 additions and 229 deletions.
197 changes: 0 additions & 197 deletions Makefile.shared

This file was deleted.

14 changes: 12 additions & 2 deletions Makefiles/Makefile.linux
Expand Up @@ -15,7 +15,7 @@ endif
GN_ARGS = is_component_build=false v8_use_external_startup_data=false v8_enable_i18n_support=false clang_base_path=\"$(LLVM_BINPATH)\" clang_use_chrome_plugins=false use_custom_libcxx=false treat_warnings_as_errors=false use_lld=false v8_monolithic=true


v8:
build/gn/out/gn:
@echo "Setting up build directory"
@mkdir -p build
@echo "Downloading LLVM"
Expand All @@ -26,9 +26,14 @@ v8:
@cd build/gn && git checkout -q eea3906f0e2a8d3622080127d2005ff214d51383
@echo "Building gn"
cd build/gn && export PATH=$$PATH:$(LLVM_BINPATH)/bin && python3 build/gen.py && ninja -C out/ gn

build/v8: build/gn/out/gn
@echo "Downloading v8 source"
@git clone -q https://github.com/v8/v8 build/v8
@cd build/v8 && git checkout -q 9.4.146.21
@cd build/v8 && git checkout -q 9.7.37
@echo "Patching v8"
@cd build/v8 && (git apply ../../patches/*.patch || true)
@echo "Downloading up third party sources"
@git clone -q https://chromium.googlesource.com/chromium/src/base/trace_event/common.git build/v8/base/trace_event/common
@cd build/v8/base/trace_event/common && git checkout -q 3da1e2fcf66acd5c7194497b4285ac163f32e239
@git clone -q https://chromium.googlesource.com/chromium/src/build.git build/v8/build
Expand All @@ -51,3 +56,8 @@ v8:
@echo "Building v8"
@cd build/v8 && export PATH=$$PATH:$(LLVM_BINPATH)/bin && ninja -C ./out.gn v8_monolith

libv8_monolith.a: build/v8

v8: libv8_monolith.a

all: v8
44 changes: 24 additions & 20 deletions contrib/web/index.js
Expand Up @@ -7,43 +7,47 @@ const files = [
'BUILDING.md',
'CONFIGURATION.md',
'FUNCTIONS.md',
'BUILTINS.md'
'BUILTINS.md',
'EXTERNAL.md'
];

const renderer = new marked.Renderer();

// template
var template = fs.readFileSync('./index.tpl', 'utf8');

// links
var links = [ ];

// Override function
renderer.heading = function (text, level) {
const escapedText = text.toLowerCase().replace(/[^\w]+/g, '-');

links.push({
level: level,
link: '#' + escapedText,
text: text
});

return `
<h${level}>
<a name="${escapedText}" class="anchor" href="#${escapedText}">
<span class="header-link"></span>
</a>
${text}
</h${level}>`;
const renderer = {
heading (text, level) {
const escapedText = text.toLowerCase().replace(/[^\w]+/g, '-');

links.push({
level: level,
link: '#' + escapedText,
text: text
});

return `
<h${level}>
<a name="${escapedText}" class="anchor" href="#${escapedText}">
<span class="header-link"></span>
</a>
${text}
</h${level}>
`;
}
};

marked.use({ renderer });

// create the content
var content = '';

files.forEach((elem) => {
const input = fs.readFileSync('../../docs/' + elem, 'utf8');

content += marked(input, { renderer: renderer });
content += marked.parse(input);
});

// replace the content of the template
Expand Down
28 changes: 24 additions & 4 deletions contrib/web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contrib/web/package.json
Expand Up @@ -8,6 +8,6 @@
},
"author": "",
"dependencies": {
"marked": "^0.3.19"
"marked": "^4.0.12"
}
}
36 changes: 34 additions & 2 deletions docs/BUILTINS.md
Expand Up @@ -59,6 +59,39 @@ function to make sure any invocation from SQL statements should not occur.
The `plv8` object provides a version string as `plv8.version`. This string
corresponds to the `plv8` module version.

### `plv8.memory_usage`

You can get your own memory usage by calling `plv8.memory_usage()` with no params.
The resulting object looks like this:
```json
{
"total_heap_size":1327104,
"total_physical_size":472712,
"used_heap_size":381748,
"heap_size_limit":270008320,
"external_memory":0,
"number_of_native_contexts":2
}
```

See nodejs [v8.getHeapStatistics()](https://nodejs.org/api/v8.html#v8_v8_getheapstatistics)

### `plv8.run_script`

Run a script from source code, it's like `eval()` but takes a second argument: script name
Can be pretty useful for debugging

Can be used like this
```js
const sourceCode = `globalThis.myFunc = () => 42`
try {
plv8.run_script(sourceCode, 'myScript.js')
myFunc()
} catch (e) {
plv8.elog(NOTICE, e.message)
}
```

## Database Access via SPI

PLV8 provides functions for database access, including prepared statements,
Expand Down Expand Up @@ -244,8 +277,7 @@ is allocated, the size will not change.
`WindowObject.set_partition_local(obj)`

Stores the partition-local value, which you can retrieve later with
`get_partition_local()``. This function internally uses `JSON.stringify()` to\
serialize the object, so if you pass a value that is not able to be serialized
`get_partition_local()`. This function internally uses `JSON.stringify()` to serialize the object, so if you pass a value that is not able to be serialized
it may end up being an unexpected value. If the size of a serialized value is
more than the allocated memory, it will throw an exception.

Expand Down

0 comments on commit d7c8345

Please sign in to comment.