Commit 652a3e13 authored by Georgia Kouveli's avatar Georgia Kouveli Committed by Commit Bot

Merge deoptimization type enums

Replace all uses of Deoptimizer::BailoutType and CodeEventListener::DeoptKind
with DeoptimizeKind from src/globals.h.

Change-Id: I5b9002583a69bc43d995cacc7619b018e5a70727
Reviewed-on: https://chromium-review.googlesource.com/1097331
Commit-Queue: Georgia Kouveli <georgia.kouveli@arm.com>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53695}
parent 249d0ea4
......@@ -86,7 +86,7 @@ void Deoptimizer::TableEntryGenerator::Generate() {
__ JumpIfSmi(r1, &context_check);
__ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
__ bind(&context_check);
__ mov(r1, Operand(type())); // bailout type,
__ mov(r1, Operand(static_cast<int>(deopt_kind())));
// r2: bailout id already loaded.
// r3: code address or 0 already loaded.
__ str(r4, MemOperand(sp, 0 * kPointerSize)); // Fp-to-sp delta.
......
......@@ -155,7 +155,7 @@ void Deoptimizer::TableEntryGenerator::Generate() {
__ Tst(x1, kSmiTagMask);
__ CzeroX(x0, eq);
__ Mov(x1, type());
__ Mov(x1, static_cast<int>(deopt_kind()));
// Following arguments are already loaded:
// - x2: bailout id
// - x3: code object address
......
......@@ -601,8 +601,8 @@ void RelocInfo::Print(Isolate* isolate, std::ostream& os) { // NOLINT
os << " (" << reinterpret_cast<const void*>(target_address()) << ")";
} else if (IsRuntimeEntry(rmode_) && isolate->deoptimizer_data() != nullptr) {
// Depotimization bailouts are stored as runtime entries.
int id = Deoptimizer::GetDeoptimizationId(
isolate, target_address(), Deoptimizer::EAGER);
int id = Deoptimizer::GetDeoptimizationId(isolate, target_address(),
DeoptimizeKind::kEager);
if (id != Deoptimizer::kNotDeoptimizationEntry) {
os << " (deoptimization bailout " << id << ")";
}
......
......@@ -88,8 +88,7 @@ class CodeEventListener {
virtual void CodeMovingGCEvent() = 0;
virtual void CodeDisableOptEvent(AbstractCode* code,
SharedFunctionInfo* shared) = 0;
enum DeoptKind { kSoft, kLazy, kEager };
virtual void CodeDeoptEvent(Code* code, DeoptKind kind, Address pc,
virtual void CodeDeoptEvent(Code* code, DeoptimizeKind kind, Address pc,
int fp_to_sp_delta) = 0;
virtual bool is_listening_to_code_events() { return false; }
......@@ -165,7 +164,7 @@ class CodeEventDispatcher {
void CodeDisableOptEvent(AbstractCode* code, SharedFunctionInfo* shared) {
CODE_EVENT_DISPATCH(CodeDisableOptEvent(code, shared));
}
void CodeDeoptEvent(Code* code, CodeEventListener::DeoptKind kind, Address pc,
void CodeDeoptEvent(Code* code, DeoptimizeKind kind, Address pc,
int fp_to_sp_delta) {
CODE_EVENT_DISPATCH(CodeDeoptEvent(code, kind, pc, fp_to_sp_delta));
}
......
......@@ -116,26 +116,10 @@ void CodeGenerator::CreateFrameAccessState(Frame* frame) {
CodeGenerator::CodeGenResult CodeGenerator::AssembleDeoptimizerCall(
int deoptimization_id, SourcePosition pos) {
DeoptimizeKind deopt_kind = GetDeoptimizationKind(deoptimization_id);
Deoptimizer::BailoutType bailout_type;
switch (deopt_kind) {
case DeoptimizeKind::kSoft: {
bailout_type = Deoptimizer::SOFT;
break;
}
case DeoptimizeKind::kEager: {
bailout_type = Deoptimizer::EAGER;
break;
}
case DeoptimizeKind::kLazy: {
bailout_type = Deoptimizer::LAZY;
break;
}
default: { UNREACHABLE(); }
}
DeoptimizeReason deoptimization_reason =
GetDeoptimizationReason(deoptimization_id);
Address deopt_entry = Deoptimizer::GetDeoptimizationEntry(
tasm()->isolate(), deoptimization_id, bailout_type);
tasm()->isolate(), deoptimization_id, deopt_kind);
if (deopt_entry == kNullAddress) return kTooManyDeoptimizationBailouts;
if (info()->is_source_positions_enabled()) {
tasm()->RecordDeoptReason(deoptimization_reason, pos, deoptimization_id);
......
......@@ -131,24 +131,31 @@ class FrameWriter {
};
DeoptimizerData::DeoptimizerData(Heap* heap) : heap_(heap), current_(nullptr) {
for (int i = 0; i <= Deoptimizer::kLastBailoutType; ++i) {
for (int i = 0; i <= DeoptimizerData::kLastDeoptimizeKind; ++i) {
deopt_entry_code_[i] = nullptr;
}
Code** start = &deopt_entry_code_[0];
Code** end = &deopt_entry_code_[Deoptimizer::kLastBailoutType + 1];
Code** end = &deopt_entry_code_[DeoptimizerData::kLastDeoptimizeKind + 1];
heap_->RegisterStrongRoots(reinterpret_cast<Object**>(start),
reinterpret_cast<Object**>(end));
}
DeoptimizerData::~DeoptimizerData() {
for (int i = 0; i <= Deoptimizer::kLastBailoutType; ++i) {
for (int i = 0; i <= DeoptimizerData::kLastDeoptimizeKind; ++i) {
deopt_entry_code_[i] = nullptr;
}
Code** start = &deopt_entry_code_[0];
heap_->UnregisterStrongRoots(reinterpret_cast<Object**>(start));
}
Code* DeoptimizerData::deopt_entry_code(DeoptimizeKind kind) {
return deopt_entry_code_[static_cast<int>(kind)];
}
void DeoptimizerData::set_deopt_entry_code(DeoptimizeKind kind, Code* code) {
deopt_entry_code_[static_cast<int>(kind)] = code;
}
Code* Deoptimizer::FindDeoptimizingCode(Address addr) {
if (function_->IsHeapObject()) {
......@@ -169,13 +176,10 @@ Code* Deoptimizer::FindDeoptimizingCode(Address addr) {
// We rely on this function not causing a GC. It is called from generated code
// without having a real stack frame in place.
Deoptimizer* Deoptimizer::New(JSFunction* function,
BailoutType type,
unsigned bailout_id,
Address from,
int fp_to_sp_delta,
Isolate* isolate) {
Deoptimizer* deoptimizer = new Deoptimizer(isolate, function, type,
Deoptimizer* Deoptimizer::New(JSFunction* function, DeoptimizeKind kind,
unsigned bailout_id, Address from,
int fp_to_sp_delta, Isolate* isolate) {
Deoptimizer* deoptimizer = new Deoptimizer(isolate, function, kind,
bailout_id, from, fp_to_sp_delta);
CHECK_NULL(isolate->deoptimizer_data()->current_);
isolate->deoptimizer_data()->current_ = deoptimizer;
......@@ -226,11 +230,10 @@ DeoptimizedFrameInfo* Deoptimizer::DebuggerInspectableFrame(
return info;
}
void Deoptimizer::GenerateDeoptimizationEntries(MacroAssembler* masm,
int count,
BailoutType type) {
void Deoptimizer::GenerateDeoptimizationEntries(MacroAssembler* masm, int count,
DeoptimizeKind kind) {
NoRootArrayScope no_root_array(masm);
TableEntryGenerator generator(masm, type, count);
TableEntryGenerator generator(masm, kind, count);
generator.Generate();
}
......@@ -457,41 +460,26 @@ void Deoptimizer::ComputeOutputFrames(Deoptimizer* deoptimizer) {
deoptimizer->DoComputeOutputFrames();
}
const char* Deoptimizer::MessageFor(BailoutType type) {
switch (type) {
case EAGER: return "eager";
case SOFT: return "soft";
case LAZY: return "lazy";
const char* Deoptimizer::MessageFor(DeoptimizeKind kind) {
switch (kind) {
case DeoptimizeKind::kEager:
return "eager";
case DeoptimizeKind::kSoft:
return "soft";
case DeoptimizeKind::kLazy:
return "lazy";
}
FATAL("Unsupported deopt type");
FATAL("Unsupported deopt kind");
return nullptr;
}
namespace {
CodeEventListener::DeoptKind DeoptKindOfBailoutType(
Deoptimizer::BailoutType bailout_type) {
switch (bailout_type) {
case Deoptimizer::EAGER:
return CodeEventListener::kEager;
case Deoptimizer::SOFT:
return CodeEventListener::kSoft;
case Deoptimizer::LAZY:
return CodeEventListener::kLazy;
}
UNREACHABLE();
}
} // namespace
Deoptimizer::Deoptimizer(Isolate* isolate, JSFunction* function,
BailoutType type, unsigned bailout_id, Address from,
DeoptimizeKind kind, unsigned bailout_id, Address from,
int fp_to_sp_delta)
: isolate_(isolate),
function_(function),
bailout_id_(bailout_id),
bailout_type_(type),
deopt_kind_(kind),
from_(from),
fp_to_sp_delta_(fp_to_sp_delta),
deoptimizing_throw_(false),
......@@ -531,7 +519,7 @@ Deoptimizer::Deoptimizer(Isolate* isolate, JSFunction* function,
// increment the function's deopt count so that we can avoid optimising
// functions that deopt too often.
if (bailout_type_ == Deoptimizer::SOFT) {
if (deopt_kind_ == DeoptimizeKind::kSoft) {
// Soft deopts shouldn't count against the overall deoptimization count
// that can eventually lead to disabling optimization for a function.
isolate->counters()->soft_deopts_executed()->Increment();
......@@ -542,8 +530,7 @@ Deoptimizer::Deoptimizer(Isolate* isolate, JSFunction* function,
if (compiled_code_->kind() == Code::OPTIMIZED_FUNCTION) {
compiled_code_->set_deopt_already_counted(true);
PROFILE(isolate_,
CodeDeoptEvent(compiled_code_, DeoptKindOfBailoutType(type), from_,
fp_to_sp_delta_));
CodeDeoptEvent(compiled_code_, kind, from_, fp_to_sp_delta_));
}
unsigned size = ComputeInputFrameSize();
int parameter_count =
......@@ -599,23 +586,21 @@ void Deoptimizer::DeleteFrameDescriptions() {
}
Address Deoptimizer::GetDeoptimizationEntry(Isolate* isolate, int id,
BailoutType type) {
DeoptimizeKind kind) {
CHECK_GE(id, 0);
if (id >= kMaxNumberOfEntries) return kNullAddress;
DeoptimizerData* data = isolate->deoptimizer_data();
CHECK_LE(type, kLastBailoutType);
CHECK_NOT_NULL(data->deopt_entry_code_[type]);
Code* code = data->deopt_entry_code_[type];
CHECK_LE(kind, DeoptimizerData::kLastDeoptimizeKind);
CHECK_NOT_NULL(data->deopt_entry_code(kind));
Code* code = data->deopt_entry_code(kind);
return code->raw_instruction_start() + (id * table_entry_size_);
}
int Deoptimizer::GetDeoptimizationId(Isolate* isolate,
Address addr,
BailoutType type) {
int Deoptimizer::GetDeoptimizationId(Isolate* isolate, Address addr,
DeoptimizeKind kind) {
DeoptimizerData* data = isolate->deoptimizer_data();
CHECK_LE(type, kLastBailoutType);
Code* code = data->deopt_entry_code_[type];
CHECK_LE(kind, DeoptimizerData::kLastDeoptimizeKind);
Code* code = data->deopt_entry_code(kind);
if (code == nullptr) return kNotDeoptimizationEntry;
Address start = code->raw_instruction_start();
if (addr < start ||
......@@ -627,7 +612,6 @@ int Deoptimizer::GetDeoptimizationId(Isolate* isolate,
return static_cast<int>(addr - start) / table_entry_size_;
}
int Deoptimizer::GetDeoptimizedCodeCount(Isolate* isolate) {
int length = 0;
// Count all entries in the deoptimizing code list of every context.
......@@ -708,14 +692,15 @@ void Deoptimizer::DoComputeOutputFrames() {
if (trace_scope_ != nullptr) {
timer.Start();
PrintF(trace_scope_->file(), "[deoptimizing (DEOPT %s): begin ",
MessageFor(bailout_type_));
MessageFor(deopt_kind_));
PrintFunctionName();
PrintF(trace_scope_->file(),
" (opt #%d) @%d, FP to SP delta: %d, caller sp: " V8PRIxPTR_FMT
"]\n",
input_data->OptimizationId()->value(), bailout_id_, fp_to_sp_delta_,
caller_frame_top_);
if (bailout_type_ == EAGER || bailout_type_ == SOFT) {
if (deopt_kind_ == DeoptimizeKind::kEager ||
deopt_kind_ == DeoptimizeKind::kSoft) {
compiled_code_->PrintDeoptLocation(
trace_scope_->file(), " ;;; deoptimize at ", from_);
}
......@@ -804,7 +789,7 @@ void Deoptimizer::DoComputeOutputFrames() {
double ms = timer.Elapsed().InMillisecondsF();
int index = output_count_ - 1; // Index of the topmost frame.
PrintF(trace_scope_->file(), "[deoptimizing (%s): end ",
MessageFor(bailout_type_));
MessageFor(deopt_kind_));
PrintFunctionName();
PrintF(trace_scope_->file(),
" @%d => node=%d, pc=" V8PRIxPTR_FMT ", caller sp=" V8PRIxPTR_FMT
......@@ -1017,7 +1002,8 @@ void Deoptimizer::DoComputeInterpretedFrame(TranslatedFrame* translated_frame,
// simulating what normal handlers do upon completion of the operation.
Builtins* builtins = isolate_->builtins();
Code* dispatch_builtin =
(!is_topmost || (bailout_type_ == LAZY)) && !goto_catch_handler
(!is_topmost || (deopt_kind_ == DeoptimizeKind::kLazy)) &&
!goto_catch_handler
? builtins->builtin(Builtins::kInterpreterEnterBytecodeAdvance)
: builtins->builtin(Builtins::kInterpreterEnterBytecodeDispatch);
output_frame->SetPc(
......@@ -1157,8 +1143,8 @@ void Deoptimizer::DoComputeConstructStubFrame(TranslatedFrame* translated_frame,
bool is_topmost = (output_count_ - 1 == frame_index);
// The construct frame could become topmost only if we inlined a constructor
// call which does a tail call (otherwise the tail callee's frame would be
// the topmost one). So it could only be the LAZY case.
CHECK(!is_topmost || bailout_type_ == LAZY);
// the topmost one). So it could only be the DeoptimizeKind::kLazy case.
CHECK(!is_topmost || deopt_kind_ == DeoptimizeKind::kLazy);
Builtins* builtins = isolate_->builtins();
Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric);
......@@ -1323,7 +1309,7 @@ void Deoptimizer::DoComputeConstructStubFrame(TranslatedFrame* translated_frame,
// Set the continuation for the topmost frame.
if (is_topmost) {
Builtins* builtins = isolate_->builtins();
DCHECK_EQ(LAZY, bailout_type_);
DCHECK_EQ(DeoptimizeKind::kLazy, deopt_kind_);
Code* continuation = builtins->builtin(Builtins::kNotifyDeoptimized);
output_frame->SetContinuation(
static_cast<intptr_t>(continuation->InstructionStart()));
......@@ -1465,7 +1451,8 @@ void Deoptimizer::DoComputeBuiltinContinuation(
const bool is_bottommost = (0 == frame_index);
const bool is_topmost = (output_count_ - 1 == frame_index);
const bool must_handle_result = !is_topmost || bailout_type_ == LAZY;
const bool must_handle_result =
!is_topmost || deopt_kind_ == DeoptimizeKind::kLazy;
const RegisterConfiguration* config(RegisterConfiguration::Default());
const int allocatable_register_count =
......@@ -1813,14 +1800,15 @@ unsigned Deoptimizer::ComputeIncomingArgumentSize(SharedFunctionInfo* shared) {
}
void Deoptimizer::EnsureCodeForDeoptimizationEntry(Isolate* isolate,
BailoutType type) {
CHECK(type == EAGER || type == SOFT || type == LAZY);
DeoptimizeKind kind) {
CHECK(kind == DeoptimizeKind::kEager || kind == DeoptimizeKind::kSoft ||
kind == DeoptimizeKind::kLazy);
DeoptimizerData* data = isolate->deoptimizer_data();
if (data->deopt_entry_code_[type] != nullptr) return;
if (data->deopt_entry_code(kind) != nullptr) return;
MacroAssembler masm(isolate, nullptr, 16 * KB, CodeObjectRequired::kYes);
masm.set_emit_debug_code(false);
GenerateDeoptimizationEntries(&masm, kMaxNumberOfEntries, type);
GenerateDeoptimizationEntries(&masm, kMaxNumberOfEntries, kind);
CodeDesc desc;
masm.GetCode(isolate, &desc);
DCHECK(!RelocInfo::RequiresRelocation(desc));
......@@ -1832,14 +1820,14 @@ void Deoptimizer::EnsureCodeForDeoptimizationEntry(Isolate* isolate,
MaybeHandle<ByteArray>(), MaybeHandle<DeoptimizationData>(), kImmovable);
CHECK(Heap::IsImmovable(*code));
CHECK_NULL(data->deopt_entry_code_[type]);
data->deopt_entry_code_[type] = *code;
CHECK_NULL(data->deopt_entry_code(kind));
data->set_deopt_entry_code(kind, *code);
}
void Deoptimizer::EnsureCodeForMaxDeoptimizationEntries(Isolate* isolate) {
EnsureCodeForDeoptimizationEntry(isolate, EAGER);
EnsureCodeForDeoptimizationEntry(isolate, LAZY);
EnsureCodeForDeoptimizationEntry(isolate, SOFT);
EnsureCodeForDeoptimizationEntry(isolate, DeoptimizeKind::kEager);
EnsureCodeForDeoptimizationEntry(isolate, DeoptimizeKind::kLazy);
EnsureCodeForDeoptimizationEntry(isolate, DeoptimizeKind::kSoft);
}
FrameDescription::FrameDescription(uint32_t frame_size, int parameter_count)
......
......@@ -14,6 +14,7 @@
#include "src/deoptimize-reason.h"
#include "src/feedback-vector.h"
#include "src/frame-constants.h"
#include "src/globals.h"
#include "src/isolate.h"
#include "src/macro-assembler.h"
#include "src/source-position.h"
......@@ -392,8 +393,6 @@ class OptimizedFunctionVisitor BASE_EMBEDDED {
class Deoptimizer : public Malloced {
public:
enum BailoutType { EAGER, LAZY, SOFT, kLastBailoutType = SOFT };
struct DeoptInfo {
DeoptInfo(SourcePosition position, DeoptimizeReason deopt_reason,
int deopt_id)
......@@ -413,41 +412,38 @@ class Deoptimizer : public Malloced {
struct JumpTableEntry : public ZoneObject {
inline JumpTableEntry(Address entry, const DeoptInfo& deopt_info,
Deoptimizer::BailoutType type, bool frame)
DeoptimizeKind kind, bool frame)
: label(),
address(entry),
deopt_info(deopt_info),
bailout_type(type),
deopt_kind(kind),
needs_frame(frame) {}
bool IsEquivalentTo(const JumpTableEntry& other) const {
return address == other.address && bailout_type == other.bailout_type &&
return address == other.address && deopt_kind == other.deopt_kind &&
needs_frame == other.needs_frame;
}
Label label;
Address address;
DeoptInfo deopt_info;
Deoptimizer::BailoutType bailout_type;
DeoptimizeKind deopt_kind;
bool needs_frame;
};
static const char* MessageFor(BailoutType type);
static const char* MessageFor(DeoptimizeKind kind);
int output_count() const { return output_count_; }
Handle<JSFunction> function() const;
Handle<Code> compiled_code() const;
BailoutType bailout_type() const { return bailout_type_; }
DeoptimizeKind deopt_kind() const { return deopt_kind_; }
// Number of created JS frames. Not all created frames are necessarily JS.
int jsframe_count() const { return jsframe_count_; }
static Deoptimizer* New(JSFunction* function,
BailoutType type,
unsigned bailout_id,
Address from,
int fp_to_sp_delta,
static Deoptimizer* New(JSFunction* function, DeoptimizeKind kind,
unsigned bailout_id, Address from, int fp_to_sp_delta,
Isolate* isolate);
static Deoptimizer* Grab(Isolate* isolate);
......@@ -478,10 +474,9 @@ class Deoptimizer : public Malloced {
static void ComputeOutputFrames(Deoptimizer* deoptimizer);
static Address GetDeoptimizationEntry(Isolate* isolate, int id,
BailoutType type);
static int GetDeoptimizationId(Isolate* isolate,
Address addr,
BailoutType type);
DeoptimizeKind kind);
static int GetDeoptimizationId(Isolate* isolate, Address addr,
DeoptimizeKind kind);
// Code generation support.
static int input_offset() { return OFFSET_OF(Deoptimizer, input_); }
......@@ -501,14 +496,14 @@ class Deoptimizer : public Malloced {
// Generators for the deoptimization entry code.
class TableEntryGenerator BASE_EMBEDDED {
public:
TableEntryGenerator(MacroAssembler* masm, BailoutType type, int count)
: masm_(masm), type_(type), count_(count) {}
TableEntryGenerator(MacroAssembler* masm, DeoptimizeKind kind, int count)
: masm_(masm), deopt_kind_(kind), count_(count) {}
void Generate();
protected:
MacroAssembler* masm() const { return masm_; }
BailoutType type() const { return type_; }
DeoptimizeKind deopt_kind() const { return deopt_kind_; }
Isolate* isolate() const { return masm_->isolate(); }
void GeneratePrologue();
......@@ -517,12 +512,12 @@ class Deoptimizer : public Malloced {
int count() const { return count_; }
MacroAssembler* masm_;
Deoptimizer::BailoutType type_;
DeoptimizeKind deopt_kind_;
int count_;
};
static void EnsureCodeForDeoptimizationEntry(Isolate* isolate,
BailoutType type);
DeoptimizeKind kind);
static void EnsureCodeForMaxDeoptimizationEntries(Isolate* isolate);
Isolate* isolate() const { return isolate_; }
......@@ -535,7 +530,7 @@ class Deoptimizer : public Malloced {
static const int kMinNumberOfEntries = 64;
static const int kMaxNumberOfEntries = 16384;
Deoptimizer(Isolate* isolate, JSFunction* function, BailoutType type,
Deoptimizer(Isolate* isolate, JSFunction* function, DeoptimizeKind kind,
unsigned bailout_id, Address from, int fp_to_sp_delta);
Code* FindOptimizedCode();
void PrintFunctionName();
......@@ -573,8 +568,8 @@ class Deoptimizer : public Malloced {
static unsigned ComputeIncomingArgumentSize(SharedFunctionInfo* shared);
static unsigned ComputeOutgoingArgumentSize(Code* code, unsigned bailout_id);
static void GenerateDeoptimizationEntries(
MacroAssembler* masm, int count, BailoutType type);
static void GenerateDeoptimizationEntries(MacroAssembler* masm, int count,
DeoptimizeKind kind);
// Marks all the code in the given context for deoptimization.
static void MarkAllCodeForContext(Context* native_context);
......@@ -595,7 +590,7 @@ class Deoptimizer : public Malloced {
JSFunction* function_;
Code* compiled_code_;
unsigned bailout_id_;
BailoutType bailout_type_;
DeoptimizeKind deopt_kind_;
Address from_;
int fp_to_sp_delta_;
bool deoptimizing_throw_;
......@@ -846,7 +841,11 @@ class DeoptimizerData {
private:
Heap* heap_;
Code* deopt_entry_code_[Deoptimizer::kLastBailoutType + 1];
static const int kLastDeoptimizeKind =
static_cast<int>(DeoptimizeKind::kLastDeoptimizeKind);
Code* deopt_entry_code_[kLastDeoptimizeKind + 1];
Code* deopt_entry_code(DeoptimizeKind kind);
void set_deopt_entry_code(DeoptimizeKind kind, Code* code);
Deoptimizer* current_;
......
......@@ -160,11 +160,13 @@ static void PrintRelocInfo(StringBuilder* out, Isolate* isolate,
// A runtime entry reloinfo might be a deoptimization bailout->
Address addr = relocinfo->target_address();
int id =
Deoptimizer::GetDeoptimizationId(isolate, addr, Deoptimizer::EAGER);
Deoptimizer::GetDeoptimizationId(isolate, addr, DeoptimizeKind::kEager);
if (id == Deoptimizer::kNotDeoptimizationEntry) {
id = Deoptimizer::GetDeoptimizationId(isolate, addr, Deoptimizer::LAZY);
id = Deoptimizer::GetDeoptimizationId(isolate, addr,
DeoptimizeKind::kLazy);
if (id == Deoptimizer::kNotDeoptimizationEntry) {
id = Deoptimizer::GetDeoptimizationId(isolate, addr, Deoptimizer::SOFT);
id = Deoptimizer::GetDeoptimizationId(isolate, addr,
DeoptimizeKind::kSoft);
if (id == Deoptimizer::kNotDeoptimizationEntry) {
out->AddFormatted(" ;; %s", RelocInfo::RelocModeName(rmode));
} else {
......
......@@ -373,8 +373,20 @@ constexpr int kNoSourcePosition = -1;
// This constant is used to indicate missing deoptimization information.
constexpr int kNoDeoptimizationId = -1;
// Deoptimize bailout kind.
enum class DeoptimizeKind : uint8_t { kEager, kSoft, kLazy };
// Deoptimize bailout kind:
// - Eager: a check failed in the optimized code and deoptimization happens
// immediately.
// - Lazy: the code has been marked as dependent on some assumption which
// is checked elsewhere and can trigger deoptimization the next time the
// code is executed.
// - Soft: similar to lazy deoptimization, but does not contribute to the
// total deopt count which can lead to disabling optimization for a function.
enum class DeoptimizeKind : uint8_t {
kEager,
kSoft,
kLazy,
kLastDeoptimizeKind = kLazy
};
inline size_t hash_value(DeoptimizeKind kind) {
return static_cast<size_t>(kind);
}
......
......@@ -72,7 +72,8 @@ void Deoptimizer::TableEntryGenerator::Generate() {
__ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
__ bind(&context_check);
__ mov(Operand(esp, 0 * kPointerSize), eax); // Function.
__ mov(Operand(esp, 1 * kPointerSize), Immediate(type())); // Bailout type.
__ mov(Operand(esp, 1 * kPointerSize),
Immediate(static_cast<int>(deopt_kind())));
__ mov(Operand(esp, 2 * kPointerSize), ebx); // Bailout id.
__ mov(Operand(esp, 3 * kPointerSize), ecx); // Code address or 0.
__ mov(Operand(esp, 4 * kPointerSize), edx); // Fp-to-sp delta.
......
......@@ -1045,7 +1045,7 @@ void Logger::SharedLibraryEvent(const std::string& library_path,
msg.WriteToLogFile();
}
void Logger::CodeDeoptEvent(Code* code, DeoptKind kind, Address pc,
void Logger::CodeDeoptEvent(Code* code, DeoptimizeKind kind, Address pc,
int fp_to_sp_delta) {
if (!log_->IsEnabled()) return;
Deoptimizer::DeoptInfo info = Deoptimizer::GetDeoptInfo(code, pc);
......@@ -1066,17 +1066,7 @@ void Logger::CodeDeoptEvent(Code* code, DeoptKind kind, Address pc,
deopt_location << "<unknown>";
}
msg << kNext << inlining_id << kNext << script_offset << kNext;
switch (kind) {
case kLazy:
msg << "lazy" << kNext;
break;
case kSoft:
msg << "soft" << kNext;
break;
case kEager:
msg << "eager" << kNext;
break;
}
msg << Deoptimizer::MessageFor(kind) << kNext;
msg << deopt_location.str().c_str() << kNext
<< DeoptimizeReasonToString(info.deopt_reason);
msg.WriteToLogFile();
......
......@@ -220,7 +220,7 @@ class Logger : public CodeEventListener {
void CodeNameEvent(Address addr, int pos, const char* code_name);
void CodeDeoptEvent(Code* code, DeoptKind kind, Address pc,
void CodeDeoptEvent(Code* code, DeoptimizeKind kind, Address pc,
int fp_to_sp_delta);
void ICEvent(const char* type, bool keyed, Map* map, Object* key,
......@@ -419,7 +419,7 @@ class CodeEventLogger : public CodeEventListener {
void SetterCallbackEvent(Name* name, Address entry_point) override {}
void SharedFunctionInfoMoveEvent(Address from, Address to) override {}
void CodeMovingGCEvent() override {}
void CodeDeoptEvent(Code* code, DeoptKind kind, Address pc,
void CodeDeoptEvent(Code* code, DeoptimizeKind kind, Address pc,
int fp_to_sp_delta) override {}
private:
......@@ -470,7 +470,7 @@ class ExternalCodeEventListener : public CodeEventListener {
void CodeDisableOptEvent(AbstractCode* code,
SharedFunctionInfo* shared) override {}
void CodeMovingGCEvent() override {}
void CodeDeoptEvent(Code* code, DeoptKind kind, Address pc,
void CodeDeoptEvent(Code* code, DeoptimizeKind kind, Address pc,
int fp_to_sp_delta) override {}
void StartListening(CodeEventHandler* code_event_handler);
......
......@@ -84,7 +84,7 @@ void Deoptimizer::TableEntryGenerator::Generate() {
__ JumpIfSmi(a1, &context_check);
__ lw(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
__ bind(&context_check);
__ li(a1, Operand(type())); // Bailout type.
__ li(a1, Operand(static_cast<int>(deopt_kind())));
// a2: bailout id already loaded.
// a3: code address or 0 already loaded.
__ sw(t0, CFunctionArgumentOperand(5)); // Fp-to-sp delta.
......
......@@ -84,7 +84,7 @@ void Deoptimizer::TableEntryGenerator::Generate() {
__ JumpIfSmi(a1, &context_check);
__ Ld(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
__ bind(&context_check);
__ li(a1, Operand(type())); // Bailout type.
__ li(a1, Operand(static_cast<int>(deopt_kind())));
// a2: bailout id already loaded.
// a3: code address or 0 already loaded.
// a4: already has fp-to-sp delta.
......
......@@ -83,7 +83,7 @@ void Deoptimizer::TableEntryGenerator::Generate() {
__ JumpIfSmi(r4, &context_check);
__ LoadP(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
__ bind(&context_check);
__ li(r4, Operand(type())); // bailout type,
__ li(r4, Operand(static_cast<int>(deopt_kind())));
// r5: bailout id already loaded.
// r6: code address or 0 already loaded.
// r7: Fp-to-sp delta.
......
......@@ -142,8 +142,8 @@ void ProfilerListener::CodeDisableOptEvent(AbstractCode* code,
DispatchCodeEvent(evt_rec);
}
void ProfilerListener::CodeDeoptEvent(Code* code, DeoptKind kind, Address pc,
int fp_to_sp_delta) {
void ProfilerListener::CodeDeoptEvent(Code* code, DeoptimizeKind kind,
Address pc, int fp_to_sp_delta) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_DEOPT);
CodeDeoptEventRecord* rec = &evt_rec.CodeDeoptEventRecord_;
Deoptimizer::DeoptInfo info = Deoptimizer::GetDeoptInfo(code, pc);
......
......@@ -47,7 +47,7 @@ class ProfilerListener : public CodeEventListener {
void CodeMoveEvent(AbstractCode* from, Address to) override;
void CodeDisableOptEvent(AbstractCode* code,
SharedFunctionInfo* shared) override;
void CodeDeoptEvent(Code* code, DeoptKind kind, Address pc,
void CodeDeoptEvent(Code* code, DeoptimizeKind kind, Address pc,
int fp_to_sp_delta) override;
void GetterCallbackEvent(Name* name, Address entry_point) override;
void RegExpCodeCreateEvent(AbstractCode* code, String* source) override;
......
......@@ -153,7 +153,7 @@ RUNTIME_FUNCTION(Runtime_NotifyDeoptimized) {
TimerEventScope<TimerEventDeoptimizeCode> timer(isolate);
TRACE_EVENT0("v8", "V8.DeoptimizeCode");
Handle<JSFunction> function = deoptimizer->function();
Deoptimizer::BailoutType type = deoptimizer->bailout_type();
DeoptimizeKind type = deoptimizer->deopt_kind();
// TODO(turbofan): We currently need the native context to materialize
// the arguments object, but only to get to its map.
......@@ -169,7 +169,7 @@ RUNTIME_FUNCTION(Runtime_NotifyDeoptimized) {
isolate->set_context(Context::cast(top_frame->context()));
// Invalidate the underlying optimized code on non-lazy deopts.
if (type != Deoptimizer::LAZY) {
if (type != DeoptimizeKind::kLazy) {
Deoptimizer::DeoptimizeFunction(*function);
}
......
......@@ -79,7 +79,7 @@ void Deoptimizer::TableEntryGenerator::Generate() {
__ JumpIfSmi(r3, &context_check);
__ LoadP(r2, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
__ bind(&context_check);
__ LoadImmP(r3, Operand(type())); // bailout type,
__ LoadImmP(r3, Operand(static_cast<int>(deopt_kind())));
// r4: bailout id already loaded.
// r5: code address or 0 already loaded.
// r6: Fp-to-sp delta.
......
......@@ -101,7 +101,7 @@ void Deoptimizer::TableEntryGenerator::Generate() {
__ movp(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
__ bind(&context_check);
__ movp(arg_reg_1, rax);
__ Set(arg_reg_2, type());
__ Set(arg_reg_2, static_cast<int>(deopt_kind()));
// Args 3 and 4 are already in the right registers.
// On windows put the arguments on the stack (PrepareCallCFunction
......
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