Skip to content
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

Memory improvements + Type analysis #56

Open
wants to merge 40 commits into
base: main
Choose a base branch
from

Conversation

BobVarioa
Copy link
Contributor

@BobVarioa BobVarioa commented Jun 2, 2024

Summary:

  • adds an allocString method to the allocator, currently only for the static allocator
  • changes String.prototype.concat to be a builtin method, instead of a function in codegen
  • removed all Porffor.bs/s calls
  • adds Porffor.allocatePage<type> and Porffor.allocateBytes<type> as simple memory management utilities
  • rewrites some methods to allocate bytes instead of pages
  • reenables js type inference (this allows String.prototype.concat to function in more cases, along with many other methods)
  • adds Porffor.allocateNamedPage<type>(key) to create a pointer to a single keyed place in memory

Current issues: (box is checked if it is completed)

  • Precompiled strings are not yet included at runtime
  • All strings should be initialized at the beginning of a program, and not at various locations throughout
  • makeStringBuffer should be removed, as it has been superceded by the Porffor.allocate methods
  • Improve compiler performance for precompiled strings, it's currently at unacceptable levels
  • Investigate the -0.09 percent test262 drop
    • Most of these seem to be uncovered issues? i.e. there is a lot of new TypedArray failures, but that's mostly because we don't have ArrayBuffer

Future extensions:

  • Avoid Porffor.allocatePage whenever possible, choosing Porffor.allocateBytes instead
  • Convert the current array implementation to a linked list so that it can actually have the benefits of allocateBytes (set as well)
  • Actual malloc and free, to be any useful requires a GC so likely far future

Copy link
Owner

@CanadaHonk CanadaHonk left a comment

Choose a reason for hiding this comment

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

Thanks! Commented

compiler/builtins/string_f64.ts Outdated Show resolved Hide resolved
@BobVarioa BobVarioa changed the title Compress constant strings Memory improvements Jun 4, 2024
@BobVarioa BobVarioa changed the title Memory improvements Memory improvements + Type analysis Jun 6, 2024
@BobVarioa BobVarioa marked this pull request as ready for review June 7, 2024 14:55
@BobVarioa
Copy link
Contributor Author

I still think this PR is not quite ready to be merged, but I think it's at a stage where this is no longer a draft

Copy link
Owner

@CanadaHonk CanadaHonk left a comment

Choose a reason for hiding this comment

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

We're going to slowly incrementally add the improvements from this into main instead of just merging one chunky PR :)

compiler/builtins/annexb_string.js Show resolved Hide resolved
compiler/builtins/annexb_string.ts Show resolved Hide resolved
compiler/builtins/array.ts Show resolved Hide resolved
CanadaHonk added a commit that referenced this pull request Jun 7, 2024
based off #56

Co-Authored-By: Bob Varioa <60078104+BobVarioa@users.noreply.github.com>
CanadaHonk added a commit that referenced this pull request Jun 21, 2024
partially from #56

Co-Authored-By: Bob Varioa <60078104+BobVarioa@users.noreply.github.com>
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.

None yet

3 participants