| Index: src/crankshaft/lithium-codegen.cc
|
| diff --git a/src/crankshaft/lithium-codegen.cc b/src/crankshaft/lithium-codegen.cc
|
| index 41f78cd1837ff4e528b184ae504657030e4108db..10e06dd65d4e4865ca224094cc7f94504779723d 100644
|
| --- a/src/crankshaft/lithium-codegen.cc
|
| +++ b/src/crankshaft/lithium-codegen.cc
|
| @@ -53,8 +53,12 @@ LCodeGenBase::LCodeGenBase(LChunk* chunk, MacroAssembler* assembler,
|
| current_block_(-1),
|
| current_instruction_(-1),
|
| instructions_(chunk->instructions()),
|
| + deoptimizations_(4, info->zone()),
|
| deoptimization_literals_(8, info->zone()),
|
| - last_lazy_deopt_pc_(0) {}
|
| + translations_(info->zone()),
|
| + inlined_function_count_(0),
|
| + last_lazy_deopt_pc_(0),
|
| + osr_pc_offset_(-1) {}
|
|
|
|
|
| bool LCodeGenBase::GenerateBody() {
|
| @@ -280,6 +284,61 @@ void LCodeGenBase::WriteTranslationFrame(LEnvironment* environment,
|
| }
|
|
|
|
|
| +void LCodeGenBase::PopulateDeoptimizationData(Handle<Code> code) {
|
| + int length = deoptimizations_.length();
|
| + if (length == 0) return;
|
| + Handle<DeoptimizationInputData> data =
|
| + DeoptimizationInputData::New(isolate(), length, TENURED);
|
| +
|
| + Handle<ByteArray> translations =
|
| + translations_.CreateByteArray(isolate()->factory());
|
| + data->SetTranslationByteArray(*translations);
|
| + data->SetInlinedFunctionCount(Smi::FromInt(inlined_function_count_));
|
| + data->SetOptimizationId(Smi::FromInt(info_->optimization_id()));
|
| + if (info_->IsOptimizing()) {
|
| + // Reference to shared function info does not change between phases.
|
| + AllowDeferredHandleDereference allow_handle_dereference;
|
| + data->SetSharedFunctionInfo(*info_->shared_info());
|
| + } else {
|
| + data->SetSharedFunctionInfo(Smi::FromInt(0));
|
| + }
|
| + data->SetWeakCellCache(Smi::FromInt(0));
|
| +
|
| + Handle<FixedArray> literals =
|
| + factory()->NewFixedArray(deoptimization_literals_.length(), TENURED);
|
| + {
|
| + AllowDeferredHandleDereference copy_handles;
|
| + for (int i = 0; i < deoptimization_literals_.length(); i++) {
|
| + literals->set(i, *deoptimization_literals_[i]);
|
| + }
|
| + data->SetLiteralArray(*literals);
|
| + }
|
| +
|
| + data->SetOsrAstId(Smi::FromInt(info_->osr_ast_id().ToInt()));
|
| + data->SetOsrPcOffset(Smi::FromInt(osr_pc_offset_));
|
| +
|
| + // Populate the deoptimization entries.
|
| + for (int i = 0; i < length; i++) {
|
| + LEnvironment* env = deoptimizations_[i];
|
| + data->SetAstId(i, env->ast_id());
|
| + data->SetTranslationIndex(i, Smi::FromInt(env->translation_index()));
|
| + data->SetArgumentsStackHeight(i,
|
| + Smi::FromInt(env->arguments_stack_height()));
|
| + data->SetPc(i, Smi::FromInt(env->pc_offset()));
|
| + }
|
| + code->set_deoptimization_data(*data);
|
| +}
|
| +
|
| +
|
| +void LCodeGenBase::PopulateDeoptimizationLiteralsWithInlinedFunctions() {
|
| + DCHECK_EQ(0, deoptimization_literals_.length());
|
| + for (auto function : chunk()->inlined_functions()) {
|
| + DefineDeoptimizationLiteral(function);
|
| + }
|
| + inlined_function_count_ = deoptimization_literals_.length();
|
| +}
|
| +
|
| +
|
| Deoptimizer::DeoptInfo LCodeGenBase::MakeDeoptInfo(
|
| LInstruction* instr, Deoptimizer::DeoptReason deopt_reason) {
|
| Deoptimizer::DeoptInfo deopt_info(instr->hydrogen_value()->position(),
|
|
|