Upgrade V8 to 5.1.281.57 DO NOT MERGE
FPIIM-449
Change-Id: Id981b686b4d587ac31697662eb98bb34be42ad90
(cherry picked from commit 3b9bc31999c9787eb726ecdbfd5796bfdec32a18)
diff --git a/src/log.cc b/src/log.cc
index cbdd9dd..93111a2 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -13,9 +13,12 @@
#include "src/code-stubs.h"
#include "src/deoptimizer.h"
#include "src/global-handles.h"
+#include "src/interpreter/bytecodes.h"
+#include "src/interpreter/interpreter.h"
#include "src/log-inl.h"
#include "src/log-utils.h"
#include "src/macro-assembler.h"
+#include "src/perf-jit.h"
#include "src/profiler/cpu-profiler.h"
#include "src/runtime-profiler.h"
#include "src/string-stream.h"
@@ -45,11 +48,13 @@
} \
} while (false);
-static const char* ComputeMarker(SharedFunctionInfo* shared, Code* code) {
+static const char* ComputeMarker(SharedFunctionInfo* shared,
+ AbstractCode* code) {
switch (code->kind()) {
- case Code::FUNCTION:
+ case AbstractCode::FUNCTION:
+ case AbstractCode::INTERPRETED_FUNCTION:
return shared->optimization_disabled() ? "" : "~";
- case Code::OPTIMIZED_FUNCTION:
+ case AbstractCode::OPTIMIZED_FUNCTION:
return "*";
default:
return "";
@@ -159,42 +164,35 @@
CodeEventLogger::~CodeEventLogger() { delete name_buffer_; }
-
void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag,
- Code* code,
- const char* comment) {
+ AbstractCode* code, const char* comment) {
name_buffer_->Init(tag);
name_buffer_->AppendBytes(comment);
LogRecordedBuffer(code, NULL, name_buffer_->get(), name_buffer_->size());
}
-
void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag,
- Code* code,
- Name* name) {
+ AbstractCode* code, Name* name) {
name_buffer_->Init(tag);
name_buffer_->AppendName(name);
LogRecordedBuffer(code, NULL, name_buffer_->get(), name_buffer_->size());
}
-
void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag,
- Code* code,
+ AbstractCode* code,
SharedFunctionInfo* shared,
- CompilationInfo* info,
- Name* name) {
+ CompilationInfo* info, Name* name) {
name_buffer_->Init(tag);
name_buffer_->AppendBytes(ComputeMarker(shared, code));
name_buffer_->AppendName(name);
LogRecordedBuffer(code, shared, name_buffer_->get(), name_buffer_->size());
}
-
void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag,
- Code* code,
+ AbstractCode* code,
SharedFunctionInfo* shared,
- CompilationInfo* info,
- Name* source, int line, int column) {
+ CompilationInfo* info, Name* source,
+ int line, int column) {
name_buffer_->Init(tag);
name_buffer_->AppendBytes(ComputeMarker(shared, code));
name_buffer_->AppendString(shared->DebugName());
@@ -211,17 +209,15 @@
LogRecordedBuffer(code, shared, name_buffer_->get(), name_buffer_->size());
}
-
void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag,
- Code* code,
- int args_count) {
+ AbstractCode* code, int args_count) {
name_buffer_->Init(tag);
name_buffer_->AppendInt(args_count);
LogRecordedBuffer(code, NULL, name_buffer_->get(), name_buffer_->size());
}
-
-void CodeEventLogger::RegExpCodeCreateEvent(Code* code, String* source) {
+void CodeEventLogger::RegExpCodeCreateEvent(AbstractCode* code,
+ String* source) {
name_buffer_->Init(Logger::REG_EXP_TAG);
name_buffer_->AppendString(source);
LogRecordedBuffer(code, NULL, name_buffer_->get(), name_buffer_->size());
@@ -232,17 +228,15 @@
class PerfBasicLogger : public CodeEventLogger {
public:
PerfBasicLogger();
- virtual ~PerfBasicLogger();
+ ~PerfBasicLogger() override;
- virtual void CodeMoveEvent(Address from, Address to) { }
- virtual void CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared) { }
- virtual void CodeDeleteEvent(Address from) { }
+ void CodeMoveEvent(AbstractCode* from, Address to) override {}
+ void CodeDisableOptEvent(AbstractCode* code,
+ SharedFunctionInfo* shared) override {}
private:
- virtual void LogRecordedBuffer(Code* code,
- SharedFunctionInfo* shared,
- const char* name,
- int length);
+ void LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo* shared,
+ const char* name, int length) override;
// Extension added to V8 log file name to get the low-level log name.
static const char kFilenameFormatString[];
@@ -281,16 +275,12 @@
perf_output_handle_ = NULL;
}
-
-void PerfBasicLogger::LogRecordedBuffer(Code* code,
- SharedFunctionInfo*,
- const char* name,
- int length) {
- DCHECK(code->instruction_start() == code->address() + Code::kHeaderSize);
-
+void PerfBasicLogger::LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo*,
+ const char* name, int length) {
if (FLAG_perf_basic_prof_only_functions &&
- (code->kind() != Code::FUNCTION &&
- code->kind() != Code::OPTIMIZED_FUNCTION)) {
+ (code->kind() != AbstractCode::FUNCTION &&
+ code->kind() != AbstractCode::INTERPRETED_FUNCTION &&
+ code->kind() != AbstractCode::OPTIMIZED_FUNCTION)) {
return;
}
@@ -306,19 +296,17 @@
class LowLevelLogger : public CodeEventLogger {
public:
explicit LowLevelLogger(const char* file_name);
- virtual ~LowLevelLogger();
+ ~LowLevelLogger() override;
- virtual void CodeMoveEvent(Address from, Address to);
- virtual void CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared) { }
- virtual void CodeDeleteEvent(Address from);
- virtual void SnapshotPositionEvent(Address addr, int pos);
- virtual void CodeMovingGCEvent();
+ void CodeMoveEvent(AbstractCode* from, Address to) override;
+ void CodeDisableOptEvent(AbstractCode* code,
+ SharedFunctionInfo* shared) override {}
+ void SnapshotPositionEvent(HeapObject* obj, int pos);
+ void CodeMovingGCEvent() override;
private:
- virtual void LogRecordedBuffer(Code* code,
- SharedFunctionInfo* shared,
- const char* name,
- int length);
+ void LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo* shared,
+ const char* name, int length) override;
// Low-level profiling event structures.
struct CodeCreateStruct {
@@ -338,21 +326,6 @@
};
- struct CodeDeleteStruct {
- static const char kTag = 'D';
-
- Address address;
- };
-
-
- struct SnapshotPositionStruct {
- static const char kTag = 'P';
-
- Address address;
- int32_t position;
- };
-
-
static const char kCodeMovingGCTag = 'G';
@@ -416,21 +389,19 @@
const char arch[] = "x87";
#elif V8_TARGET_ARCH_ARM64
const char arch[] = "arm64";
+#elif V8_TARGET_ARCH_S390
+ const char arch[] = "s390";
#else
const char arch[] = "unknown";
#endif
LogWriteBytes(arch, sizeof(arch));
}
-
-void LowLevelLogger::LogRecordedBuffer(Code* code,
- SharedFunctionInfo*,
- const char* name,
- int length) {
+void LowLevelLogger::LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo*,
+ const char* name, int length) {
CodeCreateStruct event;
event.name_size = length;
event.code_address = code->instruction_start();
- DCHECK(event.code_address == code->address() + Code::kHeaderSize);
event.code_size = code->instruction_size();
LogWriteStruct(event);
LogWriteBytes(name, length);
@@ -439,26 +410,11 @@
code->instruction_size());
}
-
-void LowLevelLogger::CodeMoveEvent(Address from, Address to) {
+void LowLevelLogger::CodeMoveEvent(AbstractCode* from, Address to) {
CodeMoveStruct event;
- event.from_address = from + Code::kHeaderSize;
- event.to_address = to + Code::kHeaderSize;
- LogWriteStruct(event);
-}
-
-
-void LowLevelLogger::CodeDeleteEvent(Address from) {
- CodeDeleteStruct event;
- event.address = from + Code::kHeaderSize;
- LogWriteStruct(event);
-}
-
-
-void LowLevelLogger::SnapshotPositionEvent(Address addr, int pos) {
- SnapshotPositionStruct event;
- event.address = addr + Code::kHeaderSize;
- event.position = pos;
+ event.from_address = from->instruction_start();
+ size_t header_size = from->instruction_start() - from->address();
+ event.to_address = to + header_size;
LogWriteStruct(event);
}
@@ -484,23 +440,19 @@
public:
explicit JitLogger(JitCodeEventHandler code_event_handler);
- virtual void CodeMoveEvent(Address from, Address to);
- virtual void CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared) { }
- virtual void CodeDeleteEvent(Address from);
- virtual void AddCodeLinePosInfoEvent(
- void* jit_handler_data,
- int pc_offset,
- int position,
- JitCodeEvent::PositionType position_type);
+ void CodeMoveEvent(AbstractCode* from, Address to) override;
+ void CodeDisableOptEvent(AbstractCode* code,
+ SharedFunctionInfo* shared) override {}
+ void AddCodeLinePosInfoEvent(void* jit_handler_data, int pc_offset,
+ int position,
+ JitCodeEvent::PositionType position_type);
void* StartCodePosInfoEvent();
- void EndCodePosInfoEvent(Code* code, void* jit_handler_data);
+ void EndCodePosInfoEvent(AbstractCode* code, void* jit_handler_data);
private:
- virtual void LogRecordedBuffer(Code* code,
- SharedFunctionInfo* shared,
- const char* name,
- int length);
+ void LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo* shared,
+ const char* name, int length) override;
JitCodeEventHandler code_event_handler_;
base::Mutex logger_mutex_;
@@ -511,10 +463,8 @@
: code_event_handler_(code_event_handler) {
}
-
-void JitLogger::LogRecordedBuffer(Code* code,
- SharedFunctionInfo* shared,
- const char* name,
+void JitLogger::LogRecordedBuffer(AbstractCode* code,
+ SharedFunctionInfo* shared, const char* name,
int length) {
JitCodeEvent event;
memset(&event, 0, sizeof(event));
@@ -531,35 +481,19 @@
code_event_handler_(&event);
}
-
-void JitLogger::CodeMoveEvent(Address from, Address to) {
+void JitLogger::CodeMoveEvent(AbstractCode* from, Address to) {
base::LockGuard<base::Mutex> guard(&logger_mutex_);
- Code* from_code = Code::cast(HeapObject::FromAddress(from));
JitCodeEvent event;
event.type = JitCodeEvent::CODE_MOVED;
- event.code_start = from_code->instruction_start();
- event.code_len = from_code->instruction_size();
+ event.code_start = from->instruction_start();
+ event.code_len = from->instruction_size();
// Calculate the header size.
- const size_t header_size =
- from_code->instruction_start() - reinterpret_cast<byte*>(from_code);
+ const size_t header_size = from->instruction_start() - from->address();
// Calculate the new start address of the instructions.
- event.new_code_start =
- reinterpret_cast<byte*>(HeapObject::FromAddress(to)) + header_size;
-
- code_event_handler_(&event);
-}
-
-
-void JitLogger::CodeDeleteEvent(Address from) {
- Code* from_code = Code::cast(HeapObject::FromAddress(from));
-
- JitCodeEvent event;
- event.type = JitCodeEvent::CODE_REMOVED;
- event.code_start = from_code->instruction_start();
- event.code_len = from_code->instruction_size();
+ event.new_code_start = to + header_size;
code_event_handler_(&event);
}
@@ -590,8 +524,8 @@
return event.user_data;
}
-
-void JitLogger::EndCodePosInfoEvent(Code* code, void* jit_handler_data) {
+void JitLogger::EndCodePosInfoEvent(AbstractCode* code,
+ void* jit_handler_data) {
JitCodeEvent event;
memset(&event, 0, sizeof(event));
event.type = JitCodeEvent::CODE_END_LINE_INFO_RECORDING;
@@ -778,19 +712,18 @@
//
Logger::Logger(Isolate* isolate)
- : isolate_(isolate),
- ticker_(NULL),
- profiler_(NULL),
- log_events_(NULL),
- is_logging_(false),
- log_(new Log(this)),
- perf_basic_logger_(NULL),
- ll_logger_(NULL),
- jit_logger_(NULL),
- listeners_(5),
- is_initialized_(false) {
-}
-
+ : isolate_(isolate),
+ ticker_(NULL),
+ profiler_(NULL),
+ log_events_(NULL),
+ is_logging_(false),
+ log_(new Log(this)),
+ perf_basic_logger_(NULL),
+ perf_jit_logger_(NULL),
+ ll_logger_(NULL),
+ jit_logger_(NULL),
+ listeners_(5),
+ is_initialized_(false) {}
Logger::~Logger() {
delete log_;
@@ -934,7 +867,6 @@
void Logger::EnterExternal(Isolate* isolate) {
LOG(isolate, TimerEvent(START, TimerEventExternal::name()));
- TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("v8"), "V8.External");
DCHECK(isolate->current_vm_state() == JS);
isolate->set_current_vm_state(EXTERNAL);
}
@@ -942,7 +874,6 @@
void Logger::LeaveExternal(Isolate* isolate) {
LOG(isolate, TimerEvent(END, TimerEventExternal::name()));
- TRACE_EVENT_END0(TRACE_DISABLED_BY_DEFAULT("v8"), "V8.External");
DCHECK(isolate->current_vm_state() == EXTERNAL);
isolate->set_current_vm_state(JS);
}
@@ -971,7 +902,7 @@
// (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"")
Handle<Object> source =
- Object::GetProperty(isolate, regexp, "source").ToHandleChecked();
+ JSReceiver::GetProperty(isolate, regexp, "source").ToHandleChecked();
if (!source->IsString()) {
msg->Append("no source");
return;
@@ -990,19 +921,19 @@
// global flag
Handle<Object> global =
- Object::GetProperty(isolate, regexp, "global").ToHandleChecked();
+ JSReceiver::GetProperty(isolate, regexp, "global").ToHandleChecked();
if (global->IsTrue()) {
msg->Append('g');
}
// ignorecase flag
Handle<Object> ignorecase =
- Object::GetProperty(isolate, regexp, "ignoreCase").ToHandleChecked();
+ JSReceiver::GetProperty(isolate, regexp, "ignoreCase").ToHandleChecked();
if (ignorecase->IsTrue()) {
msg->Append('i');
}
// multiline flag
Handle<Object> multiline =
- Object::GetProperty(isolate, regexp, "multiline").ToHandleChecked();
+ JSReceiver::GetProperty(isolate, regexp, "multiline").ToHandleChecked();
if (multiline->IsTrue()) {
msg->Append('m');
}
@@ -1136,10 +1067,9 @@
CallbackEventInternal("set ", name, entry_point);
}
-
static void AppendCodeCreateHeader(Log::MessageBuilder* msg,
Logger::LogEventsAndTags tag,
- Code* code) {
+ AbstractCode* code) {
DCHECK(msg);
msg->Append("%s,%s,%d,",
kLogEventsNames[Logger::CODE_CREATION_EVENT],
@@ -1149,9 +1079,7 @@
msg->Append(",%d,", code->ExecutableSize());
}
-
-void Logger::CodeCreateEvent(LogEventsAndTags tag,
- Code* code,
+void Logger::CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
const char* comment) {
PROFILER_LOG(CodeCreateEvent(tag, code, comment));
@@ -1165,9 +1093,7 @@
msg.WriteToLogFile();
}
-
-void Logger::CodeCreateEvent(LogEventsAndTags tag,
- Code* code,
+void Logger::CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
Name* name) {
PROFILER_LOG(CodeCreateEvent(tag, code, name));
@@ -1187,11 +1113,8 @@
msg.WriteToLogFile();
}
-
-void Logger::CodeCreateEvent(LogEventsAndTags tag,
- Code* code,
- SharedFunctionInfo* shared,
- CompilationInfo* info,
+void Logger::CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
+ SharedFunctionInfo* shared, CompilationInfo* info,
Name* name) {
PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, name));
@@ -1199,7 +1122,10 @@
CALL_LISTENERS(CodeCreateEvent(tag, code, shared, info, name));
if (!FLAG_log_code || !log_->IsEnabled()) return;
- if (code == isolate_->builtins()->builtin(Builtins::kCompileLazy)) return;
+ if (code == AbstractCode::cast(
+ isolate_->builtins()->builtin(Builtins::kCompileLazy))) {
+ return;
+ }
Log::MessageBuilder msg(log_);
AppendCodeCreateHeader(&msg, tag, code);
@@ -1220,10 +1146,8 @@
// Although, it is possible to extract source and line from
// the SharedFunctionInfo object, we left it to caller
// to leave logging functions free from heap allocations.
-void Logger::CodeCreateEvent(LogEventsAndTags tag,
- Code* code,
- SharedFunctionInfo* shared,
- CompilationInfo* info,
+void Logger::CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
+ SharedFunctionInfo* shared, CompilationInfo* info,
Name* source, int line, int column) {
PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, source, line, column));
@@ -1250,9 +1174,7 @@
msg.WriteToLogFile();
}
-
-void Logger::CodeCreateEvent(LogEventsAndTags tag,
- Code* code,
+void Logger::CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
int args_count) {
PROFILER_LOG(CodeCreateEvent(tag, code, args_count));
@@ -1266,8 +1188,7 @@
msg.WriteToLogFile();
}
-
-void Logger::CodeDisableOptEvent(Code* code,
+void Logger::CodeDisableOptEvent(AbstractCode* code,
SharedFunctionInfo* shared) {
PROFILER_LOG(CodeDisableOptEvent(code, shared));
@@ -1294,8 +1215,7 @@
base::OS::SignalCodeMovingGC();
}
-
-void Logger::RegExpCodeCreateEvent(Code* code, String* source) {
+void Logger::RegExpCodeCreateEvent(AbstractCode* code, String* source) {
PROFILER_LOG(RegExpCodeCreateEvent(code, source));
if (!is_logging_code_events()) return;
@@ -1310,33 +1230,16 @@
msg.WriteToLogFile();
}
-
-void Logger::CodeMoveEvent(Address from, Address to) {
+void Logger::CodeMoveEvent(AbstractCode* from, Address to) {
PROFILER_LOG(CodeMoveEvent(from, to));
if (!is_logging_code_events()) return;
CALL_LISTENERS(CodeMoveEvent(from, to));
- MoveEventInternal(CODE_MOVE_EVENT, from, to);
+ MoveEventInternal(CODE_MOVE_EVENT, from->address(), to);
}
-
-void Logger::CodeDeleteEvent(Address from) {
- PROFILER_LOG(CodeDeleteEvent(from));
-
- if (!is_logging_code_events()) return;
- CALL_LISTENERS(CodeDeleteEvent(from));
-
- if (!FLAG_log_code || !log_->IsEnabled()) return;
- Log::MessageBuilder msg(log_);
- msg.Append("%s,", kLogEventsNames[CODE_DELETE_EVENT]);
- msg.AppendAddress(from);
- msg.WriteToLogFile();
-}
-
-
void Logger::CodeLinePosInfoAddPositionEvent(void* jit_handler_data,
- int pc_offset,
- int position) {
+ int pc_offset, int position) {
JIT_LOG(AddCodeLinePosInfoEvent(jit_handler_data,
pc_offset,
position,
@@ -1360,8 +1263,7 @@
}
}
-
-void Logger::CodeEndLinePosInfoRecordEvent(Code* code,
+void Logger::CodeEndLinePosInfoRecordEvent(AbstractCode* code,
void* jit_handler_data) {
JIT_LOG(EndCodePosInfoEvent(code, jit_handler_data));
}
@@ -1376,18 +1278,6 @@
}
-void Logger::SnapshotPositionEvent(Address addr, int pos) {
- if (!log_->IsEnabled()) return;
- LL_LOG(SnapshotPositionEvent(addr, pos));
- if (!FLAG_log_snapshot_positions) return;
- Log::MessageBuilder msg(log_);
- msg.Append("%s,", kLogEventsNames[SNAPSHOT_POSITION_EVENT]);
- msg.AppendAddress(addr);
- msg.Append(",%d", pos);
- msg.WriteToLogFile();
-}
-
-
void Logger::SharedFunctionInfoMoveEvent(Address from, Address to) {
if (!is_logging_code_events()) return;
MoveEventInternal(SHARED_FUNC_MOVE_EVENT, from, to);
@@ -1535,9 +1425,9 @@
class EnumerateOptimizedFunctionsVisitor: public OptimizedFunctionVisitor {
public:
EnumerateOptimizedFunctionsVisitor(Handle<SharedFunctionInfo>* sfis,
- Handle<Code>* code_objects,
+ Handle<AbstractCode>* code_objects,
int* count)
- : sfis_(sfis), code_objects_(code_objects), count_(count) { }
+ : sfis_(sfis), code_objects_(code_objects), count_(count) {}
virtual void EnterContext(Context* context) {}
virtual void LeaveContext(Context* context) {}
@@ -1551,22 +1441,22 @@
sfis_[*count_] = Handle<SharedFunctionInfo>(sfi);
}
if (code_objects_ != NULL) {
- DCHECK(function->code()->kind() == Code::OPTIMIZED_FUNCTION);
- code_objects_[*count_] = Handle<Code>(function->code());
+ DCHECK(function->abstract_code()->kind() ==
+ AbstractCode::OPTIMIZED_FUNCTION);
+ code_objects_[*count_] = Handle<AbstractCode>(function->abstract_code());
}
*count_ = *count_ + 1;
}
private:
Handle<SharedFunctionInfo>* sfis_;
- Handle<Code>* code_objects_;
+ Handle<AbstractCode>* code_objects_;
int* count_;
};
-
static int EnumerateCompiledFunctions(Heap* heap,
Handle<SharedFunctionInfo>* sfis,
- Handle<Code>* code_objects) {
+ Handle<AbstractCode>* code_objects) {
HeapIterator iterator(heap);
DisallowHeapAllocation no_gc;
int compiled_funcs_count = 0;
@@ -1583,7 +1473,8 @@
sfis[compiled_funcs_count] = Handle<SharedFunctionInfo>(sfi);
}
if (code_objects != NULL) {
- code_objects[compiled_funcs_count] = Handle<Code>(sfi->code());
+ code_objects[compiled_funcs_count] =
+ Handle<AbstractCode>(sfi->abstract_code());
}
++compiled_funcs_count;
}
@@ -1600,60 +1491,71 @@
void Logger::LogCodeObject(Object* object) {
- Code* code_object = Code::cast(object);
+ AbstractCode* code_object = AbstractCode::cast(object);
LogEventsAndTags tag = Logger::STUB_TAG;
const char* description = "Unknown code from the snapshot";
switch (code_object->kind()) {
- case Code::FUNCTION:
- case Code::OPTIMIZED_FUNCTION:
+ case AbstractCode::FUNCTION:
+ case AbstractCode::INTERPRETED_FUNCTION:
+ case AbstractCode::OPTIMIZED_FUNCTION:
return; // We log this later using LogCompiledFunctions.
- case Code::BINARY_OP_IC:
- case Code::COMPARE_IC: // fall through
- case Code::COMPARE_NIL_IC: // fall through
- case Code::TO_BOOLEAN_IC: // fall through
- case Code::STUB:
- description = CodeStub::MajorName(CodeStub::GetMajorKey(code_object));
+ case AbstractCode::BYTECODE_HANDLER:
+ return; // We log it later by walking the dispatch table.
+ case AbstractCode::BINARY_OP_IC: // fall through
+ case AbstractCode::COMPARE_IC: // fall through
+ case AbstractCode::TO_BOOLEAN_IC: // fall through
+
+ case AbstractCode::STUB:
+ description =
+ CodeStub::MajorName(CodeStub::GetMajorKey(code_object->GetCode()));
if (description == NULL)
description = "A stub from the snapshot";
tag = Logger::STUB_TAG;
break;
- case Code::REGEXP:
+ case AbstractCode::REGEXP:
description = "Regular expression code";
tag = Logger::REG_EXP_TAG;
break;
- case Code::BUILTIN:
- description = isolate_->builtins()->name(code_object->builtin_index());
+ case AbstractCode::BUILTIN:
+ description =
+ isolate_->builtins()->name(code_object->GetCode()->builtin_index());
tag = Logger::BUILTIN_TAG;
break;
- case Code::HANDLER:
+ case AbstractCode::HANDLER:
description = "An IC handler from the snapshot";
tag = Logger::HANDLER_TAG;
break;
- case Code::KEYED_LOAD_IC:
+ case AbstractCode::KEYED_LOAD_IC:
description = "A keyed load IC from the snapshot";
tag = Logger::KEYED_LOAD_IC_TAG;
break;
- case Code::LOAD_IC:
+ case AbstractCode::LOAD_IC:
description = "A load IC from the snapshot";
tag = Logger::LOAD_IC_TAG;
break;
- case Code::CALL_IC:
+ case AbstractCode::CALL_IC:
description = "A call IC from the snapshot";
tag = Logger::CALL_IC_TAG;
break;
- case Code::STORE_IC:
+ case AbstractCode::STORE_IC:
description = "A store IC from the snapshot";
tag = Logger::STORE_IC_TAG;
break;
- case Code::KEYED_STORE_IC:
+ case AbstractCode::KEYED_STORE_IC:
description = "A keyed store IC from the snapshot";
tag = Logger::KEYED_STORE_IC_TAG;
break;
- case Code::WASM_FUNCTION:
- description = "A wasm function";
+ case AbstractCode::WASM_FUNCTION:
+ description = "A Wasm function";
tag = Logger::STUB_TAG;
break;
- case Code::NUMBER_OF_KINDS:
+ case AbstractCode::JS_TO_WASM_FUNCTION:
+ description = "A JavaScript to Wasm adapter";
+ tag = Logger::STUB_TAG;
+ break;
+ case AbstractCode::WASM_TO_JS_FUNCTION:
+ description = "A Wasm to JavaScript adapter";
+ tag = Logger::STUB_TAG;
break;
}
PROFILE(isolate_, CodeCreateEvent(tag, code_object, description));
@@ -1668,12 +1570,34 @@
DisallowHeapAllocation no_gc;
for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
if (obj->IsCode()) LogCodeObject(obj);
+ if (obj->IsBytecodeArray()) LogCodeObject(obj);
}
}
+void Logger::LogBytecodeHandlers() {
+ if (!FLAG_ignition) return;
+
+ interpreter::Interpreter* interpreter = isolate_->interpreter();
+ const int last_index = static_cast<int>(interpreter::Bytecode::kLast);
+ for (auto operand_scale = interpreter::OperandScale::kSingle;
+ operand_scale <= interpreter::OperandScale::kMaxValid;
+ operand_scale =
+ interpreter::Bytecodes::NextOperandScale(operand_scale)) {
+ for (int index = 0; index <= last_index; ++index) {
+ interpreter::Bytecode bytecode = interpreter::Bytecodes::FromByte(index);
+ if (interpreter::Bytecodes::BytecodeHasHandler(bytecode, operand_scale)) {
+ Code* code = interpreter->GetBytecodeHandler(bytecode, operand_scale);
+ std::string bytecode_name =
+ interpreter::Bytecodes::ToString(bytecode, operand_scale);
+ CodeCreateEvent(Logger::BYTECODE_HANDLER_TAG, AbstractCode::cast(code),
+ bytecode_name.c_str());
+ }
+ }
+ }
+}
void Logger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
- Handle<Code> code) {
+ Handle<AbstractCode> code) {
Handle<String> func_name(shared->DebugName());
if (shared->script()->IsScript()) {
Handle<Script> script(Script::cast(shared->script()));
@@ -1730,7 +1654,7 @@
HandleScope scope(isolate_);
const int compiled_funcs_count = EnumerateCompiledFunctions(heap, NULL, NULL);
ScopedVector< Handle<SharedFunctionInfo> > sfis(compiled_funcs_count);
- ScopedVector< Handle<Code> > code_objects(compiled_funcs_count);
+ ScopedVector<Handle<AbstractCode> > code_objects(compiled_funcs_count);
EnumerateCompiledFunctions(heap, sfis.start(), code_objects.start());
// During iteration, there can be heap allocation due to
@@ -1827,11 +1751,6 @@
if (is_initialized_) return true;
is_initialized_ = true;
- // --ll-prof implies --log-code and --log-snapshot-positions.
- if (FLAG_ll_prof) {
- FLAG_log_snapshot_positions = true;
- }
-
std::ostringstream log_file_name;
PrepareLogFileName(log_file_name, isolate, FLAG_logfile);
log_->Initialize(log_file_name.str().c_str());
@@ -1842,6 +1761,11 @@
addCodeEventListener(perf_basic_logger_);
}
+ if (FLAG_perf_prof) {
+ perf_jit_logger_ = new PerfJitLogger();
+ addCodeEventListener(perf_jit_logger_);
+ }
+
if (FLAG_ll_prof) {
ll_logger_ = new LowLevelLogger(log_file_name.str().c_str());
addCodeEventListener(ll_logger_);
@@ -1910,6 +1834,12 @@
perf_basic_logger_ = NULL;
}
+ if (perf_jit_logger_) {
+ removeCodeEventListener(perf_jit_logger_);
+ delete perf_jit_logger_;
+ perf_jit_logger_ = NULL;
+ }
+
if (ll_logger_) {
removeCodeEventListener(ll_logger_);
delete ll_logger_;