Commit 2485f005 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[log] Move IC::GetAbstractPC to the isolate

This is in preparation for the new --trace-maps feature which will also log the
current PC.

Change-Id: I20f60c8a1e0104d4497460bafab623840a129f41
Reviewed-on: https://chromium-review.googlesource.com/734463Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48851}
parent eff39bbb
......@@ -71,36 +71,6 @@ void IC::TraceIC(const char* type, Handle<Object> name) {
}
}
Address IC::GetAbstractPC(int* line, int* column) const {
JavaScriptFrameIterator it(isolate());
JavaScriptFrame* frame = it.frame();
DCHECK(!frame->is_builtin());
int position = frame->position();
Object* maybe_script = frame->function()->shared()->script();
if (maybe_script->IsScript()) {
Handle<Script> script(Script::cast(maybe_script), isolate());
Script::PositionInfo info;
Script::GetPositionInfo(script, position, &info, Script::WITH_OFFSET);
*line = info.line + 1;
*column = info.column + 1;
} else {
*line = position;
*column = -1;
}
if (frame->is_interpreted()) {
InterpretedFrame* iframe = static_cast<InterpretedFrame*>(frame);
Address bytecode_start =
reinterpret_cast<Address>(iframe->GetBytecodeArray()) - kHeapObjectTag +
BytecodeArray::kHeaderSize;
return bytecode_start + iframe->GetBytecodeOffset();
}
return frame->pc();
}
void IC::TraceIC(const char* type, Handle<Object> name, State old_state,
State new_state) {
if (V8_LIKELY(!FLAG_ic_stats)) return;
......@@ -119,10 +89,7 @@ void IC::TraceIC(const char* type, Handle<Object> name, State old_state,
if (!(FLAG_ic_stats &
v8::tracing::TracingCategoryObserver::ENABLED_BY_TRACING)) {
int line;
int column;
Address pc = GetAbstractPC(&line, &column);
LOG(isolate(), ICEvent(type, is_keyed(), pc, line, column, map, *name,
LOG(isolate(), ICEvent(type, is_keyed(), map, *name,
TransitionMarkFromState(old_state),
TransitionMarkFromState(new_state), modifier,
slow_stub_reason_));
......
......@@ -72,7 +72,6 @@ class IC {
void set_slow_stub_reason(const char* reason) { slow_stub_reason_ = reason; }
Address GetAbstractPC(int* line, int* column) const;
Isolate* isolate() const { return isolate_; }
// Get the caller function object.
......
......@@ -656,6 +656,35 @@ Handle<FixedArray> Isolate::GetDetailedStackTrace(
return Handle<FixedArray>();
}
Address Isolate::GetAbstractPC(int* line, int* column) {
JavaScriptFrameIterator it(this);
JavaScriptFrame* frame = it.frame();
DCHECK(!frame->is_builtin());
int position = frame->position();
Object* maybe_script = frame->function()->shared()->script();
if (maybe_script->IsScript()) {
Handle<Script> script(Script::cast(maybe_script), this);
Script::PositionInfo info;
Script::GetPositionInfo(script, position, &info, Script::WITH_OFFSET);
*line = info.line + 1;
*column = info.column + 1;
} else {
*line = position;
*column = -1;
}
if (frame->is_interpreted()) {
InterpretedFrame* iframe = static_cast<InterpretedFrame*>(frame);
Address bytecode_start =
reinterpret_cast<Address>(iframe->GetBytecodeArray()) - kHeapObjectTag +
BytecodeArray::kHeaderSize;
return bytecode_start + iframe->GetBytecodeOffset();
}
return frame->pc();
}
class CaptureStackTraceHelper {
public:
......
......@@ -751,6 +751,8 @@ class Isolate {
Handle<Object> caller);
Handle<FixedArray> GetDetailedStackTrace(Handle<JSObject> error_object);
Address GetAbstractPC(int* line, int* column);
// Returns if the given context may access the given global object. If
// the result is false, the pending exception is guaranteed to be
// set.
......
......@@ -1330,14 +1330,16 @@ void Logger::TickEvent(v8::TickSample* sample, bool overflow) {
msg.WriteToLogFile();
}
void Logger::ICEvent(const char* type, bool keyed, const Address pc, int line,
int column, Map* map, Object* key, char old_state,
char new_state, const char* modifier,
void Logger::ICEvent(const char* type, bool keyed, Map* map, Object* key,
char old_state, char new_state, const char* modifier,
const char* slow_stub_reason) {
if (!log_->IsEnabled() || !FLAG_trace_ic) return;
Log::MessageBuilder msg(log_);
if (keyed) msg << "Keyed";
msg << type << kNext;
int line;
int column;
Address pc = isolate_->GetAbstractPC(&line, &column);
msg.AppendAddress(pc);
msg << kNext << line << kNext << column << kNext << old_state << kNext
<< new_state << kNext << reinterpret_cast<void*>(map) << kNext;
......
......@@ -191,9 +191,8 @@ class Logger : public CodeEventListener {
void CodeDeoptEvent(Code* code, DeoptKind kind, Address pc,
int fp_to_sp_delta);
void ICEvent(const char* type, bool keyed, const Address pc, int line,
int column, Map* map, Object* key, char old_state,
char new_state, const char* modifier,
void ICEvent(const char* type, bool keyed, Map* map, Object* key,
char old_state, char new_state, const char* modifier,
const char* slow_stub_reason);
// ==== Events logged by --log-gc. ====
......
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