mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 02:37:53 +00:00
[vm/compiler] Remove PushArguments from ThrowInstr, ReThrowInstr
Issue: https://github.com/dart-lang/sdk/issues/39788 Change-Id: Ic47d3b57a35182162848df61495f8963afd55fc6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129321 Commit-Queue: Alexander Markov <alexmarkov@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
parent
2477378537
commit
ad12931304
|
@ -2769,27 +2769,19 @@ class NativeReturnInstr : public ReturnInstr {
|
|||
|
||||
typedef ZoneGrowableArray<PushArgumentInstr*> PushArgumentsArray;
|
||||
|
||||
class ThrowInstr : public TemplateInstruction<0, Throws> {
|
||||
class ThrowInstr : public TemplateInstruction<1, Throws> {
|
||||
public:
|
||||
enum { kNumArguments = 1 };
|
||||
|
||||
explicit ThrowInstr(TokenPosition token_pos,
|
||||
intptr_t deopt_id,
|
||||
PushArgumentsArray* arguments)
|
||||
: TemplateInstruction(deopt_id),
|
||||
token_pos_(token_pos),
|
||||
arguments_(arguments) {
|
||||
ASSERT(arguments_->length() == kNumArguments);
|
||||
Value* exception)
|
||||
: TemplateInstruction(deopt_id), token_pos_(token_pos) {
|
||||
SetInputAt(0, exception);
|
||||
}
|
||||
|
||||
DECLARE_INSTRUCTION(Throw)
|
||||
|
||||
virtual intptr_t ArgumentCount() const { return kNumArguments; }
|
||||
virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
|
||||
return (*arguments_)[index];
|
||||
}
|
||||
|
||||
virtual TokenPosition token_pos() const { return token_pos_; }
|
||||
Value* exception() const { return inputs_[0]; }
|
||||
|
||||
virtual bool ComputeCanDeoptimize() const { return !FLAG_precompiled_mode; }
|
||||
|
||||
|
@ -2797,35 +2789,32 @@ class ThrowInstr : public TemplateInstruction<0, Throws> {
|
|||
|
||||
private:
|
||||
const TokenPosition token_pos_;
|
||||
PushArgumentsArray* const arguments_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ThrowInstr);
|
||||
};
|
||||
|
||||
class ReThrowInstr : public TemplateInstruction<0, Throws> {
|
||||
class ReThrowInstr : public TemplateInstruction<2, Throws> {
|
||||
public:
|
||||
// 'catch_try_index' can be kInvalidTryIndex if the
|
||||
// rethrow has been artificially generated by the parser.
|
||||
ReThrowInstr(TokenPosition token_pos,
|
||||
intptr_t catch_try_index,
|
||||
intptr_t deopt_id,
|
||||
PushArgumentsArray* arguments)
|
||||
Value* exception,
|
||||
Value* stacktrace)
|
||||
: TemplateInstruction(deopt_id),
|
||||
token_pos_(token_pos),
|
||||
catch_try_index_(catch_try_index),
|
||||
arguments_(arguments) {
|
||||
ASSERT(arguments_->length() == 2);
|
||||
catch_try_index_(catch_try_index) {
|
||||
SetInputAt(0, exception);
|
||||
SetInputAt(1, stacktrace);
|
||||
}
|
||||
|
||||
DECLARE_INSTRUCTION(ReThrow)
|
||||
|
||||
virtual intptr_t ArgumentCount() const { return 2; }
|
||||
virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
|
||||
return (*arguments_)[index];
|
||||
}
|
||||
|
||||
virtual TokenPosition token_pos() const { return token_pos_; }
|
||||
intptr_t catch_try_index() const { return catch_try_index_; }
|
||||
Value* exception() const { return inputs_[0]; }
|
||||
Value* stacktrace() const { return inputs_[1]; }
|
||||
|
||||
virtual bool ComputeCanDeoptimize() const { return !FLAG_precompiled_mode; }
|
||||
|
||||
|
@ -2834,7 +2823,6 @@ class ReThrowInstr : public TemplateInstruction<0, Throws> {
|
|||
private:
|
||||
const TokenPosition token_pos_;
|
||||
const intptr_t catch_try_index_;
|
||||
PushArgumentsArray* const arguments_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ReThrowInstr);
|
||||
};
|
||||
|
|
|
@ -7157,21 +7157,38 @@ void BitCastInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
|||
}
|
||||
|
||||
LocationSummary* ThrowInstr::MakeLocationSummary(Zone* zone, bool opt) const {
|
||||
return new (zone) LocationSummary(zone, 0, 0, LocationSummary::kCall);
|
||||
const intptr_t kNumInputs = 1;
|
||||
const intptr_t kNumTemps = 0;
|
||||
LocationSummary* summary = new (zone)
|
||||
LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall);
|
||||
summary->set_in(0, Location::RegisterLocation(R0));
|
||||
return summary;
|
||||
}
|
||||
|
||||
void ThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
||||
const Register exception_reg = locs()->in(0).reg();
|
||||
__ Push(exception_reg);
|
||||
compiler->GenerateRuntimeCall(token_pos(), deopt_id(), kThrowRuntimeEntry, 1,
|
||||
locs());
|
||||
__ bkpt(0);
|
||||
}
|
||||
|
||||
LocationSummary* ReThrowInstr::MakeLocationSummary(Zone* zone, bool opt) const {
|
||||
return new (zone) LocationSummary(zone, 0, 0, LocationSummary::kCall);
|
||||
const intptr_t kNumInputs = 2;
|
||||
const intptr_t kNumTemps = 0;
|
||||
LocationSummary* summary = new (zone)
|
||||
LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall);
|
||||
summary->set_in(0, Location::RegisterLocation(R0));
|
||||
summary->set_in(1, Location::RegisterLocation(R1));
|
||||
return summary;
|
||||
}
|
||||
|
||||
void ReThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
||||
const Register exception_reg = locs()->in(0).reg();
|
||||
const Register stacktrace_reg = locs()->in(1).reg();
|
||||
compiler->SetNeedsStackTrace(catch_try_index());
|
||||
__ Push(exception_reg);
|
||||
__ Push(stacktrace_reg);
|
||||
compiler->GenerateRuntimeCall(token_pos(), deopt_id(), kReThrowRuntimeEntry,
|
||||
2, locs());
|
||||
__ bkpt(0);
|
||||
|
|
|
@ -6161,21 +6161,38 @@ void UnboxedWidthExtenderInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
|||
}
|
||||
|
||||
LocationSummary* ThrowInstr::MakeLocationSummary(Zone* zone, bool opt) const {
|
||||
return new (zone) LocationSummary(zone, 0, 0, LocationSummary::kCall);
|
||||
const intptr_t kNumInputs = 1;
|
||||
const intptr_t kNumTemps = 0;
|
||||
LocationSummary* summary = new (zone)
|
||||
LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall);
|
||||
summary->set_in(0, Location::RegisterLocation(R0));
|
||||
return summary;
|
||||
}
|
||||
|
||||
void ThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
||||
const Register exception_reg = locs()->in(0).reg();
|
||||
__ Push(exception_reg);
|
||||
compiler->GenerateRuntimeCall(token_pos(), deopt_id(), kThrowRuntimeEntry, 1,
|
||||
locs());
|
||||
__ brk(0);
|
||||
}
|
||||
|
||||
LocationSummary* ReThrowInstr::MakeLocationSummary(Zone* zone, bool opt) const {
|
||||
return new (zone) LocationSummary(zone, 0, 0, LocationSummary::kCall);
|
||||
const intptr_t kNumInputs = 2;
|
||||
const intptr_t kNumTemps = 0;
|
||||
LocationSummary* summary = new (zone)
|
||||
LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall);
|
||||
summary->set_in(0, Location::RegisterLocation(R0));
|
||||
summary->set_in(1, Location::RegisterLocation(R1));
|
||||
return summary;
|
||||
}
|
||||
|
||||
void ReThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
||||
const Register exception_reg = locs()->in(0).reg();
|
||||
const Register stacktrace_reg = locs()->in(1).reg();
|
||||
compiler->SetNeedsStackTrace(catch_try_index());
|
||||
__ Push(exception_reg);
|
||||
__ Push(stacktrace_reg);
|
||||
compiler->GenerateRuntimeCall(token_pos(), deopt_id(), kReThrowRuntimeEntry,
|
||||
2, locs());
|
||||
__ brk(0);
|
||||
|
|
|
@ -1294,10 +1294,9 @@ StrictCompareInstr* FlowGraphDeserializer::DeserializeStrictCompare(
|
|||
|
||||
ThrowInstr* FlowGraphDeserializer::DeserializeThrow(SExpList* sexp,
|
||||
const InstrInfo& info) {
|
||||
auto const arguments = FetchPushedArguments(sexp, ThrowInstr::kNumArguments);
|
||||
if (arguments == nullptr) return nullptr;
|
||||
|
||||
return new (zone()) ThrowInstr(info.token_pos, info.deopt_id, arguments);
|
||||
Value* exception = ParseValue(Retrieve(sexp, 1));
|
||||
if (exception == nullptr) return nullptr;
|
||||
return new (zone()) ThrowInstr(info.token_pos, info.deopt_id, exception);
|
||||
}
|
||||
|
||||
bool FlowGraphDeserializer::ParseCallInfo(SExpList* call, CallInfo* out) {
|
||||
|
|
|
@ -6317,21 +6317,38 @@ void UnboxedWidthExtenderInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
|||
}
|
||||
|
||||
LocationSummary* ThrowInstr::MakeLocationSummary(Zone* zone, bool opt) const {
|
||||
return new (zone) LocationSummary(zone, 0, 0, LocationSummary::kCall);
|
||||
const intptr_t kNumInputs = 1;
|
||||
const intptr_t kNumTemps = 0;
|
||||
LocationSummary* summary = new (zone)
|
||||
LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall);
|
||||
summary->set_in(0, Location::RegisterLocation(EAX));
|
||||
return summary;
|
||||
}
|
||||
|
||||
void ThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
||||
const Register exception_reg = locs()->in(0).reg();
|
||||
__ pushl(exception_reg);
|
||||
compiler->GenerateRuntimeCall(token_pos(), deopt_id(), kThrowRuntimeEntry, 1,
|
||||
locs());
|
||||
__ int3();
|
||||
}
|
||||
|
||||
LocationSummary* ReThrowInstr::MakeLocationSummary(Zone* zone, bool opt) const {
|
||||
return new (zone) LocationSummary(zone, 0, 0, LocationSummary::kCall);
|
||||
const intptr_t kNumInputs = 2;
|
||||
const intptr_t kNumTemps = 0;
|
||||
LocationSummary* summary = new (zone)
|
||||
LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall);
|
||||
summary->set_in(0, Location::RegisterLocation(EAX));
|
||||
summary->set_in(1, Location::RegisterLocation(EDX));
|
||||
return summary;
|
||||
}
|
||||
|
||||
void ReThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
||||
const Register exception_reg = locs()->in(0).reg();
|
||||
const Register stacktrace_reg = locs()->in(1).reg();
|
||||
compiler->SetNeedsStackTrace(catch_try_index());
|
||||
__ pushl(exception_reg);
|
||||
__ pushl(stacktrace_reg);
|
||||
compiler->GenerateRuntimeCall(token_pos(), deopt_id(), kReThrowRuntimeEntry,
|
||||
2, locs());
|
||||
__ int3();
|
||||
|
|
|
@ -6559,21 +6559,38 @@ void UnboxedWidthExtenderInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
|||
}
|
||||
|
||||
LocationSummary* ThrowInstr::MakeLocationSummary(Zone* zone, bool opt) const {
|
||||
return new (zone) LocationSummary(zone, 0, 0, LocationSummary::kCall);
|
||||
const intptr_t kNumInputs = 1;
|
||||
const intptr_t kNumTemps = 0;
|
||||
LocationSummary* summary = new (zone)
|
||||
LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall);
|
||||
summary->set_in(0, Location::RegisterLocation(RAX));
|
||||
return summary;
|
||||
}
|
||||
|
||||
void ThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
||||
const Register exception_reg = locs()->in(0).reg();
|
||||
__ pushq(exception_reg);
|
||||
compiler->GenerateRuntimeCall(token_pos(), deopt_id(), kThrowRuntimeEntry, 1,
|
||||
locs());
|
||||
__ int3();
|
||||
}
|
||||
|
||||
LocationSummary* ReThrowInstr::MakeLocationSummary(Zone* zone, bool opt) const {
|
||||
return new (zone) LocationSummary(zone, 0, 0, LocationSummary::kCall);
|
||||
const intptr_t kNumInputs = 2;
|
||||
const intptr_t kNumTemps = 0;
|
||||
LocationSummary* summary = new (zone)
|
||||
LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall);
|
||||
summary->set_in(0, Location::RegisterLocation(RAX));
|
||||
summary->set_in(1, Location::RegisterLocation(RDX));
|
||||
return summary;
|
||||
}
|
||||
|
||||
void ReThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
||||
const Register exception_reg = locs()->in(0).reg();
|
||||
const Register stacktrace_reg = locs()->in(1).reg();
|
||||
compiler->SetNeedsStackTrace(catch_try_index());
|
||||
__ pushq(exception_reg);
|
||||
__ pushq(stacktrace_reg);
|
||||
compiler->GenerateRuntimeCall(token_pos(), deopt_id(), kReThrowRuntimeEntry,
|
||||
2, locs());
|
||||
__ int3();
|
||||
|
|
|
@ -1692,19 +1692,19 @@ void BytecodeFlowGraphBuilder::BuildThrow() {
|
|||
|
||||
if (DecodeOperandA().value() == 0) {
|
||||
// throw
|
||||
const intptr_t kNumArguments = 1;
|
||||
LoadStackSlots(kNumArguments);
|
||||
ArgumentArray arguments = GetArguments(kNumArguments);
|
||||
LoadStackSlots(1);
|
||||
Value* exception = Pop();
|
||||
code_ +=
|
||||
Fragment(new (Z) ThrowInstr(position_, B->GetNextDeoptId(), arguments))
|
||||
Fragment(new (Z) ThrowInstr(position_, B->GetNextDeoptId(), exception))
|
||||
.closed();
|
||||
} else {
|
||||
// rethrow
|
||||
const intptr_t kNumArguments = 2;
|
||||
LoadStackSlots(kNumArguments);
|
||||
ArgumentArray arguments = GetArguments(kNumArguments);
|
||||
LoadStackSlots(2);
|
||||
Value* stacktrace = Pop();
|
||||
Value* exception = Pop();
|
||||
code_ += Fragment(new (Z) ReThrowInstr(position_, kInvalidTryIndex,
|
||||
B->GetNextDeoptId(), arguments))
|
||||
B->GetNextDeoptId(), exception,
|
||||
stacktrace))
|
||||
.closed();
|
||||
}
|
||||
|
||||
|
|
|
@ -3740,9 +3740,7 @@ Fragment StreamingFlowGraphBuilder::BuildRethrow(TokenPosition* p) {
|
|||
|
||||
Fragment instructions = DebugStepCheck(position);
|
||||
instructions += LoadLocal(catch_block()->exception_var());
|
||||
instructions += PushArgument();
|
||||
instructions += LoadLocal(catch_block()->stack_trace_var());
|
||||
instructions += PushArgument();
|
||||
instructions += RethrowException(position, catch_block()->catch_try_index());
|
||||
|
||||
return instructions;
|
||||
|
@ -3759,7 +3757,6 @@ Fragment StreamingFlowGraphBuilder::BuildThrow(TokenPosition* p) {
|
|||
if (NeedsDebugStepCheck(stack(), position)) {
|
||||
instructions = DebugStepCheck(position) + instructions;
|
||||
}
|
||||
instructions += PushArgument();
|
||||
instructions += ThrowException(position);
|
||||
ASSERT(instructions.is_closed());
|
||||
|
||||
|
@ -4180,7 +4177,6 @@ Fragment StreamingFlowGraphBuilder::BuildAssertStatement() {
|
|||
// paren, not the beginning of 'assert'.
|
||||
otherwise_fragment +=
|
||||
StaticCall(condition_start_offset, target, 3, ICData::kStatic);
|
||||
otherwise_fragment += PushArgument();
|
||||
otherwise_fragment += ThrowException(TokenPosition::kNoSource);
|
||||
otherwise_fragment += Drop();
|
||||
|
||||
|
@ -4516,7 +4512,6 @@ Fragment StreamingFlowGraphBuilder::BuildSwitchStatement() {
|
|||
body_fragment += Drop();
|
||||
|
||||
// Throw the exception
|
||||
body_fragment += PushArgument();
|
||||
body_fragment += ThrowException(TokenPosition::kNoSource);
|
||||
body_fragment += Drop();
|
||||
}
|
||||
|
@ -4836,9 +4831,7 @@ Fragment StreamingFlowGraphBuilder::BuildTryCatch() {
|
|||
// handler).
|
||||
if (catch_body.is_open()) {
|
||||
catch_body += LoadLocal(CurrentException());
|
||||
catch_body += PushArgument();
|
||||
catch_body += LoadLocal(CurrentStackTrace());
|
||||
catch_body += PushArgument();
|
||||
catch_body += RethrowException(TokenPosition::kNoSource, try_handler_index);
|
||||
Drop();
|
||||
}
|
||||
|
@ -4921,9 +4914,7 @@ Fragment StreamingFlowGraphBuilder::BuildTryFinally() {
|
|||
finally_body += BuildStatement(); // read finalizer
|
||||
if (finally_body.is_open()) {
|
||||
finally_body += LoadLocal(CurrentException());
|
||||
finally_body += PushArgument();
|
||||
finally_body += LoadLocal(CurrentStackTrace());
|
||||
finally_body += PushArgument();
|
||||
finally_body +=
|
||||
RethrowException(TokenPosition::kNoSource, try_handler_index);
|
||||
Drop();
|
||||
|
@ -4999,9 +4990,7 @@ Fragment StreamingFlowGraphBuilder::BuildYieldStatement() {
|
|||
|
||||
Fragment rethrow(error);
|
||||
rethrow += LoadLocal(exception_var);
|
||||
rethrow += PushArgument();
|
||||
rethrow += LoadLocal(stack_trace_var);
|
||||
rethrow += PushArgument();
|
||||
rethrow += RethrowException(position, kInvalidTryIndex);
|
||||
Drop();
|
||||
|
||||
|
|
|
@ -387,10 +387,9 @@ Fragment FlowGraphBuilder::FfiCall(
|
|||
|
||||
Fragment FlowGraphBuilder::ThrowException(TokenPosition position) {
|
||||
Fragment instructions;
|
||||
const intptr_t kNumArguments = 1;
|
||||
ArgumentArray arguments = GetArguments(kNumArguments);
|
||||
Value* exception = Pop();
|
||||
instructions +=
|
||||
Fragment(new (Z) ThrowInstr(position, GetNextDeoptId(), arguments))
|
||||
Fragment(new (Z) ThrowInstr(position, GetNextDeoptId(), exception))
|
||||
.closed();
|
||||
// Use it's side effect of leaving a constant on the stack (does not change
|
||||
// the graph).
|
||||
|
@ -402,11 +401,12 @@ Fragment FlowGraphBuilder::ThrowException(TokenPosition position) {
|
|||
Fragment FlowGraphBuilder::RethrowException(TokenPosition position,
|
||||
int catch_try_index) {
|
||||
Fragment instructions;
|
||||
const intptr_t kNumArguments = 2;
|
||||
ArgumentArray arguments = GetArguments(kNumArguments);
|
||||
instructions += Fragment(new (Z) ReThrowInstr(position, catch_try_index,
|
||||
GetNextDeoptId(), arguments))
|
||||
.closed();
|
||||
Value* stacktrace = Pop();
|
||||
Value* exception = Pop();
|
||||
instructions +=
|
||||
Fragment(new (Z) ReThrowInstr(position, catch_try_index, GetNextDeoptId(),
|
||||
exception, stacktrace))
|
||||
.closed();
|
||||
// Use it's side effect of leaving a constant on the stack (does not change
|
||||
// the graph).
|
||||
NullConstant();
|
||||
|
@ -748,7 +748,6 @@ Fragment FlowGraphBuilder::ThrowTypeError() {
|
|||
instructions += Drop();
|
||||
|
||||
// Throw the exception
|
||||
instructions += PushArgument();
|
||||
instructions += ThrowException(TokenPosition::kNoSource);
|
||||
|
||||
return instructions;
|
||||
|
|
Loading…
Reference in a new issue