Hi, all:
I am a newbie to V8. When I use the following test-case to study the EscapeAnalysis pass in V8, I found that:
===========================test case start===========================
$ cat examp0.js
function f(x) {
var o = new Object();
if (x < 30)
x = x - 5;
else
x = 23;
o.myprop = x;
}
for (var i = 0; i < 1000; ++i) {
f(i);
}
===========================test case end ===========================
I add a HIR dump function like this:
=================================================================
+ void HEscapeAnalysisPhase::dumpCurrentGraph() {
+ HGraph *G = graph();
+ const ZoneList<HBasicBlock*>* blocks = G->blocks();
+ for (int i = 0; i < blocks->length(); i++) {
+ HBasicBlock* current = blocks->at(i);
+ std::cout << "B" << current->block_id() << ":\n";
+ for (HInstructionIterator it(current); !it.Done(); it.Advance()) {
+ HInstruction* instruction = it.Current();
+ std::cout << " " << NameOf(instruction) << " " << *instruction << "\n";
+ }
+ }
+
+ return;
+ }
+
void HEscapeAnalysisPhase::Run() {
// TODO(mstarzinger): We disable escape analysis with OSR for now, because
// spill slots might be uninitialized. Needs investigation.
if (graph()->has_osr()) return;
+ dumpCurrentGraph();
int max_fixpoint_iteration_count = FLAG_escape_analysis_iterations;
...
=================================================================
the results and questions:
1, V8 calls the HEscapeAnalysisPhase::Run() for 4 times.
question? When does v8 call this function?
2, dumpCurrentGraph() corrupt in the fourth call, the error messages are:
=======================================================
$ d8 --use_escape_analysis --trace_escape_analysis examp0.js 1>code.hir
#
# Fatal error in .././src/isolate.h, line 497
# Check failed: isolate != __null.
#
==== C stack trace ===============================
1: V8_Fatal
2: v8::internal::Isolate::Current()
3: v8::internal::HConstant::PrintDataTo(std::ostream&) const
4: v8::internal::HInstruction::PrintTo(std::ostream&) const
5: v8::internal::operator<<(std::ostream&, v8::internal::HValue const&)
6: v8::internal::HEscapeAnalysisPhase::dumpCurrentGraph()
7: v8::internal::HEscapeAnalysisPhase::Run()
8: void v8::internal::HGraph::Run<v8::internal::HEscapeAnalysisPhase>()
9: v8::internal::HGraph::Optimize(v8::internal::BailoutReason*)
10: v8::internal::OptimizedCompileJob::OptimizeGraph()
11: v8::internal::OptimizingCompilerThread::CompileNext(v8::internal::OptimizedCompileJob*)
12: v8::internal::OptimizingCompilerThread::Run()
13: v8::base::Thread::NotifyStartedAndRun()
14: ??
15: ??
16: clone
Illegal instruction (core dumped)
=======================================================
question? wha's the reason?
Thanks for your help. Thanks.