Commit 8be73bad authored by Mathias Bynens's avatar Mathias Bynens Committed by Commit Bot

[printing] Print feedback vectors

This patch makes `%DebugPrint(fn)` print `fn`’s feedback vector when
available.

Example output:

```
d8> fn = (x) => x + '.'; fn(''); %DebugPrint(fn)
DebugPrint: 0x1c12b950df81: [Function]
 - map = 0x1c12b1802361 [FastProperties]
 - prototype = 0x1c12ec904591
 - elements = 0x1c12f5702241 <FixedArray[0]> [HOLEY_ELEMENTS]
 - initial_map =
 - shared_info = 0x1c12ec92fde9 <SharedFunctionInfo fn>
 - name = 0x1c12ec92fcd1 <String[2]: fn>
 - formal_parameter_count = 1
 - kind = [ ArrowFunction ]
 - context = 0x1c12ec903cd1 <FixedArray[278]>
 - code = 0x220721125061 <Code BUILTIN>
 - interpreted
 - bytecode = 0x1c12ec930181
 - source code = (x) => x + '.'
 - properties = 0x1c12f5702241 <FixedArray[0]> {
    #length: 0x1c12e3095eb1 <AccessorInfo> (const accessor descriptor)
    #name: 0x1c12e3095f21 <AccessorInfo> (const accessor descriptor)
 }

 - feedback vector: 0x1c12ec9301f9: [FeedbackVector] in OldSpace
 - length: 1
 SharedFunctionInfo: 0x1c12ec92fde9 <SharedFunctionInfo fn>
 Optimized Code: 0
 Invocation Count: 1
 Profiler Ticks: 0
 Slot #0 BinaryOp MONOMORPHIC
  [0]: 8
0x1c12b1802361: [Map]
 - type: JS_FUNCTION_TYPE
 - instance size: 72
 - inobject properties: 0
 - elements kind: HOLEY_ELEMENTS
 - unused property fields: 0
 - enum length: invalid
 - callable
 - back pointer: 0x1c12f57022d1 <undefined>
 - instance descriptors (own) #2: 0x1c12ec9048e9 <FixedArray[8]>
 - layout descriptor: 0x0
 - prototype: 0x1c12ec904591 <JSFunction (sfi = 0x1c12f5707c91)>
 - constructor: 0x1c12f5702201 <null>
 - code cache: 0x1c12f5702241 <FixedArray[0]>
 - dependent code: 0x1c12f5702241 <FixedArray[0]>
 - construction counter: 0

(x) => x + '.'
```

Example output when feedback vector is not available:

```
d8> %DebugPrint(() => {})
DebugPrint: 0x1c12b950bf49: [Function]
 - map = 0x1c12b1802361 [FastProperties]
 - prototype = 0x1c12ec904591
 - elements = 0x1c12f5702241 <FixedArray[0]> [HOLEY_ELEMENTS]
 - initial_map =
 - shared_info = 0x1c12ec92c021 <SharedFunctionInfo>
 - name = 0x1c12f5702431 <String[0]: >
 - formal_parameter_count = 0
 - kind = [ ArrowFunction ]
 - context = 0x1c12ec903cd1 <FixedArray[278]>
 - code = 0x220721004861 <Code BUILTIN>
 - source code = () => {}
 - properties = 0x1c12f5702241 <FixedArray[0]> {
    #length: 0x1c12e3095eb1 <AccessorInfo> (const accessor descriptor)
    #name: 0x1c12e3095f21 <AccessorInfo> (const accessor descriptor)
 }

 - feedback vector: not available
0x1c12b1802361: [Map]
 - type: JS_FUNCTION_TYPE
 - instance size: 72
 - inobject properties: 0
 - elements kind: HOLEY_ELEMENTS
 - unused property fields: 0
 - enum length: invalid
 - callable
 - back pointer: 0x1c12f57022d1 <undefined>
 - instance descriptors (own) #2: 0x1c12ec9048e9 <FixedArray[8]>
 - layout descriptor: 0x0
 - prototype: 0x1c12ec904591 <JSFunction (sfi = 0x1c12f5707c91)>
 - constructor: 0x1c12f5702201 <null>
 - code cache: 0x1c12f5702241 <FixedArray[0]>
 - dependent code: 0x1c12f5702241 <FixedArray[0]>
 - construction counter: 0

() => {}
```

Change-Id: Ic80289bff652cfc8d04182c68740843c61c87849
Reviewed-on: https://chromium-review.googlesource.com/591369
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46977}
parent 4229ca20
......@@ -1090,7 +1090,6 @@ void JSFunction::JSFunctionPrint(std::ostream& os) { // NOLINT
<< shared()->internal_formal_parameter_count();
os << "\n - kind = " << shared()->kind();
os << "\n - context = " << Brief(context());
os << "\n - feedback vector cell = " << Brief(feedback_vector_cell());
os << "\n - code = " << Brief(code());
if (IsInterpreted()) {
os << "\n - interpreted";
......@@ -1100,6 +1099,12 @@ void JSFunction::JSFunctionPrint(std::ostream& os) { // NOLINT
}
shared()->PrintSourceCode(os);
JSObjectPrintBody(os, this);
os << "\n - feedback vector: ";
if (feedback_vector_cell()->value()->IsFeedbackVector()) {
feedback_vector()->FeedbackVectorPrint(os);
} else {
os << "not available\n";
}
}
void SharedFunctionInfo::PrintSourceCode(std::ostream& os) {
......
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