Commit 0bc811e9 authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[deoptimizer] Use consistent terms for the bytecode offset

The bytecode offset (previously 'bailout id') was referred to as 'ast
id', 'node id', 'bailout id' in different spots. And 'bailout id' was
used to refer to deoptimization exits. This CL makes used terms more
consistent.

Bug: v8:11332
Change-Id: I2b34c7d4ebf465939e18fdfba675d83852f2430a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2639756
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72190}
parent 727d22be
...@@ -158,7 +158,7 @@ class CompilerTracer : public AllStatic { ...@@ -158,7 +158,7 @@ class CompilerTracer : public AllStatic {
CodeTracer::Scope scope(isolate->GetCodeTracer()); CodeTracer::Scope scope(isolate->GetCodeTracer());
PrintTracePrefix(scope, "found optimized code for", function, code_kind); PrintTracePrefix(scope, "found optimized code for", function, code_kind);
if (!osr_offset.IsNone()) { if (!osr_offset.IsNone()) {
PrintF(scope.file(), " at OSR AST id %d", osr_offset.ToInt()); PrintF(scope.file(), " at OSR bytecode offset %d", osr_offset.ToInt());
} }
PrintTraceSuffix(scope); PrintTraceSuffix(scope);
} }
......
This diff is collapsed.
...@@ -185,7 +185,7 @@ class TranslatedFrame { ...@@ -185,7 +185,7 @@ class TranslatedFrame {
int GetValueCount(); int GetValueCount();
Kind kind() const { return kind_; } Kind kind() const { return kind_; }
BytecodeOffset node_id() const { return node_id_; } BytecodeOffset bytecode_offset() const { return bytecode_offset_; }
Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
// TODO(jgruber): Simplify/clarify the semantics of this field. The name // TODO(jgruber): Simplify/clarify the semantics of this field. The name
...@@ -293,7 +293,7 @@ class TranslatedFrame { ...@@ -293,7 +293,7 @@ class TranslatedFrame {
int height = 0, int return_value_offset = 0, int height = 0, int return_value_offset = 0,
int return_value_count = 0) int return_value_count = 0)
: kind_(kind), : kind_(kind),
node_id_(BytecodeOffset::None()), bytecode_offset_(BytecodeOffset::None()),
raw_shared_info_(shared_info), raw_shared_info_(shared_info),
height_(height), height_(height),
return_value_offset_(return_value_offset), return_value_offset_(return_value_offset),
...@@ -304,7 +304,7 @@ class TranslatedFrame { ...@@ -304,7 +304,7 @@ class TranslatedFrame {
void Handlify(); void Handlify();
Kind kind_; Kind kind_;
BytecodeOffset node_id_; BytecodeOffset bytecode_offset_;
SharedFunctionInfo raw_shared_info_; SharedFunctionInfo raw_shared_info_;
Handle<SharedFunctionInfo> shared_info_; Handle<SharedFunctionInfo> shared_info_;
int height_; int height_;
...@@ -442,12 +442,6 @@ class TranslatedState { ...@@ -442,12 +442,6 @@ class TranslatedState {
FeedbackSlot feedback_slot_; FeedbackSlot feedback_slot_;
}; };
class OptimizedFunctionVisitor {
public:
virtual ~OptimizedFunctionVisitor() = default;
virtual void VisitFunction(JSFunction function) = 0;
};
class Deoptimizer : public Malloced { class Deoptimizer : public Malloced {
public: public:
struct DeoptInfo { struct DeoptInfo {
...@@ -464,9 +458,9 @@ class Deoptimizer : public Malloced { ...@@ -464,9 +458,9 @@ class Deoptimizer : public Malloced {
static DeoptInfo GetDeoptInfo(Code code, Address from); static DeoptInfo GetDeoptInfo(Code code, Address from);
static int ComputeSourcePositionFromBytecodeArray(Isolate* isolate, static int ComputeSourcePositionFromBytecodeArray(
SharedFunctionInfo shared, Isolate* isolate, SharedFunctionInfo shared,
BytecodeOffset node_id); BytecodeOffset bytecode_offset);
static const char* MessageFor(DeoptimizeKind kind, bool reuse_code); static const char* MessageFor(DeoptimizeKind kind, bool reuse_code);
...@@ -482,8 +476,8 @@ class Deoptimizer : public Malloced { ...@@ -482,8 +476,8 @@ class Deoptimizer : public Malloced {
bool should_reuse_code() const; bool should_reuse_code() const;
static Deoptimizer* New(Address raw_function, DeoptimizeKind kind, static Deoptimizer* New(Address raw_function, DeoptimizeKind kind,
unsigned bailout_id, Address from, int fp_to_sp_delta, unsigned deopt_exit_index, Address from,
Isolate* isolate); int fp_to_sp_delta, Isolate* isolate);
static Deoptimizer* Grab(Isolate* isolate); static Deoptimizer* Grab(Isolate* isolate);
// The returned object with information on the optimized frame needs to be // The returned object with information on the optimized frame needs to be
...@@ -549,9 +543,10 @@ class Deoptimizer : public Malloced { ...@@ -549,9 +543,10 @@ class Deoptimizer : public Malloced {
static constexpr int kMaxNumberOfEntries = 16384; static constexpr int kMaxNumberOfEntries = 16384;
// This marker is passed to Deoptimizer::New as {bailout_id} on platforms // This marker is passed to Deoptimizer::New as {deopt_exit_index} on
// that have fixed deopt sizes (see also kSupportsFixedDeoptExitSizes). The // platforms that have fixed deopt sizes (see also
// actual deoptimization id is then calculated from the return address. // kSupportsFixedDeoptExitSizes). The actual deoptimization id is then
// calculated from the return address.
static constexpr unsigned kFixedExitSizeMarker = kMaxUInt32; static constexpr unsigned kFixedExitSizeMarker = kMaxUInt32;
// Set to true when the architecture supports deoptimization exit sequences // Set to true when the architecture supports deoptimization exit sequences
...@@ -581,7 +576,7 @@ class Deoptimizer : public Malloced { ...@@ -581,7 +576,7 @@ class Deoptimizer : public Malloced {
const TranslatedFrame::iterator& iterator); const TranslatedFrame::iterator& iterator);
Deoptimizer(Isolate* isolate, JSFunction function, DeoptimizeKind kind, Deoptimizer(Isolate* isolate, JSFunction function, DeoptimizeKind kind,
unsigned bailout_id, Address from, int fp_to_sp_delta); unsigned deopt_exit_index, Address from, int fp_to_sp_delta);
Code FindOptimizedCode(); Code FindOptimizedCode();
void DeleteFrameDescriptions(); void DeleteFrameDescriptions();
...@@ -607,7 +602,6 @@ class Deoptimizer : public Malloced { ...@@ -607,7 +602,6 @@ class Deoptimizer : public Malloced {
unsigned ComputeInputFrameSize() const; unsigned ComputeInputFrameSize() const;
static unsigned ComputeIncomingArgumentSize(SharedFunctionInfo shared); static unsigned ComputeIncomingArgumentSize(SharedFunctionInfo shared);
static unsigned ComputeOutgoingArgumentSize(Code code, unsigned bailout_id);
static void MarkAllCodeForContext(NativeContext native_context); static void MarkAllCodeForContext(NativeContext native_context);
static void DeoptimizeMarkedCodeForContext(NativeContext native_context); static void DeoptimizeMarkedCodeForContext(NativeContext native_context);
...@@ -625,7 +619,7 @@ class Deoptimizer : public Malloced { ...@@ -625,7 +619,7 @@ class Deoptimizer : public Malloced {
CodeTracer::Scope* verbose_trace_scope() const { CodeTracer::Scope* verbose_trace_scope() const {
return FLAG_trace_deopt_verbose ? trace_scope() : nullptr; return FLAG_trace_deopt_verbose ? trace_scope() : nullptr;
} }
void TraceDeoptBegin(int optimization_id, int node_id); void TraceDeoptBegin(int optimization_id, BytecodeOffset bytecode_offset);
void TraceDeoptEnd(double deopt_duration); void TraceDeoptEnd(double deopt_duration);
#ifdef DEBUG #ifdef DEBUG
static void TraceFoundActivation(Isolate* isolate, JSFunction function); static void TraceFoundActivation(Isolate* isolate, JSFunction function);
...@@ -636,7 +630,7 @@ class Deoptimizer : public Malloced { ...@@ -636,7 +630,7 @@ class Deoptimizer : public Malloced {
Isolate* isolate_; Isolate* isolate_;
JSFunction function_; JSFunction function_;
Code compiled_code_; Code compiled_code_;
unsigned bailout_id_; unsigned deopt_exit_index_;
DeoptimizeKind deopt_kind_; DeoptimizeKind deopt_kind_;
Address from_; Address from_;
int fp_to_sp_delta_; int fp_to_sp_delta_;
......
...@@ -1551,13 +1551,13 @@ void OptimizedFrame::Summarize(std::vector<FrameSummary>* frames) const { ...@@ -1551,13 +1551,13 @@ void OptimizedFrame::Summarize(std::vector<FrameSummary>* frames) const {
it->kind() == it->kind() ==
TranslatedFrame::kJavaScriptBuiltinContinuationWithCatch) { TranslatedFrame::kJavaScriptBuiltinContinuationWithCatch) {
code_offset = 0; code_offset = 0;
abstract_code = abstract_code = handle(
handle(AbstractCode::cast(isolate()->builtins()->builtin( AbstractCode::cast(isolate()->builtins()->builtin(
Builtins::GetBuiltinFromBytecodeOffset(it->node_id()))), Builtins::GetBuiltinFromBytecodeOffset(it->bytecode_offset()))),
isolate()); isolate());
} else { } else {
DCHECK_EQ(it->kind(), TranslatedFrame::kInterpretedFunction); DCHECK_EQ(it->kind(), TranslatedFrame::kInterpretedFunction);
code_offset = it->node_id().ToInt(); // Points to current bytecode. code_offset = it->bytecode_offset().ToInt();
abstract_code = abstract_code =
handle(shared_info->abstract_code(isolate()), isolate()); handle(shared_info->abstract_code(isolate()), isolate());
} }
......
...@@ -322,8 +322,8 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { ...@@ -322,8 +322,8 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) {
// Determine the entry point for which this OSR request has been fired and // Determine the entry point for which this OSR request has been fired and
// also disarm all back edges in the calling code to stop new requests. // also disarm all back edges in the calling code to stop new requests.
BytecodeOffset ast_id = DetermineEntryAndDisarmOSRForInterpreter(frame); BytecodeOffset osr_offset = DetermineEntryAndDisarmOSRForInterpreter(frame);
DCHECK(!ast_id.IsNone()); DCHECK(!osr_offset.IsNone());
MaybeHandle<Code> maybe_result; MaybeHandle<Code> maybe_result;
Handle<JSFunction> function(frame->function(), isolate); Handle<JSFunction> function(frame->function(), isolate);
...@@ -332,9 +332,10 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { ...@@ -332,9 +332,10 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) {
CodeTracer::Scope scope(isolate->GetCodeTracer()); CodeTracer::Scope scope(isolate->GetCodeTracer());
PrintF(scope.file(), "[OSR - Compiling: "); PrintF(scope.file(), "[OSR - Compiling: ");
function->PrintName(scope.file()); function->PrintName(scope.file());
PrintF(scope.file(), " at AST id %d]\n", ast_id.ToInt()); PrintF(scope.file(), " at OSR bytecode offset %d]\n", osr_offset.ToInt());
} }
maybe_result = Compiler::GetOptimizedCodeForOSR(function, ast_id, frame); maybe_result =
Compiler::GetOptimizedCodeForOSR(function, osr_offset, frame);
// Possibly compile for NCI caching. // Possibly compile for NCI caching.
if (!MaybeSpawnNativeContextIndependentCompilationJob( if (!MaybeSpawnNativeContextIndependentCompilationJob(
...@@ -353,12 +354,13 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { ...@@ -353,12 +354,13 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) {
DeoptimizationData::cast(result->deoptimization_data()); DeoptimizationData::cast(result->deoptimization_data());
if (data.OsrPcOffset().value() >= 0) { if (data.OsrPcOffset().value() >= 0) {
DCHECK(BytecodeOffset(data.OsrBytecodeOffset().value()) == ast_id); DCHECK(BytecodeOffset(data.OsrBytecodeOffset().value()) == osr_offset);
if (FLAG_trace_osr) { if (FLAG_trace_osr) {
CodeTracer::Scope scope(isolate->GetCodeTracer()); CodeTracer::Scope scope(isolate->GetCodeTracer());
PrintF(scope.file(), PrintF(scope.file(),
"[OSR - Entry at AST id %d, offset %d in optimized code]\n", "[OSR - Entry at OSR bytecode offset %d, offset %d in optimized "
ast_id.ToInt(), data.OsrPcOffset().value()); "code]\n",
osr_offset.ToInt(), data.OsrPcOffset().value());
} }
DCHECK(result->is_turbofanned()); DCHECK(result->is_turbofanned());
...@@ -402,7 +404,7 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { ...@@ -402,7 +404,7 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) {
CodeTracer::Scope scope(isolate->GetCodeTracer()); CodeTracer::Scope scope(isolate->GetCodeTracer());
PrintF(scope.file(), "[OSR - Failed: "); PrintF(scope.file(), "[OSR - Failed: ");
function->PrintName(scope.file()); function->PrintName(scope.file());
PrintF(scope.file(), " at AST id %d]\n", ast_id.ToInt()); PrintF(scope.file(), " at OSR bytecode offset %d]\n", osr_offset.ToInt());
} }
if (!function->HasAttachedOptimizedCode()) { if (!function->HasAttachedOptimizedCode()) {
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This tests that we do not share optimized code across closures that // This tests that we do not share optimized code across closures that were
// were optimized using OSR (for a particular OSR entry AST id) even if // optimized using OSR (for a particular OSR entry bytecode offset) even if
// caching of optimized code kicks in. // caching of optimized code kicks in.
function makeClosure() { function makeClosure() {
......
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