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);
......
This diff is collapsed.
......@@ -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