Skip to content

internal: delete/replace sizegen build script #9765

Open
@paperclover

Description

@paperclover

right now sizegen.cpp is not being run. it is committed and not generated in CMake

it's original purpose does not actually work well for this case, but there are places it is useful to have an opaque type but know offsets of certain fields in order to access C++ data from Zig.

This script should be run automatically by the CMake build system so that upgrades to JavaScriptCore

  • fix the generated values.
  • compile error if JSC renames or removes a value.

Same time is a good time to refactor things like argumentsCount

    pub fn argumentsCount(self: *const CallFrame) usize {
        return @as(usize, @intCast((@as([*]align(alignment) const JSC.JSValue, @ptrCast(@alignCast(self))) + Sizes.Bun_CallFrame__argumentCountIncludingThis)[0].asInt32() - 1));
    }

This looks awful, as if someone generated this. And if you assert that the .asInt32() is valid, you find that it is not. However, this isnt an issue because the true type of argumentCountIncludingThis is c_int, which lucky for us is safe enough to interpret as a JSValue and call asInt32 on to get the c_int data out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    choreTask to improve the repository

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions