Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ export function outlineFunctions(
value.kind === 'FunctionExpression' ||
value.kind === 'ObjectMethod'
) {
// Recurse in case there are inner functions which can be outlined
outlineFunctions(value.loweredFunc.func, fbtOperands);
// Don't outline inner functions from parents with 'worklet' directive as it might break multi-threading assumptions.
const canOutlineInnerFunctions = value.loweredFunc.func.directives
? !value.loweredFunc.func.directives.includes('worklet')
: true;
if (canOutlineInnerFunctions) {
{
// Recurse in case there are inner functions which can be outlined
outlineFunctions(value.loweredFunc.func, fbtOperands);
}
}
if (
value.kind === 'FunctionExpression' &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function Component() {
t0 = () => {
"worklet";

setCount(_temp);
setCount((count_0) => count_0 + 1);
};
$[0] = t0;
} else {
Expand All @@ -45,9 +45,6 @@ function Component() {
}
return t1;
}
function _temp(count_0) {
return count_0 + 1;
}

```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function Component() {
t0 = function update() {
"worklet";

setCount(_temp);
setCount((count_0) => count_0 + 1);
};
$[0] = t0;
} else {
Expand All @@ -51,9 +51,6 @@ function Component() {
}
return t1;
}
function _temp(count_0) {
return count_0 + 1;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

## Input

```javascript
const useSomeHook = () => {};

const Component = () => {
useSomeHook(() => {
'worklet';
return [1, 2, 3].map(() => null);
});

return null;
};

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [],
isComponent: true,
};

```

## Code

```javascript
const useSomeHook = () => {};

const Component = () => {
useSomeHook(_temp);

return null;
};

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [],
isComponent: true,
};
function _temp() {
"worklet";
return [1, 2, 3].map(() => null);
}

```

### Eval output
(kind: ok) null
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const useSomeHook = () => {};

const Component = () => {
useSomeHook(() => {
'worklet';
return [1, 2, 3].map(() => null);
});

return null;
};

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [],
isComponent: true,
};