Look at the existing flags FLAG_print_opt_code and FLAG_print_bytecode, their implementations should help you figure out how to do this.
On Fri, Jun 2, 2017 at 8:07 AM, Yuan Pinghai <pinghaiy...@gmail.com> wrote: > I want to dump each piece of dynamically generated code. Meanwhile, if its > corresponding bytecode is available, I also dump the bytecode and record > the starting line number of the script code (i.e. recording the script name > and the line number). For this purpose, i inserted code snippets in > functions which would invoke "factory->NewCode". The following code is what > i inserted into "CodeGenerator::GenerateCode()". However, my code can > only successfully dump jit'ed code, but cannot dump bytecodes and record > the script information. How can I solve this problem? Thanks! > > Bye the way, i am working on Version 6.0.99, the latest commit is > 71c1795aea7573672dd264568357c0f49afc7321. > > --- a/src/compiler/code-generator.cc > +++ b/src/compiler/code-generator.cc > @@ -256,7 +256,34 @@ Handle<Code> CodeGenerator::GenerateCode() { > if (info->ShouldEnsureSpaceForLazyDeopt()) { > Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(result); > } > - > + //dump_jit_code(code, info); > + > + byte* nvstart = code->instruction_start(); > + //code->instruction_size(); > + int nvlen = code->body_size(); > + > + int type = 0; > + if (code->is_crankshafted()) > + type += (1 << 0); > + if (code->is_turbofanned()) > + type += (1 << 1); > + > + printf("%p, %i, %i \n", nvstart, nvlen, type); > + > + std::unique_ptr<char[]> debug_name = info->GetDebugName(); > + OFStream os(stdout); > + os << debug_name.get()<< std::endl; > + > + if (info->has_bytecode_array()){ > + Handle<BytecodeArray> bytecodes = info->bytecode_array(); > + bytecodes->Print(os); > + } > + > + Handle<Script> jsscript = info->GetScript(); > + std::unique_ptr<char[]> jsscript_name jsscript->name(); > + ByteArray ba = code->source_position_table(); > + script->GetLineNumber(ba[0]); > + > + > return result; > } > > -- > -- > v8-users mailing list > v8-users@googlegroups.com > http://groups.google.com/group/v8-users > --- > You received this message because you are subscribed to the Google Groups > "v8-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to v8-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.