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

Issue 848193003: Subzero: Add locking to prepare for multithreaded translation. (Closed)

Created:
5 years, 11 months ago by Jim Stichnoth
Modified:
5 years, 11 months ago
CC:
native-client-reviews_googlegroups.com
Base URL:
https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Subzero: Add locking to prepare for multithreaded translation. This just gets the locking in place. Actual multithreading will be added later. Mutexes are added for accessing the GlobalContext allocator, the constant pool, the stats data, and the profiling timers. These are managed via the LockedPtr<> helper. Finer grain locks on the constant pool may be added later, i.e. a separate lock for each data type. An vector of pointers to TLS objects is added to GlobalContext. Each new thread will get its own TLS object, whose address is added to the vector. (After threads complete, things like stats can be combined by iterating over the vector.) The dump/emit streams are guarded by a separate lock, to avoid fine-grain interleaving of output by multiple threads. E.g., lock the streams, emit an entire function, and unlock the streams. This works for dumping too, though dump output for different passes on the same function may be interleaved with that of another thread. There is an OstreamLocker helper class to keep this simple. CodeStats is made an inner class of GlobalContext (this was missed on a previous CL). BUG= none R=jfb@chromium.org, jvoung@chromium.org, kschimpf@google.com Committed: https://gerrit.chromium.org/gerrit/gitweb?p=native_client/pnacl-subzero.git;a=commit;h=e4a8f400267b3c3b9f0cb7c4b00f8512f9fbe0a1

Patch Set 1 #

Patch Set 2 : Document the OstreamLocker class #

Total comments: 12

Patch Set 3 : Code review changes #

Total comments: 13

Patch Set 4 : Code review changes #2 #

Total comments: 13

Patch Set 5 : Simply the LockedPtr implementation #

Total comments: 4

Patch Set 6 : Remove GlobalContext::IsStrLocked. Make LockedPtr<>::Lock a pointer. #

Total comments: 2

Patch Set 7 : Non-recursive mutex. '> >' --> '>>' for C++11. #

Total comments: 2

Patch Set 8 : Rebase #

Unified diffs Side-by-side diffs Delta from patch set Stats (+256 lines, -100 lines) Patch
M src/IceCfg.cpp View 1 2 3 6 chunks +9 lines, -2 lines 0 comments Download
M src/IceConverter.cpp View 2 chunks +2 lines, -4 lines 0 comments Download
M src/IceDefs.h View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M src/IceGlobalContext.h View 1 2 3 4 5 6 10 chunks +136 lines, -43 lines 0 comments Download
M src/IceGlobalContext.cpp View 1 2 3 4 5 8 chunks +69 lines, -41 lines 0 comments Download
M src/IceOperand.h View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M src/IceRegAlloc.cpp View 17 chunks +22 lines, -3 lines 0 comments Download
M src/IceTargetLoweringX8632.cpp View 4 5 5 chunks +5 lines, -0 lines 0 comments Download
M src/IceTranslator.h View 1 chunk +1 line, -1 line 0 comments Download
M src/IceTranslator.cpp View 2 chunks +4 lines, -2 lines 0 comments Download
M src/PNaClTranslator.cpp View 1 2 3 4 5 6 7 2 chunks +6 lines, -2 lines 0 comments Download

Messages

Total messages: 20 (2 generated)
Jim Stichnoth
Performance penalty for the extra locking seems to be either 0.5% or in the noise.
5 years, 11 months ago (2015-01-15 00:45:05 UTC) #2
JF
https://codereview.chromium.org/848193003/diff/20001/src/IceGlobalContext.cpp File src/IceGlobalContext.cpp (right): https://codereview.chromium.org/848193003/diff/20001/src/IceGlobalContext.cpp#newcode136 src/IceGlobalContext.cpp:136: AllThreadContexts.push_back(new ThreadContext()); Do you need to lock AllThreadContexts when ...
5 years, 11 months ago (2015-01-15 01:31:01 UTC) #4
Jim Stichnoth
https://codereview.chromium.org/848193003/diff/20001/src/IceGlobalContext.cpp File src/IceGlobalContext.cpp (right): https://codereview.chromium.org/848193003/diff/20001/src/IceGlobalContext.cpp#newcode136 src/IceGlobalContext.cpp:136: AllThreadContexts.push_back(new ThreadContext()); On 2015/01/15 01:31:01, JF wrote: > Do ...
5 years, 11 months ago (2015-01-15 07:16:29 UTC) #5
JF
Overall I think it would be cleaner if each lock were only ever acquired in ...
5 years, 11 months ago (2015-01-15 16:28:39 UTC) #6
Karl
I agree (in general) with JF's comments about OstreamLocker. However, I would not have a ...
5 years, 11 months ago (2015-01-15 17:35:43 UTC) #7
jvoung (off chromium)
https://codereview.chromium.org/848193003/diff/40001/src/IceCfg.cpp File src/IceCfg.cpp (right): https://codereview.chromium.org/848193003/diff/40001/src/IceCfg.cpp#newcode461 src/IceCfg.cpp:461: if (!Ctx->getFlags().UseELFWriter) Technically, the lock doesn't need to be ...
5 years, 11 months ago (2015-01-15 18:20:40 UTC) #8
Jim Stichnoth
I've addressed all the comments except those regarding the stream bracketing/locking. More on that later... ...
5 years, 11 months ago (2015-01-17 18:44:17 UTC) #9
JF
https://codereview.chromium.org/848193003/diff/60001/src/IceCfg.cpp File src/IceCfg.cpp (right): https://codereview.chromium.org/848193003/diff/60001/src/IceCfg.cpp#newcode473 src/IceCfg.cpp:473: getAssembler<Assembler>()->emitIASBytes(Ctx); What is this locking exactly? It sounds like ...
5 years, 11 months ago (2015-01-18 03:14:20 UTC) #10
Jim Stichnoth
https://codereview.chromium.org/848193003/diff/60001/src/IceGlobalContext.h File src/IceGlobalContext.h (right): https://codereview.chromium.org/848193003/diff/60001/src/IceGlobalContext.h#newcode60 src/IceGlobalContext.h:60: LockedPtr(T *Value, GlobalLockType &Lock) : Ptr(new LockedPtrWrapper(Value, Lock)) {} ...
5 years, 11 months ago (2015-01-19 21:44:05 UTC) #11
JF
https://codereview.chromium.org/848193003/diff/60001/src/IceGlobalContext.h File src/IceGlobalContext.h (right): https://codereview.chromium.org/848193003/diff/60001/src/IceGlobalContext.h#newcode60 src/IceGlobalContext.h:60: LockedPtr(T *Value, GlobalLockType &Lock) : Ptr(new LockedPtrWrapper(Value, Lock)) {} ...
5 years, 11 months ago (2015-01-20 01:23:05 UTC) #12
Jim Stichnoth
I think I've addressed all the comments, but please double-check that I haven't missed anything. ...
5 years, 11 months ago (2015-01-20 16:22:54 UTC) #13
JF
https://codereview.chromium.org/848193003/diff/60001/src/IceGlobalContext.h File src/IceGlobalContext.h (right): https://codereview.chromium.org/848193003/diff/60001/src/IceGlobalContext.h#newcode300 src/IceGlobalContext.h:300: bool IsStrLocked; On 2015/01/20 16:22:54, stichnot wrote: > On ...
5 years, 11 months ago (2015-01-20 17:20:21 UTC) #14
jvoung (off chromium)
https://codereview.chromium.org/848193003/diff/40001/src/IceTargetLoweringX8632.cpp File src/IceTargetLoweringX8632.cpp (right): https://codereview.chromium.org/848193003/diff/40001/src/IceTargetLoweringX8632.cpp#newcode1027 src/IceTargetLoweringX8632.cpp:1027: if (Ctx->getFlags().UseELFWriter) { On 2015/01/20 16:22:54, stichnot wrote: > ...
5 years, 11 months ago (2015-01-20 17:34:30 UTC) #15
Jim Stichnoth
https://codereview.chromium.org/848193003/diff/40001/src/IceTargetLoweringX8632.cpp File src/IceTargetLoweringX8632.cpp (right): https://codereview.chromium.org/848193003/diff/40001/src/IceTargetLoweringX8632.cpp#newcode1027 src/IceTargetLoweringX8632.cpp:1027: if (Ctx->getFlags().UseELFWriter) { On 2015/01/20 17:34:30, jvoung wrote: > ...
5 years, 11 months ago (2015-01-20 18:14:54 UTC) #16
JF
(ノ◕ヮ◕)ノ*:・゚✧ lgtm
5 years, 11 months ago (2015-01-20 19:27:56 UTC) #17
jvoung (off chromium)
< lgtm > ------ \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||
5 years, 11 months ago (2015-01-20 19:51:05 UTC) #18
Karl
lgtm https://codereview.chromium.org/848193003/diff/120001/src/IceGlobalContext.cpp File src/IceGlobalContext.cpp (right): https://codereview.chromium.org/848193003/diff/120001/src/IceGlobalContext.cpp#newcode453 src/IceGlobalContext.cpp:453: // seems to be unused. If so, remove ...
5 years, 11 months ago (2015-01-20 20:00:36 UTC) #19
Jim Stichnoth
5 years, 11 months ago (2015-01-20 20:52:55 UTC) #20
Message was sent while issue was closed.
Committed patchset #8 (id:140001) manually as
e4a8f400267b3c3b9f0cb7c4b00f8512f9fbe0a1 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698