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

ArrayBuffers use firstChild - could they use lastChild? #2443

Open
gfwilliams opened this issue Dec 19, 2023 · 0 comments
Open

ArrayBuffers use firstChild - could they use lastChild? #2443

gfwilliams opened this issue Dec 19, 2023 · 0 comments

Comments

@gfwilliams
Copy link
Member

We had issues with ArrayBuffer not fitting in 12 byte systems: https://forum.espruino.com/conversations/392509/#comment17229419

I've fixed it, but one reason is we point to the string containing the data from firstChild, but lastChild is unused:

 | Offset | Size | Name    | STRING | STR_EXT  | NAME_STR | NAME_INT | INT  | DOUBLE  | OBJ/FUNC/ARRAY | ARRAYBUFFER | NATIVE_STR | FLAT_STR |
 | 16b    |      |         |        |          |          |          |      |         |                |             | FLASH_STR  |          |
 |--------|------|---------|--------|----------|----------|----------|------|---------|----------------|-------------|------------|----------|
 | 0 - 3  | 4    | varData | data   | data     |  data    | data     | data | data    | nativePtr      | size        | ptr        | charLen  |
 | 4 - 5  | ?    | next    | data   | data     |  next    | next     |  -   | data    | argTypes       | format      | len        | -        |
 | 6 - 7  | ?    | prev    | data   | data     |  prev    | prev     |  -   | data    | argTypes       | format      | ..len      | -        |
 | 8 - 9  | ?    | first   | data   | data     |  child   | child    |  -   | data?   | first          | stringPtr   | ..len      | -        |
 | 10-11  | ?    | refs    | refs   | data     |  refs    | refs     | refs | refs    | refs           | refs        | refs       | refs     |
 | 12-13  | ?    | last    | nextPtr| nextPtr  |  nextPtr |  -       |  -   |  -      | last           | -           | -          | -        |
 | 14-15  | 2    | Flags   | Flags  | Flags    |  Flags   | Flags    | Flags| Flags   | Flags          | Flags       | Flags      | Flags    |

I think it's done because for names we use firstChild to point onwards so we can re-use the same freeing code, but if we did use lastChild it'd give us a little more room, potentially to allow >16 bit byte offsets which I know has been asked for

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

No branches or pull requests

1 participant