Commit a56d6169 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[compiler] Remove obsolete {CompilationInfo::mode}.

This makes compilation mode predicates delegate to the underlying code
kind that is already stored in each {CompilationInfo}, thereby removing
potential ambiguity between these two values.

R=mvstanton@chromium.org

Change-Id: I9f4d1bb723074488cc47bdc275984b1abc960069
Reviewed-on: https://chromium-review.googlesource.com/916195Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51291}
parent 97a26546
......@@ -16,12 +16,9 @@
namespace v8 {
namespace internal {
// TODO(mvstanton): the Code::OPTIMIZED_FUNCTION constant below is
// bogus, it's just that I've eliminated Code::FUNCTION and there isn't
// a "better" value to put in this place.
CompilationInfo::CompilationInfo(Zone* zone, ParseInfo* parse_info,
FunctionLiteral* literal)
: CompilationInfo({}, Code::OPTIMIZED_FUNCTION, BASE, zone) {
: CompilationInfo({}, AbstractCode::INTERPRETED_FUNCTION, zone) {
// NOTE: The parse_info passed here represents the global information gathered
// during parsing, but does not represent specific details of the actual
// function literal being compiled for this CompilationInfo. As such,
......@@ -39,7 +36,7 @@ CompilationInfo::CompilationInfo(Zone* zone, ParseInfo* parse_info,
CompilationInfo::CompilationInfo(Zone* zone, Isolate* isolate,
Handle<SharedFunctionInfo> shared,
Handle<JSFunction> closure)
: CompilationInfo({}, Code::OPTIMIZED_FUNCTION, OPTIMIZE, zone) {
: CompilationInfo({}, AbstractCode::OPTIMIZED_FUNCTION, zone) {
shared_info_ = shared;
closure_ = closure;
optimization_id_ = isolate->NextOptimizationId();
......@@ -59,21 +56,21 @@ CompilationInfo::CompilationInfo(Zone* zone, Isolate* isolate,
CompilationInfo::CompilationInfo(Vector<const char> debug_name, Zone* zone,
Code::Kind code_kind)
: CompilationInfo(debug_name, code_kind, STUB, zone) {
: CompilationInfo(debug_name, static_cast<AbstractCode::Kind>(code_kind),
zone) {
if (code_kind == Code::BYTECODE_HANDLER && has_untrusted_code_mitigations()) {
SetFlag(CompilationInfo::kGenerateSpeculationPoison);
}
}
CompilationInfo::CompilationInfo(Vector<const char> debug_name,
Code::Kind code_kind, Mode mode, Zone* zone)
AbstractCode::Kind code_kind, Zone* zone)
: literal_(nullptr),
source_range_map_(nullptr),
flags_(FLAG_untrusted_code_mitigations ? kUntrustedCodeMitigations : 0),
code_kind_(code_kind),
stub_key_(0),
builtin_index_(Builtins::kNoBuiltinId),
mode_(mode),
osr_offset_(BailoutId::None()),
feedback_vector_spec_(zone),
zone_(zone),
......
......@@ -102,7 +102,11 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
bool has_shared_info() const { return !shared_info().is_null(); }
Handle<JSFunction> closure() const { return closure_; }
Handle<Code> code() const { return code_; }
Code::Kind code_kind() const { return code_kind_; }
AbstractCode::Kind abstract_code_kind() const { return code_kind_; }
Code::Kind code_kind() const {
DCHECK(code_kind_ < static_cast<AbstractCode::Kind>(Code::NUMBER_OF_KINDS));
return static_cast<Code::Kind>(code_kind_);
}
uint32_t stub_key() const { return stub_key_; }
void set_stub_key(uint32_t stub_key) { stub_key_ = stub_key; }
int32_t builtin_index() const { return builtin_index_; }
......@@ -203,9 +207,17 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
JSGlobalObject* global_object() const;
// Accessors for the different compilation modes.
bool IsOptimizing() const { return mode_ == OPTIMIZE; }
bool IsStub() const { return mode_ == STUB; }
bool IsWasm() const { return code_kind() == Code::WASM_FUNCTION; }
bool IsOptimizing() const {
return abstract_code_kind() == AbstractCode::OPTIMIZED_FUNCTION;
}
bool IsWasm() const {
return abstract_code_kind() == AbstractCode::WASM_FUNCTION;
}
bool IsStub() const {
return abstract_code_kind() != AbstractCode::OPTIMIZED_FUNCTION &&
abstract_code_kind() != AbstractCode::WASM_FUNCTION &&
abstract_code_kind() != AbstractCode::INTERPRETED_FUNCTION;
}
void SetOptimizingForOsr(BailoutId osr_offset, JavaScriptFrame* osr_frame) {
DCHECK(IsOptimizing());
osr_offset_ = osr_offset;
......@@ -285,15 +297,8 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
WasmCodeDesc* wasm_code_desc() { return &wasm_code_desc_; }
private:
// Compilation mode.
// BASE is generated by the full codegen, optionally prepared for bailouts.
// OPTIMIZE is optimized code generated by the Hydrogen-based backend.
enum Mode { BASE, OPTIMIZE, STUB };
CompilationInfo(Vector<const char> debug_name, Code::Kind code_kind,
Mode mode, Zone* zone);
void SetMode(Mode mode) { mode_ = mode; }
CompilationInfo(Vector<const char> debug_name, AbstractCode::Kind code_kind,
Zone* zone);
void SetFlag(Flag flag) { flags_ |= flag; }
......@@ -308,7 +313,7 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
unsigned flags_;
Code::Kind code_kind_;
AbstractCode::Kind code_kind_;
uint32_t stub_key_;
int32_t builtin_index_;
......@@ -320,8 +325,7 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
Handle<Code> code_;
WasmCodeDesc wasm_code_desc_;
// Compilation mode flag and whether deoptimization is allowed.
Mode mode_;
// Entry point when compiling for OSR, {BailoutId::None} otherwise.
BailoutId osr_offset_;
// Holds the bytecode array generated by the interpreter.
......
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