crosswalk-project/v8-crosswalk — pull request #38 by dp7 (2014-06-06 04:09:11+00:00)
Title: CDT CPU profiler: source info support

The idea behind of this new solution is to use the existing "relocation info" instead of consumption the CodeLinePosition events emitted by the V8 compilers.
During generation code and relocation info are generated simultaneously. When code generation is done you each code object has associated "relocation info". Relocation information lets V8 mark interesting places in the generated code: pointers that might need to be relocated (after garbage collection), correspondences between the machine program counter and source locations for stack walking.
This patch:
1. Add more source positions info in reloc info to make it suitable for source level mapping. The amount of data should not increase dramatically because (1) V8 already marks interesting places in the generated code and (2) V8 does not write redundant information (it writes a pair (pc_offset, pos) only if pos is changed and skip other)
2. When a sample happen, CPU profiler find a code object by pc, then use it reloc info to match the sample to a source line. If a source line is found that hit counter for this line is increased by one.
3. Add a new public V8 API to get the hit source lines by CDT CPU profiler. It's expected a minor patch in Blink to pack the source level info in JSON.
4. Add a test to check how the samples are distributed through source lines.