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;
}