repo
stringlengths
5
53
pr_number
int32
1
321k
task_type
stringclasses
2 values
issue_text
stringlengths
0
81.2k
pr_title
stringlengths
1
319
pr_body
stringlengths
0
105k
base_sha
stringlengths
40
40
head_sha
stringlengths
40
40
gold_diff
stringlengths
0
202M
changed_files
listlengths
0
100
review_threads
listlengths
0
100
test_patch
stringlengths
0
23.4M
merged
bool
1 class
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
### EXP optimization incorrectly folds `0^x` to zero **High Severity** <!-- DESCRIPTION START --> The rule `if left is 0 assigns 0` for `EXP` assumes `0^x = 0` for all `x`, but `0^0 = 1`. When the left operand is known to be 0 and the right operand is unknown at compile time, the optimizer replaces the `EXP` instruct...
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "### EXP optimization incorrectly folds `0^x` to zero\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\nThe rule `if left is 0 assigns 0` for `EXP` assumes `0^x = 0` for all `x`, but `0^0 = 1`. When the left operand is known to be 0 and the right operand is unknown at compile time, the optimizer ...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
### DIV optimization suppresses panic on division by zero **Medium Severity** <!-- DESCRIPTION START --> The `DIV` rule `if left is 0 assigns 0` replaces `DIV(dst, 0, x)` with `MOVI(dst, 0)` when the dividend is known to be zero but the divisor is unknown. FuelVM defines division by zero as a panic condition. If `x` ...
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "### DIV optimization suppresses panic on division by zero\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nThe `DIV` rule `if left is 0 assigns 0` replaces `DIV(dst, 0, x)` with `MOVI(dst, 0)` when the dividend is known to be zero but the divisor is unknown. FuelVM defines division by zero as...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
### `both_known` bail skips applicable identity and commutative rules **Medium Severity** <!-- DESCRIPTION START --> When both operands are known constants, the `both_known` macro arm enters its `if let` block. If the computed result doesn't fit in an 18-bit immediate, the `?` operator on `VirtualImmediate18::try_new...
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "### `both_known` bail skips applicable identity and commutative rules\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nWhen both operands are known constants, the `both_known` macro arm enters its `if let` block. If the computed result doesn't fit in an 18-bit immediate, the `?` operator on `...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
### Panicking `From<u64>` for `VirtualImmediate18` is unsound **Medium Severity** <!-- DESCRIPTION START --> The `From<u64>` implementation for `VirtualImmediate18` calls `new()`, which panics if the value exceeds 18 bits. The `From` trait contract implies infallible conversion. A `TryFrom` implementation (like the o...
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_lang/virtual_immediate.rs b/sway-core/src/asm_lang/virtual_immediate.rs index 8881fff9544..1844a0a94cb 100644 --- a/sway-core/src/asm_lang/virtual_immediate.rs +++ b/sway-core/src/asm_lang/virtual_immediate.rs @@ -120,11 +120,26 @@ impl fmt::Display for VirtualImmediate12 { } } +i...
[ "sway-core/src/asm_lang/virtual_immediate.rs" ]
[ { "comment": "### Panicking `From<u64>` for `VirtualImmediate18` is unsound\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nThe `From<u64>` implementation for `VirtualImmediate18` calls `new()`, which panics if the value exceeds 18 bits. The `From` trait contract implies infallible conversion. A `TryFrom`...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
For me being a first time reader of this code, the original comment wasn't informative enough. Proposal is to expand on it a bit. ```suggestion /// Remove `reg` and other known values that directly or indirectly (recursively) depend on `reg`. ```
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "For me being a first time reader of this code, the original comment wasn't informative enough. Proposal is to expand on it a bit. \n```suggestion\n /// Remove `reg` and other known values that directly or indirectly (recursively) depend on `reg`.\n```", "path": "sway-core/src/asm_generation...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
On first reading `clear` sounded like we are not _removing_ the values but rather setting them on some "cleared" value. IMO using _remove_ here will be much clearer. ```suggestion fn remove_dependent_on(&mut self, reg: &VirtualRegister) { ```
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "On first reading `clear` sounded like we are not _removing_ the values but rather setting them on some \"cleared\" value. IMO using _remove_ here will be much clearer.\n```suggestion\n fn remove_dependent_on(&mut self, reg: &VirtualRegister) {\n```", "path": "sway-core/src/asm_generation/fu...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
In other parts of the compiler we name this kind of a list a `worklist`. Proposal is to use the same name here. ```suggestion let mut worklist = vec![reg.clone()]; ```
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "In other parts of the compiler we name this kind of a list a `worklist`. Proposal is to use the same name here.\n```suggestion\n let mut worklist = vec![reg.clone()];\n```", "path": "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs", "hunk": "@@ -62,7 +69,18 @@ ...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
`extend` accepts an iterator so we don't need to `collect` here. Also, the `extract_if` will be fully iterated in `extend` and the elements removed. ```suggestion .map(|(k, _)| k); ```
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "`extend` accepts an iterator so we don't need to `collect` here. Also, the `extract_if` will be fully iterated in `extend` and the elements removed.\n```suggestion\n .map(|(k, _)| k);\n```", "path": "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs", "hu...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
Nitpick. Proposing as IMO better sounding enum variant name that align with "Reset what?". ```suggestion All, ```
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "Nitpick. Proposing as IMO better sounding enum variant name that align with \"Reset what?\".\n```suggestion\n All,\n```", "path": "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs", "hunk": "@@ -75,25 +93,31 @@ impl KnownValues {\n /// What knowledge is lost after a...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
Is this needed? `clear_dependent_on` also always removes the `reg` passed as an argument. So the above call to `clear_dependent_on` will also remove the `Overflow`.
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "Is this needed? `clear_dependent_on` also always removes the `reg` passed as an argument. So the above call to `clear_dependent_on` will also remove the `Overflow`.", "path": "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs", "hunk": "@@ -75,25 +93,31 @@ impl KnownVal...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
Same here for `Error`.
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "Same here for `Error`.", "path": "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs", "hunk": "@@ -75,25 +93,31 @@ impl KnownValues {\n /// What knowledge is lost after an op we don't know how to interpret?\n #[derive(Clone, Debug)]\n enum ResetKnown {\n- /// Reset a...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
Same here, `d` should be removed in the above `clear_dependent_on` call. ```suggestion ```
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "Same here, `d` should be removed in the above `clear_dependent_on` call. \n```suggestion\n```", "path": "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs", "hunk": "@@ -104,13 +128,25 @@ impl ResetKnown {\n known_values.values.remove(d);", "reso...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
Same here. ```suggestion ```
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "Same here.\n```suggestion\n```", "path": "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs", "hunk": "", "resolving_sha": "2765f4af57abc203a826d5890c77e4593c6095ff", "resolving_diff": "diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propag...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
I am thinking here about adding the `log` than to all optimization methods (`dce`, `simplify_cfg`, ...) for completeness and that it's clear we want to use this as a pattern. Currently, it looks more as a temporary exception. Moreover, we can pass than the log to `AbstractInstructionSet::optimize` from the `optimize` ...
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "I am thinking here about adding the `log` than to all optimization methods (`dce`, `simplify_cfg`, ...) for completeness and that it's clear we want to use this as a pattern. Currently, it looks more as a temporary exception.\n\nMoreover, we can pass than the log to `AbstractInstructionSet::optimi...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
```suggestion // - "JMP LABEL" if reg is not zero ```
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "```suggestion\n // - \"JMP LABEL\" if reg is not zero\n```", "path": "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs", "hunk": "@@ -137,18 +173,20 @@ impl AbstractInstructionSet {\n \n for op in &mut self.ops {\n // Perform constant pro...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
Great idea to express the transformation as a DSL! ❤️ It makes both defining the transformations and reviewing them so much easier.
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "Great idea to express the transformation as a DSL! ❤️ It makes both defining the transformations and reviewing them so much easier.", "path": "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs", "hunk": "@@ -174,75 +212,697 @@ impl AbstractInstructionSet {\n ...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
```suggestion // If the value is one of the operands, we will use MOVE, // if it is a literal we will use MOVI ```
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "```suggestion\n // If the value is one of the operands, we will use MOVE,\n // if it is a literal we will use MOVI\n```", "path": "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs", "hunk": "@@ -174,75 +212,697 @@ impl AbstractInstructionS...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
```suggestion // Also transform them if their registers are known ```
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "```suggestion\n // Also transform them if their registers are known\n```", "path": "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs", "hunk": "@@ -174,75 +212,697 @@ impl AbstractInstructionSet {\n }\n }\n \n- // Some ...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
Nitpick. IMO, looks more natural to read in English if it is in imperative mode than third person singular. ```suggestion (gen; $op:ident, $opI:ident; $dst:ident, $l:ident, $r:ident, $lv: ident, $rv:ident; if left is $initial_value:literal assign $end_value:tt; $($rest:tt)*) => { ```
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "Nitpick. IMO, looks more natural to read in English if it is in imperative mode than third person singular.\n```suggestion\n (gen; $op:ident, $opI:ident; $dst:ident, $l:ident, $r:ident, $lv: ident, $rv:ident; if left is $initial_value:literal assign $end_value:tt; $($rest:tt)*) => {...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
Same. ```suggestion (gen; $op:ident, $opI:ident; $dst:ident, $l:ident, $r:ident, $lv: ident, $rv:ident; if right is $initial_value:literal assign $end_value:tt; $($rest:tt)*) => { ```
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "Same.\n```suggestion\n (gen; $op:ident, $opI:ident; $dst:ident, $l:ident, $r:ident, $lv: ident, $rv:ident; if right is $initial_value:literal assign $end_value:tt; $($rest:tt)*) => {\n```", "path": "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs", "hun...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
```suggestion commutative: true; ```
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "```suggestion\n commutative: true;\n```", "path": "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs", "hunk": "@@ -174,75 +212,697 @@ impl AbstractInstructionSet {\n }\n }\n \n- // Some ops are known to produce ...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
Just thinking, for testing `constant_propagate` it makes no difference, but in a general case, optimizations run on functions and most of them do not care if it is an entry or not. So I guess the most general case would be `function: Some(("dummy_test_fn", false))` but indeed if feels strange as a default. I would sa...
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "Just thinking, for testing `constant_propagate` it makes no difference, but in a general case, optimizations run on functions and most of them do not care if it is an entry or not.\n\nSo I guess the most general case would be `function: Some((\"dummy_test_fn\", false))` but indeed if feels strange...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
Having a test for overflow would be good. Adding two known values that result in an overflow should not do any replacement.
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "Having a test for overflow would be good. Adding two known values that result in an overflow should not do any replacement.", "path": "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs", "hunk": "@@ -174,75 +204,697 @@ impl AbstractInstructionSet {\n }\n...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
Same here for underflow.
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "Same here for underflow.", "path": "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs", "hunk": "@@ -174,75 +204,697 @@ impl AbstractInstructionSet {\n }\n }\n \n- // Some ops are known to produce certain results, interpret them he...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
And here for overflow again.
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 1f0a93772bb..90ecbdb9768 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs" ]
[ { "comment": "And here for overflow again.", "path": "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs", "hunk": "@@ -174,75 +204,697 @@ impl AbstractInstructionSet {\n }\n }\n \n- // Some ops are known to produce certain results, interpret the...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
Nit. ```suggestion /// Examples: Error, Overflow, Flags, etc. ```
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_lang/mod.rs b/sway-core/src/asm_lang/mod.rs index 805470d600f..cc302e5fe37 100644 --- a/sway-core/src/asm_lang/mod.rs +++ b/sway-core/src/asm_lang/mod.rs @@ -94,6 +94,16 @@ pub(crate) struct Op { pub(crate) owning_span: Option<Span>, } +impl From<VirtualOp> for Op { + fn from(o...
[ "sway-core/src/asm_lang/mod.rs" ]
[ { "comment": "Nit.\n```suggestion\n /// Examples: Error, Overflow, Flags, etc.\n```", "path": "sway-core/src/asm_lang/mod.rs", "hunk": "@@ -700,20 +710,24 @@ impl Op {\n }\n \n /// Returns a list of all registers *read* by instruction `self`.\n- pub(crate) fn use_registers_mut(&mut self) -...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
```suggestion pub fn movi(a: impl Into<VirtualRegister>, b: impl Into<VirtualImmediate18>) -> VirtualOp { ```
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_lang/virtual_ops.rs b/sway-core/src/asm_lang/virtual_ops.rs index 57ac24ff488..f5a6a2dba6d 100644 --- a/sway-core/src/asm_lang/virtual_ops.rs +++ b/sway-core/src/asm_lang/virtual_ops.rs @@ -249,6 +249,146 @@ pub(crate) enum VirtualOp { } impl VirtualOp { + pub fn r#move(a: impl Int...
[ "sway-core/src/asm_lang/virtual_ops.rs" ]
[ { "comment": "```suggestion\n pub fn movi(a: impl Into<VirtualRegister>, b: impl Into<VirtualImmediate18>) -> VirtualOp {\n```", "path": "sway-core/src/asm_lang/virtual_ops.rs", "hunk": "@@ -249,6 +249,142 @@ pub(crate) enum VirtualOp {\n }\n \n impl VirtualOp {\n+ pub fn r#move(a: impl Into<Virtu...
true
FuelLabs/sway
7,550
comment_to_fix
Improve `asm` const propagation
```suggestion /// Examples: Error, Overflow, Flags, etc. ```
5cd44e7788de590177213e1b4040493b2db8b989
2765f4af57abc203a826d5890c77e4593c6095ff
diff --git a/sway-core/src/asm_lang/virtual_ops.rs b/sway-core/src/asm_lang/virtual_ops.rs index 57ac24ff488..f5a6a2dba6d 100644 --- a/sway-core/src/asm_lang/virtual_ops.rs +++ b/sway-core/src/asm_lang/virtual_ops.rs @@ -249,6 +249,146 @@ pub(crate) enum VirtualOp { } impl VirtualOp { + pub fn r#move(a: impl Int...
[ "sway-core/src/asm_lang/virtual_ops.rs" ]
[ { "comment": "```suggestion\n /// Examples: Error, Overflow, Flags, etc.\n```", "path": "sway-core/src/asm_lang/virtual_ops.rs", "hunk": "@@ -480,7 +616,8 @@ impl VirtualOp {\n }\n }\n \n- // What are the special registers that an OP may set.\n+ /// What are the special registers th...
true
FuelLabs/sway
7,569
issue_to_patch
Bump Rust to 1.93.0
## Description This PR: - bumps CI version of Rust to 1.93.0, - fixes new Clippy issues, - explicitly installs `forc-node` from the `forc` repo in the `build-mdbook` CI step. ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. ...
56a6518ed5aca466ce0c2cccfe43c5cd4f45cf03
cea3271f8288104865bae95d083a511353ee3117
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a23912d2b7b..0e379449fce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,8 +18,8 @@ permissions: env: CARGO_TERM_COLOR: always REGISTRY: ghcr.io - RUST_VERSION: 1.90.0 - NIGHTLY_RUST_VERSION: nightly-2025-09-28 +...
[ ".github/workflows/ci.yml", ".github/workflows/gh-pages.yml", "forc-pkg/src/source/git/mod.rs", "forc-plugins/forc-debug/src/server/handlers/handle_variables.rs", "sway-core/src/control_flow_analysis/dead_code_analysis.rs", "sway-core/src/language/ty/expression/expression_variant.rs", "sway-core/src/tra...
[ { "comment": "### Overbroad unused_assignments suppression on large function\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\nThe `#[allow(unused_assignments)]` is applied at the function level on `connect_expression`, which is a very large function (~800 lines with dozens of match arms and many variable assi...
diff --git a/test/src/test_consistency.rs b/test/src/test_consistency.rs index 80d69a983b4..c5055654510 100644 --- a/test/src/test_consistency.rs +++ b/test/src/test_consistency.rs @@ -124,18 +124,15 @@ fn check_test_forc_tomls(all_tests_dir: &Path) -> Result<()> { // 'implicit-std' is not explicitly set. ...
true
FuelLabs/sway
7,569
comment_to_fix
Bump Rust to 1.93.0
### Overbroad unused_assignments suppression on large function **Low Severity** <!-- DESCRIPTION START --> The `#[allow(unused_assignments)]` is applied at the function level on `connect_expression`, which is a very large function (~800 lines with dozens of match arms and many variable assignments). The comment says ...
56a6518ed5aca466ce0c2cccfe43c5cd4f45cf03
cea3271f8288104865bae95d083a511353ee3117
diff --git a/sway-core/src/control_flow_analysis/dead_code_analysis.rs b/sway-core/src/control_flow_analysis/dead_code_analysis.rs index eba1658ba2f..2e0dcf09d30 100644 --- a/sway-core/src/control_flow_analysis/dead_code_analysis.rs +++ b/sway-core/src/control_flow_analysis/dead_code_analysis.rs @@ -429,7 +429,6 @@ fn ...
[ "sway-core/src/control_flow_analysis/dead_code_analysis.rs" ]
[ { "comment": "### Overbroad unused_assignments suppression on large function\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\nThe `#[allow(unused_assignments)]` is applied at the function level on `connect_expression`, which is a very large function (~800 lines with dozens of match arms and many variable assi...
true
FuelLabs/sway
7,569
comment_to_fix
Bump Rust to 1.93.0
Is that expected change?
56a6518ed5aca466ce0c2cccfe43c5cd4f45cf03
cea3271f8288104865bae95d083a511353ee3117
diff --git a/sway-core/src/control_flow_analysis/dead_code_analysis.rs b/sway-core/src/control_flow_analysis/dead_code_analysis.rs index eba1658ba2f..2e0dcf09d30 100644 --- a/sway-core/src/control_flow_analysis/dead_code_analysis.rs +++ b/sway-core/src/control_flow_analysis/dead_code_analysis.rs @@ -429,7 +429,6 @@ fn ...
[ "sway-core/src/control_flow_analysis/dead_code_analysis.rs" ]
[ { "comment": "Is that expected change?", "path": "sway-core/src/control_flow_analysis/dead_code_analysis.rs", "hunk": "@@ -1405,7 +1401,6 @@ fn connect_expression<'eng: 'cfg, 'cfg>(\n param_leaves = vec![];\n }\n }\n- options.force_struct_fields...
true
FuelLabs/sway
7,562
issue_to_patch
Bump keccak from 0.1.5 to 0.1.6 in /test/src/sdk-harness
Bumps [keccak](https://github.com/RustCrypto/sponges) from 0.1.5 to 0.1.6. <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/RustCrypto/sponges/commit/a8936d9662ca92fd177d289580066ceabb937b0c"><code>a8936d9</code></a> keccak v0.1.6</li> <li>See full diff in <a href="https://github.com/RustCrypto...
cd3465c83d19f40b29c9b5840d9d1503db16face
aca25eb3761e2fd418bb6f1bef716fe9c0734ecf
[ "test/src/sdk-harness/Cargo.lock" ]
[]
diff --git a/test/src/sdk-harness/Cargo.lock b/test/src/sdk-harness/Cargo.lock index f179bdddc0c..d284ba23027 100644 --- a/test/src/sdk-harness/Cargo.lock +++ b/test/src/sdk-harness/Cargo.lock @@ -4464,9 +4464,9 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.5" +version = "0.1.6" source = "registr...
true
FuelLabs/sway
7,563
issue_to_patch
Verify all jumps on asm are using ControlFlowOp
## Description This PR will be useful for https://github.com/FuelLabs/sway/pull/7550 testing. Currently, we expect all jumps to use `ControlFlowOp`. We have two exceptions at the moment: 1 - JAL when returning from functions; 2 - and `__jmp_mem()` used on `run_external`. This PR fixes both by removing all jum...
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd8018e48f1..a23912d2b7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,6 @@ jobs: - check-sdk-harness-test-suite-compatibility - build-mdbook - build-forc-doc-sway-lib-std - - build-forc-...
[ ".github/workflows/ci.yml", "Cargo.lock", "sway-core/src/asm_generation/fuel/abstract_instruction_set.rs", "sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs", "sway-core/src/asm_generation/fuel/fuel_asm_builder.rs", "sway-core/src/asm_generation/fuel/functions.rs", "sway-core/src/...
[ { "comment": "### JumpToAddr not recognized as block-ending control flow\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nThe basic block tracking in `collect_far_jumps()` and `map_label_offsets()` doesn't recognize `JumpToAddr` as a block-ending control flow operation. The pattern match only checks for `L...
diff --git a/test/Cargo.toml b/test/Cargo.toml index 0707ef8080d..2c25e47067a 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -23,12 +23,14 @@ fuels.workspace = true fuels-accounts.workspace = true futures.workspace = true gag.workspace = true +gimli.workspace = true git2.workspace = true glob.workspace = tr...
true
FuelLabs/sway
7,563
comment_to_fix
Verify all jumps on asm are using ControlFlowOp
### JumpToAddr not recognized as block-ending control flow **Medium Severity** <!-- DESCRIPTION START --> The basic block tracking in `collect_far_jumps()` and `map_label_offsets()` doesn't recognize `JumpToAddr` as a block-ending control flow operation. The pattern match only checks for `Label` and `Jump`, but `Jump...
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs b/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs index e8f76595c03..abdfde3511e 100644 --- a/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs +++ b/sway-core/src/asm_generation/fuel/alloc...
[ "sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs" ]
[ { "comment": "### JumpToAddr not recognized as block-ending control flow\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nThe basic block tracking in `collect_far_jumps()` and `map_label_offsets()` doesn't recognize `JumpToAddr` as a block-ending control flow operation. The pattern match only checks for `L...
true
FuelLabs/sway
7,563
comment_to_fix
Verify all jumps on asm are using ControlFlowOp
### ReturnFromCall display has extra whitespace **Low Severity** <!-- DESCRIPTION START --> `ControlFlowOp::ReturnFromCall` formats as `jal $zero $$reta i0` with two spaces after `jal`. If any tests, snapshots, or tooling rely on stable assembly text formatting from `fmt::Display`, this can cause spurious diffs or f...
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/sway-core/src/asm_lang/mod.rs b/sway-core/src/asm_lang/mod.rs index 8a2f75fd761..805470d600f 100644 --- a/sway-core/src/asm_lang/mod.rs +++ b/sway-core/src/asm_lang/mod.rs @@ -441,54 +441,6 @@ impl Op { } /* Control Flow Instructions */ - "jmp" => { - l...
[ "sway-core/src/asm_lang/mod.rs" ]
[ { "comment": "### ReturnFromCall display has extra whitespace\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\n`ControlFlowOp::ReturnFromCall` formats as `jal $zero $$reta i0` with two spaces after `jal`. If any tests, snapshots, or tooling rely on stable assembly text formatting from `fmt::Display`, this ca...
true
FuelLabs/sway
7,563
comment_to_fix
Verify all jumps on asm are using ControlFlowOp
```suggestion // We cannot guarantee the jump will not end in an ```
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/sway-core/src/asm_generation/fuel/optimizations/reachability.rs b/sway-core/src/asm_generation/fuel/optimizations/reachability.rs index d7febb94a83..807208dd877 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/reachability.rs +++ b/sway-core/src/asm_generation/fuel/optimizations/reachability.rs...
[ "sway-core/src/asm_generation/fuel/optimizations/reachability.rs" ]
[ { "comment": "```suggestion\n // We cannot guarantee the jump will not end in an\n```", "path": "sway-core/src/asm_generation/fuel/optimizations/reachability.rs", "hunk": "@@ -15,6 +15,12 @@ impl AbstractInstructionSet {\n let mut cur_live = BTreeSet::default();\n let mut dead...
true
FuelLabs/sway
7,563
comment_to_fix
Verify all jumps on asm are using ControlFlowOp
```suggestion // We cannot guarantee the jump will not end in an ```
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/sway-core/src/asm_generation/fuel/optimizations/reachability.rs b/sway-core/src/asm_generation/fuel/optimizations/reachability.rs index d7febb94a83..807208dd877 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/reachability.rs +++ b/sway-core/src/asm_generation/fuel/optimizations/reachability.rs...
[ "sway-core/src/asm_generation/fuel/optimizations/reachability.rs" ]
[ { "comment": "```suggestion\n // We cannot guarantee the jump will not end in an\n```", "path": "sway-core/src/asm_generation/fuel/optimizations/reachability.rs", "hunk": "@@ -80,8 +86,16 @@ impl AbstractInstructionSet {\n // Keep track of a map between jump labels and op indices....
true
FuelLabs/sway
7,563
comment_to_fix
Verify all jumps on asm are using ControlFlowOp
I rather wouldn't remove jump instructions from `asm` for the reasons given in #7485. To my knowledge there is no other way to construct arbitrary ASM/bytecode at the moment if we need jumps in it for experimenting purposes. I needed that like only twice, but per Murphy's law, as soon as we remove them, there will be n...
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/sway-core/src/asm_lang/mod.rs b/sway-core/src/asm_lang/mod.rs index 8a2f75fd761..805470d600f 100644 --- a/sway-core/src/asm_lang/mod.rs +++ b/sway-core/src/asm_lang/mod.rs @@ -441,54 +441,6 @@ impl Op { } /* Control Flow Instructions */ - "jmp" => { - l...
[ "sway-core/src/asm_lang/mod.rs" ]
[ { "comment": "I rather wouldn't remove jump instructions from `asm` for the reasons given in #7485. To my knowledge there is no other way to construct arbitrary ASM/bytecode at the moment if we need jumps in it for experimenting purposes. I needed that like only twice, but per Murphy's law, as soon as we remove...
true
FuelLabs/sway
7,563
comment_to_fix
Verify all jumps on asm are using ControlFlowOp
We can use `op`'s `ownning_span` here. ```suggestion op.owning_span.as_ref().unwrap_or(&Span::dummy()).clone(), ```
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/sway-core/src/asm_generation/fuel/optimizations/verify.rs b/sway-core/src/asm_generation/fuel/optimizations/verify.rs index 4b3c03b6b55..cdef3fb5409 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/verify.rs +++ b/sway-core/src/asm_generation/fuel/optimizations/verify.rs @@ -1,19 +1,40 @@ -use ...
[ "sway-core/src/asm_generation/fuel/optimizations/verify.rs" ]
[ { "comment": "We can use `op`'s `ownning_span` here.\n```suggestion\n op.owning_span.as_ref().unwrap_or(&Span::dummy()).clone(),\n```", "path": "sway-core/src/asm_generation/fuel/optimizations/verify.rs", "hunk": "@@ -1,19 +1,40 @@\n-use std::collections::HashSet;\n-\n-use sway_er...
true
FuelLabs/sway
7,563
comment_to_fix
Verify all jumps on asm are using ControlFlowOp
```suggestion op.owning_span.as_ref().unwrap_or(&Span::dummy()).clone(), ```
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/sway-core/src/asm_generation/fuel/optimizations/verify.rs b/sway-core/src/asm_generation/fuel/optimizations/verify.rs index 4b3c03b6b55..cdef3fb5409 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/verify.rs +++ b/sway-core/src/asm_generation/fuel/optimizations/verify.rs @@ -1,19 +1,40 @@ -use ...
[ "sway-core/src/asm_generation/fuel/optimizations/verify.rs" ]
[ { "comment": "```suggestion\n op.owning_span.as_ref().unwrap_or(&Span::dummy()).clone(),\n```", "path": "sway-core/src/asm_generation/fuel/optimizations/verify.rs", "hunk": "@@ -1,19 +1,40 @@\n-use std::collections::HashSet;\n-\n-use sway_error::error::CompileError;\n-use sway_typ...
true
FuelLabs/sway
7,563
comment_to_fix
Verify all jumps on asm are using ControlFlowOp
Do we need these two asserts, assuming we do the verification in the `verify`?
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs b/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs index e8f76595c03..abdfde3511e 100644 --- a/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs +++ b/sway-core/src/asm_generation/fuel/alloc...
[ "sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs" ]
[ { "comment": "Do we need these two asserts, assuming we do the verification in the `verify`?", "path": "sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs", "hunk": "@@ -330,7 +330,32 @@ impl AllocatedAbstractInstructionSet {\n }\n ControlFlow...
true
FuelLabs/sway
7,563
comment_to_fix
Verify all jumps on asm are using ControlFlowOp
As mentioned in the previous review comment, I would keep the jumps as supported in `asm` for experimenting purposes if needed, and leave the original check below.
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs index 98800af7cca..dc3565a0d00 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs +++ b/sway-core/src/semantic_analysis/ast_nod...
[ "sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs" ]
[ { "comment": "As mentioned in the previous review comment, I would keep the jumps as supported in `asm` for experimenting purposes if needed, and leave the original check below.", "path": "sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs", "hunk": "@@ -3186,40 +3186,37 @@ fn check...
true
FuelLabs/sway
7,563
comment_to_fix
Verify all jumps on asm are using ControlFlowOp
> I think it makes more sense for successors to return an Option<>, and abort any optimisation on None. I agree we should do something here. I am not sure if aborting optimizations if any of these two is encountered will work. `ReturnFromCall` is always there in `ops` and has a clear semantics. `JumpToAddr` is problem...
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/sway-core/src/asm_lang/mod.rs b/sway-core/src/asm_lang/mod.rs index 8a2f75fd761..805470d600f 100644 --- a/sway-core/src/asm_lang/mod.rs +++ b/sway-core/src/asm_lang/mod.rs @@ -441,54 +441,6 @@ impl Op { } /* Control Flow Instructions */ - "jmp" => { - l...
[ "sway-core/src/asm_lang/mod.rs" ]
[ { "comment": "> I think it makes more sense for successors to return an Option<>, and abort any optimisation on None.\n\nI agree we should do something here. I am not sure if aborting optimizations if any of these two is encountered will work. `ReturnFromCall` is always there in `ops` and has a clear semantics....
true
FuelLabs/sway
7,563
comment_to_fix
Verify all jumps on asm are using ControlFlowOp
### Commented-out receipt filter contradicts its documentation comment **Low Severity** <!-- DESCRIPTION START --> The `get_gas_and_receipts` function has a comment saying "Only retain `Log` and `LogData` receipts" but the `.filter(...)` call is entirely commented out. All receipts are returned instead of just log-re...
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/test/src/snapshot/mod.rs b/test/src/snapshot/mod.rs index 767c254d041..78a72e4be4e 100644 --- a/test/src/snapshot/mod.rs +++ b/test/src/snapshot/mod.rs @@ -1,9 +1,22 @@ use anyhow::Result; +use fuel_vm::{ + prelude::{GasCostsValues, TransactionBuilderExt as _}, + state::ProgramState, + storage::M...
[ "test/src/snapshot/mod.rs" ]
[ { "comment": "### Commented-out receipt filter contradicts its documentation comment\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\nThe `get_gas_and_receipts` function has a comment saying \"Only retain `Log` and `LogData` receipts\" but the `.filter(...)` call is entirely commented out. All receipts are re...
true
FuelLabs/sway
7,563
comment_to_fix
Verify all jumps on asm are using ControlFlowOp
### Arithmetic underflow when DWARF row has no line info **Low Severity** <!-- DESCRIPTION START --> In `patch_file`, when `row.line()` returns `None`, `line` is set to `0`. The subsequent `(line - 1) as usize` causes an arithmetic underflow panic in debug mode (or wraps to `u64::MAX` in release mode, leading to `.ne...
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/test/src/snapshot/mod.rs b/test/src/snapshot/mod.rs index 767c254d041..78a72e4be4e 100644 --- a/test/src/snapshot/mod.rs +++ b/test/src/snapshot/mod.rs @@ -1,9 +1,22 @@ use anyhow::Result; +use fuel_vm::{ + prelude::{GasCostsValues, TransactionBuilderExt as _}, + state::ProgramState, + storage::M...
[ "test/src/snapshot/mod.rs" ]
[ { "comment": "### Arithmetic underflow when DWARF row has no line info\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\nIn `patch_file`, when `row.line()` returns `None`, `line` is set to `0`. The subsequent `(line - 1) as usize` causes an arithmetic underflow panic in debug mode (or wraps to `u64::MAX` in re...
true
FuelLabs/sway
7,563
comment_to_fix
Verify all jumps on asm are using ControlFlowOp
### patch_file corrupts unrelated instructions sharing DWARF source line **Medium Severity** <!-- DESCRIPTION START --> The `patch_file` function iterates all DWARF rows and patches every instruction whose source line contains `// PATCH:`. When DWARF maps multiple instruction addresses to the same source line, all of...
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/test/src/snapshot/mod.rs b/test/src/snapshot/mod.rs index 767c254d041..78a72e4be4e 100644 --- a/test/src/snapshot/mod.rs +++ b/test/src/snapshot/mod.rs @@ -1,9 +1,22 @@ use anyhow::Result; +use fuel_vm::{ + prelude::{GasCostsValues, TransactionBuilderExt as _}, + state::ProgramState, + storage::M...
[ "test/src/snapshot/mod.rs" ]
[ { "comment": "### patch_file corrupts unrelated instructions sharing DWARF source line\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nThe `patch_file` function iterates all DWARF rows and patches every instruction whose source line contains `// PATCH:`. When DWARF maps multiple instruction addresses to t...
true
FuelLabs/sway
7,563
comment_to_fix
Verify all jumps on asm are using ControlFlowOp
### Production `assert!` panics instead of returning compile errors **Medium Severity** <!-- DESCRIPTION START --> The `ReturnFromCall` lowering path uses `assert!` (not `debug_assert!`) to check that `zero` is `$zero` and `reta` is `$reta`. While `verify()` checks this earlier at the `VirtualRegister` level, the ass...
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs b/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs index e8f76595c03..abdfde3511e 100644 --- a/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs +++ b/sway-core/src/asm_generation/fuel/alloc...
[ "sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs" ]
[ { "comment": "### Production `assert!` panics instead of returning compile errors\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nThe `ReturnFromCall` lowering path uses `assert!` (not `debug_assert!`) to check that `zero` is `$zero` and `reta` is `$reta`. While `verify()` checks this earlier at the `Virt...
true
FuelLabs/sway
7,563
comment_to_fix
Verify all jumps on asm are using ControlFlowOp
### `ReturnFromCall` misclassifies `zero` register as read instead of written **Low Severity** <!-- DESCRIPTION START --> `ControlFlowOp::ReturnFromCall` reports `zero` in `use_registers()` (registers read), but the `JAL` instruction it represents *writes* the return address to its first operand (`zero`) and *reads* ...
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/sway-core/src/asm_lang/mod.rs b/sway-core/src/asm_lang/mod.rs index 8a2f75fd761..805470d600f 100644 --- a/sway-core/src/asm_lang/mod.rs +++ b/sway-core/src/asm_lang/mod.rs @@ -441,54 +441,6 @@ impl Op { } /* Control Flow Instructions */ - "jmp" => { - l...
[ "sway-core/src/asm_lang/mod.rs" ]
[ { "comment": "### `ReturnFromCall` misclassifies `zero` register as read instead of written\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\n`ControlFlowOp::ReturnFromCall` reports `zero` in `use_registers()` (registers read), but the `JAL` instruction it represents *writes* the return address to its first op...
true
FuelLabs/sway
7,563
comment_to_fix
Verify all jumps on asm are using ControlFlowOp
```suggestion std = { path = "../../../../../reduced_std_libs/sway-lib-std-core" } ```
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/asm/asm_patch/Forc.toml b/test/src/e2e_vm_tests/test_programs/should_pass/language/asm/asm_patch/Forc.toml new file mode 100644 index 00000000000..5277747c59f --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/asm/asm_patch/...
[ "test/src/e2e_vm_tests/test_programs/should_pass/language/asm/asm_patch/Forc.toml" ]
[ { "comment": "```suggestion\nstd = { path = \"../../../../../reduced_std_libs/sway-lib-std-core\" }\n```", "path": "test/src/e2e_vm_tests/test_programs/should_pass/language/asm/asm_patch/Forc.toml", "hunk": "@@ -0,0 +1,9 @@\n+[project]\n+authors = [\"Fuel Labs <contact@fuel.sh>\"]\n+entry = \"main.sw\"\...
true
FuelLabs/sway
7,563
comment_to_fix
Verify all jumps on asm are using ControlFlowOp
```suggestion panic!("`{cmd}` is not a supported snapshot command.\nPossible tool commands: echo, forc, forc doc, forc migrate, replace-file, patch-bin, fuel-vm\nPossible filtering commands: sub, regex, filter-fn"); ```
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/test/src/snapshot/mod.rs b/test/src/snapshot/mod.rs index 767c254d041..78a72e4be4e 100644 --- a/test/src/snapshot/mod.rs +++ b/test/src/snapshot/mod.rs @@ -1,9 +1,22 @@ use anyhow::Result; +use fuel_vm::{ + prelude::{GasCostsValues, TransactionBuilderExt as _}, + state::ProgramState, + storage::M...
[ "test/src/snapshot/mod.rs" ]
[ { "comment": "```suggestion\n panic!(\"`{cmd}` is not a supported snapshot command.\\nPossible tool commands: echo, forc, forc doc, forc migrate, replace-file, patch-bin, fuel-vm\\nPossible filtering commands: sub, regex, filter-fn\");\n```", "path": "test/src/snapshot/mod.rs", "h...
true
FuelLabs/sway
7,563
comment_to_fix
Verify all jumps on asm are using ControlFlowOp
### Confusing matches! syntax with leading pipe looks like closure **Medium Severity** <!-- DESCRIPTION START --> The `matches!(op.0, |VirtualOp::RET(..)| VirtualOp::RETD(..) | VirtualOp::RVRT(..))` expression uses a leading `|` before the first pattern, making `|VirtualOp::RET(..)| VirtualOp::RETD(..)` visually indi...
f9de5456ea65806768cc83ddd74333fc90271711
4e4d13296c762c0c010586231b4e4be667f428a2
diff --git a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs index 98800af7cca..dc3565a0d00 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs +++ b/sway-core/src/semantic_analysis/ast_nod...
[ "sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs" ]
[ { "comment": "### Confusing matches! syntax with leading pipe looks like closure\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nThe `matches!(op.0, |VirtualOp::RET(..)| VirtualOp::RETD(..) | VirtualOp::RVRT(..))` expression uses a leading `|` before the first pattern, making `|VirtualOp::RET(..)| Virtual...
true
FuelLabs/sway
7,128
issue_to_patch
chore: update codeowners from swayex to onchain team
This pull request updates the `.github/CODEOWNERS` file to reflect changes in team ownership for specific directories. The most notable changes involve replacing `@FuelLabs/swayex` with `@FuelLabs/onchain` for several directory assignments. Ownership updates: * [`/docs/`](diffhunk://#diff-3d36a1bf06148bc6ba1ce2ed...
1a1502b071913f0eea699ee98e04713a28edd560
e2e26dfe32f033b90d70f99157cda3be346732a7
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 35d56cc0dd2..05ede1b8a8f 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -2,11 +2,11 @@ * @FuelLabs/leads # Documentation -/docs/ @FuelLabs/tooling @FuelLabs/sway-compiler @FuelLabs/swayex @FuelLabs/Devrel +/docs/ @FuelLabs/tooling @FuelLabs/swa...
[ ".github/CODEOWNERS" ]
[]
true
FuelLabs/sway
7,242
issue_to_patch
Add criterion benchmark to forc-doc + initial code quality pass
## Description Doing some general code quality changes at the same time. ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - ...
0ac606c13232af77d646944b4eeb77f1b48ab02a
7e4be669bb2e8a45aab16b92e4360437d3628362
diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 4f40b19a74f..7903654f5c1 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -10,7 +10,7 @@ on: - sway-lsp/** - forc-pkg/** - sway-core/** - + - forc-plugins/forc-doc/** ...
[ ".github/workflows/benchmark.yml", "Cargo.lock", "forc-plugins/forc-doc/Cargo.toml", "forc-plugins/forc-doc/benches/bench_main.rs", "forc-plugins/forc-doc/src/cli.rs", "forc-plugins/forc-doc/src/doc/descriptor.rs", "forc-plugins/forc-doc/src/doc/mod.rs", "forc-plugins/forc-doc/src/doc/module.rs", "f...
[ { "comment": "nit:\n```suggestion\n #[clap(long)]\n```", "path": "forc-plugins/forc-doc/src/lib.rs", "hunk": "@@ -1,30 +1,94 @@\n-pub mod cli;\n pub mod doc;\n pub mod render;\n pub mod search;\n-pub mod tests;\n \n use anyhow::{bail, Result};\n-use cli::Command;\n+use clap::Parser;\n use doc::Docume...
diff --git a/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs b/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs deleted file mode 100644 index 9cb96a58f38..00000000000 --- a/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs +++ /dev/null @@ -1,128 +0,0 @@ -#![cfg(test)] -use crate::{ - cli...
true
FuelLabs/sway
7,242
comment_to_fix
Add criterion benchmark to forc-doc + initial code quality pass
nit: ```suggestion #[clap(long)] ```
0ac606c13232af77d646944b4eeb77f1b48ab02a
7e4be669bb2e8a45aab16b92e4360437d3628362
diff --git a/forc-plugins/forc-doc/src/lib.rs b/forc-plugins/forc-doc/src/lib.rs index a264481a8f3..af3b5d20840 100644 --- a/forc-plugins/forc-doc/src/lib.rs +++ b/forc-plugins/forc-doc/src/lib.rs @@ -1,21 +1,19 @@ -pub mod cli; pub mod doc; pub mod render; pub mod search; -pub mod tests; use anyhow::{bail, Resul...
[ "forc-plugins/forc-doc/src/lib.rs" ]
[ { "comment": "nit:\n```suggestion\n #[clap(long)]\n```", "path": "forc-plugins/forc-doc/src/lib.rs", "hunk": "@@ -1,30 +1,94 @@\n-pub mod cli;\n pub mod doc;\n pub mod render;\n pub mod search;\n-pub mod tests;\n \n use anyhow::{bail, Result};\n-use cli::Command;\n+use clap::Parser;\n use doc::Docume...
true
FuelLabs/sway
7,242
comment_to_fix
Add criterion benchmark to forc-doc + initial code quality pass
nit: ```suggestion #[clap(long, short = 's')] ```
0ac606c13232af77d646944b4eeb77f1b48ab02a
7e4be669bb2e8a45aab16b92e4360437d3628362
diff --git a/forc-plugins/forc-doc/src/lib.rs b/forc-plugins/forc-doc/src/lib.rs index a264481a8f3..af3b5d20840 100644 --- a/forc-plugins/forc-doc/src/lib.rs +++ b/forc-plugins/forc-doc/src/lib.rs @@ -1,21 +1,19 @@ -pub mod cli; pub mod doc; pub mod render; pub mod search; -pub mod tests; use anyhow::{bail, Resul...
[ "forc-plugins/forc-doc/src/lib.rs" ]
[ { "comment": "nit:\n```suggestion\n #[clap(long, short = 's')]\n```", "path": "forc-plugins/forc-doc/src/lib.rs", "hunk": "@@ -1,30 +1,94 @@\n-pub mod cli;\n pub mod doc;\n pub mod render;\n pub mod search;\n-pub mod tests;\n \n use anyhow::{bail, Result};\n-use cli::Command;\n+use clap::Parser;\n us...
true
Genymobile/scrcpy
6,859
issue_to_patch
Fix size constraints algorithm
The algorithm used to constrain a size according to the video capabilities, implemented in #6766, was too simplistic: it computed the maximum landscape size by retrieving the maximum width and its associated maximum height (and vice versa for the maximum portrait size). In addition to width and height, encoders are ...
4d79fb5b260a00665f54e3fe618d42d154497a83
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
diff --git a/server/src/main/java/com/genymobile/scrcpy/model/Size.java b/server/src/main/java/com/genymobile/scrcpy/model/Size.java index 63648a9e8f..51211969e2 100644 --- a/server/src/main/java/com/genymobile/scrcpy/model/Size.java +++ b/server/src/main/java/com/genymobile/scrcpy/model/Size.java @@ -1,8 +1,12 @@ pac...
[ "server/src/main/java/com/genymobile/scrcpy/model/Size.java", "server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java", "server/src/main/java/com/genymobile/scrcpy/video/SurfaceEncoder.java", "server/src/main/java/com/genymobile/scrcpy/video/VideoConstraints.java", "server/src/test/java/com/genym...
[ { "comment": "```suggestion\n int minMinor = alignUp(landscape ? caps.getSupportedHeights().getLower() : caps.getSupportedWidths().getLower(), alignment);\n```\nFor below assertions to work.", "path": "server/src/main/java/com/genymobile/scrcpy/model/Size.java", "hunk": "@@ -38,61 +42,99 @@ publi...
diff --git a/server/src/test/java/com/genymobile/scrcpy/model/SizeTest.java b/server/src/test/java/com/genymobile/scrcpy/model/SizeTest.java deleted file mode 100644 index d86048fac5..0000000000 --- a/server/src/test/java/com/genymobile/scrcpy/model/SizeTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.genymobile.s...
true
Genymobile/scrcpy
6,859
comment_to_fix
Fix size constraints algorithm
```suggestion int minMinor = alignUp(landscape ? caps.getSupportedHeights().getLower() : caps.getSupportedWidths().getLower(), alignment); ``` For below assertions to work.
4d79fb5b260a00665f54e3fe618d42d154497a83
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
diff --git a/server/src/main/java/com/genymobile/scrcpy/model/Size.java b/server/src/main/java/com/genymobile/scrcpy/model/Size.java index 63648a9e8f..51211969e2 100644 --- a/server/src/main/java/com/genymobile/scrcpy/model/Size.java +++ b/server/src/main/java/com/genymobile/scrcpy/model/Size.java @@ -1,8 +1,12 @@ pac...
[ "server/src/main/java/com/genymobile/scrcpy/model/Size.java" ]
[ { "comment": "```suggestion\n int minMinor = alignUp(landscape ? caps.getSupportedHeights().getLower() : caps.getSupportedWidths().getLower(), alignment);\n```\nFor below assertions to work.", "path": "server/src/main/java/com/genymobile/scrcpy/model/Size.java", "hunk": "@@ -38,61 +42,99 @@ publi...
true
Genymobile/scrcpy
6,859
comment_to_fix
Fix size constraints algorithm
```suggestion minMajor = alignUp(minMajor, alignment); maxMajor = align(maxMajor, alignment); int minBlock = minMajor / alignment; int maxBlock = maxMajor / alignment; ``` Well, this suggestion is not optimal and not necessary even for assertions to be correct. But maybe a bit mo...
4d79fb5b260a00665f54e3fe618d42d154497a83
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
diff --git a/server/src/main/java/com/genymobile/scrcpy/model/Size.java b/server/src/main/java/com/genymobile/scrcpy/model/Size.java index 63648a9e8f..51211969e2 100644 --- a/server/src/main/java/com/genymobile/scrcpy/model/Size.java +++ b/server/src/main/java/com/genymobile/scrcpy/model/Size.java @@ -1,8 +1,12 @@ pac...
[ "server/src/main/java/com/genymobile/scrcpy/model/Size.java" ]
[ { "comment": "```suggestion\r\n minMajor = alignUp(minMajor, alignment);\r\n maxMajor = align(maxMajor, alignment);\r\n\r\n int minBlock = minMajor / alignment;\r\n int maxBlock = maxMajor / alignment;\r\n```\r\nWell, this suggestion is not optimal and not necessary even for assertio...
true
Genymobile/scrcpy
6,859
comment_to_fix
Fix size constraints algorithm
```suggestion maxMinor = align(maxMinor, alignment); bestMinor = maxMinor; ``` To match the previous comment, but this may be a ridiculous suggestion.
4d79fb5b260a00665f54e3fe618d42d154497a83
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
diff --git a/server/src/main/java/com/genymobile/scrcpy/model/Size.java b/server/src/main/java/com/genymobile/scrcpy/model/Size.java index 63648a9e8f..51211969e2 100644 --- a/server/src/main/java/com/genymobile/scrcpy/model/Size.java +++ b/server/src/main/java/com/genymobile/scrcpy/model/Size.java @@ -1,8 +1,12 @@ pac...
[ "server/src/main/java/com/genymobile/scrcpy/model/Size.java" ]
[ { "comment": "```suggestion\n maxMinor = align(maxMinor, alignment);\n bestMinor = maxMinor;\n```\nTo match the previous comment, but this may be a ridiculous suggestion.", "path": "server/src/main/java/com/genymobile/scrcpy/model/Size.java", "hunk": "@@ -38,61 +42,99 @@ public Siz...
true
Genymobile/scrcpy
6,859
comment_to_fix
Fix size constraints algorithm
In this case the size should still be aligned, shouldn't it?
4d79fb5b260a00665f54e3fe618d42d154497a83
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
diff --git a/server/src/main/java/com/genymobile/scrcpy/model/Size.java b/server/src/main/java/com/genymobile/scrcpy/model/Size.java index 63648a9e8f..51211969e2 100644 --- a/server/src/main/java/com/genymobile/scrcpy/model/Size.java +++ b/server/src/main/java/com/genymobile/scrcpy/model/Size.java @@ -1,8 +1,12 @@ pac...
[ "server/src/main/java/com/genymobile/scrcpy/model/Size.java" ]
[ { "comment": "In this case the size should still be aligned, shouldn't it?", "path": "server/src/main/java/com/genymobile/scrcpy/model/Size.java", "hunk": "@@ -38,61 +42,99 @@ public Size constrain(VideoConstraints constraints) {\n public Size constrain(VideoConstraints constraints, boolean preserve...
true
Genymobile/scrcpy
6,859
comment_to_fix
Fix size constraints algorithm
Notice that `landscape`, `major` and `minor` are not used in the scope of `if (caps == null)` so they could be moved down.
4d79fb5b260a00665f54e3fe618d42d154497a83
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
diff --git a/server/src/main/java/com/genymobile/scrcpy/model/Size.java b/server/src/main/java/com/genymobile/scrcpy/model/Size.java index 63648a9e8f..51211969e2 100644 --- a/server/src/main/java/com/genymobile/scrcpy/model/Size.java +++ b/server/src/main/java/com/genymobile/scrcpy/model/Size.java @@ -1,8 +1,12 @@ pac...
[ "server/src/main/java/com/genymobile/scrcpy/model/Size.java" ]
[ { "comment": "Notice that `landscape`, `major` and `minor` are not used in the scope of `if (caps == null)` so they could be moved down.", "path": "server/src/main/java/com/genymobile/scrcpy/model/Size.java", "hunk": "@@ -38,61 +42,99 @@ public Size constrain(VideoConstraints constraints) {\n public...
true
Genymobile/scrcpy
6,859
comment_to_fix
Fix size constraints algorithm
```suggestion w = Math.max(align(w, alignment), alignment); h = Math.max(align(h, alignment), alignment); ``` To not miss the case where `w` or `h` would be lower than `alignment` (thus 0 upon return), which should be the minimum allowed size in this case I think (in other words, `int minSize = ...
4d79fb5b260a00665f54e3fe618d42d154497a83
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
diff --git a/server/src/main/java/com/genymobile/scrcpy/model/Size.java b/server/src/main/java/com/genymobile/scrcpy/model/Size.java index 63648a9e8f..51211969e2 100644 --- a/server/src/main/java/com/genymobile/scrcpy/model/Size.java +++ b/server/src/main/java/com/genymobile/scrcpy/model/Size.java @@ -1,8 +1,12 @@ pac...
[ "server/src/main/java/com/genymobile/scrcpy/model/Size.java" ]
[ { "comment": "```suggestion\n w = Math.max(align(w, alignment), alignment);\n h = Math.max(align(h, alignment), alignment);\n```\nTo not miss the case where `w` or `h` would be lower than `alignment` (thus 0 upon return), which should be the minimum allowed size in this case I think (in ot...
true
Genymobile/scrcpy
6,859
comment_to_fix
Fix size constraints algorithm
I guess you could avoid binary search entirely in most cases if you first check whether `maxMajor` with its corresponding minor is a supported size. Would be equivalent to adding `if (predicate.test(high)) return high;` at the top of `BinarySearch.findLastTrue()`, but it could probably be optimized if done from `Size.c...
4d79fb5b260a00665f54e3fe618d42d154497a83
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
diff --git a/server/src/main/java/com/genymobile/scrcpy/model/Size.java b/server/src/main/java/com/genymobile/scrcpy/model/Size.java index 63648a9e8f..51211969e2 100644 --- a/server/src/main/java/com/genymobile/scrcpy/model/Size.java +++ b/server/src/main/java/com/genymobile/scrcpy/model/Size.java @@ -1,8 +1,12 @@ pac...
[ "server/src/main/java/com/genymobile/scrcpy/model/Size.java" ]
[ { "comment": "I guess you could avoid binary search entirely in most cases if you first check whether `maxMajor` with its corresponding minor is a supported size. Would be equivalent to adding `if (predicate.test(high)) return high;` at the top of `BinarySearch.findLastTrue()`, but it could probably be optimize...
true
Genymobile/scrcpy
6,859
comment_to_fix
Fix size constraints algorithm
```suggestion * Find the highest value for which the predicate is true. ```
4d79fb5b260a00665f54e3fe618d42d154497a83
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
diff --git a/server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java b/server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java new file mode 100644 index 0000000000..381601fefd --- /dev/null +++ b/server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java @@ -0,0 +1,53 @@ +package com.genymob...
[ "server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java" ]
[ { "comment": "```suggestion\n * Find the highest value for which the predicate is true.\n```", "path": "server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java", "hunk": "@@ -0,0 +1,45 @@\n+package com.genymobile.scrcpy.util;\n+\n+import com.genymobile.scrcpy.AndroidVersions;\n+\n+import a...
true
Genymobile/scrcpy
6,859
comment_to_fix
Fix size constraints algorithm
```suggestion public static int findHighestTrue(int low, int high, Predicate<Integer> predicate) { ``` What do you think of renaming? `@return` uses "highest". And "last" makes me think of linear search intuitively, but that's not a strong argument.
4d79fb5b260a00665f54e3fe618d42d154497a83
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
diff --git a/server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java b/server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java new file mode 100644 index 0000000000..381601fefd --- /dev/null +++ b/server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java @@ -0,0 +1,53 @@ +package com.genymob...
[ "server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java" ]
[ { "comment": "```suggestion\n public static int findHighestTrue(int low, int high, Predicate<Integer> predicate) {\n```\nWhat do you think of renaming? `@return` uses \"highest\". And \"last\" makes me think of linear search intuitively, but that's not a strong argument.", "path": "server/src/main/java/c...
true
Genymobile/scrcpy
6,859
comment_to_fix
Fix size constraints algorithm
```suggestion // predicate holds, go up ```
4d79fb5b260a00665f54e3fe618d42d154497a83
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
diff --git a/server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java b/server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java new file mode 100644 index 0000000000..381601fefd --- /dev/null +++ b/server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java @@ -0,0 +1,53 @@ +package com.genymob...
[ "server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java" ]
[ { "comment": "```suggestion\n // predicate holds, go up\n```", "path": "server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java", "hunk": "@@ -0,0 +1,45 @@\n+package com.genymobile.scrcpy.util;\n+\n+import com.genymobile.scrcpy.AndroidVersions;\n+\n+import android.annotation.Tar...
true
Genymobile/scrcpy
6,859
comment_to_fix
Fix size constraints algorithm
```suggestion // predicate false, go down ``` low <-> high, thus down <-> up, what do you think?
4d79fb5b260a00665f54e3fe618d42d154497a83
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
diff --git a/server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java b/server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java new file mode 100644 index 0000000000..381601fefd --- /dev/null +++ b/server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java @@ -0,0 +1,53 @@ +package com.genymob...
[ "server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java" ]
[ { "comment": "```suggestion\n // predicate false, go down\n```\nlow <-> high, thus down <-> up, what do you think?", "path": "server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java", "hunk": "@@ -0,0 +1,45 @@\n+package com.genymobile.scrcpy.util;\n+\n+import com.genymobile.scrc...
true
Genymobile/scrcpy
6,859
comment_to_fix
Fix size constraints algorithm
At first sight, in the case where `preserveAspectRatio` is `false`, I think this strategy works when the major dimension is the first to reach the encoder's limits, but maybe not when it's the minor dimension that must be constrained. Imagine the limits are always 500x1000 (max size is zero) and the alignment is 1px...
4d79fb5b260a00665f54e3fe618d42d154497a83
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
diff --git a/server/src/main/java/com/genymobile/scrcpy/model/Size.java b/server/src/main/java/com/genymobile/scrcpy/model/Size.java index 63648a9e8f..51211969e2 100644 --- a/server/src/main/java/com/genymobile/scrcpy/model/Size.java +++ b/server/src/main/java/com/genymobile/scrcpy/model/Size.java @@ -1,8 +1,12 @@ pac...
[ "server/src/main/java/com/genymobile/scrcpy/model/Size.java" ]
[ { "comment": "At first sight, in the case where `preserveAspectRatio` is `false`, I think this strategy works when the major dimension is the first to reach the encoder's limits, but maybe not when it's the minor dimension that must be constrained.\r\n\r\nImagine the limits are always 500x1000 (max size is zero...
true
Genymobile/scrcpy
6,859
comment_to_fix
Fix size constraints algorithm
Notice that it would be trivial to locally define the required interface: ```suggestion public interface Predicate { boolean test(int value); } public static int findHighestTrue(int low, int high, Predicate predicate) { ```
4d79fb5b260a00665f54e3fe618d42d154497a83
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
diff --git a/server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java b/server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java new file mode 100644 index 0000000000..381601fefd --- /dev/null +++ b/server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java @@ -0,0 +1,53 @@ +package com.genymob...
[ "server/src/main/java/com/genymobile/scrcpy/util/BinarySearch.java" ]
[ { "comment": "Notice that it would be trivial to locally define the required interface:\n```suggestion\n public interface Predicate {\n boolean test(int value);\n }\n\n public static int findHighestTrue(int low, int high, Predicate predicate) {\n```", "path": "server/src/main/java/com/genymo...
true
Genymobile/scrcpy
6,859
comment_to_fix
Fix size constraints algorithm
This assert may not be satisfied when binary search fails, either because `maxSize < minMajor` or when `maxMajor - minMajor < alignment - 1`. These are corner cases that should not be observed in practice, but that are valid in theory. For instance, consider a codec alignment of 1px but a user-requested `alignment = 4...
4d79fb5b260a00665f54e3fe618d42d154497a83
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
diff --git a/server/src/main/java/com/genymobile/scrcpy/model/Size.java b/server/src/main/java/com/genymobile/scrcpy/model/Size.java index 63648a9e8f..51211969e2 100644 --- a/server/src/main/java/com/genymobile/scrcpy/model/Size.java +++ b/server/src/main/java/com/genymobile/scrcpy/model/Size.java @@ -1,8 +1,12 @@ pac...
[ "server/src/main/java/com/genymobile/scrcpy/model/Size.java" ]
[ { "comment": "This assert may not be satisfied when binary search fails, either because `maxSize < minMajor` or when `maxMajor - minMajor < alignment - 1`. These are corner cases that should not be observed in practice, but that are valid in theory.\n\nFor instance, consider a codec alignment of 1px but a user-...
true
Genymobile/scrcpy
6,859
comment_to_fix
Fix size constraints algorithm
```suggestion h = Math.min(height, maxSize); ``` Typo introduced in https://github.com/Genymobile/scrcpy/compare/7a054d4227f70774931d00a318e3b30122468ae9..31fa71c3fd830a44c0f3bf65621d73a39beccbb3.
4d79fb5b260a00665f54e3fe618d42d154497a83
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
diff --git a/server/src/main/java/com/genymobile/scrcpy/model/Size.java b/server/src/main/java/com/genymobile/scrcpy/model/Size.java index 63648a9e8f..51211969e2 100644 --- a/server/src/main/java/com/genymobile/scrcpy/model/Size.java +++ b/server/src/main/java/com/genymobile/scrcpy/model/Size.java @@ -1,8 +1,12 @@ pac...
[ "server/src/main/java/com/genymobile/scrcpy/model/Size.java" ]
[ { "comment": "```suggestion\n h = Math.min(height, maxSize);\n```\nTypo introduced in https://github.com/Genymobile/scrcpy/compare/7a054d4227f70774931d00a318e3b30122468ae9..31fa71c3fd830a44c0f3bf65621d73a39beccbb3.", "path": "server/src/main/java/com/genymobile/scrcpy/model/Size.java", ...
true
Genymobile/scrcpy
6,859
comment_to_fix
Fix size constraints algorithm
The commit says `then the second dimension derived from this optimal size can be extended`, but now it should be "then both dimensions […] can be extended" (potentially), shouldn't it?
4d79fb5b260a00665f54e3fe618d42d154497a83
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
diff --git a/server/src/main/java/com/genymobile/scrcpy/model/Size.java b/server/src/main/java/com/genymobile/scrcpy/model/Size.java index 63648a9e8f..51211969e2 100644 --- a/server/src/main/java/com/genymobile/scrcpy/model/Size.java +++ b/server/src/main/java/com/genymobile/scrcpy/model/Size.java @@ -1,8 +1,12 @@ pac...
[ "server/src/main/java/com/genymobile/scrcpy/model/Size.java" ]
[ { "comment": "The commit says `then the second\r\ndimension derived from this optimal size can be extended`, but now it should be \"then both dimensions […] can be extended\" (potentially), shouldn't it?", "path": "server/src/main/java/com/genymobile/scrcpy/model/Size.java", "hunk": "@@ -38,61 +42,111 @...
true
Genymobile/scrcpy
6,859
comment_to_fix
Fix size constraints algorithm
This could be optimized a bit I think: ```suggestion int testMajor = block * alignment; int testMinor = align(minor * testMajor / major, alignment); int w = landscape ? testMajor : testMinor; int h = landscape ? testMinor : testMajor; ...
4d79fb5b260a00665f54e3fe618d42d154497a83
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
diff --git a/server/src/main/java/com/genymobile/scrcpy/model/Size.java b/server/src/main/java/com/genymobile/scrcpy/model/Size.java index 63648a9e8f..51211969e2 100644 --- a/server/src/main/java/com/genymobile/scrcpy/model/Size.java +++ b/server/src/main/java/com/genymobile/scrcpy/model/Size.java @@ -1,8 +1,12 @@ pac...
[ "server/src/main/java/com/genymobile/scrcpy/model/Size.java" ]
[ { "comment": "This could be optimized a bit I think:\r\n```suggestion\r\n int testMajor = block * alignment;\r\n int testMinor = align(minor * testMajor / major, alignment);\r\n int w = landscape ? testMajor : testMinor;\r\n int h = lan...
true
Genymobile/scrcpy
6,769
issue_to_patch
Encoder support for new Onyx Devices - [x] I have checked that a similar [feature request](https://github.com/Genymobile/scrcpy/issues?q=is%3Aopen+is%3Aissue+label%3A%22feature+request%22) does not already exist. **Is your feature request related to a problem? Please describe.** A clear and concise description of wh...
Add support for VP8 and VP9 video encoders
### **Summary** This PR adds support for **VP8** and **VP9** video codecs. This is primarily intended as a fallback for devices where the manufacturer has intentionally disabled H.264 (AVC) and H.265 (HEVC) encoders in the firmware. ### **The Problem (Onyx Boox Note X case)** On recent Onyx Boox devices (e.g., Not...
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
0bdd750447b0826039d8c6111c2c21dc10d70af1
diff --git a/app/data/bash-completion/scrcpy b/app/data/bash-completion/scrcpy index 80551d7765..53ab5edc45 100644 --- a/app/data/bash-completion/scrcpy +++ b/app/data/bash-completion/scrcpy @@ -118,7 +118,7 @@ _scrcpy() { case "$prev" in --video-codec) - COMPREPLY=($(compgen -W 'h264 h265 av...
[ "app/data/bash-completion/scrcpy", "app/data/zsh-completion/_scrcpy", "app/deps/ffmpeg.sh", "app/scrcpy.1", "app/src/cli.c", "app/src/demuxer.c", "app/src/options.h", "app/src/recorder.c", "app/src/recorder.h", "app/src/server.c", "doc/develop.md", "server/src/main/java/com/genymobile/scrcpy/v...
[ { "comment": "```suggestion\n bool video_expects_config_packet;\n bool audio_expects_config_packet;\n```\nAbove and below, `video_*` is always declared before `audio_*`.", "path": "app/src/recorder.h", "hunk": "@@ -54,6 +54,7 @@ struct sc_recorder {\n bool audio_init;\n \n bool audio_expec...
true
Genymobile/scrcpy
6,769
comment_to_fix
Add support for VP8 and VP9 video encoders
```suggestion bool video_expects_config_packet; bool audio_expects_config_packet; ``` Above and below, `video_*` is always declared before `audio_*`.
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
0bdd750447b0826039d8c6111c2c21dc10d70af1
diff --git a/app/src/recorder.h b/app/src/recorder.h index 70b738362c..8638c72ee6 100644 --- a/app/src/recorder.h +++ b/app/src/recorder.h @@ -53,6 +53,7 @@ struct sc_recorder { bool video_init; bool audio_init; + bool video_expects_config_packet; bool audio_expects_config_packet; struct sc_r...
[ "app/src/recorder.h" ]
[ { "comment": "```suggestion\n bool video_expects_config_packet;\n bool audio_expects_config_packet;\n```\nAbove and below, `video_*` is always declared before `audio_*`.", "path": "app/src/recorder.h", "hunk": "@@ -54,6 +54,7 @@ struct sc_recorder {\n bool audio_init;\n \n bool audio_expec...
true
Genymobile/scrcpy
6,769
comment_to_fix
Add support for VP8 and VP9 video encoders
```suggestion recorder->video_expects_config_packet = false; recorder->audio_expects_config_packet = false; ```
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
0bdd750447b0826039d8c6111c2c21dc10d70af1
diff --git a/app/src/recorder.c b/app/src/recorder.c index f6d5fe4cc0..5c5121b103 100644 --- a/app/src/recorder.c +++ b/app/src/recorder.c @@ -181,7 +181,8 @@ sc_recorder_close_output_file(struct sc_recorder *recorder) { static inline bool sc_recorder_must_wait_for_config_packets(struct sc_recorder *recorder) { - ...
[ "app/src/recorder.c" ]
[ { "comment": "```suggestion\n recorder->video_expects_config_packet = false;\n recorder->audio_expects_config_packet = false;\n```", "path": "app/src/recorder.c", "hunk": "@@ -785,6 +791,7 @@ sc_recorder_init(struct sc_recorder *recorder, const char *filename,\n recorder->audio_init = false;\n...
true
Genymobile/scrcpy
6,769
comment_to_fix
Add support for VP8 and VP9 video encoders
Just noticing that at some places, VP8 & VP9 are put before AV1, at other places they come after AV1. Would be nice if that were consistent.
f457fd4cf5ff4e91853159cbbbbbb98efa8f30b3
0bdd750447b0826039d8c6111c2c21dc10d70af1
diff --git a/server/src/main/java/com/genymobile/scrcpy/video/VideoCodec.java b/server/src/main/java/com/genymobile/scrcpy/video/VideoCodec.java index 5f19603d81..8b9de0ff5d 100644 --- a/server/src/main/java/com/genymobile/scrcpy/video/VideoCodec.java +++ b/server/src/main/java/com/genymobile/scrcpy/video/VideoCodec.ja...
[ "server/src/main/java/com/genymobile/scrcpy/video/VideoCodec.java" ]
[ { "comment": "Just noticing that at some places, VP8 & VP9 are put before AV1, at other places they come after AV1. Would be nice if that were consistent.", "path": "server/src/main/java/com/genymobile/scrcpy/video/VideoCodec.java", "hunk": "@@ -9,7 +9,9 @@ public enum VideoCodec implements Codec {\n ...
true
Genymobile/scrcpy
6,772
issue_to_patch
Add flex display support (resizable virtual display)
```bash # Start Android Settings in a window scrcpy --new-display=1024x768 --start-app=com.android.settings --flex-display # -x is equivalent to --flex-display scrcpy --new-display=1024x768 --start-app=com.android.settings -x # By default, the display size/dpi is 1280x960/160 scrcpy --new-display --start-app=...
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/app/data/bash-completion/scrcpy b/app/data/bash-completion/scrcpy index e8cae851af..f55db26f10 100644 --- a/app/data/bash-completion/scrcpy +++ b/app/data/bash-completion/scrcpy @@ -82,6 +82,7 @@ _scrcpy() { --record-format= --record-orientation= --render-driver= + --rende...
[ "app/data/bash-completion/scrcpy", "app/data/zsh-completion/_scrcpy", "app/scrcpy.1", "app/src/cli.c", "app/src/control_msg.c", "app/src/control_msg.h", "app/src/controller.c", "app/src/controller.h", "app/src/demuxer.c", "app/src/frame_buffer.c", "app/src/frame_buffer.h", "app/src/input_manag...
[ { "comment": "Other places in this file signal the condvar with the lock held, so for consistency the mutex should be unlocked at the end of this function. (In this case it surely doesn't matter, but I think it would matter in the case of multiple waiter threads for scheduling policy/predictability.)", "pat...
diff --git a/app/tests/test_control_msg_serialize.c b/app/tests/test_control_msg_serialize.c index bd445a1d4d..f674b70480 100644 --- a/app/tests/test_control_msg_serialize.c +++ b/app/tests/test_control_msg_serialize.c @@ -495,6 +495,27 @@ static void test_serialize_camera_zoom_out(void) { assert(!memcmp(buf, expe...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
Other places in this file signal the condvar with the lock held, so for consistency the mutex should be unlocked at the end of this function. (In this case it surely doesn't matter, but I think it would matter in the case of multiple waiter threads for scheduling policy/predictability.)
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/app/src/controller.c b/app/src/controller.c index 749de0a501..19e2acb860 100644 --- a/app/src/controller.c +++ b/app/src/controller.c @@ -59,6 +59,9 @@ sc_controller_init(struct sc_controller *controller, sc_socket control_socket, controller->control_socket = control_socket; controller->stopped =...
[ "app/src/controller.c" ]
[ { "comment": "Other places in this file signal the condvar with the lock held, so for consistency the mutex should be unlocked at the end of this function. (In this case it surely doesn't matter, but I think it would matter in the case of multiple waiter threads for scheduling policy/predictability.)", "pat...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
In this file at line 120 there is a comment still referring to `invalidate()`, at least it should be updated but maybe it can be rephrased to avoid using the name of a specific method.
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java b/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java index e0ec2141fb..c1038c9302 100644 --- a/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java +++ b/server/src/main/java/com/genymobile/scrcp...
[ "server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java" ]
[ { "comment": "In this file at line 120 there is a comment still referring to `invalidate()`, at least it should be updated but maybe it can be rephrased to avoid using the name of a specific method.", "path": "server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java", "hunk": "@@ -201,7 +...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
Technically any display properties can change, but I guess a rotation change implies a size change (except for a square display)?
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/server/src/main/java/com/genymobile/scrcpy/video/CaptureControl.java b/server/src/main/java/com/genymobile/scrcpy/video/CaptureControl.java new file mode 100644 index 0000000000..7933ea725f --- /dev/null +++ b/server/src/main/java/com/genymobile/scrcpy/video/CaptureControl.java @@ -0,0 +1,42 @@ +package co...
[ "server/src/main/java/com/genymobile/scrcpy/video/CaptureControl.java" ]
[ { "comment": "Technically any display properties can change, but I guess a rotation change implies a size change (except for a square display)?", "path": "server/src/main/java/com/genymobile/scrcpy/video/CaptureControl.java", "hunk": "@@ -2,21 +2,34 @@\n \n import android.media.MediaCodec;\n \n-import j...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
```suggestion Ln.v(getClass().getSimpleName() + ": " + props + " (unchanged)"); ```
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/server/src/main/java/com/genymobile/scrcpy/display/DisplayPropertiesTracker.java b/server/src/main/java/com/genymobile/scrcpy/display/DisplayPropertiesTracker.java new file mode 100644 index 0000000000..adc606aafe --- /dev/null +++ b/server/src/main/java/com/genymobile/scrcpy/display/DisplayPropertiesTrack...
[ "server/src/main/java/com/genymobile/scrcpy/display/DisplayPropertiesTracker.java" ]
[ { "comment": "```suggestion\n Ln.v(getClass().getSimpleName() + \": \" + props + \" (unchanged)\");\n```", "path": "server/src/main/java/com/genymobile/scrcpy/display/DisplayPropertiesTracker.java", "hunk": "@@ -0,0 +1,43 @@\n+package com.genymobile.scrcpy.display;\n+\n+import com.genymob...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
Should add `#include "util/thread.h"` in `screen.h` and remove it from `frame_buffer.h`.
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/app/src/screen.h b/app/src/screen.h index 68b597d2c8..a8058d9ff7 100644 --- a/app/src/screen.h +++ b/app/src/screen.h @@ -22,6 +22,7 @@ #include "trait/key_processor.h" #include "trait/frame_sink.h" #include "trait/mouse_processor.h" +#include "util/thread.h" #ifdef __APPLE__ # define SC_DISPLAY_FOR...
[ "app/src/screen.h" ]
[ { "comment": "Should add `#include \"util/thread.h\"` in `screen.h` and remove it from `frame_buffer.h`.", "path": "app/src/screen.h", "hunk": "@@ -41,9 +41,11 @@ struct sc_screen {\n struct sc_texture tex;\n struct sc_input_manager im;\n struct sc_mouse_capture mc; // only used in mouse rel...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
It's a bit sad that the `PACKET_FLAG_SESSION` constant is declared in this class but never used explicitly. Maybe it should be defined as `1L << 31` instead? I understand the issue is that on the one hand you have (media) packet flags + PTS in 8 bytes and on the other hand you have session flag + padding in 4 bytes. I ...
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/server/src/main/java/com/genymobile/scrcpy/device/Streamer.java b/server/src/main/java/com/genymobile/scrcpy/device/Streamer.java index a00b0280aa..e793f67b54 100644 --- a/server/src/main/java/com/genymobile/scrcpy/device/Streamer.java +++ b/server/src/main/java/com/genymobile/scrcpy/device/Streamer.java @...
[ "server/src/main/java/com/genymobile/scrcpy/device/Streamer.java" ]
[ { "comment": "It's a bit sad that the `PACKET_FLAG_SESSION` constant is declared in this class but never used explicitly. Maybe it should be defined as `1L << 31` instead? I understand the issue is that on the one hand you have (media) packet flags + PTS in 8 bytes and on the other hand you have session flag + ...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
You would need to update the schema in `doc/develop.md` accordingly.
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/app/src/demuxer.c b/app/src/demuxer.c index 634b010fc9..f0709424d6 100644 --- a/app/src/demuxer.c +++ b/app/src/demuxer.c @@ -76,10 +76,10 @@ sc_demuxer_recv_header(struct sc_demuxer *demuxer, // which only contains a 12-byte header: // // byte 0 byte 1 byte 2 byte 3 - // 10000000 ...
[ "app/src/demuxer.c" ]
[ { "comment": "You would need to update the schema in `doc/develop.md` accordingly.", "path": "app/src/demuxer.c", "hunk": "@@ -77,9 +77,9 @@ sc_demuxer_recv_header(struct sc_demuxer *demuxer,\n //\n // byte 0 byte 1 byte 2 byte 3\n // 10000000 00000000 00000000 00000000\n- // ^<---...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
Both `scrcpy.1` and `cli.c` write "render-fit mode" with a hyphen, so maybe there should be one here too? ```suggestion '--render-fit=[Set the render-fit mode]:render-fit mode:(letterbox disabled)' ``` or ```suggestion '--render-fit=[Set the render-fit mode]:mode:(letterbox disabled)' ```
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/app/data/zsh-completion/_scrcpy b/app/data/zsh-completion/_scrcpy index 8896e73839..a6dd68d9a0 100644 --- a/app/data/zsh-completion/_scrcpy +++ b/app/data/zsh-completion/_scrcpy @@ -87,6 +87,7 @@ arguments=( '--record-format=[Force recording format]:format:(mp4 mkv m4a mka opus aac flac wav)' '--...
[ "app/data/zsh-completion/_scrcpy" ]
[ { "comment": "Both `scrcpy.1` and `cli.c` write \"render-fit mode\" with a hyphen, so maybe there should be one here too?\r\n```suggestion\r\n '--render-fit=[Set the render-fit mode]:render-fit mode:(letterbox disabled)'\r\n```\r\nor\r\n```suggestion\r\n '--render-fit=[Set the render-fit mode]:mode:(lette...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
This new option should probably be documented somewhere in `doc/window.md` or `doc/video.md`.
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/app/src/cli.c b/app/src/cli.c index 2cb0d3e23d..dbe264fcba 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -107,6 +107,7 @@ enum { OPT_NO_WINDOW_ASPECT_RATIO_LOCK, OPT_KEEP_ACTIVE, OPT_BACKGROUND_COLOR, + OPT_RENDER_FIT, }; struct sc_option { @@ -501,9 +502,12 @@ static const struct...
[ "app/src/cli.c" ]
[ { "comment": "This new option should probably be documented somewhere in `doc/window.md` or `doc/video.md`.", "path": "app/src/cli.c", "hunk": "@@ -778,6 +779,20 @@ static const struct sc_option options[] = {\n \"\\\"opengles2\\\", \\\"opengles\\\", \\\"metal\\\" and \\\"software\\\".\\n...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
This new option should probably be documented in `doc/virtual_display.md`.
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/app/src/cli.c b/app/src/cli.c index 2cb0d3e23d..dbe264fcba 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -107,6 +107,7 @@ enum { OPT_NO_WINDOW_ASPECT_RATIO_LOCK, OPT_KEEP_ACTIVE, OPT_BACKGROUND_COLOR, + OPT_RENDER_FIT, }; struct sc_option { @@ -501,9 +502,12 @@ static const struct...
[ "app/src/cli.c" ]
[ { "comment": "This new option should probably be documented in `doc/virtual_display.md`.", "path": "app/src/cli.c", "hunk": "@@ -1016,6 +1017,11 @@ static const struct sc_option options[] = {\n .text = \"Set the initial window height.\\n\"\n \"Default is 0 (automatic).\",\n }...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
I suspect you meant this instead (meaning, bitwise NOT instead of logical NOT): ```suggestion assert(!(event->data1 & ~0xFFFF)); assert(!(event->data2 & ~0xFFFF)); ``` Otherwise the current conditions are always true if I'm not mistaken.
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/app/src/screen.c b/app/src/screen.c index b02629d716..5c280c7f1c 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -72,10 +72,10 @@ static bool is_optimal_size(struct sc_size current_size, struct sc_size content_size) { // The size is optimal if we can recompute one dimension of the current ...
[ "app/src/screen.c" ]
[ { "comment": "I suspect you meant this instead (meaning, bitwise NOT instead of logical NOT):\n```suggestion\n assert(!(event->data1 & ~0xFFFF));\n assert(!(event->data2 & ~0xFFFF));\n```\nOtherwise the current conditions are always true if I'm not mistaken.", "path": "app/src/screen.c...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
```suggestion sc_controller_resize_display(screen->controller, width, height); ```
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/app/src/screen.c b/app/src/screen.c index b02629d716..5c280c7f1c 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -72,10 +72,10 @@ static bool is_optimal_size(struct sc_size current_size, struct sc_size content_size) { // The size is optimal if we can recompute one dimension of the current ...
[ "app/src/screen.c" ]
[ { "comment": "```suggestion\n sc_controller_resize_display(screen->controller, width, height);\n```", "path": "app/src/screen.c", "hunk": "@@ -286,10 +286,27 @@ sc_screen_render(struct sc_screen *screen, bool update_content_rect) {\n }\n \n static void\n-sc_screen_on_resize(struct sc_screen *...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
```suggestion public static final int RESET_REASON_CLIENT_RESIZED = 1 << 3; ```
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/server/src/main/java/com/genymobile/scrcpy/video/CaptureControl.java b/server/src/main/java/com/genymobile/scrcpy/video/CaptureControl.java new file mode 100644 index 0000000000..7933ea725f --- /dev/null +++ b/server/src/main/java/com/genymobile/scrcpy/video/CaptureControl.java @@ -0,0 +1,42 @@ +package co...
[ "server/src/main/java/com/genymobile/scrcpy/video/CaptureControl.java" ]
[ { "comment": "```suggestion\n public static final int RESET_REASON_CLIENT_RESIZED = 1 << 3;\n```", "path": "server/src/main/java/com/genymobile/scrcpy/video/CaptureControl.java", "hunk": "@@ -7,6 +7,7 @@ public class CaptureControl {\n public static final int RESET_REASON_TERMINATE = 1;\n pub...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
Just wondering if this comment is at the right place or if it relates to the call to `encode()` at line 136?
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/server/src/main/java/com/genymobile/scrcpy/video/SurfaceEncoder.java b/server/src/main/java/com/genymobile/scrcpy/video/SurfaceEncoder.java index 0333203e4d..be022fc97b 100644 --- a/server/src/main/java/com/genymobile/scrcpy/video/SurfaceEncoder.java +++ b/server/src/main/java/com/genymobile/scrcpy/video/S...
[ "server/src/main/java/com/genymobile/scrcpy/video/SurfaceEncoder.java" ]
[ { "comment": "Just wondering if this comment is at the right place or if it relates to the call to `encode()` at line 136?", "path": "server/src/main/java/com/genymobile/scrcpy/video/SurfaceEncoder.java", "hunk": "@@ -128,7 +128,11 @@ private void streamCapture() throws IOException, ConfigurationExcepti...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
Should you check for `flexDisplay` here too? ```suggestion if (flexDisplay && getVideoConstraints().getMaxSize() != 0) { ``` Then maybe the two conditions should be wrapped into a `flexDisplay` check: ```java if (flexDisplay) { if (crop != null) { [...] } ...
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java b/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java index e0ec2141fb..c1038c9302 100644 --- a/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java +++ b/server/src/main/java/com/genymobile/scrcp...
[ "server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java" ]
[ { "comment": "Should you check for `flexDisplay` here too?\n```suggestion\n if (flexDisplay && getVideoConstraints().getMaxSize() != 0) {\n```\nThen maybe the two conditions should be wrapped into a `flexDisplay` check:\n```java\n if (flexDisplay) {\n if (crop != null) {\n ...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
```suggestion displaySize = displaySize.align(constraints.getAlignment()); ```
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java b/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java index e0ec2141fb..c1038c9302 100644 --- a/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java +++ b/server/src/main/java/com/genymobile/scrcp...
[ "server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java" ]
[ { "comment": "```suggestion\n displaySize = displaySize.align(constraints.getAlignment());\n```", "path": "server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java", "hunk": "@@ -103,16 +124,20 @@ protected void init() {\n \n @Override\n public void prepare() {\n+ ...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
```suggestion assert pendingClientResized.isAligned(constraints.getAlignment()) : "pendingClientResized must be aligned"; ```
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java b/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java index e0ec2141fb..c1038c9302 100644 --- a/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java +++ b/server/src/main/java/com/genymobile/scrcp...
[ "server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java" ]
[ { "comment": "```suggestion\n assert pendingClientResized.isAligned(constraints.getAlignment()) : \"pendingClientResized must be aligned\";\n```", "path": "server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java", "hunk": "@@ -124,8 +149,27 @@ public void prepare() {\n ...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
```suggestion displaySize = displayInfo.getSize().align(constraints.getAlignment()); ```
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java b/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java index e0ec2141fb..c1038c9302 100644 --- a/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java +++ b/server/src/main/java/com/genymobile/scrcp...
[ "server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java" ]
[ { "comment": "```suggestion\n displaySize = displayInfo.getSize().align(constraints.getAlignment());\n```", "path": "server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java", "hunk": "@@ -124,8 +149,27 @@ public void prepare() {\n dpi = displayInfo.getDpi();\n ...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
```suggestion Ln.v(getClass().getSimpleName() + ": constrained size = " + newSize); ```
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java b/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java index e0ec2141fb..c1038c9302 100644 --- a/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java +++ b/server/src/main/java/com/genymobile/scrcp...
[ "server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java" ]
[ { "comment": "```suggestion\n Ln.v(getClass().getSimpleName() + \": constrained size = \" + newSize);\n```", "path": "server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java", "hunk": "@@ -257,4 +302,51 @@ private static int scaleDpi(Size initialSize, int initialDpi, Size size...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
```suggestion preserving the aspect ratio (`--render-fit=stretched`). ``` L77: "while preserving the aspect ratio". Thus adding "the" here for consistency. Also "without preserving the aspect ratio" currently used in `cli.c` & `scrcpy.1`.
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/doc/window.md b/doc/window.md index 9e0a34af39..349326ebe9 100644 --- a/doc/window.md +++ b/doc/window.md @@ -91,3 +91,24 @@ computer. To disable it: ```bash scrcpy --disable-screensaver ``` + + +## Render fit + +By default, the video stream is rendered in [letterbox] mode: the content fits +the window ...
[ "doc/window.md" ]
[ { "comment": "```suggestion\npreserving the aspect ratio (`--render-fit=stretched`).\n```\nL77: \"while preserving the aspect ratio\". Thus adding \"the\" here for consistency.\nAlso \"without preserving the aspect ratio\" currently used in `cli.c` & `scrcpy.1`.", "path": "doc/window.md", "hunk": "@@ -6...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
You can do the same (i.e. call `align`) with `maxWidth` & `maxHeight` L55-56.
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/server/src/main/java/com/genymobile/scrcpy/model/Size.java b/server/src/main/java/com/genymobile/scrcpy/model/Size.java index 385597a8a2..63648a9e8f 100644 --- a/server/src/main/java/com/genymobile/scrcpy/model/Size.java +++ b/server/src/main/java/com/genymobile/scrcpy/model/Size.java @@ -32,6 +32,10 @@ pu...
[ "server/src/main/java/com/genymobile/scrcpy/model/Size.java" ]
[ { "comment": "You can do the same (i.e. call `align`) with `maxWidth` & `maxHeight` L55-56.", "path": "server/src/main/java/com/genymobile/scrcpy/model/Size.java", "hunk": "@@ -85,16 +85,16 @@ public Size constrain(VideoConstraints constraints) {\n }\n \n public Size align(int alignment) {\n- ...
true
Genymobile/scrcpy
6,772
comment_to_fix
Add flex display support (resizable virtual display)
The logic is wrong now. With the disconnected icon on a flex display, `is_icon` is `true` and `render_fit` is `SC_RENDER_FIT_DISABLED` (default render-fit mode), thus this assert fails when the icon is too large. I could make it abort for real by compiling a debug build and forcing a size too small for the emulator: ...
32d2f06f84ef7e423103f7653979554d3e85d44b
1db8da559fd5b412b02b564e9ad40c2580bb9b34
diff --git a/app/src/screen.c b/app/src/screen.c index b02629d716..5c280c7f1c 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -72,10 +72,10 @@ static bool is_optimal_size(struct sc_size current_size, struct sc_size content_size) { // The size is optimal if we can recompute one dimension of the current ...
[ "app/src/screen.c" ]
[ { "comment": "The logic is wrong now. With the disconnected icon on a flex display, `is_icon` is `true` and `render_fit` is `SC_RENDER_FIT_DISABLED` (default render-fit mode), thus this assert fails when the icon is too large.\r\nI could make it abort for real by compiling a debug build and forcing a size too s...
true