Commit 8447072d authored by ssanfilippo's avatar ssanfilippo Committed by Commit bot

[Interpreter] Log code-creation events for bytecode handlers.

BUG=v8:4280
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#34631}
parent 240b7db9
......@@ -309,6 +309,7 @@ base::SmartArrayPointer<char> CompilationInfo::GetDebugName() const {
StackFrame::Type CompilationInfo::GetOutputStackFrameType() const {
switch (output_code_kind()) {
case Code::STUB:
case Code::BYTECODE_HANDLER:
case Code::HANDLER:
case Code::BUILTIN:
return StackFrame::STUB;
......
......@@ -23,9 +23,10 @@ using compiler::Node;
InterpreterAssembler::InterpreterAssembler(Isolate* isolate, Zone* zone,
Bytecode bytecode)
: compiler::CodeStubAssembler(
isolate, zone, InterpreterDispatchDescriptor(isolate),
Code::ComputeFlags(Code::STUB), Bytecodes::ToString(bytecode), 0),
: compiler::CodeStubAssembler(isolate, zone,
InterpreterDispatchDescriptor(isolate),
Code::ComputeFlags(Code::BYTECODE_HANDLER),
Bytecodes::ToString(bytecode), 0),
bytecode_(bytecode),
accumulator_(this, MachineRepresentation::kTagged),
context_(this, MachineRepresentation::kTagged),
......
......@@ -11,6 +11,7 @@
#include "src/interpreter/bytecode-generator.h"
#include "src/interpreter/bytecodes.h"
#include "src/interpreter/interpreter-assembler.h"
#include "src/log.h"
#include "src/zone.h"
namespace v8 {
......@@ -37,6 +38,9 @@ void Interpreter::Initialize() {
Do##Name(&assembler); \
Handle<Code> code = assembler.GenerateCode(); \
TraceCodegen(code, #Name); \
LOG_CODE_EVENT(isolate_, \
CodeCreateEvent(Logger::BYTECODE_HANDLER_TAG, \
AbstractCode::cast(*code), #Name)); \
dispatch_table_[Bytecodes::ToByte(Bytecode::k##Name)] = *code; \
}
BYTECODE_LIST(GENERATE_CODE)
......
......@@ -13,6 +13,8 @@
#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"
......@@ -1525,6 +1527,8 @@ void Logger::LogCodeObject(Object* object) {
case AbstractCode::INTERPRETED_FUNCTION:
case AbstractCode::OPTIMIZED_FUNCTION:
return; // We log this later using LogCompiledFunctions.
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
......@@ -1598,6 +1602,18 @@ void Logger::LogCodeObjects() {
}
}
void Logger::LogBytecodeHandlers() {
if (!FLAG_ignition) return;
const int last_index = static_cast<int>(interpreter::Bytecode::kLast);
for (int index = 0; index <= last_index; ++index) {
interpreter::Bytecode bytecode = interpreter::Bytecodes::FromByte(index);
Code* code = isolate_->interpreter()->GetBytecodeHandler(bytecode);
CodeCreateEvent(Logger::BYTECODE_HANDLER_TAG, AbstractCode::cast(code),
interpreter::Bytecodes::ToString(bytecode));
}
}
void Logger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
Handle<AbstractCode> code) {
Handle<String> func_name(shared->DebugName());
......
......@@ -82,63 +82,62 @@ struct TickSample;
logger->Call; \
} while (false)
#define LOG_EVENTS_AND_TAGS_LIST(V) \
V(CODE_CREATION_EVENT, "code-creation") \
V(CODE_DISABLE_OPT_EVENT, "code-disable-optimization") \
V(CODE_MOVE_EVENT, "code-move") \
V(CODE_DELETE_EVENT, "code-delete") \
V(CODE_MOVING_GC, "code-moving-gc") \
V(SHARED_FUNC_MOVE_EVENT, "sfi-move") \
V(SNAPSHOT_POSITION_EVENT, "snapshot-pos") \
V(SNAPSHOT_CODE_NAME_EVENT, "snapshot-code-name") \
V(TICK_EVENT, "tick") \
V(REPEAT_META_EVENT, "repeat") \
V(BUILTIN_TAG, "Builtin") \
V(CALL_DEBUG_BREAK_TAG, "CallDebugBreak") \
V(CALL_DEBUG_PREPARE_STEP_IN_TAG, "CallDebugPrepareStepIn") \
V(CALL_INITIALIZE_TAG, "CallInitialize") \
V(CALL_MEGAMORPHIC_TAG, "CallMegamorphic") \
V(CALL_MISS_TAG, "CallMiss") \
V(CALL_NORMAL_TAG, "CallNormal") \
V(CALL_PRE_MONOMORPHIC_TAG, "CallPreMonomorphic") \
V(LOAD_INITIALIZE_TAG, "LoadInitialize") \
V(LOAD_PREMONOMORPHIC_TAG, "LoadPreMonomorphic") \
V(LOAD_MEGAMORPHIC_TAG, "LoadMegamorphic") \
V(STORE_INITIALIZE_TAG, "StoreInitialize") \
V(STORE_PREMONOMORPHIC_TAG, "StorePreMonomorphic") \
V(STORE_GENERIC_TAG, "StoreGeneric") \
V(STORE_MEGAMORPHIC_TAG, "StoreMegamorphic") \
V(KEYED_CALL_DEBUG_BREAK_TAG, "KeyedCallDebugBreak") \
V(KEYED_CALL_DEBUG_PREPARE_STEP_IN_TAG, \
"KeyedCallDebugPrepareStepIn") \
V(KEYED_CALL_INITIALIZE_TAG, "KeyedCallInitialize") \
V(KEYED_CALL_MEGAMORPHIC_TAG, "KeyedCallMegamorphic") \
V(KEYED_CALL_MISS_TAG, "KeyedCallMiss") \
V(KEYED_CALL_NORMAL_TAG, "KeyedCallNormal") \
V(KEYED_CALL_PRE_MONOMORPHIC_TAG, "KeyedCallPreMonomorphic") \
V(CALLBACK_TAG, "Callback") \
V(EVAL_TAG, "Eval") \
V(FUNCTION_TAG, "Function") \
V(HANDLER_TAG, "Handler") \
V(KEYED_LOAD_IC_TAG, "KeyedLoadIC") \
V(KEYED_LOAD_POLYMORPHIC_IC_TAG, "KeyedLoadPolymorphicIC") \
V(KEYED_EXTERNAL_ARRAY_LOAD_IC_TAG, "KeyedExternalArrayLoadIC") \
V(KEYED_STORE_IC_TAG, "KeyedStoreIC") \
V(KEYED_STORE_POLYMORPHIC_IC_TAG, "KeyedStorePolymorphicIC") \
V(KEYED_EXTERNAL_ARRAY_STORE_IC_TAG, "KeyedExternalArrayStoreIC") \
V(LAZY_COMPILE_TAG, "LazyCompile") \
V(CALL_IC_TAG, "CallIC") \
V(LOAD_IC_TAG, "LoadIC") \
V(LOAD_POLYMORPHIC_IC_TAG, "LoadPolymorphicIC") \
V(REG_EXP_TAG, "RegExp") \
V(SCRIPT_TAG, "Script") \
V(STORE_IC_TAG, "StoreIC") \
V(STORE_POLYMORPHIC_IC_TAG, "StorePolymorphicIC") \
V(STUB_TAG, "Stub") \
V(NATIVE_FUNCTION_TAG, "Function") \
V(NATIVE_LAZY_COMPILE_TAG, "LazyCompile") \
V(NATIVE_SCRIPT_TAG, "Script")
#define LOG_EVENTS_AND_TAGS_LIST(V) \
V(CODE_CREATION_EVENT, "code-creation") \
V(CODE_DISABLE_OPT_EVENT, "code-disable-optimization") \
V(CODE_MOVE_EVENT, "code-move") \
V(CODE_DELETE_EVENT, "code-delete") \
V(CODE_MOVING_GC, "code-moving-gc") \
V(SHARED_FUNC_MOVE_EVENT, "sfi-move") \
V(SNAPSHOT_POSITION_EVENT, "snapshot-pos") \
V(SNAPSHOT_CODE_NAME_EVENT, "snapshot-code-name") \
V(TICK_EVENT, "tick") \
V(REPEAT_META_EVENT, "repeat") \
V(BUILTIN_TAG, "Builtin") \
V(CALL_DEBUG_BREAK_TAG, "CallDebugBreak") \
V(CALL_DEBUG_PREPARE_STEP_IN_TAG, "CallDebugPrepareStepIn") \
V(CALL_INITIALIZE_TAG, "CallInitialize") \
V(CALL_MEGAMORPHIC_TAG, "CallMegamorphic") \
V(CALL_MISS_TAG, "CallMiss") \
V(CALL_NORMAL_TAG, "CallNormal") \
V(CALL_PRE_MONOMORPHIC_TAG, "CallPreMonomorphic") \
V(LOAD_INITIALIZE_TAG, "LoadInitialize") \
V(LOAD_PREMONOMORPHIC_TAG, "LoadPreMonomorphic") \
V(LOAD_MEGAMORPHIC_TAG, "LoadMegamorphic") \
V(STORE_INITIALIZE_TAG, "StoreInitialize") \
V(STORE_PREMONOMORPHIC_TAG, "StorePreMonomorphic") \
V(STORE_GENERIC_TAG, "StoreGeneric") \
V(STORE_MEGAMORPHIC_TAG, "StoreMegamorphic") \
V(KEYED_CALL_DEBUG_BREAK_TAG, "KeyedCallDebugBreak") \
V(KEYED_CALL_DEBUG_PREPARE_STEP_IN_TAG, "KeyedCallDebugPrepareStepIn") \
V(KEYED_CALL_INITIALIZE_TAG, "KeyedCallInitialize") \
V(KEYED_CALL_MEGAMORPHIC_TAG, "KeyedCallMegamorphic") \
V(KEYED_CALL_MISS_TAG, "KeyedCallMiss") \
V(KEYED_CALL_NORMAL_TAG, "KeyedCallNormal") \
V(KEYED_CALL_PRE_MONOMORPHIC_TAG, "KeyedCallPreMonomorphic") \
V(CALLBACK_TAG, "Callback") \
V(EVAL_TAG, "Eval") \
V(FUNCTION_TAG, "Function") \
V(HANDLER_TAG, "Handler") \
V(BYTECODE_HANDLER_TAG, "BytecodeHandler") \
V(KEYED_LOAD_IC_TAG, "KeyedLoadIC") \
V(KEYED_LOAD_POLYMORPHIC_IC_TAG, "KeyedLoadPolymorphicIC") \
V(KEYED_EXTERNAL_ARRAY_LOAD_IC_TAG, "KeyedExternalArrayLoadIC") \
V(KEYED_STORE_IC_TAG, "KeyedStoreIC") \
V(KEYED_STORE_POLYMORPHIC_IC_TAG, "KeyedStorePolymorphicIC") \
V(KEYED_EXTERNAL_ARRAY_STORE_IC_TAG, "KeyedExternalArrayStoreIC") \
V(LAZY_COMPILE_TAG, "LazyCompile") \
V(CALL_IC_TAG, "CallIC") \
V(LOAD_IC_TAG, "LoadIC") \
V(LOAD_POLYMORPHIC_IC_TAG, "LoadPolymorphicIC") \
V(REG_EXP_TAG, "RegExp") \
V(SCRIPT_TAG, "Script") \
V(STORE_IC_TAG, "StoreIC") \
V(STORE_POLYMORPHIC_IC_TAG, "StorePolymorphicIC") \
V(STUB_TAG, "Stub") \
V(NATIVE_FUNCTION_TAG, "Function") \
V(NATIVE_LAZY_COMPILE_TAG, "LazyCompile") \
V(NATIVE_SCRIPT_TAG, "Script")
// Note that 'NATIVE_' cases for functions and scripts are mapped onto
// original tags when writing to the log.
......@@ -318,6 +317,8 @@ class Logger {
void LogAccessorCallbacks();
// Used for logging stubs found in the snapshot.
void LogCodeObjects();
// Used for logging bytecode handlers found in the snapshot.
void LogBytecodeHandlers();
// Converts tag to a corresponding NATIVE_... if the script is native.
INLINE(static LogEventsAndTags ToNativeByScript(LogEventsAndTags, Script*));
......
......@@ -4880,6 +4880,7 @@ class Code: public HeapObject {
#define NON_IC_KIND_LIST(V) \
V(FUNCTION) \
V(OPTIMIZED_FUNCTION) \
V(BYTECODE_HANDLER) \
V(STUB) \
V(HANDLER) \
V(BUILTIN) \
......
......@@ -66,6 +66,7 @@ void CodeSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
case Code::HANDLER: // No handlers patched in yet.
case Code::REGEXP: // No regexp literals initialized yet.
case Code::NUMBER_OF_KINDS: // Pseudo enum value.
case Code::BYTECODE_HANDLER: // No direct references to handlers.
CHECK(false);
case Code::BUILTIN:
SerializeBuiltin(code_object->builtin_index(), how_to_code,
......
......@@ -102,6 +102,7 @@ void Deserializer::Deserialize(Isolate* isolate) {
// Issue code events for newly deserialized code objects.
LOG_CODE_EVENT(isolate_, LogCodeObjects());
LOG_CODE_EVENT(isolate_, LogBytecodeHandlers());
LOG_CODE_EVENT(isolate_, LogCompiledFunctions());
}
......
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