Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Issue 139453002: Implement nacl_irt_futex for non-sfi mode. (Closed)

Created:
6 years, 11 months ago by hidehiko
Modified:
6 years, 11 months ago
Reviewers:
Mark Seaborn
CC:
chromium-reviews, hamaji
Visibility:
Public.

Description

Implement nacl_irt_futex for non-sfi mode. This CL implements nacl_irt_futex for non-sfi mode. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3734 TEST=Tried to call a newly added function from plugin via AT_SYSINFO. Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=245248

Patch Set 1 #

Total comments: 15

Patch Set 2 : Rebase #

Patch Set 3 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+85 lines, -0 lines) Patch
M components/nacl.gyp View 1 chunk +1 line, -0 lines 0 comments Download
A components/nacl/loader/nonsfi/irt_futex.cc View 1 2 1 chunk +82 lines, -0 lines 0 comments Download
M components/nacl/loader/nonsfi/irt_interfaces.h View 1 chunk +1 line, -0 lines 0 comments Download
M components/nacl/loader/nonsfi/irt_interfaces.cc View 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
hidehiko
This CL is based on crrev.com/133683011, which is just sent to you for code review ...
6 years, 11 months ago (2014-01-15 14:40:31 UTC) #1
Mark Seaborn
LGTM https://codereview.chromium.org/139453002/diff/1/components/nacl/loader/nonsfi/irt_futex.cc File components/nacl/loader/nonsfi/irt_futex.cc (right): https://codereview.chromium.org/139453002/diff/1/components/nacl/loader/nonsfi/irt_futex.cc#newcode18 components/nacl/loader/nonsfi/irt_futex.cc:18: // Converts a pair of nacl's timespec of ...
6 years, 11 months ago (2014-01-15 19:27:54 UTC) #2
hidehiko
Thank you for your review. Submitting... https://codereview.chromium.org/139453002/diff/1/components/nacl/loader/nonsfi/irt_futex.cc File components/nacl/loader/nonsfi/irt_futex.cc (right): https://codereview.chromium.org/139453002/diff/1/components/nacl/loader/nonsfi/irt_futex.cc#newcode18 components/nacl/loader/nonsfi/irt_futex.cc:18: // Converts a ...
6 years, 11 months ago (2014-01-16 06:52:23 UTC) #3
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/hidehiko@chromium.org/139453002/140001
6 years, 11 months ago (2014-01-16 06:53:55 UTC) #4
commit-bot: I haz the power
Change committed as 245248
6 years, 11 months ago (2014-01-16 18:07:23 UTC) #5
Mark Seaborn
6 years, 11 months ago (2014-01-16 19:39:47 UTC) #6
Message was sent while issue was closed.
https://codereview.chromium.org/139453002/diff/1/components/nacl/loader/nonsf...
File components/nacl/loader/nonsfi/irt_futex.cc (right):

https://codereview.chromium.org/139453002/diff/1/components/nacl/loader/nonsf...
components/nacl/loader/nonsfi/irt_futex.cc:26: int64 elapsed_nsec =
On 2014/01/16 06:52:23, hidehiko wrote:
> On 2014/01/15 19:27:54, Mark Seaborn wrote:
> > It's better to do what unsandboxed_irt.c does:
> > 
> >     reltime.tv_sec = abstime->tv_sec - time_now.tv_sec;
> >     reltime.tv_nsec = abstime->tv_nsec - time_now.tv_nsec;
> >     if (reltime.tv_nsec < 0) {
> >       reltime.tv_sec -= 1;
> >       reltime.tv_nsec += 1000000000;
> >     }
> > 
> > This doesn't involve multiplication and division, so it's more efficient.
> 
> Done, assuming both input tv_nsec are non-negative.

Right.  It's required that 0 <= tv_nsec < 1000000000.  Linux's futex syscall
returns EINVAL otherwise.  We should probably document this in irt.h.

I suppose it would be worthwhile checking for that condition here too, before
the calculation.  Want to add a check?

I haven't checked whether/where this constraint is specified in the pthread
standard.  Might be worth checking...


> BTW, just curious, the cost of "if + decrement + add" is cheaper than
> "multiplication + division" in most cases? (I believe you, but I'd also like
to
> know the source so that I can make a criterion in my mind for future CLs :-).

Yes, multiplication tends to use a lot more cycles, and division is even more
complex.  On x86-32 and ARM, 64-bit div/mod involve calling out to external
functions.

e.g. See the code for __moddi3 in "objdump -dr /usr/lib32/libgcc_s.so.1".

Checking for 10^9 and doing the carry is the common pattern in glibc.  For
example, see
https://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/pthread_mutex_timedlock....

Powered by Google App Engine
This is Rietveld 408576698