Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
buffer: align fast buffers on 8 byte boundary
Browse files Browse the repository at this point in the history
Prevents alignment issues when people create a typed array from a buffer.
Unaligned loads or stores are less efficent and (on some architectures) unsafe.
  • Loading branch information
bnoordhuis committed Mar 28, 2012
1 parent 67fc1da commit 285d8c6
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/buffer.js
Expand Up @@ -250,6 +250,7 @@ function Buffer(subject, encoding, offset) {
this.parent = pool;
this.offset = pool.used;
pool.used += this.length;
if (pool.used & 7) pool.used = (pool.used + 8) & ~7;
}

// Treat array-ish objects as a byte array.
Expand Down

4 comments on commit 285d8c6

@kapouer
Copy link

Choose a reason for hiding this comment

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

I'm going to check this on armv4t ! I still have that alignment issue with "über" test.

@kapouer
Copy link

Choose a reason for hiding this comment

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

With that patch applied on node 0.6.12,
test-buffer.js now pass on armv4t, while it's been failing reliably for quite some time.

@bnoordhuis
Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, that's good news. This commit is a provisional fix, there are more places that need alignment fix-ups. #3029 is the tracking issue.

@kapouer
Copy link

Choose a reason for hiding this comment

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

BTW all 0.6.12 tests pass on this armv5tel server
http://db.debian.org/machines.cgi?host=abel

but that's with the debian package (meaning using system v8, ev, cares).

Please sign in to comment.