Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Unified Diff: src/a64/lithium-codegen-a64.cc

Issue 166343004: A64: Improve the deoptimization helpers to generate fewer instructions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merge DeoptimizeHeader into DeoptimizeBranch Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/a64/lithium-codegen-a64.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/a64/lithium-codegen-a64.cc
diff --git a/src/a64/lithium-codegen-a64.cc b/src/a64/lithium-codegen-a64.cc
index 033a439513672589c0727811ac25f47fd4d984a6..fe45ed8fe4acad18b8c2123129f97b355c80fd2d 100644
--- a/src/a64/lithium-codegen-a64.cc
+++ b/src/a64/lithium-codegen-a64.cc
@@ -960,22 +960,26 @@ void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() {
}
-Deoptimizer::BailoutType LCodeGen::DeoptimizeHeader(
+void LCodeGen::DeoptimizeBranch(
LEnvironment* environment,
+ BranchType branch_type, Register reg, int bit,
Deoptimizer::BailoutType* override_bailout_type) {
RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
+ Deoptimizer::BailoutType bailout_type =
+ info()->IsStub() ? Deoptimizer::LAZY : Deoptimizer::EAGER;
+
+ if (override_bailout_type != NULL) {
+ bailout_type = *override_bailout_type;
+ }
+
ASSERT(environment->HasBeenRegistered());
ASSERT(info()->IsOptimizing() || info()->IsStub());
int id = environment->deoptimization_index();
- Deoptimizer::BailoutType bailout_type =
- info()->IsStub() ? Deoptimizer::LAZY : Deoptimizer::EAGER;
- if (override_bailout_type) bailout_type = *override_bailout_type;
Address entry =
Deoptimizer::GetDeoptimizationEntry(isolate(), id, bailout_type);
if (entry == NULL) {
Abort(kBailoutWasNotPrepared);
- return bailout_type;
}
if (FLAG_deopt_every_n_times != 0 && !info()->IsStub()) {
@@ -1001,26 +1005,20 @@ Deoptimizer::BailoutType LCodeGen::DeoptimizeHeader(
__ Pop(x0, x1, x2);
}
- return bailout_type;
-}
-
-
-void LCodeGen::Deoptimize(LEnvironment* environment,
- Deoptimizer::BailoutType bailout_type) {
- ASSERT(environment->HasBeenRegistered());
- ASSERT(info()->IsOptimizing() || info()->IsStub());
- int id = environment->deoptimization_index();
- Address entry =
- Deoptimizer::GetDeoptimizationEntry(isolate(), id, bailout_type);
-
if (info()->ShouldTrapOnDeopt()) {
+ Label dont_trap;
+ __ B(&dont_trap, InvertBranchType(branch_type), reg, bit);
__ Debug("trap_on_deopt", __LINE__, BREAK);
+ __ Bind(&dont_trap);
}
ASSERT(info()->IsStub() || frame_is_built_);
// Go through jump table if we need to build frame, or restore caller doubles.
if (frame_is_built_ && !info()->saves_caller_doubles()) {
+ Label dont_deopt;
+ __ B(&dont_deopt, InvertBranchType(branch_type), reg, bit);
__ Call(entry, RelocInfo::RUNTIME_ENTRY);
+ __ Bind(&dont_deopt);
} else {
// We often have several deopts to the same entry, reuse the last
// jump entry if this is the case.
@@ -1033,82 +1031,58 @@ void LCodeGen::Deoptimize(LEnvironment* environment,
!frame_is_built_);
deopt_jump_table_.Add(table_entry, zone());
}
- __ B(&deopt_jump_table_.last().label);
+ __ B(&deopt_jump_table_.last().label,
+ branch_type, reg, bit);
}
}
-void LCodeGen::Deoptimize(LEnvironment* environment) {
- Deoptimizer::BailoutType bailout_type = DeoptimizeHeader(environment, NULL);
- Deoptimize(environment, bailout_type);
+void LCodeGen::Deoptimize(LEnvironment* environment,
+ Deoptimizer::BailoutType* override_bailout_type) {
+ DeoptimizeBranch(environment, always, NoReg, -1, override_bailout_type);
}
void LCodeGen::DeoptimizeIf(Condition cond, LEnvironment* environment) {
- Label dont_deopt;
- Deoptimizer::BailoutType bailout_type = DeoptimizeHeader(environment, NULL);
- __ B(InvertCondition(cond), &dont_deopt);
- Deoptimize(environment, bailout_type);
- __ Bind(&dont_deopt);
+ DeoptimizeBranch(environment, static_cast<BranchType>(cond));
}
void LCodeGen::DeoptimizeIfZero(Register rt, LEnvironment* environment) {
- Label dont_deopt;
- Deoptimizer::BailoutType bailout_type = DeoptimizeHeader(environment, NULL);
- __ Cbnz(rt, &dont_deopt);
- Deoptimize(environment, bailout_type);
- __ Bind(&dont_deopt);
+ DeoptimizeBranch(environment, reg_zero, rt);
}
void LCodeGen::DeoptimizeIfNegative(Register rt, LEnvironment* environment) {
- Label dont_deopt;
- Deoptimizer::BailoutType bailout_type = DeoptimizeHeader(environment, NULL);
- __ Tbz(rt, rt.Is64Bits() ? kXSignBit : kWSignBit, &dont_deopt);
- Deoptimize(environment, bailout_type);
- __ Bind(&dont_deopt);
+ int sign_bit = rt.Is64Bits() ? kXSignBit : kWSignBit;
+ DeoptimizeBranch(environment, reg_bit_set, rt, sign_bit);
}
void LCodeGen::DeoptimizeIfSmi(Register rt,
LEnvironment* environment) {
- Label dont_deopt;
- Deoptimizer::BailoutType bailout_type = DeoptimizeHeader(environment, NULL);
- __ JumpIfNotSmi(rt, &dont_deopt);
- Deoptimize(environment, bailout_type);
- __ Bind(&dont_deopt);
+ DeoptimizeBranch(environment, reg_bit_clear, rt, MaskToBit(kSmiTagMask));
}
void LCodeGen::DeoptimizeIfNotSmi(Register rt, LEnvironment* environment) {
- Label dont_deopt;
- Deoptimizer::BailoutType bailout_type = DeoptimizeHeader(environment, NULL);
- __ JumpIfSmi(rt, &dont_deopt);
- Deoptimize(environment, bailout_type);
- __ Bind(&dont_deopt);
+ DeoptimizeBranch(environment, reg_bit_set, rt, MaskToBit(kSmiTagMask));
}
void LCodeGen::DeoptimizeIfRoot(Register rt,
Heap::RootListIndex index,
LEnvironment* environment) {
- Label dont_deopt;
- Deoptimizer::BailoutType bailout_type = DeoptimizeHeader(environment, NULL);
- __ JumpIfNotRoot(rt, index, &dont_deopt);
- Deoptimize(environment, bailout_type);
- __ Bind(&dont_deopt);
+ __ CompareRoot(rt, index);
+ DeoptimizeIf(eq, environment);
}
void LCodeGen::DeoptimizeIfNotRoot(Register rt,
Heap::RootListIndex index,
LEnvironment* environment) {
- Label dont_deopt;
- Deoptimizer::BailoutType bailout_type = DeoptimizeHeader(environment, NULL);
- __ JumpIfRoot(rt, index, &dont_deopt);
- Deoptimize(environment, bailout_type);
- __ Bind(&dont_deopt);
+ __ CompareRoot(rt, index);
+ DeoptimizeIf(ne, environment);
}
@@ -2126,9 +2100,6 @@ void LCodeGen::DoCheckMaps(LCheckMaps* instr) {
void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) {
if (!instr->hydrogen()->value()->IsHeapObject()) {
- // TODO(all): Depending of how we chose to implement the deopt, if we could
- // guarantee that we have a deopt handler reachable by a tbz instruction,
- // we could use tbz here and produce less code to support this instruction.
DeoptimizeIfSmi(ToRegister(instr->value()), instr->environment());
}
}
@@ -2137,7 +2108,6 @@ void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) {
void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
Register value = ToRegister(instr->value());
ASSERT(!instr->result() || ToRegister(instr->result()).Is(value));
- // TODO(all): See DoCheckNonSmi for comments on use of tbz.
DeoptimizeIfNotSmi(value, instr->environment());
}
@@ -2577,8 +2547,7 @@ void LCodeGen::DoDeoptimize(LDeoptimize* instr) {
}
Comment(";;; deoptimize: %s", instr->hydrogen()->reason());
- DeoptimizeHeader(instr->environment(), &type);
- Deoptimize(instr->environment(), type);
+ Deoptimize(instr->environment(), &type);
}
« no previous file with comments | « src/a64/lithium-codegen-a64.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698