Closed Bug 554860 Opened 14 years ago Closed 14 years ago

Sampler::takeSample should be volatile

Categories

(Tamarin Graveyard :: Virtual Machine, defect, P3)

Tracking

(Not tracked)

RESOLVED FIXED
Q3 11 - Serrano

People

(Reporter: mike, Assigned: mike)

Details

Attachments

(1 file)

In Sampler.h, "int32_t takeSample" should be "volatile int32_t takeSample", because that variable is set from one thread and accessed from another thread.  A compiler might optimize away the reads, thus causing the profiler not to take samples as often as it should.

It's an easy change, but in practice, this is highly unlikely because of the calling pattern, so I'm fine with deferring this until flash10.2.
Assignee: nobody → mmoreart
Flags: flashplayer-qrb+
Priority: -- → P3
Target Milestone: --- → flash10.2
Attached patch patchSplinter Review
Attachment #443674 - Flags: superreview?(edwsmith)
Attachment #443674 - Flags: review?(treilly)
Status: NEW → ASSIGNED
Is it necessary to transmit the volatile keyword up to the OSDep API?  (unrelated:  is OSDep pretty much obsolete now with VMPI?)
(In reply to comment #2)
> Is it necessary to transmit the volatile keyword up to the OSDep API? 

I was wondering that too.  I don't really feel that it is necessary to transmit it; but I tried leaving the OSDep API unchanged, and then I got a compiler warning on the line of Sampler.cpp that calls OSDep::startIntWriterTimer() -- the compiler didn't like the fact that I was passing a (volatile int *) to a function that is expecting an (int *).  Obviously that would be easy to fix with a cast, but in general casts are somewhat undesirable.

I really don't have a strong opinion about it -- I'd be fine with putting in a cast if others think that's a better approach.
i dont have a strong opinion either, just odd.
Comment on attachment 443674 [details] [diff] [review]
patch

On second thought I think volatile is correct at the interface; the contract is that a background thread will write to *addr.
Attachment #443674 - Flags: superreview?(edwsmith) → superreview+
Attachment #443674 - Flags: review?(treilly) → review+
Pushed: http://hg.mozilla.org/tamarin-redux/rev/5d9d0b0e8be8
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Flags: flashplayer-bug+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: