From 8307afaf3627cd88a07b48e184a1a6839268e70a Mon Sep 17 00:00:00 2001 From: Ilya Trubachev Date: Tue, 13 Sep 2022 15:28:49 +0300 Subject: [PATCH] fix for enabling mandreel.js Signed-off-by: Ilya Trubachev --- .../ir_builder/ecmascript_inst_builder.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/compiler/optimizer/ir_builder/ecmascript_inst_builder.cpp b/compiler/optimizer/ir_builder/ecmascript_inst_builder.cpp index a598059e1..837a608f6 100644 --- a/compiler/optimizer/ir_builder/ecmascript_inst_builder.cpp +++ b/compiler/optimizer/ir_builder/ecmascript_inst_builder.cpp @@ -39,6 +39,10 @@ void InstBuilder::BuildEcmaFnCall(const BytecodeInstruction *bc_inst, bool is_ra { // Check callee is suitable to call (!IsConstructor) auto fn_class_check = GetGraph()->CreateInstIntrinsic(DataType::ANY, bc_pc); + if (fn_class_check == nullptr) { + failed_ = true; + return; + } fn_class_check->SetIntrinsicId(RuntimeInterface::IntrinsicId::INTRINSIC_DYN_CALL_CHECK); AdjustFlags(fn_class_check->GetIntrinsicId(), fn_class_check); fn_class_check->SetFlag(inst_flags::CAN_DEOPTIMIZE); @@ -52,6 +56,10 @@ void InstBuilder::BuildEcmaFnCall(const BytecodeInstruction *bc_inst, bool is_ra } auto call_inst = GetGraph()->CreateInstCallDynamic(DataType::ANY, bc_pc); + if (call_inst == nullptr) { + failed_ = true; + return; + } call_inst->SetCanNativeException(true); // func, new_target, this?, args..., ss @@ -96,6 +104,10 @@ void InstBuilder::BuildEcmaNewobjdynrange(const BytecodeInstruction *bc_inst) auto start_reg = bc_inst->GetVReg(0); auto inst = graph->CreateInstIntrinsic(DataType::ANY, bc_pc); + if (inst == nullptr) { + failed_ = true; + return; + } inst->SetIntrinsicId(RuntimeInterface::IntrinsicId::INTRINSIC_NEWOBJ_DYNRANGE); AdjustFlags(inst->GetIntrinsicId(), inst); inst->SetFlag(inst_flags::CAN_THROW); @@ -134,12 +146,20 @@ void InstBuilder::BuildStGlobalVar(const BytecodeInstruction *bc_inst, size_t ty auto pc = GetPc(bc_inst->GetAddress()); auto save_state = CreateSaveState(Opcode::SaveState, pc); auto get_address = graph_->CreateInstGetGlobalVarAddress(DataType::REFERENCE, pc); + if (get_address == nullptr) { + failed_ = true; + return; + } get_address->SetTypeId(type_id); get_address->SetMethod(GetGraph()->GetMethod()); get_address->SetInput(0, save_state); auto store_object = graph_->CreateInstStoreObject(DataType::ANY, pc); + if (store_object == nullptr) { + failed_ = true; + return; + } store_object->SetTypeId(type_id); store_object->SetMethod(GetGraph()->GetMethod()); store_object->SetObjField(nullptr); @@ -165,12 +185,20 @@ void InstBuilder::BuildLdGlobalVar(const BytecodeInstruction *bc_inst, size_t ty auto pc = GetPc(bc_inst->GetAddress()); auto save_state = CreateSaveState(Opcode::SaveState, pc); auto get_address = graph_->CreateInstGetGlobalVarAddress(DataType::REFERENCE, pc); + if (get_address == nullptr) { + failed_ = true; + return; + } get_address->SetTypeId(type_id); get_address->SetMethod(GetGraph()->GetMethod()); get_address->SetInput(0, save_state); auto load_object = graph_->CreateInstLoadObject(DataType::ANY, pc); + if (load_object == nullptr) { + failed_ = true; + return; + } load_object->SetTypeId(type_id); load_object->SetMethod(GetGraph()->GetMethod()); load_object->SetObjField(nullptr); -- Gitee