Most recent activity
-
If I'm not passing the array as a flat data area in the ram, the source code says, that I'm getting an array of JSVar pointers instead. So would it be correct to have an **int params parameter then, since it's actually an array of pointers. How do I retrieve the value of this variable then? Is there some param[0]->get_value()? I did not find anything in the source code.
But I actually would prefer the flat array option, since this makes working with the values far easier. As said in a comment above: I'm really not that into C at all. I'm just tinkering around with it. Thanks for any of your help. -
Thank you for your reply. Your advice at least solves part of the problem. Now the first variable in the array params[0] is the expected value. But unfortunately not the others (params[1..n]).
I tried padding the Uint32Array to 32bytes and 64bytes without any further luck. Do you have any other Idea? Does it have something to do with signed or unsigned bytes? -
I also tried to change my C-function signature to
int find_sequence(unsigned char* buffer, unsigned char* sequence, int sequence_length, int* params) {}
And pass in an Int32Array. This does not work either. What I noticed is, that whenever I'm returning any of the values from params, I get a static value, which stays the same - so something more like a fixed memory address. But I read that accessing a value by ptr[X] automatically dereferences it and lets me access the value as *(ptr + 0) would do.
-
Hi Gordon, I just came accross this question here and I've the same problem as user113695. I followed your advice, but I just get "garbage" data delivered in my C-function.
I'm not the C guy, so I definitly doing something wrong here
C-Function:// int find_sequence(int, int, int, int) int find_sequence(unsigned char* buffer, unsigned char* sequence, unsigned int sequence_length, unsigned int* params) {... return params[0]; }
And in the code I'm calling it with
const result = findNative.find_sequence( E.getAddressOf(this.buffer, true), E.getAddressOf(sequence, true), sequence.length, E.getAddressOf(new Uint32Array([ this.idx, this.next, offset, stepping ]), true) );
The first three parameters are working beautifully. No matter if I'm accessing params[0], params[1], params[2] or params[3], they all seem to have random values stored within.
Could you help out Gordon?
Thank you very much in advance. -
-
Ok, I found the mistake. "continue" is not supported. As I fixed that it worked after turning off any minification of the code. If I minify, it does somehow not work anymore but does not give me any hint why. I was finally able to shave off another 150ms from my computation, which is very good :) Thank you very much Gordon.
-
Thank you very much. After a bit of experimenting, I'm currently trying to find out, why the following function hangs indefinitly. It's a function which scans a portion (from this.idx to this.next) of an array for a given sequence, starting at an offset using a given stepping width.
find(sequence, offset, stepping) { "jit"; if (stepping === undefined) { stepping = 1; } if (offset === undefined) { offset = 0; } for (let i = this.idx + offset; i < this.next - sequence.length; i+=stepping) { if (this.buffer[i] !== sequence[0]) { continue; } let idx = i; for (let j = 1; j < sequence.length; j++) { if (this.buffer[i + j] !== sequence[j]) { idx = -1; // JIT lacks break statement j = sequence.length - 1; } } if (idx !== -1) { return idx; } } return -1; }
When I run it without jit it works as expected. If the function is jitted, the application hangs without any error. Thank you for your reply
-
Now it gets really strange: This works, but why?
Accessing data at index 0, 8, 12 and 13. Any other "configuration" using different 0-spacings does not work. I'm completly lost.