Skip to content

Commit

Permalink
Emulator: force stack alignment of 'data' variable when accessing Arr…
Browse files Browse the repository at this point in the history
…ayBuffers (fix #2463)
  • Loading branch information
gfwilliams committed Feb 7, 2024
1 parent 1c52b62 commit 548f35d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
: Graphics: Ensure floodFill sets modified area correctly
nRF52: Lower expected BLE XTAL accuracy to 50ppm (can improve BLE stability on some Bangle.js 2)
Emulator: force stack alignment of 'data' variable when accessing ArrayBuffers (fix #2463)

2v21 : nRF52: free up 800b more flash by removing vector table padding
Throw Exception when a Promise tries to resolve with another Promise (#2450)
Expand Down
10 changes: 5 additions & 5 deletions src/jsvariterator.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ static JsVarFloat jsvArrayBufferIteratorDataToFloat(JsvArrayBufferIterator *it,

JsVar *jsvArrayBufferIteratorGetValue(JsvArrayBufferIterator *it, bool bigEndian) {
if (it->type == ARRAYBUFFERVIEW_UNDEFINED) return 0;
char data[8];
char data[8] __attribute__ ((aligned (4)));
jsvArrayBufferIteratorGetValueData(it, data);
if (bigEndian)
reverseBytes(data, JSV_ARRAYBUFFER_GET_SIZE(it->type));
Expand All @@ -612,7 +612,7 @@ JsVar *jsvArrayBufferIteratorGetValueAndRewind(JsvArrayBufferIterator *it) {

JsVarInt jsvArrayBufferIteratorGetIntegerValue(JsvArrayBufferIterator *it) {
if (it->type == ARRAYBUFFERVIEW_UNDEFINED) return 0;
char data[8];
char data[8] __attribute__ ((aligned (4)));
jsvArrayBufferIteratorGetValueData(it, data);
if (JSV_ARRAYBUFFER_IS_FLOAT(it->type)) {
return (JsVarInt)jsvArrayBufferIteratorDataToFloat(it, data);
Expand All @@ -623,7 +623,7 @@ JsVarInt jsvArrayBufferIteratorGetIntegerValue(JsvArrayBufferIterator *it) {

JsVarFloat jsvArrayBufferIteratorGetFloatValue(JsvArrayBufferIterator *it) {
if (it->type == ARRAYBUFFERVIEW_UNDEFINED) return 0;
char data[8];
char data[8] __attribute__ ((aligned (4)));
jsvArrayBufferIteratorGetValueData(it, data);
if (JSV_ARRAYBUFFER_IS_FLOAT(it->type)) {
return jsvArrayBufferIteratorDataToFloat(it, data);
Expand Down Expand Up @@ -653,7 +653,7 @@ static void jsvArrayBufferIteratorFloatToData(char *data, unsigned int dataLen,
void jsvArrayBufferIteratorSetIntegerValue(JsvArrayBufferIterator *it, JsVarInt v) {
if (it->type == ARRAYBUFFERVIEW_UNDEFINED) return;
assert(!it->hasAccessedElement); // we just haven't implemented this case yet
char data[8];
char data[8] __attribute__ ((aligned (4)));
unsigned int i,dataLen = JSV_ARRAYBUFFER_GET_SIZE(it->type);

if (JSV_ARRAYBUFFER_IS_FLOAT(it->type)) {
Expand All @@ -672,7 +672,7 @@ void jsvArrayBufferIteratorSetIntegerValue(JsvArrayBufferIterator *it, JsVarInt
void jsvArrayBufferIteratorSetValue(JsvArrayBufferIterator *it, JsVar *value, bool bigEndian) {
if (it->type == ARRAYBUFFERVIEW_UNDEFINED) return;
assert(!it->hasAccessedElement); // we just haven't implemented this case yet
char data[8];
char data[8] __attribute__ ((aligned (8)));

This comment has been minimized.

Copy link
@fanoush

fanoush Feb 7, 2024

Contributor

just wondering, is the aligned (8) here a typo? Why 8 here and 4 in all other places?

This comment has been minimized.

Copy link
@gfwilliams

gfwilliams Feb 7, 2024

Author Member

Yes - typo!

int i,dataLen = (int)JSV_ARRAYBUFFER_GET_SIZE(it->type);

if (JSV_ARRAYBUFFER_IS_FLOAT(it->type)) {
Expand Down

0 comments on commit 548f35d

Please sign in to comment.