Skip to content

Split runtime into multiple files #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jan 24, 2022
Merged

Split runtime into multiple files #150

merged 22 commits into from
Jan 24, 2022

Conversation

j-f1
Copy link
Member

@j-f1 j-f1 commented Jan 8, 2022

This PR:

  • splits the runtime TypeScript code up into several separate modules
  • adds Rollup to compile that back into a single JS file
  • uses Rollup to produce two bundles instead of one:
    • one that uses UMD to allow use with Node-style require, or by embedding it with a <script> tag and using window.JavaScriptKit
    • one that uses ES Modules
  • refactor the codebase to use a Memory class that provides easy access to memory and the heap
  • check for FinalizationRegistry availability in SwiftClosureDeallocator constructor rather than outside of it

@github-actions
Copy link

github-actions bot commented Jan 8, 2022

Time Change: -307ms (3%)

Total Time: 8,905.5ms

Test name Duration Change
Object heap/Increment and decrement RC 2,731.25ms -223ms (8%)
ℹ️ View Unchanged
Test name Duration Change
Serialization/Write JavaScript number directly 196ms -6ms (3%)
Serialization/Write JavaScript string directly 200.25ms -4.5ms (2%)
Serialization/Swift Int to JavaScript 2,983.75ms +2.75ms (0%)
Serialization/Swift String to JavaScript 2,794.25ms -76.25ms (2%)

performance-action

@kateinoigakukun
Copy link
Member

Some tests are failing 👀

Error in Literal Conversion

MessageError(message: "Expect to be equal \"212205744152385\" and \"4746794007244308480\"", file: "/home/runner/work/JavaScriptKit/JavaScriptKit/IntegrationTests/TestSuites/Sources/PrimaryTests/main.swift", line: 26, column: 28)

Swift/ErrorType.swift:200: Fatal error: Error raised at top level: PrimaryTests.MessageError(message: "Expect to be equal \"212205744152385\" and \"4746794007244308480\"", file: "/home/runner/work/JavaScriptKit/JavaScriptKit/IntegrationTests/TestSuites/Sources/PrimaryTests/main.swift", line: 26, column: 28)

RuntimeError: unreachable
    at $ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF (wasm://wasm/02991d2a:wasm-function[2633]:0xccfd3)
    at swift_errorInMain (wasm://wasm/02991d2a:wasm-function[4819]:0x14b4ac)
    at main (wasm://wasm/02991d2a:wasm-function[1532]:0x76025)
    at main (wasm://wasm/02991d2a:wasm-function[29674]:0x622f25)
    at __main_void (wasm://wasm/02991d2a:wasm-function[29675]:0x622fa1)
    at __original_main (wasm://wasm/02991d2a:wasm-function[29672]:0x622ee6)
    at _start (wasm://wasm/02991d2a:wasm-function[45]:0x10884)
    at d.start (/home/runner/work/JavaScriptKit/JavaScriptKit/IntegrationTests/node_modules/@wasmer/wasi/lib/index.cjs.js:77:280)
    at startWasiTask (/home/runner/work/JavaScriptKit/JavaScriptKit/IntegrationTests/lib.js:47:10)

@j-f1
Copy link
Member Author

j-f1 commented Jan 24, 2022

It turned out to be an endianness issue, oof. Hoping this change fixes it 🤞

@j-f1 j-f1 requested a review from a team January 24, 2022 12:49
@MaxDesiatov MaxDesiatov requested a review from a team January 24, 2022 13:02
Copy link
Contributor

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall seems legit 👍 but I'd wait for at least one more approval from the team

@MaxDesiatov MaxDesiatov requested a review from a team January 24, 2022 13:46
@j-f1 j-f1 merged commit 20c634a into main Jan 24, 2022
@j-f1 j-f1 deleted the jed/runtime-js-modules branch January 24, 2022 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants