Revert "[compiler] Delay allocation of heap numbers for deoptimization literals."
This reverts commit bb90a2e85d
.
Reason for revert: https://bugs.chromium.org/p/chromium/issues/detail?id=722978
Original change's description:
> [compiler] Delay allocation of heap numbers for deoptimization literals.
>
> ... until after the main bulk of code generation, which will soon run on a
> different thread.
>
> R=jarin@chromium.org
>
> Bug: v8:6048
> Change-Id: I12aaaf2725e2422f588c29f50084eb77b56ad9a5
> Reviewed-on: https://chromium-review.googlesource.com/505616
> Commit-Queue: Georg Neis <neis@chromium.org>
> Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#45340}
TBR=jarin@chromium.org,neis@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Bug: v8:6048
Change-Id: I161f175685c24dc59ee4e761ea6d00a235573e7a
Reviewed-on: https://chromium-review.googlesource.com/506021
Reviewed-by: Georg Neis <neis@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45366}
This commit is contained in:
parent
74519c43fd
commit
9798469980
@ -100,8 +100,7 @@ Handle<Code> CodeGenerator::GenerateCode() {
|
||||
for (CompilationInfo::InlinedFunctionHolder& inlined :
|
||||
info->inlined_functions()) {
|
||||
if (!inlined.shared_info.equals(info->shared_info())) {
|
||||
int index = DefineDeoptimizationLiteral(
|
||||
DeoptimizationLiteral(inlined.shared_info));
|
||||
int index = DefineDeoptimizationLiteral(inlined.shared_info);
|
||||
inlined.RegisterInlinedFunctionId(index);
|
||||
}
|
||||
}
|
||||
@ -112,8 +111,7 @@ Handle<Code> CodeGenerator::GenerateCode() {
|
||||
for (const CompilationInfo::InlinedFunctionHolder& inlined :
|
||||
info->inlined_functions()) {
|
||||
if (!inlined.shared_info.equals(info->shared_info())) {
|
||||
DefineDeoptimizationLiteral(
|
||||
DeoptimizationLiteral(inlined.inlined_code_object_root));
|
||||
DefineDeoptimizationLiteral(inlined.inlined_code_object_root);
|
||||
}
|
||||
}
|
||||
|
||||
@ -577,11 +575,13 @@ void CodeGenerator::PopulateDeoptimizationData(Handle<Code> code_object) {
|
||||
|
||||
Handle<FixedArray> literals = isolate()->factory()->NewFixedArray(
|
||||
static_cast<int>(deoptimization_literals_.size()), TENURED);
|
||||
for (unsigned i = 0; i < deoptimization_literals_.size(); i++) {
|
||||
Handle<Object> object = deoptimization_literals_[i].Reify(isolate());
|
||||
literals->set(i, *object);
|
||||
{
|
||||
AllowDeferredHandleDereference copy_handles;
|
||||
for (unsigned i = 0; i < deoptimization_literals_.size(); i++) {
|
||||
literals->set(i, *deoptimization_literals_[i]);
|
||||
}
|
||||
data->SetLiteralArray(*literals);
|
||||
}
|
||||
data->SetLiteralArray(*literals);
|
||||
|
||||
Handle<PodArray<InliningPosition>> inl_pos = CreateInliningPositions(info);
|
||||
data->SetInliningPositions(*inl_pos);
|
||||
@ -656,10 +656,11 @@ void CodeGenerator::RecordCallPosition(Instruction* instr) {
|
||||
}
|
||||
}
|
||||
|
||||
int CodeGenerator::DefineDeoptimizationLiteral(DeoptimizationLiteral literal) {
|
||||
|
||||
int CodeGenerator::DefineDeoptimizationLiteral(Handle<Object> literal) {
|
||||
int result = static_cast<int>(deoptimization_literals_.size());
|
||||
for (unsigned i = 0; i < deoptimization_literals_.size(); ++i) {
|
||||
if (deoptimization_literals_[i] == literal) return i;
|
||||
if (deoptimization_literals_[i].equals(literal)) return i;
|
||||
}
|
||||
deoptimization_literals_.push_back(literal);
|
||||
return result;
|
||||
@ -721,8 +722,8 @@ void CodeGenerator::TranslateStateValueDescriptor(
|
||||
DCHECK(desc->IsOptimizedOut());
|
||||
if (translation != nullptr) {
|
||||
if (optimized_out_literal_id_ == -1) {
|
||||
optimized_out_literal_id_ = DefineDeoptimizationLiteral(
|
||||
DeoptimizationLiteral(isolate()->factory()->optimized_out()));
|
||||
optimized_out_literal_id_ =
|
||||
DefineDeoptimizationLiteral(isolate()->factory()->optimized_out());
|
||||
}
|
||||
translation->StoreLiteral(optimized_out_literal_id_);
|
||||
}
|
||||
@ -789,8 +790,7 @@ void CodeGenerator::BuildTranslationForFrameStateDescriptor(
|
||||
}
|
||||
shared_info = info()->shared_info();
|
||||
}
|
||||
int shared_info_id =
|
||||
DefineDeoptimizationLiteral(DeoptimizationLiteral(shared_info));
|
||||
int shared_info_id = DefineDeoptimizationLiteral(shared_info);
|
||||
|
||||
switch (descriptor->type()) {
|
||||
case FrameStateType::kJavaScriptFunction:
|
||||
@ -906,23 +906,22 @@ void CodeGenerator::AddTranslationForOperand(Translation* translation,
|
||||
CHECK(op->IsImmediate());
|
||||
InstructionOperandConverter converter(this, instr);
|
||||
Constant constant = converter.ToConstant(op);
|
||||
DeoptimizationLiteral literal;
|
||||
Handle<Object> constant_object;
|
||||
switch (constant.type()) {
|
||||
case Constant::kInt32:
|
||||
if (type.representation() == MachineRepresentation::kTagged) {
|
||||
// When pointers are 4 bytes, we can use int32 constants to represent
|
||||
// Smis.
|
||||
DCHECK_EQ(4, kPointerSize);
|
||||
Smi* smi = reinterpret_cast<Smi*>(constant.ToInt32());
|
||||
DCHECK(smi->IsSmi());
|
||||
literal = DeoptimizationLiteral(smi->value());
|
||||
constant_object =
|
||||
handle(reinterpret_cast<Smi*>(constant.ToInt32()), isolate());
|
||||
DCHECK(constant_object->IsSmi());
|
||||
} else if (type.representation() == MachineRepresentation::kBit) {
|
||||
if (constant.ToInt32() == 0) {
|
||||
literal =
|
||||
DeoptimizationLiteral(isolate()->factory()->false_value());
|
||||
constant_object = isolate()->factory()->false_value();
|
||||
} else {
|
||||
DCHECK_EQ(1, constant.ToInt32());
|
||||
literal = DeoptimizationLiteral(isolate()->factory()->true_value());
|
||||
constant_object = isolate()->factory()->true_value();
|
||||
}
|
||||
} else {
|
||||
// TODO(jarin,bmeurer): We currently pass in raw pointers to the
|
||||
@ -934,10 +933,11 @@ void CodeGenerator::AddTranslationForOperand(Translation* translation,
|
||||
DCHECK(type.representation() != MachineRepresentation::kNone ||
|
||||
constant.ToInt32() == FrameStateDescriptor::kImpossibleValue);
|
||||
if (type == MachineType::Uint32()) {
|
||||
literal = DeoptimizationLiteral(
|
||||
static_cast<uint32_t>(constant.ToInt32()));
|
||||
constant_object =
|
||||
isolate()->factory()->NewNumberFromUint(constant.ToInt32());
|
||||
} else {
|
||||
literal = DeoptimizationLiteral(constant.ToInt32());
|
||||
constant_object =
|
||||
isolate()->factory()->NewNumberFromInt(constant.ToInt32());
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -949,33 +949,31 @@ void CodeGenerator::AddTranslationForOperand(Translation* translation,
|
||||
DCHECK(type.representation() == MachineRepresentation::kWord64 ||
|
||||
type.representation() == MachineRepresentation::kTagged);
|
||||
DCHECK_EQ(8, kPointerSize);
|
||||
{
|
||||
Smi* smi = reinterpret_cast<Smi*>(constant.ToInt64());
|
||||
DCHECK(smi->IsSmi());
|
||||
literal = DeoptimizationLiteral(smi->value());
|
||||
}
|
||||
constant_object =
|
||||
handle(reinterpret_cast<Smi*>(constant.ToInt64()), isolate());
|
||||
DCHECK(constant_object->IsSmi());
|
||||
break;
|
||||
case Constant::kFloat32:
|
||||
DCHECK(type.representation() == MachineRepresentation::kFloat32 ||
|
||||
type.representation() == MachineRepresentation::kTagged);
|
||||
literal = DeoptimizationLiteral(constant.ToFloat32());
|
||||
constant_object = isolate()->factory()->NewNumber(constant.ToFloat32());
|
||||
break;
|
||||
case Constant::kFloat64:
|
||||
DCHECK(type.representation() == MachineRepresentation::kFloat64 ||
|
||||
type.representation() == MachineRepresentation::kTagged);
|
||||
literal = DeoptimizationLiteral(constant.ToFloat64());
|
||||
constant_object = isolate()->factory()->NewNumber(constant.ToFloat64());
|
||||
break;
|
||||
case Constant::kHeapObject:
|
||||
DCHECK_EQ(MachineRepresentation::kTagged, type.representation());
|
||||
literal = DeoptimizationLiteral(constant.ToHeapObject());
|
||||
constant_object = constant.ToHeapObject();
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
if (literal.object().equals(info()->closure())) {
|
||||
if (constant_object.equals(info()->closure())) {
|
||||
translation->StoreJSFrameFunction();
|
||||
} else {
|
||||
int literal_id = DefineDeoptimizationLiteral(literal);
|
||||
int literal_id = DefineDeoptimizationLiteral(constant_object);
|
||||
translation->StoreLiteral(literal_id);
|
||||
}
|
||||
}
|
||||
|
@ -48,30 +48,6 @@ class InstructionOperandIterator {
|
||||
size_t pos_;
|
||||
};
|
||||
|
||||
// Either a non-null Handle<Object> or a double.
|
||||
class DeoptimizationLiteral {
|
||||
public:
|
||||
DeoptimizationLiteral() : object_(), number_(0) {}
|
||||
explicit DeoptimizationLiteral(Handle<Object> object)
|
||||
: object_(object), number_(0) {
|
||||
DCHECK(!object_.is_null());
|
||||
}
|
||||
explicit DeoptimizationLiteral(double number) : object_(), number_(number) {}
|
||||
|
||||
Handle<Object> object() const { return object_; }
|
||||
|
||||
bool operator==(const DeoptimizationLiteral& other) const {
|
||||
return object_.equals(other.object_) && number_ == other.number_;
|
||||
}
|
||||
|
||||
Handle<Object> Reify(Isolate* isolate) const {
|
||||
return object_.is_null() ? isolate->factory()->NewNumber(number_) : object_;
|
||||
}
|
||||
|
||||
private:
|
||||
Handle<Object> object_;
|
||||
double number_;
|
||||
};
|
||||
|
||||
// Generates native code for a sequence of instructions.
|
||||
class CodeGenerator final : public GapResolver::Assembler {
|
||||
@ -232,7 +208,7 @@ class CodeGenerator final : public GapResolver::Assembler {
|
||||
|
||||
void RecordCallPosition(Instruction* instr);
|
||||
void PopulateDeoptimizationData(Handle<Code> code);
|
||||
int DefineDeoptimizationLiteral(DeoptimizationLiteral literal);
|
||||
int DefineDeoptimizationLiteral(Handle<Object> literal);
|
||||
DeoptimizationEntry const& GetDeoptimizationEntry(Instruction* instr,
|
||||
size_t frame_state_offset);
|
||||
DeoptimizeKind GetDeoptimizationKind(int deoptimization_id) const;
|
||||
@ -307,7 +283,7 @@ class CodeGenerator final : public GapResolver::Assembler {
|
||||
ZoneVector<HandlerInfo> handlers_;
|
||||
ZoneDeque<DeoptimizationExit*> deoptimization_exits_;
|
||||
ZoneDeque<DeoptimizationState*> deoptimization_states_;
|
||||
ZoneDeque<DeoptimizationLiteral> deoptimization_literals_;
|
||||
ZoneDeque<Handle<Object>> deoptimization_literals_;
|
||||
size_t inlined_function_count_;
|
||||
TranslationBuffer translations_;
|
||||
int last_lazy_deopt_pc_;
|
||||
|
Loading…
Reference in New Issue
Block a user