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 :
|
for (CompilationInfo::InlinedFunctionHolder& inlined :
|
||||||
info->inlined_functions()) {
|
info->inlined_functions()) {
|
||||||
if (!inlined.shared_info.equals(info->shared_info())) {
|
if (!inlined.shared_info.equals(info->shared_info())) {
|
||||||
int index = DefineDeoptimizationLiteral(
|
int index = DefineDeoptimizationLiteral(inlined.shared_info);
|
||||||
DeoptimizationLiteral(inlined.shared_info));
|
|
||||||
inlined.RegisterInlinedFunctionId(index);
|
inlined.RegisterInlinedFunctionId(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,8 +111,7 @@ Handle<Code> CodeGenerator::GenerateCode() {
|
|||||||
for (const CompilationInfo::InlinedFunctionHolder& inlined :
|
for (const CompilationInfo::InlinedFunctionHolder& inlined :
|
||||||
info->inlined_functions()) {
|
info->inlined_functions()) {
|
||||||
if (!inlined.shared_info.equals(info->shared_info())) {
|
if (!inlined.shared_info.equals(info->shared_info())) {
|
||||||
DefineDeoptimizationLiteral(
|
DefineDeoptimizationLiteral(inlined.inlined_code_object_root);
|
||||||
DeoptimizationLiteral(inlined.inlined_code_object_root));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -577,11 +575,13 @@ void CodeGenerator::PopulateDeoptimizationData(Handle<Code> code_object) {
|
|||||||
|
|
||||||
Handle<FixedArray> literals = isolate()->factory()->NewFixedArray(
|
Handle<FixedArray> literals = isolate()->factory()->NewFixedArray(
|
||||||
static_cast<int>(deoptimization_literals_.size()), TENURED);
|
static_cast<int>(deoptimization_literals_.size()), TENURED);
|
||||||
for (unsigned i = 0; i < deoptimization_literals_.size(); i++) {
|
{
|
||||||
Handle<Object> object = deoptimization_literals_[i].Reify(isolate());
|
AllowDeferredHandleDereference copy_handles;
|
||||||
literals->set(i, *object);
|
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);
|
Handle<PodArray<InliningPosition>> inl_pos = CreateInliningPositions(info);
|
||||||
data->SetInliningPositions(*inl_pos);
|
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());
|
int result = static_cast<int>(deoptimization_literals_.size());
|
||||||
for (unsigned i = 0; i < deoptimization_literals_.size(); ++i) {
|
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);
|
deoptimization_literals_.push_back(literal);
|
||||||
return result;
|
return result;
|
||||||
@ -721,8 +722,8 @@ void CodeGenerator::TranslateStateValueDescriptor(
|
|||||||
DCHECK(desc->IsOptimizedOut());
|
DCHECK(desc->IsOptimizedOut());
|
||||||
if (translation != nullptr) {
|
if (translation != nullptr) {
|
||||||
if (optimized_out_literal_id_ == -1) {
|
if (optimized_out_literal_id_ == -1) {
|
||||||
optimized_out_literal_id_ = DefineDeoptimizationLiteral(
|
optimized_out_literal_id_ =
|
||||||
DeoptimizationLiteral(isolate()->factory()->optimized_out()));
|
DefineDeoptimizationLiteral(isolate()->factory()->optimized_out());
|
||||||
}
|
}
|
||||||
translation->StoreLiteral(optimized_out_literal_id_);
|
translation->StoreLiteral(optimized_out_literal_id_);
|
||||||
}
|
}
|
||||||
@ -789,8 +790,7 @@ void CodeGenerator::BuildTranslationForFrameStateDescriptor(
|
|||||||
}
|
}
|
||||||
shared_info = info()->shared_info();
|
shared_info = info()->shared_info();
|
||||||
}
|
}
|
||||||
int shared_info_id =
|
int shared_info_id = DefineDeoptimizationLiteral(shared_info);
|
||||||
DefineDeoptimizationLiteral(DeoptimizationLiteral(shared_info));
|
|
||||||
|
|
||||||
switch (descriptor->type()) {
|
switch (descriptor->type()) {
|
||||||
case FrameStateType::kJavaScriptFunction:
|
case FrameStateType::kJavaScriptFunction:
|
||||||
@ -906,23 +906,22 @@ void CodeGenerator::AddTranslationForOperand(Translation* translation,
|
|||||||
CHECK(op->IsImmediate());
|
CHECK(op->IsImmediate());
|
||||||
InstructionOperandConverter converter(this, instr);
|
InstructionOperandConverter converter(this, instr);
|
||||||
Constant constant = converter.ToConstant(op);
|
Constant constant = converter.ToConstant(op);
|
||||||
DeoptimizationLiteral literal;
|
Handle<Object> constant_object;
|
||||||
switch (constant.type()) {
|
switch (constant.type()) {
|
||||||
case Constant::kInt32:
|
case Constant::kInt32:
|
||||||
if (type.representation() == MachineRepresentation::kTagged) {
|
if (type.representation() == MachineRepresentation::kTagged) {
|
||||||
// When pointers are 4 bytes, we can use int32 constants to represent
|
// When pointers are 4 bytes, we can use int32 constants to represent
|
||||||
// Smis.
|
// Smis.
|
||||||
DCHECK_EQ(4, kPointerSize);
|
DCHECK_EQ(4, kPointerSize);
|
||||||
Smi* smi = reinterpret_cast<Smi*>(constant.ToInt32());
|
constant_object =
|
||||||
DCHECK(smi->IsSmi());
|
handle(reinterpret_cast<Smi*>(constant.ToInt32()), isolate());
|
||||||
literal = DeoptimizationLiteral(smi->value());
|
DCHECK(constant_object->IsSmi());
|
||||||
} else if (type.representation() == MachineRepresentation::kBit) {
|
} else if (type.representation() == MachineRepresentation::kBit) {
|
||||||
if (constant.ToInt32() == 0) {
|
if (constant.ToInt32() == 0) {
|
||||||
literal =
|
constant_object = isolate()->factory()->false_value();
|
||||||
DeoptimizationLiteral(isolate()->factory()->false_value());
|
|
||||||
} else {
|
} else {
|
||||||
DCHECK_EQ(1, constant.ToInt32());
|
DCHECK_EQ(1, constant.ToInt32());
|
||||||
literal = DeoptimizationLiteral(isolate()->factory()->true_value());
|
constant_object = isolate()->factory()->true_value();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO(jarin,bmeurer): We currently pass in raw pointers to the
|
// 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 ||
|
DCHECK(type.representation() != MachineRepresentation::kNone ||
|
||||||
constant.ToInt32() == FrameStateDescriptor::kImpossibleValue);
|
constant.ToInt32() == FrameStateDescriptor::kImpossibleValue);
|
||||||
if (type == MachineType::Uint32()) {
|
if (type == MachineType::Uint32()) {
|
||||||
literal = DeoptimizationLiteral(
|
constant_object =
|
||||||
static_cast<uint32_t>(constant.ToInt32()));
|
isolate()->factory()->NewNumberFromUint(constant.ToInt32());
|
||||||
} else {
|
} else {
|
||||||
literal = DeoptimizationLiteral(constant.ToInt32());
|
constant_object =
|
||||||
|
isolate()->factory()->NewNumberFromInt(constant.ToInt32());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -949,33 +949,31 @@ void CodeGenerator::AddTranslationForOperand(Translation* translation,
|
|||||||
DCHECK(type.representation() == MachineRepresentation::kWord64 ||
|
DCHECK(type.representation() == MachineRepresentation::kWord64 ||
|
||||||
type.representation() == MachineRepresentation::kTagged);
|
type.representation() == MachineRepresentation::kTagged);
|
||||||
DCHECK_EQ(8, kPointerSize);
|
DCHECK_EQ(8, kPointerSize);
|
||||||
{
|
constant_object =
|
||||||
Smi* smi = reinterpret_cast<Smi*>(constant.ToInt64());
|
handle(reinterpret_cast<Smi*>(constant.ToInt64()), isolate());
|
||||||
DCHECK(smi->IsSmi());
|
DCHECK(constant_object->IsSmi());
|
||||||
literal = DeoptimizationLiteral(smi->value());
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case Constant::kFloat32:
|
case Constant::kFloat32:
|
||||||
DCHECK(type.representation() == MachineRepresentation::kFloat32 ||
|
DCHECK(type.representation() == MachineRepresentation::kFloat32 ||
|
||||||
type.representation() == MachineRepresentation::kTagged);
|
type.representation() == MachineRepresentation::kTagged);
|
||||||
literal = DeoptimizationLiteral(constant.ToFloat32());
|
constant_object = isolate()->factory()->NewNumber(constant.ToFloat32());
|
||||||
break;
|
break;
|
||||||
case Constant::kFloat64:
|
case Constant::kFloat64:
|
||||||
DCHECK(type.representation() == MachineRepresentation::kFloat64 ||
|
DCHECK(type.representation() == MachineRepresentation::kFloat64 ||
|
||||||
type.representation() == MachineRepresentation::kTagged);
|
type.representation() == MachineRepresentation::kTagged);
|
||||||
literal = DeoptimizationLiteral(constant.ToFloat64());
|
constant_object = isolate()->factory()->NewNumber(constant.ToFloat64());
|
||||||
break;
|
break;
|
||||||
case Constant::kHeapObject:
|
case Constant::kHeapObject:
|
||||||
DCHECK_EQ(MachineRepresentation::kTagged, type.representation());
|
DCHECK_EQ(MachineRepresentation::kTagged, type.representation());
|
||||||
literal = DeoptimizationLiteral(constant.ToHeapObject());
|
constant_object = constant.ToHeapObject();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
if (literal.object().equals(info()->closure())) {
|
if (constant_object.equals(info()->closure())) {
|
||||||
translation->StoreJSFrameFunction();
|
translation->StoreJSFrameFunction();
|
||||||
} else {
|
} else {
|
||||||
int literal_id = DefineDeoptimizationLiteral(literal);
|
int literal_id = DefineDeoptimizationLiteral(constant_object);
|
||||||
translation->StoreLiteral(literal_id);
|
translation->StoreLiteral(literal_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,30 +48,6 @@ class InstructionOperandIterator {
|
|||||||
size_t pos_;
|
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.
|
// Generates native code for a sequence of instructions.
|
||||||
class CodeGenerator final : public GapResolver::Assembler {
|
class CodeGenerator final : public GapResolver::Assembler {
|
||||||
@ -232,7 +208,7 @@ class CodeGenerator final : public GapResolver::Assembler {
|
|||||||
|
|
||||||
void RecordCallPosition(Instruction* instr);
|
void RecordCallPosition(Instruction* instr);
|
||||||
void PopulateDeoptimizationData(Handle<Code> code);
|
void PopulateDeoptimizationData(Handle<Code> code);
|
||||||
int DefineDeoptimizationLiteral(DeoptimizationLiteral literal);
|
int DefineDeoptimizationLiteral(Handle<Object> literal);
|
||||||
DeoptimizationEntry const& GetDeoptimizationEntry(Instruction* instr,
|
DeoptimizationEntry const& GetDeoptimizationEntry(Instruction* instr,
|
||||||
size_t frame_state_offset);
|
size_t frame_state_offset);
|
||||||
DeoptimizeKind GetDeoptimizationKind(int deoptimization_id) const;
|
DeoptimizeKind GetDeoptimizationKind(int deoptimization_id) const;
|
||||||
@ -307,7 +283,7 @@ class CodeGenerator final : public GapResolver::Assembler {
|
|||||||
ZoneVector<HandlerInfo> handlers_;
|
ZoneVector<HandlerInfo> handlers_;
|
||||||
ZoneDeque<DeoptimizationExit*> deoptimization_exits_;
|
ZoneDeque<DeoptimizationExit*> deoptimization_exits_;
|
||||||
ZoneDeque<DeoptimizationState*> deoptimization_states_;
|
ZoneDeque<DeoptimizationState*> deoptimization_states_;
|
||||||
ZoneDeque<DeoptimizationLiteral> deoptimization_literals_;
|
ZoneDeque<Handle<Object>> deoptimization_literals_;
|
||||||
size_t inlined_function_count_;
|
size_t inlined_function_count_;
|
||||||
TranslationBuffer translations_;
|
TranslationBuffer translations_;
|
||||||
int last_lazy_deopt_pc_;
|
int last_lazy_deopt_pc_;
|
||||||
|
Loading…
Reference in New Issue
Block a user