Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit cee5f84
Author: Jonathan Geddes <geddes.jonathan@gmail.com>
Date:   Mon Apr 10 10:09:13 2023 -0600

    shared array buffers (rogchap#378)

    * Initial support for SharedArrayBuffer

commit 0e40e6e
Author: Randy Goodman <mullan17@gmail.com>
Date:   Mon Mar 20 19:27:55 2023 -0400

    v0.9.0 (rogchap#376)

commit be4ff5e
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Tue Mar 21 07:17:39 2023 +1100

    Upgrade V8 binaries for 11.1.277.13 version (rogchap#373)

commit 02e1763
Author: Jacques Nadeau <jacquesnadeau@gmail.com>
Date:   Mon Jan 30 06:51:45 2023 -0800

    Upgrade V8 binaries for 10.9.194.9 version **working** (rogchap#363)

    * Upgrade V8 binaries for 10.9.194.9 version

    * Fixes to support newest stable v8.

    - Update github workflow to use go 18 & 19
    - Update github workflow to use macos-latest
    - Update github build workflow to use ubuntu 22.04
    - Add gitignore for jetbrains and .gclient_previous files
    - Switch cgo build to C++17 and enable sandbox at build time
    - Update test with update to date error message
    - Remove no longer supported build flag.
    - Move initialization to v8go.go and include flag set to avoid flag freezing
    - Reorder initialization so allocator is initialized after v8 (required by latest v8)

    * Update V8 static library for macos-11 x86_64

    * Update V8 static library for ubuntu-22.04 x86_64

    * Update V8 static library for macos-11 arm64

    * Update V8 static library for ubuntu-22.04 arm64

    * Update changelog and remove no-longer valid comment

    ---------

    Co-authored-by: jacques-n <jacques-n@users.noreply.github.com>

commit 7d843f1
Author: Kyle Maxwell <kyle@kylemaxwell.com>
Date:   Thu Jan 19 13:17:30 2023 -0800

    v8.Value becomes manually releaseable (rogchap#361)

    * values are manually releaseable

    Co-authored-by: Kyle Maxwell <kyle.maxwell@reddit.com>

commit 1f00b50
Author: Ryan H. Lewis <ryan@ryanlewis.dev>
Date:   Wed Nov 2 14:15:10 2022 -0600

    adding additional profile values (rogchap#341)

commit fc8b9f1
Author: Ryan H. Lewis <ryan@ryanlewis.dev>
Date:   Mon Aug 8 16:10:42 2022 -0600

    updating context documentation (rogchap#335)

    Co-authored-by: Ryan H Lewis <ryan.lewis@reddit.com>

commit da7f43c
Author: Lukas Malkmus <lukasmalkmus@users.noreply.github.com>
Date:   Wed Apr 13 16:20:09 2022 +0200

    Fix typo in promise.go (rogchap#310)

    Literally just fixing a typo in `promise.go` that I discovered while strolling through the code.

commit db78170
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Wed Mar 9 14:29:03 2022 -0800

    Upgrade V8 binaries for 9.7.106.19 version (rogchap#278)

    * Upgrade V8 binaries for 9.7.106.19 version

    * Update V8 static library for ubuntu-18.04 x86_64 (rogchap#292)

    Co-authored-by: genevieve <genevieve@users.noreply.github.com>

    * Update V8 static library for ubuntu-18.04 arm64 (rogchap#293)

    Co-authored-by: genevieve <genevieve@users.noreply.github.com>

    * Update V8 static library for macos-11 x86_64 (rogchap#294)

    Co-authored-by: genevieve <genevieve@users.noreply.github.com>

    * Update V8 static library for macos-11 arm64 (rogchap#295)

    Co-authored-by: genevieve <genevieve@users.noreply.github.com>

    Co-authored-by: dylanahsmith <dylanahsmith@users.noreply.github.com>
    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    Co-authored-by: genevieve <genevieve@users.noreply.github.com>

commit 5e91d3d
Author: Dylan Thacker-Smith <dylan.smith@shopify.com>
Date:   Wed Jan 12 17:06:50 2022 -0500

    Fix Object.Set with an empty key string (rogchap#276)

commit 1d433f7
Author: Genevieve <genevieve.lesperance@shopify.com>
Date:   Wed Jan 12 10:41:04 2022 -0800

    Use length to ensure null chars do not cause early termination of C string copies/reads (rogchap#272)

    * Intro test case for null terminator string

    * unexpected result: expected ss, got sx00s

    * Fix the assertion, add Unicode symbols

    * Pass go string length into v8::String::New to ensure it does not cut off
    at null chars

    * Reuse the existing RtnString type

    * Formatting

    * Update value_test.go

    Co-authored-by: Dylan Thacker-Smith <dylan.smith@shopify.com>

    * Table tests for NewValue

    * Use std::string constructor in CopyString(Utf8Value) to keep whole
    string

    * Update changelog

    Co-authored-by: Genevieve L'Esperance <glesperance@doximity.com>
    Co-authored-by: Maxim Shirshin <maxim.shirshin@shopify.com>
    Co-authored-by: Dylan Thacker-Smith <dylan.smith@shopify.com>

commit cb8779b
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Wed Jan 12 07:51:03 2022 -0800

    Upgrade V8 binaries for 9.7.106.18 version (rogchap#264)

    Co-authored-by: dylanahsmith <dylanahsmith@users.noreply.github.com>
    Co-authored-by: Genevieve <genevieve.lesperance@shopify.com>

commit c0dbfd3
Author: Dylan Thacker-Smith <dylan.smith@shopify.com>
Date:   Wed Jan 12 09:58:36 2022 -0500

    Remove unnecessary nested Locker and Isolate::Scope use (rogchap#275)

    * Remove unnecessary nested Locker and Isolate::Scope use

    * Make ExceptionError static, since it isn't used outside that file

commit ede7cee
Author: Liu Xiangchao <iwind.liu@gmail.com>
Date:   Fri Jan 7 01:33:29 2022 +0800

    modify -fpic to -fPIC (rogchap#263)

commit a0417ad
Author: Dylan Thacker-Smith <dylan.smith@shopify.com>
Date:   Wed Dec 22 15:48:45 2021 -0500

    CHANGELOG: Highlight the subtlety of the Function Call breaking change (rogchap#259)

commit 943fcf9
Author: Aditya Sharma <git@adi.run>
Date:   Wed Dec 22 09:30:54 2021 -0800

    Build v8 for linux_arm64 (rogchap#223)

    * Build v8 for linux_arm64

    * Update V8 static library for ubuntu-18.04 arm64

    Co-authored-by: epk <epk@users.noreply.github.com>

commit e635d48
Author: Genevieve <genevieve.lesperance@shopify.com>
Date:   Mon Dec 13 09:28:33 2021 -0800

    Allocate children array with count (rogchap#256)

commit 6e4af34
Author: Roger Chapman <rogchap@gmail.com>
Date:   Thu Dec 9 10:29:56 2021 +1100

    v0.7.0

commit 762c7a8
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Wed Dec 8 15:22:43 2021 -0800

    Upgrade V8 binaries for 9.6.180.12 version (rogchap#231)

    * Upgrade V8 binaries for 9.6.180.12 version

    * Add -ldl flag to linux build to fix missing dlsym errors

    * Update V8 static library for macos-11 x86_64 (rogchap#249)

    Co-authored-by: genevieve <genevieve@users.noreply.github.com>

    * Update V8 static library for ubuntu-18.04 x86_64 (rogchap#250)

    Co-authored-by: genevieve <genevieve@users.noreply.github.com>

    * Update V8 static library for macos-11 arm64 (rogchap#251)

    Co-authored-by: genevieve <genevieve@users.noreply.github.com>

    * Update changelog

    Co-authored-by: dylanahsmith <dylanahsmith@users.noreply.github.com>
    Co-authored-by: Genevieve L'Esperance <genevieve.lesperance@shopify.com>
    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    Co-authored-by: genevieve <genevieve@users.noreply.github.com>

commit a92639e
Author: Genevieve <genevieve.lesperance@shopify.com>
Date:   Tue Nov 30 12:59:03 2021 -0800

    Enable intl support and store data in v8 binary (rogchap#242)

    * Enable intl support and store data in v8 binary

    * Update V8 static library for ubuntu-18.04 x86_64

    * Update V8 static library for macos-11 arm64

    * Update changelog

    Co-authored-by: genevieve <genevieve@users.noreply.github.com>

commit f55271d
Author: Genevieve <genevieve.lesperance@shopify.com>
Date:   Mon Nov 22 14:50:43 2021 -0800

    Remove Windows support (rogchap#234)

    * Remove Windows binary support

    * Update CHANGELOG.md

    Co-authored-by: Oliver Fuerst <87430407+ofuerst@users.noreply.github.com>

    * Update CHANGELOG.md

    Co-authored-by: Dylan Thacker-Smith <dylan.smith@shopify.com>

    * Update windows section

    * Update README.md

    Co-authored-by: Dylan Thacker-Smith <dylan.smith@shopify.com>

    * Update README.md

    Co-authored-by: Dylan Thacker-Smith <dylan.smith@shopify.com>

    * Remove windows fossa step

    * Remove deps/windows_x86_64

    Co-authored-by: Oliver Fuerst <87430407+ofuerst@users.noreply.github.com>
    Co-authored-by: Dylan Thacker-Smith <dylan.smith@shopify.com>
    Co-authored-by: Roger Chapman <rogchap@gmail.com>
  • Loading branch information
wowngasb committed Jan 19, 2024
1 parent 2477c44 commit ec2c03e
Show file tree
Hide file tree
Showing 141 changed files with 18,802 additions and 16,095 deletions.
21 changes: 4 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ jobs:
name: Tests on ${{ matrix.go-version }} ${{ matrix.platform }}
strategy:
matrix:
go-version: [1.16.8, 1.17.1]
# We use macos-11 over macos-latest because macos-latest defaults to Catalina(10.15) and not Big Sur(11.0)
# We can switch to macos-latest whenever Big Sur becomes the default
# See https://github.com/actions/virtual-environments#available-environments
platform: [ubuntu-latest, macos-11, windows-latest]
go-version: [1.18.10, 1.19.5]
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}

steps:
Expand All @@ -26,10 +23,6 @@ jobs:
go-version: ${{ matrix.go-version }}
- name: Checkout
uses: actions/checkout@v2
- name: Add MINGW to PATH
if: matrix.platform == 'windows-latest'
run: echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
shell: bash
- name: Go Test
env:
CGO_CXXFLAGS: "-Werror"
Expand All @@ -45,16 +38,10 @@ jobs:
- name: Add GOPATH to GITHUB_ENV
run: echo "GOPATH=$(go env GOPATH)" >>"$GITHUB_ENV"
- name: Scan and upload FOSSA data (Linux/Mac)
if: env.FOSSA_API_KEY != '' && github.ref == 'refs/heads/master' && matrix.platform != 'windows-latest'
if: env.FOSSA_API_KEY != '' && github.ref == 'refs/heads/master'
run: |
curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install.sh | sudo bash
fossa analyze
env:
FOSSA_API_KEY: ${{ secrets.FOSSA_API_KEY }}
- name: Scan and upload FOSSA data (Windows)
if: env.FOSSA_API_KEY != '' && github.ref == 'refs/heads/master' && matrix.platform == 'windows-latest'
run: |
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/fossas/fossa-cli/master/install.ps1'))
C:\ProgramData\fossa-cli\fossa.exe analyze
env:
FOSSA_API_KEY: ${{ secrets.FOSSA_API_KEY }}

22 changes: 5 additions & 17 deletions .github/workflows/v8build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@ jobs:
#
# We need xcode 12.4 or newer to cross compile between arm64/amd64
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md#xcode
platform: [ubuntu-18.04, macos-11, windows-latest]
platform: [ubuntu-22.04, macos-11]
arch: [x86_64, arm64]
exclude:
- platform: ubuntu-18.04
arch: arm64
- platform: windows-latest
arch: arm64
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
Expand All @@ -31,22 +26,15 @@ jobs:
- name: Update depot_tools fetch config
run: cd deps/depot_tools && git config --unset-all remote.origin.fetch; git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
shell: bash
- name: Install g++-aarch64-linux-gnu
if: matrix.platform == 'ubuntu-22.04' && matrix.arch == 'arm64'
run: sudo apt update && sudo apt install g++-aarch64-linux-gnu -y
- name: Build V8 linux
if: matrix.platform == 'ubuntu-18.04'
if: matrix.platform == 'ubuntu-22.04'
run: cd deps && ./build.py --no-clang --arch ${{ matrix.arch }}
- name: Build V8 macOS
if: matrix.platform == 'macos-11'
run: cd deps && ./build.py --arch ${{ matrix.arch }}
- name: Add MSYS2 to PATH
if: matrix.platform == 'windows-latest'
run: echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
shell: bash
- name: Build V8 windows
if: matrix.platform == 'windows-latest'
run: cd deps; python build.py --no-clang --arch ${{ matrix.arch }}
env:
MSYSTEM: MINGW64
DEPOT_TOOLS_WIN_TOOLCHAIN: 0
- name: Create PR
uses: peter-evans/create-pull-request@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
.gclient_entries

deps/darwin-x86_64/libv8_debug.a

deps/.gclient_previous*
c.out

.idea/*
/v8go.test
.idea/
35 changes: 33 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,35 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [v0.10.0] - 2023-04-10

### Changed
- Required Go version changed to 1.17 (needed for SharedArrayBuffer support)

### Added
- Support for getting the underlying data (as a `[]byte`) from a SharedArrayBuffer

### Fixed
- Upgrade to V8 11.1.277.13


## [v0.9.0] - 2023-03-30

### Fixed
- Upgrade to V8 11.1.277.13

## [v0.8.0] - 2023-01-19

### Added
- Added support for Value.release() and FunctionCallbackInfo.release(). This is useful when using v8go in a long-running context.

### Fixed
- Use string length to ensure null character-containing strings in Go/JS are not terminated early.
- Object.Set with an empty key string is now supported
- Upgrade to V8 10.9.194.9
- Upgrade V8 build OS to Ubuntu 22.04

## [v0.7.0] - 2021-12-09

### Added
- Support for calling constructors functions with NewInstance on Function
Expand All @@ -21,13 +49,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support for creating a code cache from an UnboundScript which can be used to create an UnboundScript in other isolates
to run a pre-compiled script in new contexts.
- Included compile error location in `%+v` formatting of JSError
- Enable i18n support

### Changed
- Removed error return value from NewIsolate which never fails
- Removed error return value from NewContext which never fails
- Removed error return value from Context.Isolate() which never fails
- Removed error return value from NewObjectTemplate and NewFunctionTemplate. Panic if given a nil argument.
- Function Call accepts receiver as first argument.
- Function Call accepts receiver as first argument. This **subtle breaking change** will compile old code but interpret the first argument as the receiver. Use `Undefined` to prepend an argument to fix old Call use.
- Removed Windows support until its build issues are addressed.
- Upgrade to V8 9.6.180.12

### Fixed
- Add some missing error propagation
Expand Down
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,20 @@ please join the [**#v8go**](https://gophers.slack.com/channels/v8go) channel on

### Windows

In order to build a project using v8go on Windows, Go requires a gcc compiler to be installed.
There used to be Windows binary support. For further information see, [PR #234](https://github.com/rogchap/v8go/pull/234).

To set this up:
1. Install MSYS2 (https://www.msys2.org/)
2. Add the Mingw-w64 bin to your PATH environment variable (`C:\msys64\mingw64\bin` by default)
3. Open MSYS2 MSYS and execute `pacman -S mingw-w64-x86_64-toolchain`

V8 requires 64-bit on Windows, therefore it will not work on 32-bit systems.
The v8go library would welcome contributions from anyone able to get an external windows
build of the V8 library linking with v8go, using the version of V8 checked out in the
`deps/v8` git submodule, and documentation of the process involved. This process will likely
involve passing a linker flag when building v8go (e.g. using the `CGO_LDFLAGS` environment
variable.

## V8 dependency

V8 version: **9.0.257.18** (April 2021)

In order to make `v8go` usable as a standard Go package, prebuilt static libraries of V8
are included for Linux, macOS and Windows ie. you *should not* require to build V8 yourself.
are included for Linux and macOS. you *should not* require to build V8 yourself.

Due to security concerns of binary blobs hiding malicious code, the V8 binary is built via CI *ONLY*.

Expand Down Expand Up @@ -247,7 +246,7 @@ The next steps are:
1) The build is not yet triggered automatically. To trigger it manually, go to the [V8
Build](https://github.com/rogchap/v8go/actions?query=workflow%3A%22V8+Build%22) Github Action, Select "Run workflow",
and select your pushed branch eg. `v8_upgrade/<v8-version>`.
1) Once built, this should open 3 PRs against your branch to add the `libv8.a` for Linux, macOS and Windows; merge
1) Once built, this should open 3 PRs against your branch to add the `libv8.a` for Linux (for x86_64) and macOS for x86_64 and arm64; merge
these PRs into your branch. You are now ready to raise the PR against `master` with the latest version of V8.

### Flushing after C/C++ standard library printing for debugging
Expand Down
8 changes: 4 additions & 4 deletions cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ package v8go

//go:generate clang-format -i --verbose -style=Chromium v8go.h v8go.cc

// #cgo CXXFLAGS: -fno-rtti -fpic -std=c++14 -DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH -I${SRCDIR}/deps/include -Wall
// #cgo CXXFLAGS: -fno-rtti -fPIC -std=c++17 -DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH -I${SRCDIR}/deps/include -Wall -DV8_ENABLE_SANDBOX
// #cgo LDFLAGS: -pthread -lv8
// #cgo darwin,amd64 LDFLAGS: -L${SRCDIR}/deps/darwin_x86_64
// #cgo darwin,arm64 LDFLAGS: -L${SRCDIR}/deps/darwin_arm64
// #cgo linux LDFLAGS: -L${SRCDIR}/deps/linux_x86_64
// #cgo windows LDFLAGS: -L${SRCDIR}/deps/windows_x86_64 -static -ldbghelp -lssp -lwinmm -lz
// #cgo linux,amd64 LDFLAGS: -L${SRCDIR}/deps/linux_x86_64 -ldl
// #cgo linux,arm64 LDFLAGS: -L${SRCDIR}/deps/linux_arm64 -ldl
import "C"

// These imports forces `go mod vendor` to pull in all the folders that
Expand All @@ -21,6 +21,6 @@ import (
_ "rogchap.com/v8go/deps/darwin_arm64"
_ "rogchap.com/v8go/deps/darwin_x86_64"
_ "rogchap.com/v8go/deps/include"
_ "rogchap.com/v8go/deps/linux_arm64"
_ "rogchap.com/v8go/deps/linux_x86_64"
_ "rogchap.com/v8go/deps/windows_x86_64"
)
9 changes: 7 additions & 2 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,17 @@ func NewContext(opt ...ContextOption) *Context {
return ctx
}

// Isolate gets the current context's parent isolate.An error is returned
// if the isolate has been terninated.
// Isolate gets the current context's parent isolate.
func (c *Context) Isolate() *Isolate {
return c.iso
}

func (c *Context) RetainedValueCount() int {
ctxMutex.Lock()
defer ctxMutex.Unlock()
return int(C.ContextRetainedValueCount(c.ptr))
}

// RunScript executes the source JavaScript; origin (a.k.a. filename) provides a
// reference for the script and used in the stack trace if there is an error.
// error will be of type `JSError` if not nil.
Expand Down
6 changes: 3 additions & 3 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestJSExceptions(t *testing.T) {
origin string
err string
}{
{"SyntaxError", "bad js syntax", "syntax.js", "SyntaxError: Unexpected identifier"},
{"SyntaxError", "bad js syntax", "syntax.js", "SyntaxError: Unexpected identifier 'js'"},
{"ReferenceError", "add()", "add.js", "ReferenceError: add is not defined"},
}

Expand Down Expand Up @@ -104,8 +104,8 @@ func TestMemoryLeak(t *testing.T) {

for i := 0; i < 6000; i++ {
ctx := v8.NewContext(iso)
obj := ctx.Global()
_ = obj.String()
_ = ctx.Global()
// _ = obj.String()
_, _ = ctx.RunScript("2", "")
ctx.Close()
}
Expand Down
32 changes: 32 additions & 0 deletions cpuprofilenode.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
package v8go

type CPUProfileNode struct {
// The id of the current node, unique within the tree.
nodeId int

// The id of the script where the function originates.
scriptId int

// The resource name for script from where the function originates.
scriptResourceName string

Expand All @@ -17,13 +23,29 @@ type CPUProfileNode struct {
// The number of the column where the function originates.
columnNumber int

// The count of samples where the function was currently executing.
hitCount int

// The bailout reason for the function if the optimization was disabled for it.
bailoutReason string

// The children node of this node.
children []*CPUProfileNode

// The parent node of this node.
parent *CPUProfileNode
}

// Returns node id.
func (c *CPUProfileNode) GetNodeId() int {
return c.nodeId
}

// Returns id for script from where the function originates.
func (c *CPUProfileNode) GetScriptId() int {
return c.scriptId
}

// Returns function name (empty string for anonymous functions.)
func (c *CPUProfileNode) GetFunctionName() string {
return c.functionName
Expand All @@ -44,6 +66,16 @@ func (c *CPUProfileNode) GetColumnNumber() int {
return c.columnNumber
}

// Returns count of samples where the function was currently executing.
func (c *CPUProfileNode) GetHitCount() int {
return c.hitCount
}

// Returns the bailout reason for the function if the optimization was disabled for it.
func (c *CPUProfileNode) GetBailoutReason() string {
return c.bailoutReason
}

// Retrieves the ancestor node, or nil if the root.
func (c *CPUProfileNode) GetParent() *CPUProfileNode {
return c.parent
Expand Down
9 changes: 7 additions & 2 deletions cpuprofiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,21 @@ func (c *CPUProfiler) StopProfiling(title string) *CPUProfile {

func newCPUProfileNode(node *C.CPUProfileNode, parent *CPUProfileNode) *CPUProfileNode {
n := &CPUProfileNode{
nodeId: int(node.nodeId),
scriptId: int(node.scriptId),
scriptResourceName: C.GoString(node.scriptResourceName),
functionName: C.GoString(node.functionName),
lineNumber: int(node.lineNumber),
columnNumber: int(node.columnNumber),
hitCount: int(node.hitCount),
bailoutReason: C.GoString(node.bailoutReason),
parent: parent,
}

if node.childrenCount > 0 {
for _, child := range (*[1 << 28]*C.CPUProfileNode)(unsafe.Pointer(node.children))[:node.childrenCount:node.childrenCount] {
n.children = append(n.children, newCPUProfileNode(child, n))
n.children = make([]*CPUProfileNode, node.childrenCount)
for i, child := range (*[1 << 28]*C.CPUProfileNode)(unsafe.Pointer(node.children))[:node.childrenCount:node.childrenCount] {
n.children[i] = newCPUProfileNode(child, n)
}
}

Expand Down
4 changes: 2 additions & 2 deletions deps/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
treat_warnings_as_errors=false
v8_embedder_string="-v8go"
v8_enable_gdbjit=false
v8_enable_i18n_support=false
v8_enable_i18n_support=true
icu_use_data_file=false
v8_enable_test_features=false
v8_untrusted_code_mitigations=false
exclude_unwind_tables=true
"""

Expand Down
Loading

0 comments on commit ec2c03e

Please sign in to comment.