-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add tests on register management for strjoin()
The current register management in the code generator needs overhaul. Here are some tests to check operations in strjoin(). Some of these tests are marked @@xfail until the overhaul has been done. For example, here is what happens in tst.reg_spilling5.d. The D script is: trace(strjoin("abc", strjoin("def", strjoin("ghi", strjoin("jkl", strjoin("mno", "pqrstuvwx" ) ) ) ) ) ); The generated code basically does this: r8 = pointer to "abc" r7 = pointer to "def" r6 = pointer to "ghi" r5 = pointer to "jkl" r4 = pointer to "mno" r3 = pointer to "pqrstuvwx" Then it does the innermost strjoin: r2 = pointer to tstring(0) spill %r2 spill %r3 spill %r4 spill %r5 dt_strjoin(tstring(0), "mno", "pqrstuvwx"); restore %r2 restore %r5 Then it starts the next strjoin: r4 = pointer to tstring(1) spill %r2 spill %r4 spill %r5 Next, it must fill the arguments for the dt_strjoin(dst, s1, s2) call. It uses the following code from dt_cg_subr_strjoin(): BPF_MOV_REG(BPF_REG_1, dnp->dn_reg); BPF_MOV_REG(BPF_REG_2, s1->dn_reg); dt_regset_free(s1->dn_reg); BPF_MOV_REG(BPF_REG_3, s2->dn_reg); dt_regset_free(s2->dn_reg); At this point, however: r4 is dst r5 is s1 r2 is s2 So the code is: r1 = r4 // loads dst into r1, okay r2 = r5 // loads s1 into r2, but overwrites s2! fill r5 // okay, we do not care r3 = r2 // uses overwritten value! fill r2 // overwrites a function arg! Careful register management in dt_cg_subr_strjoin() could fix this problem, but resolution will be left for the larger overhaul. Signed-off-by: Eugene Loh <eugene.loh@oracle.com> Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
- Loading branch information
Showing
12 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. | ||
* Licensed under the Universal Permissive License v 1.0 as shown at | ||
* http://oss.oracle.com/licenses/upl. | ||
*/ | ||
|
||
/* | ||
* ASSERTION: Test that the code generator's spill/fill works with strjoin(). | ||
*/ | ||
|
||
#pragma D option quiet | ||
|
||
BEGIN | ||
{ | ||
trace(strjoin("abc", | ||
strjoin("def", | ||
"ghijklmnopqrstuvwx" | ||
) | ||
) | ||
); | ||
exit(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
abcdefghijklmnopqrstuvwx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. | ||
* Licensed under the Universal Permissive License v 1.0 as shown at | ||
* http://oss.oracle.com/licenses/upl. | ||
*/ | ||
|
||
/* | ||
* ASSERTION: Test that the code generator's spill/fill works with strjoin(). | ||
*/ | ||
|
||
#pragma D option quiet | ||
|
||
BEGIN | ||
{ | ||
trace(strjoin("abc", | ||
strjoin("def", | ||
strjoin("ghi", | ||
"jklmnopqrstuvwx" | ||
) | ||
) | ||
) | ||
); | ||
exit(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
abcdefghijklmnopqrstuvwx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. | ||
* Licensed under the Universal Permissive License v 1.0 as shown at | ||
* http://oss.oracle.com/licenses/upl. | ||
*/ | ||
|
||
/* | ||
* ASSERTION: Test that the code generator's spill/fill works with strjoin(). | ||
*/ | ||
|
||
#pragma D option quiet | ||
|
||
BEGIN | ||
{ | ||
trace(strjoin("abc", | ||
strjoin("def", | ||
strjoin("ghi", | ||
strjoin("jkl", | ||
"mnopqrstuvwx" | ||
) | ||
) | ||
) | ||
) | ||
); | ||
exit(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
abcdefghijklmnopqrstuvwx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. | ||
* Licensed under the Universal Permissive License v 1.0 as shown at | ||
* http://oss.oracle.com/licenses/upl. | ||
*/ | ||
|
||
/* | ||
* ASSERTION: Test that the code generator's spill/fill works with strjoin(). | ||
*/ | ||
/* @@xfail: DTv2 register management */ | ||
|
||
#pragma D option quiet | ||
|
||
BEGIN | ||
{ | ||
trace(strjoin("abc", | ||
strjoin("def", | ||
strjoin("ghi", | ||
strjoin("jkl", | ||
strjoin("mno", | ||
"pqrstuvwx" | ||
) | ||
) | ||
) | ||
) | ||
) | ||
); | ||
exit(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
abcdefghijklmnopqrstuvwx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. | ||
* Licensed under the Universal Permissive License v 1.0 as shown at | ||
* http://oss.oracle.com/licenses/upl. | ||
*/ | ||
|
||
/* | ||
* ASSERTION: Test that the code generator's spill/fill works with strjoin(). | ||
*/ | ||
/* @@xfail: DTv2 register management */ | ||
|
||
#pragma D option quiet | ||
|
||
BEGIN | ||
{ | ||
trace(strjoin("abc", | ||
strjoin("def", | ||
strjoin("ghi", | ||
strjoin("jkl", | ||
strjoin("mno", | ||
strjoin("pqr", | ||
"stuvwx" | ||
) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
); | ||
exit(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
abcdefghijklmnopqrstuvwx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. | ||
* Licensed under the Universal Permissive License v 1.0 as shown at | ||
* http://oss.oracle.com/licenses/upl. | ||
*/ | ||
|
||
/* | ||
* ASSERTION: Test that the code generator's spill/fill works with strjoin(). | ||
*/ | ||
/* @@xfail: DTv2 register management */ | ||
|
||
#pragma D option quiet | ||
|
||
BEGIN | ||
{ | ||
trace(strjoin("abc", | ||
strjoin("def", | ||
strjoin("ghi", | ||
strjoin("jkl", | ||
strjoin("mno", | ||
strjoin("pqr", | ||
strjoin("stu", "vwx") | ||
) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
); | ||
exit(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
abcdefghijklmnopqrstuvwx |