Commit 433cd531 authored by cbruni's avatar cbruni Committed by Commit bot

[tools] Support more map information in --trace-ic and ic-explorer.html

BUG=

Review-Url: https://codereview.chromium.org/2451173002
Cr-Commit-Position: refs/heads/master@{#40611}
parent c4d770b1
......@@ -4,6 +4,8 @@
#include "src/ic/ic.h"
#include <iostream>
#include "src/accessors.h"
#include "src/api-arguments-inl.h"
#include "src/api.h"
......@@ -99,45 +101,51 @@ void IC::TraceIC(const char* type, Handle<Object> name) {
void IC::TraceIC(const char* type, Handle<Object> name, State old_state,
State new_state) {
if (FLAG_trace_ic) {
PrintF("[%s%s in ", is_keyed() ? "Keyed" : "", type);
// TODO(jkummerow): Add support for "apply". The logic is roughly:
// marker = [fp_ + kMarkerOffset];
// if marker is smi and marker.value == INTERNAL and
// the frame's code == builtin(Builtins::kFunctionApply):
// then print "apply from" and advance one frame
Object* maybe_function =
Memory::Object_at(fp_ + JavaScriptFrameConstants::kFunctionOffset);
if (maybe_function->IsJSFunction()) {
JSFunction* function = JSFunction::cast(maybe_function);
int code_offset = 0;
if (function->code()->is_interpreter_trampoline_builtin()) {
code_offset = InterpretedFrame::GetBytecodeOffset(fp());
} else {
code_offset =
static_cast<int>(pc() - function->code()->instruction_start());
}
JavaScriptFrame::PrintFunctionAndOffset(
function, function->abstract_code(), code_offset, stdout, true);
}
const char* modifier = "";
if (kind() == Code::KEYED_STORE_IC) {
KeyedAccessStoreMode mode =
casted_nexus<KeyedStoreICNexus>()->GetKeyedAccessStoreMode();
modifier = GetTransitionMarkModifier(mode);
}
void* map = nullptr;
if (!receiver_map().is_null()) {
map = reinterpret_cast<void*>(*receiver_map());
if (!FLAG_trace_ic) return;
PrintF("[%s%s in ", is_keyed() ? "Keyed" : "", type);
// TODO(jkummerow): Add support for "apply". The logic is roughly:
// marker = [fp_ + kMarkerOffset];
// if marker is smi and marker.value == INTERNAL and
// the frame's code == builtin(Builtins::kFunctionApply):
// then print "apply from" and advance one frame
Object* maybe_function =
Memory::Object_at(fp_ + JavaScriptFrameConstants::kFunctionOffset);
if (maybe_function->IsJSFunction()) {
JSFunction* function = JSFunction::cast(maybe_function);
int code_offset = 0;
if (function->code()->is_interpreter_trampoline_builtin()) {
code_offset = InterpretedFrame::GetBytecodeOffset(fp());
} else {
code_offset =
static_cast<int>(pc() - function->code()->instruction_start());
}
PrintF(" (%c->%c%s) map=%p ", TransitionMarkFromState(old_state),
TransitionMarkFromState(new_state), modifier, map);
name->ShortPrint(stdout);
PrintF("]\n");
}
JavaScriptFrame::PrintFunctionAndOffset(function, function->abstract_code(),
code_offset, stdout, true);
}
const char* modifier = "";
if (kind() == Code::KEYED_STORE_IC) {
KeyedAccessStoreMode mode =
casted_nexus<KeyedStoreICNexus>()->GetKeyedAccessStoreMode();
modifier = GetTransitionMarkModifier(mode);
}
Map* map = nullptr;
if (!receiver_map().is_null()) {
map = *receiver_map();
}
PrintF(" (%c->%c%s) map=(%p", TransitionMarkFromState(old_state),
TransitionMarkFromState(new_state), modifier,
reinterpret_cast<void*>(map));
if (map != nullptr) {
PrintF(" dict=%u own=%u type=", map->is_dictionary_map(),
map->NumberOfOwnDescriptors());
std::cout << map->instance_type();
}
PrintF(") ");
name->ShortPrint(stdout);
PrintF("]\n");
}
......
......@@ -40,6 +40,11 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
"use strict"
var entries = [];
var properties = ['type', 'category', 'file', 'filePosition', 'state',
'key', 'isNative', 'map', 'propertiesMode', 'numberOfOwnProperties',
'instanceType'
]
class Entry {
constructor(id, line) {
this.id = id;
......@@ -50,8 +55,11 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
if (parts[0][0] !== "[") return;
if (parts[1] === "patching") return;
this.type = parts[0].substr(1);
this.category = "Other";
this.map = undefined;
this.category = "unknown";
this.map = "unknown";
this.propertiesMode = "unknown";
this.numberOfOwnProperties = 0;
this.instanceType = "unknown";
if (this.type.indexOf("Store") !== -1) {
this.category = "Store";
} else if (this.type.indexOf("Load") !== -1) {
......@@ -70,13 +78,22 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
var offset = this.parsePositionAndFile(parts, 2);
if (offset == -1) return
this.state = parts[++offset];
this.map = parts[offset + 1];
if (this.map !== undefined && this.map.startsWith("map=")) {
this.map = this.map.substring(4);
offset++;
} else {
this.map = undefined;
}
var mapPart = parts[offset + 1];
if (mapPart !== undefined && mapPart.startsWith("map=")) {
if (mapPart[4] == "(") {
if (mapPart.endsWith(")")) {
this.map = mapPart.substr(5, mapPart.length-6);
} else {
this.map = mapPart.substr(5);
}
offset++;
offset = this.parseMapProperties(parts, offset);
} else {
this.map = mapPart.substr(4);
offset++;
}
if (this.map == "(nil)") this.map = "unknown";
}
if (this.type !== "CompareIC") {
// if there is no address we have a smi key
var address = parts[++offset];
......@@ -108,6 +125,17 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
this.isValid = true;
}
parseMapProperties(parts, offset) {
var next = parts[++offset];
if (!next.startsWith('dict')) return offset;
this.propertiesMode =
next.substr(5) == "0" ? "fast" : "slow";
this.numberOfOwnProperties = parts[++offset].substr(4);
next = parts[++offset];
this.instanceType = next.substr(5, next.length-6);
return offset;
}
parsePositionAndFile(parts, start) {
// find the position of 'at' in the parts array.
var offset = start;
......@@ -157,11 +185,6 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
}
var properties = ['type', 'category', 'file', 'filePosition', 'state',
'key', 'isNative', 'map'
]
class Group {
constructor(property, key, entry) {
this.property = property;
......@@ -332,10 +355,14 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
select.add(option);
}
}
function handleOnLoad() {
document.querySelector("#uploadInput").focus();
}
</script>
</head>
<body>
<body onload="handleOnLoad()">
<h1>
<span style="color: #00FF00">I</span>
<span style="color: #FF00FF">C</span>
......
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