Commit cb29f9cd authored by rmcilroy's avatar rmcilroy Committed by Commit bot

[Interpreter] Add support for cpu profiler logging.

Adds support for cpu profiler logging to the interpreter. Modifies the
the API to be passed AbstractCode objects instead of Code objects, and
adds extra functions to AbstractCode which is required by log.cc and
cpu-profiler.cc.

The main change in sampler.cc is to determine if a stack frame is an
interpreter stack frame, and if so, use the bytecode address as the pc
for that frame. This allows sampling of bytecode functions. This
requires adding support to SafeStackIterator to determine if a frame is
interpreted, which we do by checking the PC against pre-stored addresses
for the start and end of interpreter entry builtins.

Also removes CodeDeleteEvents which are dead code and haven't
been reported for some time.

Still to do is tracking source positions which will be done in a
followup CL.

BUG=v8:4766
LOG=N

Review URL: https://codereview.chromium.org/1728593002

Cr-Commit-Position: refs/heads/master@{#34321}
parent 9f4c3e74
......@@ -4427,7 +4427,8 @@ void Builtins::SetUp(Isolate* isolate, bool create_heap_objects) {
isolate->factory()->NewCode(desc, flags, masm.CodeObject());
// Log the event and add the code to the builtins array.
PROFILE(isolate,
CodeCreateEvent(Logger::BUILTIN_TAG, *code, functions[i].s_name));
CodeCreateEvent(Logger::BUILTIN_TAG, AbstractCode::cast(*code),
functions[i].s_name));
builtins_[i] = *code;
code->set_builtin_index(i);
#ifdef ENABLE_DISASSEMBLER
......
......@@ -82,7 +82,8 @@ void CodeStub::RecordCodeGeneration(Handle<Code> code) {
std::ostringstream os;
os << *this;
PROFILE(isolate(),
CodeCreateEvent(Logger::STUB_TAG, *code, os.str().c_str()));
CodeCreateEvent(Logger::STUB_TAG, AbstractCode::cast(*code),
os.str().c_str()));
Counters* counters = isolate()->counters();
counters->total_stubs_code_size()->Increment(code->instruction_size());
#ifdef DEBUG
......
......@@ -717,8 +717,9 @@ static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
if (info->isolate()->logger()->is_logging_code_events() ||
info->isolate()->cpu_profiler()->is_profiling()) {
Handle<Script> script = info->parse_info()->script();
Handle<Code> code = info->code();
if (code.is_identical_to(info->isolate()->builtins()->CompileLazy())) {
Handle<AbstractCode> abstract_code = info->abstract_code();
if (abstract_code.is_identical_to(
info->isolate()->builtins()->CompileLazy())) {
return;
}
int line_num = Script::GetLineNumber(script, shared->start_position()) + 1;
......@@ -729,7 +730,7 @@ static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
: info->isolate()->heap()->empty_string();
Logger::LogEventsAndTags log_tag = Logger::ToNativeByScript(tag, *script);
PROFILE(info->isolate(),
CodeCreateEvent(log_tag, *code, *shared, info, script_name,
CodeCreateEvent(log_tag, *abstract_code, *shared, info, script_name,
line_num, column_num));
}
}
......@@ -824,9 +825,7 @@ MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon(
// Compile either unoptimized code or bytecode for the interpreter.
if (!CompileBaselineCode(info)) return MaybeHandle<Code>();
if (info->code()->kind() == Code::FUNCTION) { // Only for full code.
RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared);
}
RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared);
// Update the shared function info with the scope info. Allocating the
// ScopeInfo object may cause a GC.
......@@ -1329,8 +1328,8 @@ static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
? Logger::EVAL_TAG
: Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script);
PROFILE(isolate, CodeCreateEvent(
log_tag, *info->code(), *result, info, *script_name));
PROFILE(isolate, CodeCreateEvent(log_tag, *info->abstract_code(), *result,
info, *script_name));
// Hint to the runtime system used when allocating space for initial
// property space by setting the expected number of properties for
......
......@@ -116,6 +116,11 @@ class CompilationInfo {
bool has_bytecode_array() const { return !bytecode_array_.is_null(); }
Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; }
Handle<AbstractCode> abstract_code() const {
return has_bytecode_array() ? Handle<AbstractCode>::cast(bytecode_array())
: Handle<AbstractCode>::cast(code());
}
bool is_tracking_positions() const { return track_positions_; }
bool is_calling() const {
......
......@@ -217,7 +217,8 @@ Handle<Code> CodeGenerator::GenerateCode() {
// Emit a code line info recording stop event.
void* line_info = recorder->DetachJITHandlerData();
LOG_CODE_EVENT(isolate(), CodeEndLinePosInfoRecordEvent(*result, line_info));
LOG_CODE_EVENT(isolate(), CodeEndLinePosInfoRecordEvent(
AbstractCode::cast(*result), line_info));
return result;
}
......
......@@ -1982,8 +1982,8 @@ static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
Handle<Code> code = info->code();
Handle<SharedFunctionInfo> shared =
isolate->factory()->NewSharedFunctionInfo(name_str, code, false);
PROFILE(isolate,
CodeCreateEvent(tag, *code, *shared, info, *script_str, 0, 0));
PROFILE(isolate, CodeCreateEvent(tag, AbstractCode::cast(*code), *shared,
info, *script_str, 0, 0));
}
}
......
......@@ -461,7 +461,8 @@ Handle<Code> LChunk::Codegen() {
void* jit_handler_data =
assembler.positions_recorder()->DetachJITHandlerData();
LOG_CODE_EVENT(info()->isolate(),
CodeEndLinePosInfoRecordEvent(*code, jit_handler_data));
CodeEndLinePosInfoRecordEvent(AbstractCode::cast(*code),
jit_handler_data));
CodeGenerator::PrintCode(code, info());
DCHECK(!(info()->isolate()->serializer_enabled() &&
......
......@@ -401,6 +401,17 @@ void StackFrame::SetReturnAddressLocationResolver(
return_address_location_resolver_ = resolver;
}
static bool IsInterpreterFramePc(Isolate* isolate, Address pc) {
Code* interpreter_entry_trampoline =
isolate->builtins()->builtin(Builtins::kInterpreterEntryTrampoline);
Code* interpreter_bytecode_dispatch =
isolate->builtins()->builtin(Builtins::kInterpreterEnterBytecodeDispatch);
return (pc >= interpreter_entry_trampoline->instruction_start() &&
pc < interpreter_entry_trampoline->instruction_end()) ||
(pc >= interpreter_bytecode_dispatch->instruction_start() &&
pc < interpreter_bytecode_dispatch->instruction_end());
}
StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
State* state) {
......@@ -427,6 +438,9 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
Memory::Object_at(state->fp + StandardFrameConstants::kMarkerOffset);
if (marker->IsSmi()) {
return static_cast<StackFrame::Type>(Smi::cast(marker)->value());
} else if (FLAG_ignition && IsInterpreterFramePc(iterator->isolate(),
*(state->pc_address))) {
return INTERPRETED;
} else {
return JAVA_SCRIPT;
}
......
......@@ -67,7 +67,8 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) {
CodeGenerator::PrintCode(code, info);
info->SetCode(code);
void* line_info = masm.positions_recorder()->DetachJITHandlerData();
LOG_CODE_EVENT(isolate, CodeEndLinePosInfoRecordEvent(*code, line_info));
LOG_CODE_EVENT(isolate, CodeEndLinePosInfoRecordEvent(
AbstractCode::cast(*code), line_info));
#ifdef DEBUG
// Check that no context-specific object has been embedded.
......
......@@ -2630,11 +2630,14 @@ void MarkCompactCollector::MigrateObject(HeapObject* dst, HeapObject* src,
DCHECK(IsAligned(size, kPointerSize));
heap()->MoveBlock(dst->address(), src->address(), size);
if (FLAG_ignition && dst->IsBytecodeArray()) {
PROFILE(isolate(), CodeMoveEvent(AbstractCode::cast(src), dst_addr));
}
RecordMigratedSlotVisitor visitor(this, old_to_old_slots, old_to_new_slots);
dst->IterateBody(&visitor);
} else if (dest == CODE_SPACE) {
DCHECK_CODEOBJECT_SIZE(size, heap()->code_space());
PROFILE(isolate(), CodeMoveEvent(src_addr, dst_addr));
PROFILE(isolate(), CodeMoveEvent(AbstractCode::cast(src), dst_addr));
heap()->MoveBlock(dst_addr, src_addr, size);
old_to_old_slots->Record(RELOCATED_CODE_OBJECT, dst_addr);
Code::cast(dst)->Relocate(dst_addr - src_addr);
......@@ -3876,18 +3879,6 @@ void MarkCompactCollector::ParallelSweepSpacesComplete() {
sweeping_list(heap()->map_space()).clear();
}
// TODO(1466) ReportDeleteIfNeeded is not called currently.
// Our profiling tools do not expect intersections between
// code objects. We should either reenable it or change our tools.
void MarkCompactCollector::ReportDeleteIfNeeded(HeapObject* obj,
Isolate* isolate) {
if (obj->IsCode()) {
PROFILE(isolate, CodeDeleteEvent(obj->address()));
}
}
Isolate* MarkCompactCollector::isolate() const { return heap_->isolate(); }
......
......@@ -3102,8 +3102,6 @@ void LargeObjectSpace::FreeUnmarkedObjects() {
}
// Free the chunk.
heap()->mark_compact_collector()->ReportDeleteIfNeeded(object,
heap()->isolate());
size_ -= static_cast<int>(page->size());
AccountUncommitted(static_cast<intptr_t>(page->size()));
objects_size_ -= object->Size();
......
......@@ -81,7 +81,8 @@ Handle<Code> PropertyHandlerCompiler::GetCode(Code::Kind kind,
Handle<Name> name) {
Code::Flags flags = Code::ComputeHandlerFlags(kind, type, cache_holder());
Handle<Code> code = GetCodeWithFlags(flags, name);
PROFILE(isolate(), CodeCreateEvent(Logger::HANDLER_TAG, *code, *name));
PROFILE(isolate(), CodeCreateEvent(Logger::HANDLER_TAG,
AbstractCode::cast(*code), *name));
#ifdef DEBUG
code->VerifyEmbeddedObjects();
#endif
......
......@@ -175,7 +175,8 @@ void PropertyICCompiler::ComputeKeyedStorePolymorphicHandlers(
Handle<Code> PropertyICCompiler::CompileLoadInitialize(Code::Flags flags) {
LoadIC::GenerateInitialize(masm());
Handle<Code> code = GetCodeWithFlags(flags, "CompileLoadInitialize");
PROFILE(isolate(), CodeCreateEvent(Logger::LOAD_INITIALIZE_TAG, *code, 0));
PROFILE(isolate(), CodeCreateEvent(Logger::LOAD_INITIALIZE_TAG,
AbstractCode::cast(*code), 0));
return code;
}
......@@ -183,7 +184,8 @@ Handle<Code> PropertyICCompiler::CompileLoadInitialize(Code::Flags flags) {
Handle<Code> PropertyICCompiler::CompileStoreInitialize(Code::Flags flags) {
StoreIC::GenerateInitialize(masm());
Handle<Code> code = GetCodeWithFlags(flags, "CompileStoreInitialize");
PROFILE(isolate(), CodeCreateEvent(Logger::STORE_INITIALIZE_TAG, *code, 0));
PROFILE(isolate(), CodeCreateEvent(Logger::STORE_INITIALIZE_TAG,
AbstractCode::cast(*code), 0));
return code;
}
......@@ -191,8 +193,8 @@ Handle<Code> PropertyICCompiler::CompileStoreInitialize(Code::Flags flags) {
Handle<Code> PropertyICCompiler::CompileStorePreMonomorphic(Code::Flags flags) {
StoreIC::GeneratePreMonomorphic(masm());
Handle<Code> code = GetCodeWithFlags(flags, "CompileStorePreMonomorphic");
PROFILE(isolate(),
CodeCreateEvent(Logger::STORE_PREMONOMORPHIC_TAG, *code, 0));
PROFILE(isolate(), CodeCreateEvent(Logger::STORE_PREMONOMORPHIC_TAG,
AbstractCode::cast(*code), 0));
return code;
}
......@@ -202,7 +204,8 @@ Handle<Code> PropertyICCompiler::CompileStoreGeneric(Code::Flags flags) {
LanguageMode language_mode = StoreICState::GetLanguageMode(extra_state);
GenerateRuntimeSetProperty(masm(), language_mode);
Handle<Code> code = GetCodeWithFlags(flags, "CompileStoreGeneric");
PROFILE(isolate(), CodeCreateEvent(Logger::STORE_GENERIC_TAG, *code, 0));
PROFILE(isolate(), CodeCreateEvent(Logger::STORE_GENERIC_TAG,
AbstractCode::cast(*code), 0));
return code;
}
......@@ -210,7 +213,8 @@ Handle<Code> PropertyICCompiler::CompileStoreGeneric(Code::Flags flags) {
Handle<Code> PropertyICCompiler::CompileStoreMegamorphic(Code::Flags flags) {
StoreIC::GenerateMegamorphic(masm());
Handle<Code> code = GetCodeWithFlags(flags, "CompileStoreMegamorphic");
PROFILE(isolate(), CodeCreateEvent(Logger::STORE_MEGAMORPHIC_TAG, *code, 0));
PROFILE(isolate(), CodeCreateEvent(Logger::STORE_MEGAMORPHIC_TAG,
AbstractCode::cast(*code), 0));
return code;
}
......@@ -221,7 +225,8 @@ Handle<Code> PropertyICCompiler::GetCode(Code::Kind kind, Code::StubType type,
Code::Flags flags =
Code::ComputeFlags(kind, state, extra_ic_state_, type, cache_holder());
Handle<Code> code = GetCodeWithFlags(flags, name);
PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name));
PROFILE(isolate(),
CodeCreateEvent(log_kind(code), AbstractCode::cast(*code), *name));
#ifdef DEBUG
code->VerifyEmbeddedObjects();
#endif
......
This diff is collapsed.
......@@ -224,30 +224,24 @@ class Logger {
void GetterCallbackEvent(Name* name, Address entry_point);
void SetterCallbackEvent(Name* name, Address entry_point);
// Emits a code create event.
void CodeCreateEvent(LogEventsAndTags tag,
Code* code, const char* source);
void CodeCreateEvent(LogEventsAndTags tag,
Code* code, Name* name);
void CodeCreateEvent(LogEventsAndTags tag,
Code* code,
SharedFunctionInfo* shared,
CompilationInfo* info,
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
const char* source);
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code, Name* name);
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
SharedFunctionInfo* shared, CompilationInfo* info,
Name* name);
void CodeCreateEvent(LogEventsAndTags tag,
Code* code,
SharedFunctionInfo* shared,
CompilationInfo* info,
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
SharedFunctionInfo* shared, CompilationInfo* info,
Name* source, int line, int column);
void CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count);
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
int args_count);
// Emits a code deoptimization event.
void CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared);
void CodeDisableOptEvent(AbstractCode* code, SharedFunctionInfo* shared);
void CodeMovingGCEvent();
// Emits a code create event for a RegExp.
void RegExpCodeCreateEvent(Code* code, String* source);
void RegExpCodeCreateEvent(AbstractCode* code, String* source);
// Emits a code move event.
void CodeMoveEvent(Address from, Address to);
// Emits a code delete event.
void CodeDeleteEvent(Address from);
void CodeMoveEvent(AbstractCode* from, Address to);
// Emits a code line info add event with Postion type.
void CodeLinePosInfoAddPositionEvent(void* jit_handler_data,
int pc_offset,
......@@ -260,7 +254,8 @@ class Logger {
void CodeStartLinePosInfoRecordEvent(PositionsRecorder* pos_recorder);
// Emits a code line info finish record event.
// It's the callee's responsibility to dispose the parameter jit_handler_data.
void CodeEndLinePosInfoRecordEvent(Code* code, void* jit_handler_data);
void CodeEndLinePosInfoRecordEvent(AbstractCode* code,
void* jit_handler_data);
void SharedFunctionInfoMoveEvent(Address from, Address to);
......@@ -316,7 +311,7 @@ class Logger {
void StopProfiler();
void LogExistingFunction(Handle<SharedFunctionInfo> shared,
Handle<Code> code);
Handle<AbstractCode> code);
// Logs all compiled functions found in the heap.
void LogCompiledFunctions();
// Logs all accessor callbacks found in the heap.
......@@ -451,78 +446,61 @@ class CodeEventListener {
public:
virtual ~CodeEventListener() {}
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code,
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
const char* comment) = 0;
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code,
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
Name* name) = 0;
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code,
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
SharedFunctionInfo* shared,
CompilationInfo* info,
Name* name) = 0;
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code,
CompilationInfo* info, Name* name) = 0;
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
SharedFunctionInfo* shared,
CompilationInfo* info,
Name* source,
int line, int column) = 0;
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code,
CompilationInfo* info, Name* source, int line,
int column) = 0;
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
int args_count) = 0;
virtual void CallbackEvent(Name* name, Address entry_point) = 0;
virtual void GetterCallbackEvent(Name* name, Address entry_point) = 0;
virtual void SetterCallbackEvent(Name* name, Address entry_point) = 0;
virtual void RegExpCodeCreateEvent(Code* code, String* source) = 0;
virtual void CodeMoveEvent(Address from, Address to) = 0;
virtual void CodeDeleteEvent(Address from) = 0;
virtual void RegExpCodeCreateEvent(AbstractCode* code, String* source) = 0;
virtual void CodeMoveEvent(AbstractCode* from, Address to) = 0;
virtual void SharedFunctionInfoMoveEvent(Address from, Address to) = 0;
virtual void CodeMovingGCEvent() = 0;
virtual void CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared) = 0;
virtual void CodeDisableOptEvent(AbstractCode* code,
SharedFunctionInfo* shared) = 0;
};
class CodeEventLogger : public CodeEventListener {
public:
CodeEventLogger();
virtual ~CodeEventLogger();
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code,
const char* comment);
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code,
Name* name);
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code,
int args_count);
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code,
SharedFunctionInfo* shared,
CompilationInfo* info,
Name* name);
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code,
SharedFunctionInfo* shared,
CompilationInfo* info,
Name* source,
int line, int column);
virtual void RegExpCodeCreateEvent(Code* code, String* source);
virtual void CallbackEvent(Name* name, Address entry_point) { }
virtual void GetterCallbackEvent(Name* name, Address entry_point) { }
virtual void SetterCallbackEvent(Name* name, Address entry_point) { }
virtual void SharedFunctionInfoMoveEvent(Address from, Address to) { }
virtual void CodeMovingGCEvent() { }
~CodeEventLogger() override;
void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
const char* comment) override;
void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
Name* name) override;
void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
int args_count) override;
void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
SharedFunctionInfo* shared, CompilationInfo* info,
Name* name) override;
void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
SharedFunctionInfo* shared, CompilationInfo* info,
Name* source, int line, int column) override;
void RegExpCodeCreateEvent(AbstractCode* code, String* source) override;
void CallbackEvent(Name* name, Address entry_point) override {}
void GetterCallbackEvent(Name* name, Address entry_point) override {}
void SetterCallbackEvent(Name* name, Address entry_point) override {}
void SharedFunctionInfoMoveEvent(Address from, Address to) override {}
void CodeMovingGCEvent() override {}
private:
class NameBuffer;
virtual void LogRecordedBuffer(Code* code,
SharedFunctionInfo* shared,
const char* name,
int length) = 0;
virtual void LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo* shared,
const char* name, int length) = 0;
NameBuffer* name_buffer_;
};
......
......@@ -5130,7 +5130,7 @@ class Code::FindAndReplacePattern {
friend class Code;
};
int AbstractCode::Size() {
int AbstractCode::instruction_size() {
if (IsCode()) {
return GetCode()->instruction_size();
} else {
......@@ -5138,6 +5138,45 @@ int AbstractCode::Size() {
}
}
int AbstractCode::ExecutableSize() {
if (IsCode()) {
return GetCode()->ExecutableSize();
} else {
return GetBytecodeArray()->BytecodeArraySize();
}
}
Address AbstractCode::instruction_start() {
if (IsCode()) {
return GetCode()->instruction_start();
} else {
return GetBytecodeArray()->GetFirstBytecodeAddress();
}
}
Address AbstractCode::instruction_end() {
if (IsCode()) {
return GetCode()->instruction_end();
} else {
return GetBytecodeArray()->GetFirstBytecodeAddress() +
GetBytecodeArray()->length();
}
}
bool AbstractCode::contains(byte* inner_pointer) {
return (address() <= inner_pointer) && (inner_pointer <= address() + Size());
}
AbstractCode::Kind AbstractCode::kind() {
if (IsCode()) {
STATIC_ASSERT(AbstractCode::FUNCTION ==
static_cast<AbstractCode::Kind>(Code::FUNCTION));
return static_cast<AbstractCode::Kind>(GetCode()->kind());
} else {
return INTERPRETED_FUNCTION;
}
}
Code* AbstractCode::GetCode() { return Code::cast(this); }
BytecodeArray* AbstractCode::GetBytecodeArray() {
......@@ -5629,6 +5668,13 @@ BOOL_GETTER(SharedFunctionInfo,
optimization_disabled,
kOptimizationDisabled)
AbstractCode* SharedFunctionInfo::abstract_code() {
if (HasBytecodeArray()) {
return AbstractCode::cast(bytecode_array());
} else {
return AbstractCode::cast(code());
}
}
void SharedFunctionInfo::set_optimization_disabled(bool disable) {
set_compiler_hints(BooleanBit::set(compiler_hints(),
......@@ -6020,6 +6066,14 @@ void Map::InobjectSlackTrackingStep() {
}
}
AbstractCode* JSFunction::abstract_code() {
Code* code = this->code();
if (code->is_interpreter_entry_trampoline()) {
return AbstractCode::cast(shared()->bytecode_array());
} else {
return AbstractCode::cast(code);
}
}
Code* JSFunction::code() {
return Code::cast(
......
......@@ -13803,8 +13803,10 @@ void SharedFunctionInfo::DisableOptimization(BailoutReason reason) {
set_optimization_disabled(true);
set_disable_optimization_reason(reason);
// Code should be the lazy compilation stub or else unoptimized.
DCHECK(code()->kind() == Code::FUNCTION || code()->kind() == Code::BUILTIN);
PROFILE(GetIsolate(), CodeDisableOptEvent(code(), this));
DCHECK(abstract_code()->kind() == AbstractCode::FUNCTION ||
abstract_code()->kind() == AbstractCode::INTERPRETED_FUNCTION ||
abstract_code()->kind() == AbstractCode::BUILTIN);
PROFILE(GetIsolate(), CodeDisableOptEvent(abstract_code(), this));
if (FLAG_trace_opt) {
PrintF("[disabled optimization for ");
ShortPrint();
......
......@@ -5404,11 +5404,37 @@ class Code: public HeapObject {
class AbstractCode : public HeapObject {
public:
// All code kinds and INTERPRETED_FUNCTION.
enum Kind {
#define DEFINE_CODE_KIND_ENUM(name) name,
CODE_KIND_LIST(DEFINE_CODE_KIND_ENUM)
#undef DEFINE_CODE_KIND_ENUM
INTERPRETED_FUNCTION,
};
int SourcePosition(int offset);
int SourceStatementPosition(int offset);
// Returns the address of the first instruction.
inline Address instruction_start();
// Returns the address right after the last instruction.
inline Address instruction_end();
// Returns the of the code instructions.
inline int instruction_size();
// Returns true if pc is inside this object's instructions.
inline bool contains(byte* pc);
// Returns the AbstractCode::Kind of the code.
inline Kind kind();
// Calculate the size of the code object to report for log events. This takes
// the layout of the code object into account.
inline int ExecutableSize();
DECLARE_CAST(AbstractCode)
inline int Size();
inline Code* GetCode();
inline BytecodeArray* GetBytecodeArray();
};
......@@ -6606,6 +6632,10 @@ class SharedFunctionInfo: public HeapObject {
// [code]: Function code.
DECL_ACCESSORS(code, Code)
// Get the abstract code associated with the function, which will either be
// a Code object or a BytecodeArray.
inline AbstractCode* abstract_code();
inline void ReplaceCode(Code* code);
// [optimized_code_map]: Map from native context to optimized code
......@@ -7442,6 +7472,10 @@ class JSFunction: public JSObject {
inline void set_code_no_write_barrier(Code* code);
inline void ReplaceCode(Code* code);
// Get the abstract code associated with the function, which will either be
// a Code object or a BytecodeArray.
inline AbstractCode* abstract_code();
// Tells whether this function inlines the given shared function info.
bool Inlines(SharedFunctionInfo* candidate);
......
......@@ -211,10 +211,8 @@ void CpuProfiler::CallbackEvent(Name* name, Address entry_point) {
processor_->Enqueue(evt_rec);
}
void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code,
const char* name) {
AbstractCode* code, const char* name) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->start = code->address();
......@@ -226,10 +224,8 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
processor_->Enqueue(evt_rec);
}
void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code,
Name* name) {
AbstractCode* code, Name* name) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->start = code->address();
......@@ -241,8 +237,8 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
processor_->Enqueue(evt_rec);
}
void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code,
void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
AbstractCode* code,
SharedFunctionInfo* shared,
CompilationInfo* info, Name* script_name) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
......@@ -261,46 +257,51 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code,
processor_->Enqueue(evt_rec);
}
void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code,
void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
AbstractCode* abstract_code,
SharedFunctionInfo* shared,
CompilationInfo* info, Name* script_name,
int line, int column) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->start = code->address();
rec->start = abstract_code->address();
Script* script = Script::cast(shared->script());
JITLineInfoTable* line_table = NULL;
if (script) {
line_table = new JITLineInfoTable();
for (RelocIterator it(code); !it.done(); it.next()) {
RelocInfo::Mode mode = it.rinfo()->rmode();
if (RelocInfo::IsPosition(mode)) {
int position = static_cast<int>(it.rinfo()->data());
if (position >= 0) {
int pc_offset = static_cast<int>(it.rinfo()->pc() - code->address());
int line_number = script->GetLineNumber(position) + 1;
line_table->SetPosition(pc_offset, line_number);
if (abstract_code->IsCode()) {
Code* code = abstract_code->GetCode();
line_table = new JITLineInfoTable();
for (RelocIterator it(code); !it.done(); it.next()) {
RelocInfo::Mode mode = it.rinfo()->rmode();
if (RelocInfo::IsPosition(mode)) {
int position = static_cast<int>(it.rinfo()->data());
if (position >= 0) {
int pc_offset =
static_cast<int>(it.rinfo()->pc() - code->address());
int line_number = script->GetLineNumber(position) + 1;
line_table->SetPosition(pc_offset, line_number);
}
}
}
} else {
DCHECK(abstract_code->IsBytecodeArray());
// TODO(rmcilroy): source position tracking for bytecode arrays.
}
}
rec->entry = profiles_->NewCodeEntry(
tag, profiles_->GetFunctionName(shared->DebugName()),
CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name), line,
column, line_table, code->instruction_start());
column, line_table, abstract_code->instruction_start());
if (info) {
rec->entry->set_inlined_function_infos(info->inlined_function_infos());
}
rec->entry->FillFunctionInfo(shared);
rec->size = code->ExecutableSize();
rec->size = abstract_code->ExecutableSize();
processor_->Enqueue(evt_rec);
}
void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code,
int args_count) {
AbstractCode* code, int args_count) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->start = code->address();
......@@ -312,17 +313,16 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
processor_->Enqueue(evt_rec);
}
void CpuProfiler::CodeMoveEvent(Address from, Address to) {
void CpuProfiler::CodeMoveEvent(AbstractCode* from, Address to) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_MOVE);
CodeMoveEventRecord* rec = &evt_rec.CodeMoveEventRecord_;
rec->from = from;
rec->from = from->address();
rec->to = to;
processor_->Enqueue(evt_rec);
}
void CpuProfiler::CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared) {
void CpuProfiler::CodeDisableOptEvent(AbstractCode* code,
SharedFunctionInfo* shared) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_DISABLE_OPT);
CodeDisableOptEventRecord* rec = &evt_rec.CodeDisableOptEventRecord_;
rec->start = code->address();
......@@ -330,7 +330,6 @@ void CpuProfiler::CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared) {
processor_->Enqueue(evt_rec);
}
void CpuProfiler::CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_DEOPT);
CodeDeoptEventRecord* rec = &evt_rec.CodeDeoptEventRecord_;
......@@ -343,11 +342,6 @@ void CpuProfiler::CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta) {
processor_->AddDeoptStack(isolate_, pc, fp_to_sp_delta);
}
void CpuProfiler::CodeDeleteEvent(Address from) {
}
void CpuProfiler::GetterCallbackEvent(Name* name, Address entry_point) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
......@@ -360,8 +354,7 @@ void CpuProfiler::GetterCallbackEvent(Name* name, Address entry_point) {
processor_->Enqueue(evt_rec);
}
void CpuProfiler::RegExpCodeCreateEvent(Code* code, String* source) {
void CpuProfiler::RegExpCodeCreateEvent(AbstractCode* code, String* source) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->start = code->address();
......
......@@ -201,7 +201,7 @@ class CpuProfiler : public CodeEventListener {
ProfileGenerator* test_generator,
ProfilerEventsProcessor* test_processor);
virtual ~CpuProfiler();
~CpuProfiler() override;
void set_sampling_interval(base::TimeDelta value);
void CollectSample();
......@@ -220,29 +220,28 @@ class CpuProfiler : public CodeEventListener {
// Must be called via PROFILE macro, otherwise will crash when
// profiling is not enabled.
virtual void CallbackEvent(Name* name, Address entry_point);
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code, const char* comment);
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code, Name* name);
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code,
SharedFunctionInfo* shared,
CompilationInfo* info, Name* script_name);
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code,
SharedFunctionInfo* shared,
CompilationInfo* info, Name* script_name,
int line, int column);
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code, int args_count);
virtual void CodeMovingGCEvent() {}
virtual void CodeMoveEvent(Address from, Address to);
virtual void CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared);
virtual void CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta);
virtual void CodeDeleteEvent(Address from);
virtual void GetterCallbackEvent(Name* name, Address entry_point);
virtual void RegExpCodeCreateEvent(Code* code, String* source);
virtual void SetterCallbackEvent(Name* name, Address entry_point);
virtual void SharedFunctionInfoMoveEvent(Address from, Address to) {}
void CallbackEvent(Name* name, Address entry_point) override;
void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
const char* comment) override;
void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
Name* name) override;
void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
SharedFunctionInfo* shared, CompilationInfo* info,
Name* script_name) override;
void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
SharedFunctionInfo* shared, CompilationInfo* info,
Name* script_name, int line, int column) override;
void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
int args_count) override;
void CodeMovingGCEvent() override {}
void CodeMoveEvent(AbstractCode* from, Address to) override;
void CodeDisableOptEvent(AbstractCode* code,
SharedFunctionInfo* shared) override;
void CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta);
void GetterCallbackEvent(Name* name, Address entry_point) override;
void RegExpCodeCreateEvent(AbstractCode* code, String* source) override;
void SetterCallbackEvent(Name* name, Address entry_point) override;
void SharedFunctionInfoMoveEvent(Address from, Address to) override {}
INLINE(bool is_profiling() const) { return is_profiling_; }
bool* is_profiling_address() {
......
......@@ -604,6 +604,7 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
// Find out, if top of stack was pointing inside a JS function
// meaning that we have encountered a frameless invocation.
if (!pc_entry && (sample.top_frame_type == StackFrame::JAVA_SCRIPT ||
sample.top_frame_type == StackFrame::INTERPRETED ||
sample.top_frame_type == StackFrame::OPTIMIZED)) {
pc_entry = code_map_.FindEntry(sample.tos);
}
......
......@@ -731,7 +731,18 @@ void TickSample::GetStackSample(Isolate* isolate, const v8::RegisterState& regs,
frames[i++] = isolate->c_function();
}
while (!it.done() && i < frames_limit) {
frames[i++] = it.frame()->pc();
if (it.frame()->is_interpreted()) {
// For interpreted frames use the bytecode array pointer as the pc.
InterpretedFrame* frame = static_cast<InterpretedFrame*>(it.frame());
// Since the sampler can interrupt execution at any point the
// bytecode_array might be garbage, so don't dereference it.
Address bytecode_array =
reinterpret_cast<Address>(frame->GetBytecodeArray()) - kHeapObjectTag;
frames[i++] = bytecode_array + BytecodeArray::kHeaderSize +
frame->GetBytecodeOffset();
} else {
frames[i++] = it.frame()->pc();
}
it.Advance();
}
sample_info->frames_count = i;
......
......@@ -891,7 +891,8 @@ Handle<HeapObject> RegExpMacroAssemblerARM::GetCode(Handle<String> source) {
masm_->GetCode(&code_desc);
Handle<Code> code = isolate()->factory()->NewCode(
code_desc, Code::ComputeFlags(Code::REGEXP), masm_->CodeObject());
PROFILE(masm_->isolate(), RegExpCodeCreateEvent(*code, *source));
PROFILE(masm_->isolate(),
RegExpCodeCreateEvent(AbstractCode::cast(*code), *source));
return Handle<HeapObject>::cast(code);
}
......
......@@ -1088,7 +1088,8 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) {
masm_->GetCode(&code_desc);
Handle<Code> code = isolate()->factory()->NewCode(
code_desc, Code::ComputeFlags(Code::REGEXP), masm_->CodeObject());
PROFILE(masm_->isolate(), RegExpCodeCreateEvent(*code, *source));
PROFILE(masm_->isolate(),
RegExpCodeCreateEvent(AbstractCode::cast(*code), *source));
return Handle<HeapObject>::cast(code);
}
......
......@@ -936,7 +936,8 @@ Handle<HeapObject> RegExpMacroAssemblerIA32::GetCode(Handle<String> source) {
isolate()->factory()->NewCode(code_desc,
Code::ComputeFlags(Code::REGEXP),
masm_->CodeObject());
PROFILE(isolate(), RegExpCodeCreateEvent(*code, *source));
PROFILE(masm_->isolate(),
RegExpCodeCreateEvent(AbstractCode::cast(*code), *source));
return Handle<HeapObject>::cast(code);
}
......
......@@ -905,7 +905,8 @@ Handle<HeapObject> RegExpMacroAssemblerMIPS::GetCode(Handle<String> source) {
masm_->GetCode(&code_desc);
Handle<Code> code = isolate()->factory()->NewCode(
code_desc, Code::ComputeFlags(Code::REGEXP), masm_->CodeObject());
LOG(masm_->isolate(), RegExpCodeCreateEvent(*code, *source));
LOG(masm_->isolate(),
RegExpCodeCreateEvent(AbstractCode::cast(*code), *source));
return Handle<HeapObject>::cast(code);
}
......
......@@ -942,7 +942,8 @@ Handle<HeapObject> RegExpMacroAssemblerMIPS::GetCode(Handle<String> source) {
masm_->GetCode(&code_desc);
Handle<Code> code = isolate()->factory()->NewCode(
code_desc, Code::ComputeFlags(Code::REGEXP), masm_->CodeObject());
LOG(masm_->isolate(), RegExpCodeCreateEvent(*code, *source));
LOG(masm_->isolate(),
RegExpCodeCreateEvent(AbstractCode::cast(*code), *source));
return Handle<HeapObject>::cast(code);
}
......
......@@ -940,7 +940,8 @@ Handle<HeapObject> RegExpMacroAssemblerPPC::GetCode(Handle<String> source) {
masm_->GetCode(&code_desc);
Handle<Code> code = isolate()->factory()->NewCode(
code_desc, Code::ComputeFlags(Code::REGEXP), masm_->CodeObject());
PROFILE(masm_->isolate(), RegExpCodeCreateEvent(*code, *source));
PROFILE(masm_->isolate(),
RegExpCodeCreateEvent(AbstractCode::cast(*code), *source));
return Handle<HeapObject>::cast(code);
}
......
......@@ -1008,7 +1008,7 @@ Handle<HeapObject> RegExpMacroAssemblerX64::GetCode(Handle<String> source) {
Handle<Code> code = isolate->factory()->NewCode(
code_desc, Code::ComputeFlags(Code::REGEXP),
masm_.CodeObject());
PROFILE(isolate, RegExpCodeCreateEvent(*code, *source));
PROFILE(isolate, RegExpCodeCreateEvent(AbstractCode::cast(*code), *source));
return Handle<HeapObject>::cast(code);
}
......
......@@ -935,7 +935,8 @@ Handle<HeapObject> RegExpMacroAssemblerX87::GetCode(Handle<String> source) {
isolate()->factory()->NewCode(code_desc,
Code::ComputeFlags(Code::REGEXP),
masm_->CodeObject());
PROFILE(isolate(), RegExpCodeCreateEvent(*code, *source));
PROFILE(masm_->isolate(),
RegExpCodeCreateEvent(AbstractCode::cast(*code), *source));
return Handle<HeapObject>::cast(code);
}
......
......@@ -204,8 +204,8 @@ RUNTIME_FUNCTION(Runtime_SetCode) {
if (isolate->logger()->is_logging_code_events() ||
isolate->cpu_profiler()->is_profiling()) {
isolate->logger()->LogExistingFunction(source_shared,
Handle<Code>(source_shared->code()));
isolate->logger()->LogExistingFunction(
source_shared, Handle<AbstractCode>(source_shared->abstract_code()));
}
return *target;
......
......@@ -387,15 +387,12 @@ class CodeAddressMap: public CodeEventLogger {
isolate_->logger()->removeCodeEventListener(this);
}
void CodeMoveEvent(Address from, Address to) override {
address_to_name_map_.Move(from, to);
void CodeMoveEvent(AbstractCode* from, Address to) override {
address_to_name_map_.Move(from->address(), to);
}
void CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared) override {}
void CodeDeleteEvent(Address from) override {
address_to_name_map_.Remove(from);
}
void CodeDisableOptEvent(AbstractCode* code,
SharedFunctionInfo* shared) override {}
const char* Lookup(Address address) {
return address_to_name_map_.Lookup(address);
......@@ -473,8 +470,8 @@ class CodeAddressMap: public CodeEventLogger {
DISALLOW_COPY_AND_ASSIGN(NameMap);
};
void LogRecordedBuffer(Code* code, SharedFunctionInfo*, const char* name,
int length) override {
void LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo*,
const char* name, int length) override {
address_to_name_map_.Insert(code->address(), name, length);
}
......@@ -2635,7 +2632,8 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
Script* script = Script::cast(result->script());
if (script->name()->IsString()) name = String::cast(script->name());
}
isolate->logger()->CodeCreateEvent(Logger::SCRIPT_TAG, result->code(),
isolate->logger()->CodeCreateEvent(Logger::SCRIPT_TAG,
AbstractCode::cast(result->code()),
*result, NULL, name);
}
return scope.CloseAndEscape(result);
......
......@@ -527,9 +527,6 @@
'test-debug/StepInOutBranch': [FAIL],
'test-debug/DebugStepFunctionCall': [FAIL],
# TODO(yangguo,4690): Required DebuggerStatement support.
'test-profile-generator/BailoutReason': [FAIL],
# TODO(rmcilroy,4680): Check failed: toplevel_test_code_event_found.
'test-serialize/SerializeToplevelIsolates': [FAIL],
......@@ -561,33 +558,9 @@
'test-api/TryCatchMixedNesting': [FAIL],
# TODO(rmcilroy,4680): Test assert errors.
'test-cpu-profiler/CodeEvents': [FAIL],
'test-cpu-profiler/TickEvents': [FAIL],
'test-cpu-profiler/BoundFunctionCall': [FAIL],
'test-cpu-profiler/CollectCpuProfile': [FAIL],
'test-cpu-profiler/CollectSampleAPI': [FAIL],
'test-cpu-profiler/CpuProfileDeepStack': [FAIL],
'test-cpu-profiler/FunctionApplySample': [FAIL],
'test-cpu-profiler/FunctionCallSample': [FAIL],
'test-cpu-profiler/FunctionDetails': [FAIL],
'test-cpu-profiler/HotDeoptNoFrameEntry': [FAIL],
'test-cpu-profiler/JsNative1JsNative2JsSample': [FAIL],
'test-cpu-profiler/JsNativeJsRuntimeJsSample': [FAIL],
'test-cpu-profiler/JsNativeJsRuntimeJsSampleMultiple': [FAIL],
'test-cpu-profiler/JsNativeJsSample': [FAIL],
'test-cpu-profiler/NativeMethodUninitializedIC': [FAIL],
'test-cpu-profiler/NativeMethodMonomorphicIC': [FAIL],
'test-cpu-profiler/NativeAccessorUninitializedIC': [FAIL],
'test-cpu-profiler/NativeAccessorMonomorphicIC': [FAIL],
'test-cpu-profiler/SampleWhenFrameIsNotSetup': [FAIL],
'test-sampler-api/StackFramesConsistent': [FAIL],
'test-profile-generator/LineNumber': [FAIL],
'test-profile-generator/ProfileNodeScriptId': [FAIL],
'test-profile-generator/RecordStackTraceAtStartProfiling': [FAIL],
'test-feedback-vector/VectorCallICStates': [FAIL],
'test-compiler/FeedbackVectorPreservedAcrossRecompiles': [FAIL],
'test-api/PromiseRejectCallback': [FAIL],
'test-api/SetJitCodeEventHandler': [FAIL],
'test-heap/WeakFunctionInConstructor': [FAIL],
'test-heap/Regress169209': [FAIL],
'test-heap/IncrementalMarkingClearsMonomorphicConstructor': [FAIL],
......
......@@ -119,8 +119,7 @@ class TestSetup {
} // namespace
i::Code* CreateCode(LocalContext* env) {
i::AbstractCode* CreateCode(LocalContext* env) {
static int counter = 0;
i::EmbeddedVector<char, 256> script;
i::EmbeddedVector<char, 32> name;
......@@ -138,10 +137,9 @@ i::Code* CreateCode(LocalContext* env) {
i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(
v8::Utils::OpenHandle(*GetFunction(env->local(), name_start)));
return fun->code();
return fun->abstract_code();
}
TEST(CodeEvents) {
CcTest::InitializeVM();
LocalContext env;
......@@ -151,13 +149,13 @@ TEST(CodeEvents) {
i::HandleScope scope(isolate);
i::Code* aaa_code = CreateCode(&env);
i::Code* comment_code = CreateCode(&env);
i::Code* args5_code = CreateCode(&env);
i::Code* comment2_code = CreateCode(&env);
i::Code* moved_code = CreateCode(&env);
i::Code* args3_code = CreateCode(&env);
i::Code* args4_code = CreateCode(&env);
i::AbstractCode* aaa_code = CreateCode(&env);
i::AbstractCode* comment_code = CreateCode(&env);
i::AbstractCode* args5_code = CreateCode(&env);
i::AbstractCode* comment2_code = CreateCode(&env);
i::AbstractCode* moved_code = CreateCode(&env);
i::AbstractCode* args3_code = CreateCode(&env);
i::AbstractCode* args4_code = CreateCode(&env);
CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap());
profiles->StartProfiling("", false);
......@@ -174,7 +172,7 @@ TEST(CodeEvents) {
profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment_code, "comment");
profiler.CodeCreateEvent(i::Logger::STUB_TAG, args5_code, 5);
profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment2_code, "comment2");
profiler.CodeMoveEvent(comment2_code->address(), moved_code->address());
profiler.CodeMoveEvent(comment2_code, moved_code->address());
profiler.CodeCreateEvent(i::Logger::STUB_TAG, args3_code, 3);
profiler.CodeCreateEvent(i::Logger::STUB_TAG, args4_code, 4);
......@@ -203,22 +201,20 @@ TEST(CodeEvents) {
CHECK_EQ(0, strcmp("comment2", comment2->name()));
}
template<typename T>
static int CompareProfileNodes(const T* p1, const T* p2) {
return strcmp((*p1)->entry()->name(), (*p2)->entry()->name());
}
TEST(TickEvents) {
TestSetup test_setup;
LocalContext env;
i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope scope(isolate);
i::Code* frame1_code = CreateCode(&env);
i::Code* frame2_code = CreateCode(&env);
i::Code* frame3_code = CreateCode(&env);
i::AbstractCode* frame1_code = CreateCode(&env);
i::AbstractCode* frame2_code = CreateCode(&env);
i::AbstractCode* frame3_code = CreateCode(&env);
CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap());
profiles->StartProfiling("", false);
......@@ -265,7 +261,6 @@ TEST(TickEvents) {
CHECK_EQ(0, top_down_ddd_children->length());
}
// http://crbug/51594
// This test must not crash.
TEST(CrashIfStoppingLastNonExistentProfile) {
......@@ -278,7 +273,6 @@ TEST(CrashIfStoppingLastNonExistentProfile) {
profiler->StopProfiling("");
}
// http://code.google.com/p/v8/issues/detail?id=1398
// Long stacks (exceeding max frames limit) must not be erased.
TEST(Issue1398) {
......@@ -287,7 +281,7 @@ TEST(Issue1398) {
i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope scope(isolate);
i::Code* code = CreateCode(&env);
i::AbstractCode* code = CreateCode(&env);
CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap());
profiles->StartProfiling("", false);
......@@ -322,7 +316,6 @@ TEST(Issue1398) {
CHECK_EQ(1 + i::TickSample::kMaxFramesCount, actual_depth); // +1 for PC.
}
TEST(DeleteAllCpuProfiles) {
CcTest::InitializeVM();
TestSetup test_setup;
......@@ -1020,13 +1013,14 @@ TEST(TickLines) {
i::Handle<i::JSFunction> func = i::Handle<i::JSFunction>::cast(
v8::Utils::OpenHandle(*GetFunction(env.local(), func_name)));
CHECK(func->shared());
CHECK(func->shared()->code());
i::Code* code = NULL;
if (func->code()->is_optimized_code()) {
code = func->code();
CHECK(func->shared()->abstract_code());
i::AbstractCode* code = NULL;
if (func->abstract_code()->kind() == i::AbstractCode::OPTIMIZED_FUNCTION) {
code = func->abstract_code();
} else {
CHECK(func->shared()->code() == func->code() || !i::FLAG_crankshaft);
code = func->shared()->code();
CHECK(func->shared()->abstract_code() == func->abstract_code() ||
!i::FLAG_crankshaft);
code = func->shared()->abstract_code();
}
CHECK(code);
i::Address code_address = code->instruction_start();
......
......@@ -57,7 +57,7 @@ using v8::internal::TickSample;
static bool IsAddressWithinFuncCode(JSFunction* function, Address addr) {
i::Code* code = function->code();
i::AbstractCode* code = function->abstract_code();
return code->contains(addr);
}
......
......@@ -553,14 +553,13 @@ TEST(LogVersion) {
TEST(Issue539892) {
class : public i::CodeEventLogger {
public:
virtual void CodeMoveEvent(Address from, Address to) {}
virtual void CodeDeleteEvent(Address from) {}
virtual void CodeDisableOptEvent(i::Code* code,
i::SharedFunctionInfo* shared) {}
void CodeMoveEvent(i::AbstractCode* from, Address to) override {}
void CodeDisableOptEvent(i::AbstractCode* code,
i::SharedFunctionInfo* shared) override {}
private:
virtual void LogRecordedBuffer(i::Code* code, i::SharedFunctionInfo* shared,
const char* name, int length) {}
void LogRecordedBuffer(i::AbstractCode* code, i::SharedFunctionInfo* shared,
const char* name, int length) override {}
} code_event_logger;
SETUP_FLAGS();
v8::Isolate::CreateParams create_params;
......
......@@ -649,7 +649,7 @@ int GetFunctionLineNumber(LocalContext* env, const char* name) {
->Get(v8::Isolate::GetCurrent()->GetCurrentContext(),
v8_str(name))
.ToLocalChecked())));
CodeEntry* func_entry = code_map->FindEntry(func->code()->address());
CodeEntry* func_entry = code_map->FindEntry(func->abstract_code()->address());
if (!func_entry)
FATAL(name);
return func_entry->line_number();
......
......@@ -365,7 +365,6 @@ class LogReader(object):
_CODE_CREATE_TAG = "C"
_CODE_MOVE_TAG = "M"
_CODE_DELETE_TAG = "D"
_SNAPSHOT_POSITION_TAG = "P"
_CODE_MOVING_GC_TAG = "G"
......@@ -459,19 +458,6 @@ class LogReader(object):
self.code_map.Add(code)
continue
if tag == LogReader._CODE_DELETE_TAG:
event = self.code_delete_struct.from_buffer(self.log, self.log_pos)
self.log_pos += ctypes.sizeof(event)
old_start_address = event.address
code = self.code_map.Find(old_start_address)
if not code:
print >>sys.stderr, "Warning: Not found %x" % old_start_address
continue
assert code.start_address == old_start_address, \
"Inexact delete address %x for %s" % (old_start_address, code)
self.code_map.Remove(code)
continue
if tag == LogReader._SNAPSHOT_POSITION_TAG:
event = self.snapshot_position_struct.from_buffer(self.log,
self.log_pos)
......
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