[VM runtime] Introduce a DeoptIdScope class to safely save/restore deoptid.
Change-Id: I5debdd2accd9735ddabd3862165f3d04824b8247 Reviewed-on: https://dart-review.googlesource.com/71740 Commit-Queue: Régis Crelier <regis@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
9e365c811e
commit
11d986a03e
@@ -2832,8 +2832,7 @@ bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
|
||||
true, FLAG_max_speculative_inlining_attempts);
|
||||
|
||||
while (!done) {
|
||||
const intptr_t prev_deopt_id = thread()->deopt_id();
|
||||
thread()->set_deopt_id(0);
|
||||
DeoptIdScope deopt_id_scope(thread(), 0);
|
||||
LongJumpScope jump;
|
||||
const intptr_t val = setjmp(*jump.Set());
|
||||
if (val == 0) {
|
||||
@@ -2979,8 +2978,6 @@ bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
|
||||
}
|
||||
is_compiled = false;
|
||||
}
|
||||
// Reset global isolate state.
|
||||
thread()->set_deopt_id(prev_deopt_id);
|
||||
}
|
||||
return is_compiled;
|
||||
}
|
||||
|
||||
@@ -755,6 +755,21 @@ class CallTargets : public Cids {
|
||||
void MergeIntoRanges();
|
||||
};
|
||||
|
||||
class DeoptIdScope : public StackResource {
|
||||
public:
|
||||
DeoptIdScope(Thread* thread, intptr_t deopt_id)
|
||||
: StackResource(thread), prev_deopt_id_(thread->deopt_id()) {
|
||||
thread->set_deopt_id(deopt_id);
|
||||
}
|
||||
|
||||
~DeoptIdScope() { thread()->set_deopt_id(prev_deopt_id_); }
|
||||
|
||||
private:
|
||||
const intptr_t prev_deopt_id_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(DeoptIdScope);
|
||||
};
|
||||
|
||||
class Instruction : public ZoneAllocated {
|
||||
public:
|
||||
#define DECLARE_TAG(type, attrs) k##type,
|
||||
|
||||
@@ -908,11 +908,11 @@ class CallSiteInliner : public ValueObject {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Save and clear deopt id.
|
||||
const intptr_t prev_deopt_id = thread()->deopt_id();
|
||||
thread()->set_deopt_id(0);
|
||||
Error& error = Error::Handle();
|
||||
{
|
||||
// Save and clear deopt id.
|
||||
DeoptIdScope deopt_id_scope(thread(), 0);
|
||||
|
||||
// Install bailout jump.
|
||||
LongJumpScope jump;
|
||||
if (setjmp(*jump.Set()) == 0) {
|
||||
@@ -1162,7 +1162,6 @@ class CallSiteInliner : public ValueObject {
|
||||
(size > FLAG_inlining_constant_arguments_max_size_threshold)) {
|
||||
function.set_is_inlinable(false);
|
||||
}
|
||||
thread()->set_deopt_id(prev_deopt_id);
|
||||
TRACE_INLINING(
|
||||
THR_Print(" Bailout: heuristics (%s) with "
|
||||
"code size: %" Pd ", "
|
||||
@@ -1193,7 +1192,6 @@ class CallSiteInliner : public ValueObject {
|
||||
if (is_recursive_call) {
|
||||
inlined_recursive_call_ = true;
|
||||
}
|
||||
thread()->set_deopt_id(prev_deopt_id);
|
||||
|
||||
call_data->callee_graph = callee_graph;
|
||||
call_data->parameter_stubs = param_stubs;
|
||||
@@ -1233,7 +1231,6 @@ class CallSiteInliner : public ValueObject {
|
||||
if (error.raw() == Object::background_compilation_error().raw()) {
|
||||
// Fall through to exit the compilation, and retry it later.
|
||||
} else {
|
||||
thread()->set_deopt_id(prev_deopt_id);
|
||||
TRACE_INLINING(
|
||||
THR_Print(" Bailout: %s\n", error.ToErrorCString()));
|
||||
PRINT_INLINING_TREE("Bailout", &call_data->caller, &function, call);
|
||||
|
||||
@@ -788,8 +788,7 @@ RawCode* CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
|
||||
Code* volatile result = &Code::ZoneHandle(zone);
|
||||
while (!done) {
|
||||
*result = Code::null();
|
||||
const intptr_t prev_deopt_id = thread()->deopt_id();
|
||||
thread()->set_deopt_id(0);
|
||||
DeoptIdScope deopt_id_scope(thread(), 0);
|
||||
LongJumpScope jump;
|
||||
if (setjmp(*jump.Set()) == 0) {
|
||||
FlowGraph* flow_graph = nullptr;
|
||||
@@ -847,9 +846,6 @@ RawCode* CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
|
||||
#if defined(DART_USE_INTERPRETER)
|
||||
// TODO(regis): Revisit.
|
||||
if (flow_graph == NULL && function.HasBytecode()) {
|
||||
// Reset global isolate state.
|
||||
thread()->set_deopt_id(prev_deopt_id);
|
||||
|
||||
return Code::null();
|
||||
}
|
||||
#endif
|
||||
@@ -971,8 +967,6 @@ RawCode* CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
|
||||
thread()->clear_sticky_error();
|
||||
}
|
||||
}
|
||||
// Reset global isolate state.
|
||||
thread()->set_deopt_id(prev_deopt_id);
|
||||
}
|
||||
return result->raw();
|
||||
}
|
||||
@@ -1369,8 +1363,7 @@ void Compiler::ComputeLocalVarDescriptors(const Code& code) {
|
||||
ASSERT(!function.IsIrregexpFunction());
|
||||
// In background compilation, parser can produce 'errors": bailouts
|
||||
// if state changed while compiling in background.
|
||||
const intptr_t prev_deopt_id = Thread::Current()->deopt_id();
|
||||
Thread::Current()->set_deopt_id(0);
|
||||
DeoptIdScope deopt_id_scope(Thread::Current(), 0);
|
||||
LongJumpScope jump;
|
||||
if (setjmp(*jump.Set()) == 0) {
|
||||
ZoneGrowableArray<const ICData*>* ic_data_array =
|
||||
@@ -1402,7 +1395,6 @@ void Compiler::ComputeLocalVarDescriptors(const Code& code) {
|
||||
// Only possible with background compilation.
|
||||
ASSERT(Compiler::IsBackgroundCompilation());
|
||||
}
|
||||
Thread::Current()->set_deopt_id(prev_deopt_id);
|
||||
}
|
||||
|
||||
RawError* Compiler::CompileAllFunctions(const Class& cls) {
|
||||
|
||||
Reference in New Issue
Block a user