Commit b8f93dfe authored by leszeks's avatar leszeks Committed by Commit bot

[profiler] Log both code and bytecode in heap SFI traversal

The heap traversal for SFI code objects when logging compiled functions
was previously accessing the abstract code of an SFI, logging its
bytecode if it exists or code object otherwise. However, there are some
(rare) cases where an SFI has both bytecode and a non-interpreter code
object -- for example, after baseline tier-up -- in which case we want
to log both, as both could be executing (at different points on the
stack).

BUG=v8:5758

Review-Url: https://codereview.chromium.org/2603333002
Cr-Commit-Position: refs/heads/master@{#42025}
parent 0b10c044
...@@ -1329,6 +1329,17 @@ void Logger::LogFailure() { ...@@ -1329,6 +1329,17 @@ void Logger::LogFailure() {
StopProfiler(); StopProfiler();
} }
static void AddFunctionAndCode(SharedFunctionInfo* sfi,
AbstractCode* code_object,
Handle<SharedFunctionInfo>* sfis,
Handle<AbstractCode>* code_objects, int offset) {
if (sfis != NULL) {
sfis[offset] = Handle<SharedFunctionInfo>(sfi);
}
if (code_objects != NULL) {
code_objects[offset] = Handle<AbstractCode>(code_object);
}
}
class EnumerateOptimizedFunctionsVisitor: public OptimizedFunctionVisitor { class EnumerateOptimizedFunctionsVisitor: public OptimizedFunctionVisitor {
public: public:
...@@ -1345,14 +1356,11 @@ class EnumerateOptimizedFunctionsVisitor: public OptimizedFunctionVisitor { ...@@ -1345,14 +1356,11 @@ class EnumerateOptimizedFunctionsVisitor: public OptimizedFunctionVisitor {
Object* maybe_script = sfi->script(); Object* maybe_script = sfi->script();
if (maybe_script->IsScript() if (maybe_script->IsScript()
&& !Script::cast(maybe_script)->HasValidSource()) return; && !Script::cast(maybe_script)->HasValidSource()) return;
if (sfis_ != NULL) {
sfis_[*count_] = Handle<SharedFunctionInfo>(sfi); DCHECK(function->abstract_code()->kind() ==
} AbstractCode::OPTIMIZED_FUNCTION);
if (code_objects_ != NULL) { AddFunctionAndCode(sfi, function->abstract_code(), sfis_, code_objects_,
DCHECK(function->abstract_code()->kind() == *count_);
AbstractCode::OPTIMIZED_FUNCTION);
code_objects_[*count_] = Handle<AbstractCode>(function->abstract_code());
}
*count_ = *count_ + 1; *count_ = *count_ + 1;
} }
...@@ -1377,14 +1385,19 @@ static int EnumerateCompiledFunctions(Heap* heap, ...@@ -1377,14 +1385,19 @@ static int EnumerateCompiledFunctions(Heap* heap,
if (sfi->is_compiled() if (sfi->is_compiled()
&& (!sfi->script()->IsScript() && (!sfi->script()->IsScript()
|| Script::cast(sfi->script())->HasValidSource())) { || Script::cast(sfi->script())->HasValidSource())) {
if (sfis != NULL) { // In some cases, an SFI might have (and have executing!) both bytecode
sfis[compiled_funcs_count] = Handle<SharedFunctionInfo>(sfi); // and baseline code, so check for both and add them both if needed.
if (sfi->HasBytecodeArray()) {
AddFunctionAndCode(sfi, AbstractCode::cast(sfi->bytecode_array()), sfis,
code_objects, compiled_funcs_count);
++compiled_funcs_count;
} }
if (code_objects != NULL) {
code_objects[compiled_funcs_count] = if (!sfi->IsInterpreted()) {
Handle<AbstractCode>(sfi->abstract_code()); AddFunctionAndCode(sfi, AbstractCode::cast(sfi->code()), sfis,
code_objects, compiled_funcs_count);
++compiled_funcs_count;
} }
++compiled_funcs_count;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment