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

Issue 2039233005: Consider reloc info mode when merging constant pool entries

Created:
4 years, 6 months ago by Mircea Trofin
Modified:
4 years, 6 months ago
Reviewers:
bradnelson, bradn, rmcilroy
CC:
v8-reviews_googlegroups.com, v8-mips-ports_googlegroups.com, v8-ppc-ports_googlegroups.com
Base URL:
https://chromium.googlesource.com/v8/v8.git@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

This change allows us to have constants that are equal in value but with different relocation modes. For instance, the index of a wasm function and the index of a wasm import - both may be "2", but they mean different things and are relocated differently. Introduced a NONEINTPTR reloc mode. Akin NONE32 and NONE64, this signifies a "no relocation sized intptr". Opportunistically: use standard datastructures for tracking constant pool entries. Compile time is unaffected as shown by both Compile and Wasm benchmarks, while code maintainability is improved. Test to follow in subsequent change. BUG=v8:5072

Patch Set 1 #

Patch Set 2 : #

Patch Set 3 : #

Total comments: 6

Patch Set 4 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+92 lines, -99 lines) Patch
M src/arm/assembler-arm.h View 2 chunks +5 lines, -11 lines 0 comments Download
M src/arm/assembler-arm.cc View 1 2 3 21 chunks +46 lines, -66 lines 0 comments Download
M src/arm/macro-assembler-arm.cc View 1 chunk +2 lines, -2 lines 0 comments Download
M src/assembler.h View 1 2 3 6 chunks +30 lines, -11 lines 0 comments Download
M src/assembler.cc View 1 2 3 7 chunks +9 lines, -9 lines 0 comments Download

Messages

Total messages: 21 (9 generated)
Mircea Trofin
4 years, 6 months ago (2016-06-07 23:53:03 UTC) #3
bradnelson
https://codereview.chromium.org/2039233005/diff/40001/src/assembler.cc File src/assembler.cc (right): https://codereview.chromium.org/2039233005/diff/40001/src/assembler.cc#newcode1937 src/assembler.cc:1937: if ((entry_size == kPointerSize) ? entry.IntValueMayBeMergedWith(*it) It seems strange ...
4 years, 6 months ago (2016-06-08 00:58:32 UTC) #4
Mircea Trofin
https://codereview.chromium.org/2039233005/diff/40001/src/assembler.cc File src/assembler.cc (right): https://codereview.chromium.org/2039233005/diff/40001/src/assembler.cc#newcode1937 src/assembler.cc:1937: if ((entry_size == kPointerSize) ? entry.IntValueMayBeMergedWith(*it) On 2016/06/08 00:58:32, ...
4 years, 6 months ago (2016-06-08 03:32:16 UTC) #6
Mircea Trofin
PTAL - refactored more of the original code.
4 years, 6 months ago (2016-06-08 05:45:07 UTC) #7
bradn
lgtm
4 years, 6 months ago (2016-06-08 05:58:35 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2039233005/60001
4 years, 6 months ago (2016-06-08 05:58:43 UTC) #12
commit-bot: I haz the power
Try jobs failed on following builders: v8_presubmit on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_presubmit/builds/16704)
4 years, 6 months ago (2016-06-08 06:02:23 UTC) #14
Mircea Trofin
+rmcilroy for the arm files.
4 years, 6 months ago (2016-06-08 06:26:41 UTC) #16
rmcilroy
Could you clarify a bit on why you need different reloc types to not be ...
4 years, 6 months ago (2016-06-08 12:38:16 UTC) #17
Mircea Trofin
On 2016/06/08 12:38:16, rmcilroy wrote: > Could you clarify a bit on why you need ...
4 years, 6 months ago (2016-06-08 14:41:07 UTC) #18
rmcilroy
On 2016/06/08 14:41:07, Mircea Trofin wrote: > On 2016/06/08 12:38:16, rmcilroy wrote: > > Could ...
4 years, 6 months ago (2016-06-08 15:11:10 UTC) #19
Mircea Trofin
4 years, 6 months ago (2016-06-08 15:25:34 UTC) #20
On 2016/06/08 15:11:10, rmcilroy wrote:
> On 2016/06/08 14:41:07, Mircea Trofin wrote:
> > On 2016/06/08 12:38:16, rmcilroy wrote:
> > > Could you clarify a bit on why you need different reloc types to not be
> shared
> > > with each other? 
> > > 
> > > Could you just move the WASM reloc types you want to be non-merged into
the
> > > non-sharable RelocInfo types (above CELL)? 
> > 
> > The upcoming reloc types - WASM_IMPORT_CALL, WASM_DIRECT_CALL - are as
> frequent
> > as
> > CODE_TARGETs, so would benefit from merging.
> 
> Just to point out, CODE_TARGETs don't get merged at all, since they might end
up
> getting back-patched to end up pointing at different locations than they start
> pointing at. Just to check, have you identified situations where merging
> WASM_IMPORT_CALL / WASM_DIRECT_CALL substantially reduces the constant pool
size
> (i.e., are there runs of code which refer to the same WASM_DIRECT_CALL
location
> and thus benefit from merging)?

I didn't realize that, about CODE_TARGETs. Re. the other 2, I noticed cases
where merging 
them caused functional defects. In our test corpus, that happened just in a few
larger 
benchmarks. That gives some indication of frequency of occurrence, albeit a bit
skewed,
since most tests we have aren't quite large bodies of code either.

Since I was running on the assumption CODE_TARGETs are merged,  I didn't explore
not 
merging the upcoming relocs. I could do that instead. An argument for moving
forward with 
the CL, though, is that it encapsulates the criteria for merging, making this
sort of exploration 
easier to conduct.

> > > My concern with this change is that
> > > it means we also can't share identical constants of other RelocInfo types
> > which
> > > don't care about the fact they are different (e.g., a POSITION and a
> > > STATEMENT_POSITION) which might end up impacting constant pool size.
> > 
> > We can add to the logic in MayBeMerged to special case these modes. Are
there
> > more
> > than POSITION and STATEMENT_POSITION that can be cross-merged? I assume
those
> > may
> > be just merged with eachother, not, say, with CODE_TARGETs, correct? 
> 
> We currently cross-merge all entries which would never be GCed or back-patched
> (everything below CELL), regardless of their reloc-type (so all those which
have
> sharing_allowed). This isn't a problem since they can happily share the same
> constant pool entry even if they have different relocinfo entries since they
> won't ever change. I'm guessing WASM_IMPORT_CALL, WASM_DIRECT_CALL might get
> moved by the GC so we can't do this?
> 
The WASM entries get patched to become actual call targets. Initially, they only
contain indices
in one of 2 tables: WASM_IMPORT_CALL indexes into the wasm import table, and the
other one in
the wasm function table. So if a function calls both function "2" and import
"2", these will be 
completely different call targets, once we're done patching the code. 
> 
> > > Alternatively, if you still need to share entries within one of these
> > relocinfo
> > > types (and so need the reloc type in the ConstantPoolEntry), could you
also
> > move
> > > the sharing_allowed checks into the ConstantPoolEntry rather than passing
> that
> > > in as a separate argument.
> > Oh, good point, will do.
> > > 
> > > Finally, I would really prefer this as two CLs - one which changes the way
> we
> > > merge reloc info, and the other which uses std:vector instead of an array
-
> > that
> > > way it would be obvious if there is a perf regression on the bots which
> change
> > > is the cause.
> > 
> > Makes sense. Will split them, and make the necessary adjustments discussed
> here.
> > 
> > FWIW, since I was also concerned about the perf impact, note the compile
> > benchmarks 
> > run in Patch Set#1, which is just the std::vector change.

Powered by Google App Engine
This is Rietveld 408576698