Closed
Bug 557933
Opened 15 years ago
Closed 15 years ago
Hashtable String-to-number conversion is different in Argo vs. Astro
Categories
(Tamarin Graveyard :: Virtual Machine, defect, P2)
Tamarin Graveyard
Virtual Machine
Tracking
(Not tracked)
VERIFIED
FIXED
flash10.1
People
(Reporter: stejohns, Assigned: stejohns)
Details
(Whiteboard: Has patch, WE-2597170)
Attachments
(2 files, 1 obsolete file)
812 bytes,
patch
|
lhansen
:
review+
edwsmith
:
superreview+
|
Details | Diff | Splinter Review |
4.52 KB,
patch
|
lhansen
:
review+
edwsmith
:
superreview+
|
Details | Diff | Splinter Review |
When you use a string as an object key, the language quietly translate strings to integers where appropriate, so that o[3] == o["3"]. It appears that changes to the String code have changed the semantics when there are leading zeroes in the string: we used to disallow leading zeroes (so "03" was not considered equivalent to "3" or 3) but now we appear to allow exactly one leading zero.
This is flamingly wrong: consider
var o:Object = {};
o[3] = 1;
o["3"] = 2;
o["03"] = 3;
o["003"] = 4;
for (var n:* in o) {
print(n, typeof(n), o[n])
}
in 10.0 we'd get
003 string 4
03 string 3
3 number 2
but now we get
003 string 4
3 number 3
Comment 1•15 years ago
|
||
Flame on!
Assignee | ||
Comment 2•15 years ago
|
||
Problem seems to be in String::getIntAtom and String::parseIndex... it attempts to do the right thing but it appears its calculation is simply misplaced.
Assignee: nobody → stejohns
Attachment #437693 -
Flags: superreview?(edwsmith)
Attachment #437693 -
Flags: review?(lhansen)
Assignee | ||
Comment 3•15 years ago
|
||
FWIW, this was only found because of a performance regression; apparently our acceptance tests aren't finding this. I'll add one. The performance regression was from code of the form
var loops:uint = 100000;
var hash2:Object;
function init():void {
hash2 = {};
for (var i=0; i<loops; i++) {
var s:String = "0"+i; // also: +"000", and +"00000000"
hash2[s] = i/3;
}
}
function objHash2():void {
for (var n:String in hash2) {
hash2[n] += 0.2;
}
}
init();
objHash2();
Formerly, the keys were always kept as String (since they had leading zero); now, they are erroneously converted to number, then reconverted to String in the iteration loop.
Updated•15 years ago
|
Attachment #437693 -
Flags: review?(lhansen) → review+
Assignee | ||
Comment 4•15 years ago
|
||
Attachment #437699 -
Flags: superreview?(lhansen)
Attachment #437699 -
Flags: review?(edwsmith)
Updated•15 years ago
|
Attachment #437699 -
Flags: superreview?(lhansen) → superreview+
Comment 5•15 years ago
|
||
Steven, where was the perf regression observed?
Comment 6•15 years ago
|
||
Trevor: see http://watsonexp.corp.adobe.com/#bug=2597170
Comment 7•15 years ago
|
||
(In reply to comment #2)
> Created an attachment (id=437693) [details]
> Patch
You might revise the comment "// bad character, or more than one leading zero?";
as it currently stands the comment implies that exactly one leading zero might be
okay (precisely the bug you are fixing). E.g. "bad character, or has leading zeroes?"
Comment 8•15 years ago
|
||
Should this be targetted for 10.1?
Updated•15 years ago
|
Flags: in-testsuite?
Flags: flashplayer-triage+
Flags: flashplayer-qrb?
Flags: flashplayer-injection+
Status: NEW → ASSIGNED
Flags: flashplayer-qrb? → flashplayer-qrb+
Priority: -- → P2
Target Milestone: --- → flash10.1
Comment 9•15 years ago
|
||
yes!
Comment 10•15 years ago
|
||
Comment on attachment 437699 [details] [diff] [review]
Acceptance Test
as long as the test fails before and passes after the fix, its good. no idea how well it covers the area of interest tho. (negative numbers? decimals? hex literals?)
Attachment #437699 -
Flags: review?(edwsmith) → review+
Comment 11•15 years ago
|
||
Comment on attachment 437693 [details] [diff] [review]
Patch
Looks okay.
One more thought on the test: does it exersize both parseIndex() and getIntAtom()?
if not, it probably should.
Attachment #437693 -
Flags: superreview?(edwsmith) → superreview+
Assignee | ||
Comment 12•15 years ago
|
||
(In reply to comment #7)
> You might revise the comment "// bad character, or more than one leading
yep, will do
(In reply to comment #10)
> how well it covers the area of interest tho. (negative numbers? decimals? hex
> literals?) does it exersize both parseIndex() and getIntAtom()?
Will augment the test before pushing.
Assignee | ||
Comment 13•15 years ago
|
||
Pushed code change:
http://asteam.macromedia.com/hg/tamarin-redux-argo/rev/508cc7b9bd0a
http://hg.mozilla.org/tamarin-redux/rev/508cc7b9bd0a
(Testcase will be augmented prior to push)
Assignee | ||
Comment 14•15 years ago
|
||
Test per Edwin's comments.
Attachment #437699 -
Attachment is obsolete: true
Attachment #438194 -
Flags: superreview?(edwsmith)
Attachment #438194 -
Flags: review?(lhansen)
Comment 15•15 years ago
|
||
Comment on attachment 438194 [details] [diff] [review]
Updated acceptance test
Obviously we are more permissive around leading zeroes than the ECMAScript spec :-)
Attachment #438194 -
Flags: review?(lhansen) → review+
Updated•15 years ago
|
Attachment #438194 -
Flags: superreview?(edwsmith) → superreview+
Comment 16•15 years ago
|
||
Acceptance test (attachment 438194 [details] [diff] [review]) pushed redux changeset: 4438:b7ee29a3e532
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Flags: in-testsuite? → in-testsuite+
Resolution: --- → FIXED
Updated•15 years ago
|
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•