-
-
Notifications
You must be signed in to change notification settings - Fork 761
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: Support dependent strings for concatenation #16308
core: Support dependent strings for concatenation #16308
Conversation
Forgot to add: for code that is not egregiously written (so most code), this might slightly increase our memory usage. |
#9736 is fixed with this PR 馃コ |
897bab3
to
7f83143
Compare
(After rebasing, I have amended this commit with a |
7f83143
to
6fdfe7d
Compare
f48f244
to
1079695
Compare
@@ -38,6 +38,13 @@ impl<'gc> AvmString<'gc> { | |||
} | |||
} | |||
|
|||
pub fn as_managed(self) -> Option<Gc<'gc, AvmStringRepr<'gc>>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we use the 'managed' terminology anywhere else? If not, could we call this as_owned()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, forgot to mention (I also intended to add a TODO comment).
Currently the Owned
naming is extremely misleading, since a Source::Owned
string can either be dependent ("owned") or non-dependent ("owner"). IMO to resolve the overloaded usage of the term, the Source::Owned
should become Source::Managed
(in the "gc-managed" sense - feel free to propose alternatives), and "owner" terminology will only relate to dependent strings.
I didn't want to refactor this naming in this PR, but I did "pave the way" with .as_managed
, since otherwise having left.owner().as_owned()
sounds like utter nonsense.
Note: the PR is still missing size overflow checks, but the pointer logic should be stable now. |
30c4918
to
40bdff9
Compare
40bdff9
to
fc773ed
Compare
This makes affects all code that uses
AvmString::concat
, but the most important case is"a" + "b"
in both AVM1 and AVM2.(also added it to AS3
String::concat
while I was there)With the PR, the code like
Will allocate a new string buffer log(N) times, instead of N times. (note that it'll still allocate N string objects) This makes most code like this super fast instead of... crashing the player.
Should fix several SWFs, including #9736 - though I didn't test it yet.
I still want to test the code a bit more (tbh adding test-only code to inspect string internals would be great 馃槩) and mostly get a safety review from @moulins if possible.
Also might still refactor it a bit, this entire code might be moved to
AvmStringRepr
to keepAvmString
unsafe
-free and avoid exposing internal pointers.