On Wed, Jan 9, 2013 at 10:37 PM, <[email protected]> wrote:

> I am attempting to change the chromium in the following manner:
>
>
> I would like to inject some code to the end of each basic block of the AST
> while V8 compiles the javascript code,
>

You're not saying why you want to do this, but here's a problem:
V8 has two compilers. The "full compiler" does not use basic blocks. The
optimizing compiler does have basic blocks, but it's only used for hot
functions.
(Also, for the record, an AST never has basic blocks. It's a tree.)


>
> I want this code the access some data structure I create so I can update
> it about the code that is in that basic block.
>
>
> So during runtime of the code in the basic block my code is being called -
> this code needs to update my data structure .
>
>
> Where do I create my data structure ? I guess that it will be in some file
> in the V8 folder, but I am unsure exactly which file (maybe compiler.cc ?)
> and where in the file ?
>

It doesn't really matter where you put your code (assuming this is just a
one-off experiment). More important is how you initialize the objects and
how you make them accessible to generated code. For an existing example of
something similar, look for ExternalReference in assembler.cc.

Another consideration is if you want your data structures to be created on
demand and garbage collected when the function they belonged to is thrown
away. In that case they'll have to be heap objects and things will look
quite different.

Honestly, the entire idea is mighty complicated for someone who's never
worked on V8 before. It might be worthwhile to look for a simpler solution
to whatever problem you're trying to solve.
Wild guess: you're trying to figure out how often certain lines in your
program are executed (or how often certain branches are taken, which is
essentially the same question). Easy solution: use JavaScript variables as
counters and increment them where appropriate.

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to