Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add regression test for broken non commutative multiplication (#9175) #9218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Girgias wants to merge 3 commits into php:master
base: master
Choose a base branch
Loading
from Girgias:non-commutative-mul-test

Conversation

Copy link
Member

@Girgias Girgias commented Aug 1, 2022

This should add a test to catch the issue pointed out by #9175

Currently XFAIL as well it is broken.

Not sure this is the best way to write an internal object so reviews on this aspect would be appreciated.

mario-deluna and ging-dev reacted with heart emoji
Copy link
Member Author

Girgias commented Aug 1, 2022
edited
Loading

Current test output is:

object(NonCommutativeMultiplication)#1 (1) {
 ["val":"NonCommutativeMultiplication":private]=>
 int(10)
}
object(NonCommutativeMultiplication)#2 (1) {
 ["val":"NonCommutativeMultiplication":private]=>
 int(50)
}
object(NonCommutativeMultiplication)#3 (1) {
 ["val":"NonCommutativeMultiplication":private]=>
 int(100)
}
object(NonCommutativeMultiplication)#5 (1) {
 ["val":"NonCommutativeMultiplication":private]=>
 int(30)
}
int(40)
object(NonCommutativeMultiplication)#4 (1) {
 ["val":"NonCommutativeMultiplication":private]=>
 int(-40)
}
int(-140)
object(NonCommutativeMultiplication)#5 (1) {
 ["val":"NonCommutativeMultiplication":private]=>
 int(140)
}
int(-60)
object(NonCommutativeMultiplication)#4 (1) {
 ["val":"NonCommutativeMultiplication":private]=>
 int(60)
}

(削除) Which I don't even understand how it got to those results. (削除ここまで)
It reorders the operation from:

((100 - 50) - 10)
to
(10 - (100 - 50))

Copy link
Member Author

Girgias commented Aug 2, 2022

Okay I've got a fix, which is to remove the SPEC(COMMUTATIVE) marker in the VM.

Not sure how much this will affect performances, and or if there is another way to handle it.

@Girgias Girgias force-pushed the non-commutative-mul-test branch from f4a123b to e0350f4 Compare August 4, 2022 12:43
Copy link
Member

dstogov commented Aug 8, 2022

This shouldn't affect performance directly. This will slightly increase VM size and reduce code locality.
I'm not sure if simple removing the "commutativity" flag is enough. May be optimizer and JIT also relay on multiplication commutativity (I didn't check). Anyway, I don't like the idea of changing engine in favour of third-party extensions.

At first, we allow to break operators commutativity, then we will need a user defined operators order, etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@kocsismate kocsismate Awaiting requested review from kocsismate kocsismate is a code owner

@dstogov dstogov Awaiting requested review from dstogov dstogov is a code owner

@iluuu1994 iluuu1994 Awaiting requested review from iluuu1994

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /