diff --git a/compiler/codegen_intrinsics_ecmascript.cpp b/compiler/codegen_intrinsics_ecmascript.cpp index 5b717899795c56ef6c5bb306b7e7f59c158ba74e..f9dd0b3549deca650bff4be102ac6484c07a3db6 100644 --- a/compiler/codegen_intrinsics_ecmascript.cpp +++ b/compiler/codegen_intrinsics_ecmascript.cpp @@ -270,13 +270,12 @@ void Codegen::CreateDynClassGetHash([[maybe_unused]] IntrinsicInst *inst, Reg ds void Codegen::CreateLdObjDynByName([[maybe_unused]] IntrinsicInst *inst, Reg dst, SRCREGS src) { - CallFastPath(inst, EntrypointId::LOAD_OBJECT_DYNAMIC_BY_NAME, dst, {}, src[0], src[1U], src[2U], src[3U], src[4U]); + CallFastPath(inst, EntrypointId::LOAD_OBJECT_DYNAMIC_BY_NAME, dst, {}, src[0], src[1U], src[2U], src[3U]); } void Codegen::CreateStObjDynByName([[maybe_unused]] IntrinsicInst *inst, Reg dst, SRCREGS src) { - CallFastPath(inst, EntrypointId::STORE_OBJECT_DYNAMIC_BY_NAME, dst, {}, src[0], src[1U], src[2U], src[3U], src[4U], - src[5U]); + CallFastPath(inst, EntrypointId::STORE_OBJECT_DYNAMIC_BY_NAME, dst, {}, src[0], src[1U], src[2U], src[3U], src[4U]); } void Codegen::CreateAllocDynObject([[maybe_unused]] IntrinsicInst *inst, Reg dst, SRCREGS src) diff --git a/compiler/inline_intrinsics_ecmascript.cpp b/compiler/inline_intrinsics_ecmascript.cpp index c2375500d78fe2243c6d68399ee3d59559e0dafc..7825fa7dc2b3bd06e0cf9bc88085c86a856aab86 100644 --- a/compiler/inline_intrinsics_ecmascript.cpp +++ b/compiler/inline_intrinsics_ecmascript.cpp @@ -194,7 +194,7 @@ void InsertCheckJSArrayLength(Inst *obj, Inst *index, Inst *insert_after, Runtim add->InsertAfter(store_length); } -template +template Inst *InsertMemFromFieldInlined(IntrinsicInst *intrinsic, Inst *obj_inst, Inst *insert_after, uint32_t offset) { auto graph = obj_inst->GetBasicBlock()->GetGraph(); @@ -207,11 +207,7 @@ Inst *InsertMemFromFieldInlined(IntrinsicInst *intrinsic, Inst *obj_inst, Inst * } else { auto store_object = graph->CreateInstStoreObject(DataType::ANY, pc); store_object->SetInput(0, obj_inst); - if constexpr (BY_NAME) { - store_object->SetInput(1, intrinsic->GetInput(1).GetInst()); - } else { - store_object->SetInput(1, intrinsic->GetInput(2).GetInst()); - } + store_object->SetInput(1, intrinsic->GetInput(2).GetInst()); store_object->SetTypeId(offset); store_object->SetMethod(save_state->GetMethod()); store_object->SetObjField(nullptr); @@ -241,7 +237,7 @@ Inst *InsertBoundsCheck(Inst *array, Inst *index, Inst *save_state, uint32_t pc, return bounds_check; } -template +template Inst *InsertMemFromField(IntrinsicInst *intrinsic, Inst *obj_inst, Inst *insert_after, uint32_t offset) { auto graph = obj_inst->GetBasicBlock()->GetGraph(); @@ -268,11 +264,7 @@ Inst *InsertMemFromField(IntrinsicInst *intrinsic, Inst *obj_inst, Inst *insert_ auto store_array = graph->CreateInstStoreArray(DataType::ANY, pc); store_array->SetInput(0, load_object); store_array->SetInput(1, index); - if constexpr (BY_NAME) { - store_array->SetInput(2, intrinsic->GetInput(1).GetInst()); - } else { - store_array->SetInput(2, intrinsic->GetInput(2).GetInst()); - } + store_array->SetInput(2, intrinsic->GetInput(2).GetInst()); store_array->SetNeedBarrier(true); array = store_array; } @@ -333,7 +325,7 @@ Inst *InsertPrototypeCheckInst(IntrinsicInst *intrinsic, uintptr_t proto_mem, In return prototype; } -template +template Inst *InsertAccessInst(IntrinsicInst *intrinsic, Inst *obj_inst, Inst *insert_after, RuntimeInterface::NamedAccessProfileData profile) { @@ -341,27 +333,27 @@ Inst *InsertAccessInst(IntrinsicInst *intrinsic, Inst *obj_inst, Inst *insert_af RuntimeInterface::NamedAccessProfileType type = profile.type; switch (type) { case RuntimeInterface::NamedAccessProfileType::FIELD_INLINED: - return InsertMemFromFieldInlined(intrinsic, obj_inst, insert_after, offset); + return InsertMemFromFieldInlined(intrinsic, obj_inst, insert_after, offset); case RuntimeInterface::NamedAccessProfileType::FIELD: - return InsertMemFromField(intrinsic, obj_inst, insert_after, offset); + return InsertMemFromField(intrinsic, obj_inst, insert_after, offset); case RuntimeInterface::NamedAccessProfileType::TRANSITION_INLINED: { ASSERT(!IS_LOAD); auto store_class = InsertChangeClassInst(intrinsic, obj_inst, insert_after, profile.cached_value); - return InsertMemFromFieldInlined(intrinsic, obj_inst, store_class, offset); + return InsertMemFromFieldInlined(intrinsic, obj_inst, store_class, offset); } case RuntimeInterface::NamedAccessProfileType::TRANSITION: { ASSERT(!IS_LOAD); - auto store = InsertMemFromField(intrinsic, obj_inst, insert_after, offset); + auto store = InsertMemFromField(intrinsic, obj_inst, insert_after, offset); InsertChangeClassInst(intrinsic, obj_inst, store->GetPrev(), profile.cached_value); return store; } case RuntimeInterface::NamedAccessProfileType::PROTOTYPE_INLINED: { auto load_proto = InsertPrototypeCheckInst(intrinsic, profile.cached_value, &insert_after); - return InsertMemFromFieldInlined(intrinsic, load_proto, insert_after, offset); + return InsertMemFromFieldInlined(intrinsic, load_proto, insert_after, offset); } case RuntimeInterface::NamedAccessProfileType::PROTOTYPE: { auto load_proto = InsertPrototypeCheckInst(intrinsic, profile.cached_value, &insert_after); - return InsertMemFromField(intrinsic, load_proto, insert_after, offset); + return InsertMemFromField(intrinsic, load_proto, insert_after, offset); } default: UNREACHABLE(); @@ -450,11 +442,12 @@ bool InlineIntrinsics::GetICForMemValueAccess(IntrinsicInst *intrinsic) return runtime->GetProfileDataForValueAccess(GetGraph()->GetMethod(), pc, &named_access_profile_); } +template Inst *InlineIntrinsics::InsertCheckAndCastInstructions(IntrinsicInst *intrinsic) { auto pc = intrinsic->GetPc(); auto save_state = intrinsic->GetSaveState(); - auto obj_inst = intrinsic->GetInput(0).GetInst(); + auto obj_inst = intrinsic->GetInput(BY_NAME ? 1 : 0).GetInst(); auto any_check = GetGraph()->CreateInstAnyTypeCheck(DataType::ANY, pc); any_check->SetInput(0, obj_inst); @@ -576,7 +569,7 @@ void InlineIntrinsics::InlineObjByValueWithKey(IntrinsicInst *intrinsic) auto save_state = intrinsic->GetSaveState(); auto prof = named_access_profile_[0]; InsertCheckKeyInstructions(intrinsic, prof.key); - auto cast_value = InsertCheckAndCastInstructions(intrinsic); + auto cast_value = InsertCheckAndCastInstructions(intrinsic); auto get_cls_inst = InsertLoadObject(cast_value, TypeIdMixin::MEM_DYN_CLASS_ID, intrinsic->GetSaveState()->GetMethod(), pc, nullptr, ObjectType::MEM_DYN_CLASS, cast_value, DataType::REFERENCE); @@ -587,7 +580,7 @@ void InlineIntrinsics::InlineObjByValueWithKey(IntrinsicInst *intrinsic) prof.type == RuntimeInterface::NamedAccessProfileType::PROTOTYPE_INLINED) { obj = get_cls_inst; } - [[maybe_unused]] auto load_inst = InsertAccessInst(intrinsic, obj, deopt, prof); + [[maybe_unused]] auto load_inst = InsertAccessInst(intrinsic, obj, deopt, prof); if constexpr (IS_LOAD) { intrinsic->ReplaceUsers(load_inst); @@ -603,7 +596,7 @@ void InlineIntrinsics::InlineObjByValueFromElements(IntrinsicInst *intrinsic) auto save_state = intrinsic->GetSaveState(); // Check that input is heap object - auto cast_value = InsertCheckAndCastInstructions(intrinsic); + auto cast_value = InsertCheckAndCastInstructions(intrinsic); // Insert Load class for the object auto get_cls_inst = InsertLoadObject(cast_value, TypeIdMixin::MEM_DYN_CLASS_ID, save_state->GetMethod(), pc, @@ -733,7 +726,7 @@ bool InlineIntrinsics::InlineObjByName(IntrinsicInst *intrinsic) } ASSERT(!named_access_profile_.empty()); - auto cast_value = InsertCheckAndCastInstructions(intrinsic); + auto cast_value = InsertCheckAndCastInstructions(intrinsic); auto get_cls_inst = InsertLoadObject(cast_value, TypeIdMixin::MEM_DYN_CLASS_ID, intrinsic->GetSaveState()->GetMethod(), pc, nullptr, ObjectType::MEM_DYN_CLASS, cast_value, DataType::REFERENCE); @@ -857,15 +850,13 @@ bool InlineIntrinsics::InlineLdLexDyn(IntrinsicInst *intrinsic) auto *save_state = intrinsic->GetSaveState(); ASSERT(save_state != nullptr); - ASSERT(intrinsic->GetImms().size() == 3U); - // ConstPool, LexEnv, SaveState + // level, slot + ASSERT(intrinsic->GetImms().size() == 2U); + // Name, LexEnv, SaveState ASSERT(intrinsic->GetInputsCount() == 3U); auto *load_lex_var = intrinsic; load_lex_var->SetIntrinsicId(RuntimeInterface::IntrinsicId::INTRINSIC_LD_LEX_VAR_DYN); AdjustFlags(RuntimeInterface::IntrinsicId::INTRINSIC_LD_LEX_VAR_DYN, load_lex_var); - load_lex_var->SetImm(0U, load_lex_var->GetImm(1U)); // level - load_lex_var->SetImm(1U, load_lex_var->GetImm(2U)); // slot - load_lex_var->GetImms().pop_back(); // the last is not needed ASSERT(load_lex_var->GetInput(2U).GetInst()->GetOpcode() == Opcode::SaveState); load_lex_var->RemoveInput(2U); load_lex_var->RemoveInput(0U); @@ -910,18 +901,18 @@ Inst *InlineIntrinsics::GetParentLexEnv(InstAppender *appender, Inst *current_le bool InlineIntrinsics::InlineStLexDyn(IntrinsicInst *intrinsic) { - ASSERT(intrinsic->GetImms().size() == 3U); - // Acc, ConstPool, LexEnv, SaveState + ASSERT(intrinsic->GetImms().size() == 2U); + // Name, Acc, LexEnv, SaveState ASSERT(intrinsic->GetInputsCount() == 4U); - auto level = intrinsic->GetImms()[1U]; + auto level = intrinsic->GetImms()[0U]; if (level > GetLdStLexVarDynLevelThreshold()) { return false; } - auto slot = intrinsic->GetImms()[2U]; + auto slot = intrinsic->GetImms()[1U]; - auto *store_acc_val = intrinsic->GetInput(0U).GetInst(); + auto *store_acc_val = intrinsic->GetInput(1U).GetInst(); auto *store_lex_env = intrinsic->GetInput(2U).GetInst(); InstAppender appender(intrinsic->GetBasicBlock(), intrinsic); @@ -1087,7 +1078,8 @@ bool InlineIntrinsics::InlineTryLdGlobalByName(IntrinsicInst *inst) } ASSERT(inst->GetSaveState() != nullptr); auto runtime = GetGraph()->GetRuntime(); - auto type_id = inst->GetImms()[0]; + auto load_from_cp = inst->GetInput(0).GetInst(); + auto type_id = load_from_cp->CastToLoadFromConstantPool()->GetTypeId(); auto pc = inst->GetPc(); auto save_state = inst->GetSaveState(); ASSERT(save_state != nullptr); @@ -1112,10 +1104,10 @@ bool InlineIntrinsics::InlineTryLdGlobalByName(IntrinsicInst *inst) return true; } case RuntimeInterface::GlobalVarInfo::Type::NON_CONFIGURABLE: - InlineTryLdGlobalField(inst, static_cast(inline_info.value)); + InlineTryLdGlobalField(inst, type_id, static_cast(inline_info.value)); return true; case RuntimeInterface::GlobalVarInfo::Type::FIELD: - InlineTryLdGlobalField(inst, static_cast(inline_info.value)); + InlineTryLdGlobalField(inst, type_id, static_cast(inline_info.value)); return true; default: return false; @@ -1123,11 +1115,10 @@ bool InlineIntrinsics::InlineTryLdGlobalByName(IntrinsicInst *inst) } template -void InlineIntrinsics::InlineTryLdGlobalField(IntrinsicInst *inst, uintptr_t address) +void InlineIntrinsics::InlineTryLdGlobalField(IntrinsicInst *inst, uint32_t type_id, uintptr_t address) { auto pc = inst->GetPc(); auto save_state = inst->GetSaveState(); - auto type_id = inst->GetImms()[0]; auto get_address = GetGraph()->CreateInstGetGlobalVarAddress(DataType::REFERENCE, pc, address); get_address->SetTypeId(type_id); diff --git a/compiler/intrinsics_inline_ecmascript.inl.h b/compiler/intrinsics_inline_ecmascript.inl.h index b7f40549b91040ad8dba32f72c8a4a784c15b2c6..9f157aca0dd27707431554a5767c4db5f3a6fac0 100644 --- a/compiler/intrinsics_inline_ecmascript.inl.h +++ b/compiler/intrinsics_inline_ecmascript.inl.h @@ -53,6 +53,7 @@ void InlineObjByNamePolymorphic(IntrinsicInst *intrinsic, Inst *get_cls_inst, In bool GetICForMemNamedAccess(IntrinsicInst *intrinsic); bool GetICForMemValueAccess(IntrinsicInst *intrinsic); +template Inst *InsertCheckAndCastInstructions(IntrinsicInst *intrinsic); void CreateCompareClass(uint32_t pc, Inst *get_cls_inst, RuntimeInterface::ClassPtr receiver, BasicBlock *load_bb); @@ -77,6 +78,6 @@ bool InlinePopLexenvDyn(IntrinsicInst *intrinsic); bool InlineTryLdGlobalByName(IntrinsicInst *inst); template -void InlineTryLdGlobalField(IntrinsicInst *inst, uintptr_t address); +void InlineTryLdGlobalField(IntrinsicInst *inst, uint32_t type_id, uintptr_t address); #endif // PLUGINS_ECMASCRIPT_COMPILER_INLINE_INTRINSICS_ECMASCRIPT_INL_H \ No newline at end of file diff --git a/compiler/optimizer/code_generator/compiler_base_types.cpp b/compiler/optimizer/code_generator/compiler_base_types.cpp index 67028ec324cac599be72251d7373d8b8caca7094..f968d0900e48c700c20a8d1f98d9ec3db3f5b3f3 100644 --- a/compiler/optimizer/code_generator/compiler_base_types.cpp +++ b/compiler/optimizer/code_generator/compiler_base_types.cpp @@ -649,18 +649,6 @@ bool ecmascript::LoadLexicalEnvGen(const Inst *inst, EncodeVisitor *enc_v) return true; } -bool ecmascript::LoadStringDynamicGen(Inst *inst, EncodeVisitor *enc_v) -{ - auto codegen = enc_v->GetCodegen(); - auto src = codegen->ConvertRegister(inst->GetSrcReg(0), DataType::ANY); - auto dst = codegen->ConvertRegister(inst->GetDstReg(), inst->GetType()); - auto string_type = inst->CastToLoadStringDynamic()->GetTypeId(); - ASSERT(inst->IsRuntimeCall()); - codegen->CallRuntime(inst, ::panda::compiler::RuntimeInterface::EntrypointId::RESOLVE_STRING_DYNAMIC, dst, - RegMask::GetZeroMask(), src, TypedImm(string_type)); - return true; -} - bool ecmascript::HclassCheckGen(HclassCheckInst *check_inst, EncodeVisitor *enc_v) { auto enc = enc_v->GetEncoder(); diff --git a/compiler/optimizer/code_generator/compiler_base_types.h b/compiler/optimizer/code_generator/compiler_base_types.h index aaefed93527a35cf52487a8d23d39f52d928e883..b8382536c9b32acfc6645ac8251a4ec52b63fb9f 100644 --- a/compiler/optimizer/code_generator/compiler_base_types.h +++ b/compiler/optimizer/code_generator/compiler_base_types.h @@ -40,7 +40,6 @@ bool ObjByIndexCheckGen(const FixedInputsInst2 *check_inst, EncodeVisitor *enc_v bool DynamicCallCheckGen(FixedInputsInst2 *check_inst, EncodeVisitor *enc_v); bool LoadConstantPoolGen(const Inst *inst, EncodeVisitor *enc_v); bool LoadLexicalEnvGen(const Inst *inst, EncodeVisitor *enc_v); -bool LoadStringDynamicGen(Inst *inst, EncodeVisitor *enc_v); bool GetAnyTypeNameGen(const GetAnyTypeNameInst *inst, EncodeVisitor *enc_v); bool HclassCheckGen(HclassCheckInst *check_inst, EncodeVisitor *enc_v); bool IsDynHeapObject(AnyBaseType type); diff --git a/compiler/optimizer/optimizations/ecma_inlining.cpp b/compiler/optimizer/optimizations/ecma_inlining.cpp index 206525615ceee210d9855595175befbe3121fe26..31ecdd15537d34e3a23c52c89eae40c748095282 100644 --- a/compiler/optimizer/optimizations/ecma_inlining.cpp +++ b/compiler/optimizer/optimizations/ecma_inlining.cpp @@ -88,8 +88,9 @@ RuntimeInterface::MethodPtr EcmaInlining::TryResolveTargetStatic(CallInst *call_ { auto define_func = call_inst->GetDataFlowInput(0); if (IsInstSuitableForEcmaStaticInlining(define_func)) { + auto load_from_cp = define_func->CastToIntrinsic()->GetInput(0).GetInst()->CastToLoadFromConstantPool(); return GetGraph()->GetRuntime()->GetMethodByIdAndSaveJsFunction(GetGraph()->GetMethod(), - define_func->CastToIntrinsic()->GetImm(0)); + load_from_cp->GetTypeId()); } return nullptr; } diff --git a/compiler/optimizer/optimizations/inline_call_intrinsics.cpp b/compiler/optimizer/optimizations/inline_call_intrinsics.cpp index ef42b16275cb737a1956fa4f877fcb22b4b17ec6..bb2db56464b5a439940ce9177fdce75c1532201a 100644 --- a/compiler/optimizer/optimizations/inline_call_intrinsics.cpp +++ b/compiler/optimizer/optimizations/inline_call_intrinsics.cpp @@ -159,6 +159,7 @@ Inst *InlineCallIntrinsics::NewObjResolveCtorResult(InstAppender *appender, Inst resolve_result->AddInputType(DataType::ANY); resolve_result->AppendInput(ss_copy_2); resolve_result->AddInputType(DataType::NO_TYPE); + resolve_result->SetInlined(true); appender->Append({ss_copy_2, resolve_result}); diff --git a/compiler/templates/ecmascript_inst_builder_gen.cpp.erb b/compiler/templates/ecmascript_inst_builder_gen.cpp.erb index 23e4a6ae98a641f3a29ef4d1cd1666f71f188c7c..2d5988c0deb9b7548d04d4b7d734f9783a38c20a 100644 --- a/compiler/templates/ecmascript_inst_builder_gen.cpp.erb +++ b/compiler/templates/ecmascript_inst_builder_gen.cpp.erb @@ -147,12 +147,27 @@ void InstBuilder::BuildEcmaAsIntrinsics(const BytecodeInstruction* bc_inst) // N % end inst->ReserveInputs(args_count); inst->AllocateInputTypes(GetGraph()->GetAllocator(), args_count); + inst->SetInlined(true); % imm_index = 0 % vreg_index = 0 % id16_index = 0 % id32_index = 0 auto inst_save_state = CreateSaveState(Opcode::SaveState, GetPc(bc_inst->GetAddress())); +% if num_ids > 0 +% abort "Too many ids in inputs: #{opc}" if num_ids > 1 + LoadFromPoolDynamic *load_from_pool = nullptr; + if (!GetGraph()->IsBytecodeOptimizer()) { + load_from_pool = graph_->CreateInstLoadFromConstantPool(DataType::ANY, inst->GetPc()); + load_from_pool->SetInput(0, GetEnvDefinition(CONST_POOL_IDX)); + auto num_user = inst_save_state->AppendInput(load_from_pool); + inst_save_state->SetVirtualRegister(num_user, VirtualRegister(VirtualRegister::BRIDGE, VRegType::VREG)); + AddInstruction(load_from_pool); + inst->AppendInput(load_from_pool); + inst->AddInputType(DataType::ANY); + inst->SetHasIdInput(); + } +% end AddInstruction(inst_save_state); % params_arr.each_with_index do |param, input_index| % if param.imm? @@ -179,20 +194,31 @@ void InstBuilder::BuildEcmaAsIntrinsics(const BytecodeInstruction* bc_inst) // N } % vreg_index = vreg_index + 1 % elsif param.id? +% abort "Id is not the first input: #{opc}" if input_index > 0 % if inst.properties.include?("method_id") auto m_idx<%= id16_index %> = bc_inst->template GetId<<%= format %>>().AsRawValue(); if (GetGraph()->IsBytecodeOptimizer()) { - m_idx<%= id16_index %> = GetRuntime()->ResolveMethodIndex(GetGraph()->GetMethod(), m_idx<%= id16_index %>); + m_idx<%= id16_index %> = GetRuntime()->ResolveMethodIndex(GetGraph()->GetMethod(), m_idx<%= id16_index %>); + inst->AddImm(GetGraph()->GetAllocator(), m_idx<%= id16_index %>); + } else { + load_from_pool->SetTypeId(m_idx<%= id16_index %>); } - inst->AddImm(GetGraph()->GetAllocator(), m_idx<%= id16_index %>); % id16_index = id16_index + 1 % elsif inst.properties.include?("literalarray_id") auto literalarray_id<%= id16_index %> = bc_inst->template GetId<<%= format %>>().AsIndex(); - inst->AddImm(GetGraph()->GetAllocator(), literalarray_id<%= id16_index %>); + if (GetGraph()->IsBytecodeOptimizer()) { + inst->AddImm(GetGraph()->GetAllocator(), literalarray_id<%= id16_index %>); + } else { + load_from_pool->SetTypeId(literalarray_id<%= id16_index %>); + } % id16_index = id16_index + 1 % elsif inst.properties.include?("string_id") auto string_id<%= id32_index %> = bc_inst->template GetId<<%= format %>>().AsFileId().GetOffset(); - inst->AddImm(GetGraph()->GetAllocator(), string_id<%= id32_index %>); + if (GetGraph()->IsBytecodeOptimizer()) { + inst->AddImm(GetGraph()->GetAllocator(), string_id<%= id32_index %>); + } else { + load_from_pool->SetTypeId(string_id<%= id32_index %>); + } % id32_index = id32_index + 1 % end % end @@ -332,8 +358,12 @@ void InstBuilder::BuildEcmaFromIrtoc([[maybe_unused]] const BytecodeInstruction* % imm_index = imm_index + 1 % elsif param.id? auto id<%= id_index %>_payload = static_cast(bc_inst->template GetId<<%= format %>>().AsIndex()); - auto id<%= id_index %> = GetGraph()->FindOrCreateConstant(id<%= id_index %>_payload); -% inputs.push("id#{id_index}") + auto load_from_pool = graph_->CreateInstLoadFromConstantPool(DataType::ANY, GetPc(bc_inst->GetAddress())); + load_from_pool->SetInput(0, GetEnvDefinition(CONST_POOL_IDX)); + load_from_pool->SetTypeId(id<%= id_index %>_payload); + additional_def_ = load_from_pool; + AddInstruction(load_from_pool); +% inputs.push("load_from_pool") % id_index = id_index + 1 % elsif param.prof? % # Just skip profile id @@ -360,6 +390,9 @@ void InstBuilder::BuildEcmaFromIrtoc([[maybe_unused]] const BytecodeInstruction* % builder = 'Build' + inst.opcode.split('_')[0..1].map do |_| _.capitalize end.join() [[maybe_unused]] auto inst = <%= builder %>(GetGraph(), this, ¤t_bb_, <%= inputs.empty? ? '' : inputs.join(', ') + ', ' %>GetPc(bc_inst->GetAddress()), visited_block_marker_); +% if id_index > 0 + additional_def_ = nullptr; +% end % if inst.acc.include?('out') UpdateDefinitionAcc(inst); % end diff --git a/ecmascript_plugin_options.yaml b/ecmascript_plugin_options.yaml index ea781fe6c89e9431ceb7f8b285e5d408b8415e12..e0fe9252a83584100b7c8a459de6539b6c2048cd 100644 --- a/ecmascript_plugin_options.yaml +++ b/ecmascript_plugin_options.yaml @@ -52,7 +52,6 @@ func_is_any_type_can_be_subtype_of: panda::compiler::ecmascript::IsAnyTypeCanBeSubtypeOf func_load_constant_pool: panda::compiler::ecmascript::LoadConstantPoolGen func_load_lexical_env: panda::compiler::ecmascript::LoadLexicalEnvGen - func_load_string_dyn: panda::compiler::ecmascript::LoadStringDynamicGen func_is_dyn_heap_object: panda::compiler::ecmascript::IsDynHeapObject list_types: HOLE_TYPE: panda::compiler::DataType::Type::ANY diff --git a/ecmastdlib/ecmastdlib.pa b/ecmastdlib/ecmastdlib.pa index 56761698efd6e330ff02cf5871aad362c1722d38..64494c00d23e5407d6adfc8c003e82437644e057 100644 --- a/ecmastdlib/ecmastdlib.pa +++ b/ecmastdlib/ecmastdlib.pa @@ -22,7 +22,7 @@ .function any Ecmascript.Intrinsics.ldboolean(any a0) .function any Ecmascript.Intrinsics.ldnumber(any a0) .function any Ecmascript.Intrinsics.ldstring(any a0) -.function any Ecmascript.Intrinsics.ldbigint(u32 a0, any a1) +.function any Ecmascript.Intrinsics.ldbigint(any a0) .function any Ecmascript.Intrinsics.ldnull() .function any Ecmascript.Intrinsics.ldsymbol() .function any Ecmascript.Intrinsics.ldobject(any a0, any a1) @@ -62,8 +62,8 @@ .function any Ecmascript.Intrinsics.defineglobalvar(any a0, any a1) .function any Ecmascript.Intrinsics.definelocalvar(any a0, any a1) .function any Ecmascript.Intrinsics.definefuncexpr(any a0, any a1) -.function any Ecmascript.Intrinsics.definefuncDyn(u32 a0, any a1, any a2) -.function any Ecmascript.Intrinsics.defineNCFuncDyn(u32 a0, any a1, any a2, any a3) +.function any Ecmascript.Intrinsics.definefuncDyn(any a0, any a1, any a2) +.function any Ecmascript.Intrinsics.defineNCFuncDyn(any a0, any a1, any a2, any a3) .function any Ecmascript.Intrinsics.refeqDyn(any a0, any a1) .function any Ecmascript.Intrinsics.expDyn(any a0, any a1) .function any Ecmascript.Intrinsics.typeofDyn(any a0) @@ -79,9 +79,9 @@ .function any Ecmascript.Intrinsics.newlexenvDyn(u16 a0, any a1) .function any Ecmascript.Intrinsics.copylexenvDyn(any a0) .function void Ecmascript.Intrinsics.StLexVarDyn(u16 a0, u16 a1, any a2, any a3) -.function any Ecmascript.Intrinsics.StLexDyn(u32 a0, u16 a1, u16 a2, any a3, any a4, any a5) +.function any Ecmascript.Intrinsics.StLexDyn(any a0, u16 a1, u16 a2, any a3, any a4) .function any Ecmascript.Intrinsics.LdLexVarDyn(u16 a0, u16 a1, any a2) -.function any Ecmascript.Intrinsics.LdLexDyn(u32 a0, u16 a1, u16 a2, any a3, any a4) +.function any Ecmascript.Intrinsics.LdLexDyn(any a0, u16 a1, u16 a2, any a3) .function any Ecmascript.Intrinsics.ldlexenvDyn() .function any Ecmascript.Intrinsics.popLexenvDyn(any a0) .function any Ecmascript.Intrinsics.getUnmappedArgs() @@ -93,7 +93,7 @@ .function any Ecmascript.Intrinsics.isFalse(any a0) .function any Ecmascript.Intrinsics.isCoercible(any a0) .function any Ecmascript.Intrinsics.getPropIterator(any a0) -.function any Ecmascript.Intrinsics.defineGeneratorFunc(u32 a0, any a1, any a2) +.function any Ecmascript.Intrinsics.defineGeneratorFunc(any a0, any a1, any a2) .function any Ecmascript.Intrinsics.createIterResultObj(any a0, u8 a1) .function any Ecmascript.Intrinsics.setGeneratorState(any a0, u8 a1) .function any Ecmascript.Intrinsics.suspendGenerator(any a0, any a1) @@ -104,8 +104,8 @@ .function any Ecmascript.Intrinsics.getResumeMode(any a0) .function any Ecmascript.Intrinsics.createGeneratorObj(any a0) .function any Ecmascript.Intrinsics.createAsyncGeneratorObj(any a0) -.function any Ecmascript.Intrinsics.defineAsyncFunc(u32 a0, any a1, any a2) -.function any Ecmascript.Intrinsics.defineAsyncGeneratorFunc(u32 a0, any a1, any a2) +.function any Ecmascript.Intrinsics.defineAsyncFunc(any a0, any a1, any a2) +.function any Ecmascript.Intrinsics.defineAsyncGeneratorFunc(any a0, any a1, any a2) .function any Ecmascript.Intrinsics.asyncFunctionEnter() .function any Ecmascript.Intrinsics.asyncFunctionAwait(any a0, any a1) .function any Ecmascript.Intrinsics.asyncFunctionResolve(any a0, any a1) @@ -113,19 +113,19 @@ .function any Ecmascript.Intrinsics.asyncGeneratorResolve(any a0, any a1) .function any Ecmascript.Intrinsics.asyncGeneratorReject(any a0, any a1) .function void Ecmascript.Intrinsics.throwUndefined(any a0) -.function void Ecmascript.Intrinsics.throwConstAssignment(u32 a0, any a1) -.function void Ecmascript.Intrinsics.throwTdz(u32 a0, any a1) +.function void Ecmascript.Intrinsics.throwConstAssignment(any a0) +.function void Ecmascript.Intrinsics.throwTdz(any a0) .function any Ecmascript.Intrinsics.copyrestargs(u16 a0) .function any Ecmascript.Intrinsics.copyrestargsInterp(u16 a0) .function any Ecmascript.Intrinsics.ldHole() -.function any Ecmascript.Intrinsics.getMethod(u32 a0, any a1, any a2) +.function any Ecmascript.Intrinsics.getMethod(any a0, any a1) .function any Ecmascript.Intrinsics.getTemplateObject(any a0) -.function any Ecmascript.Intrinsics.TryLdGlobalByName(u32 a0, u16 a1, any a2, any a3) -.function any Ecmascript.Intrinsics.TryStGlobalByName(u32 a0, any a1, u16 a2, any a3, any a4) -.function any Ecmascript.Intrinsics.LdGlobalVar(u32 a0, u16 a1, any a2, any a3) -.function any Ecmascript.Intrinsics.StGlobalVar(u32 a0, any a1, u16 a2, any a3, any a4) -.function any Ecmascript.Intrinsics.LdObjByName(u32 a0, any a1, u16 a2, any a3, any a4) -.function any Ecmascript.Intrinsics.StObjByName(u32 a0, any a1, any a2, u16 a3, any a4, any a5) +.function any Ecmascript.Intrinsics.TryLdGlobalByName(any a0, u16 a1, any a2) +.function any Ecmascript.Intrinsics.TryStGlobalByName(any a0, any a1, u16 a2, any a3) +.function any Ecmascript.Intrinsics.LdGlobalVar(any a0, u16 a1, any a2) +.function any Ecmascript.Intrinsics.StGlobalVar(any a0, any a1, u16 a2, any a3 ) +.function any Ecmascript.Intrinsics.LdObjByName(any a0, any a1, u16 a2, any a3) +.function any Ecmascript.Intrinsics.StObjByName(any a0, any a1, any a2, u16 a3, any a4) .function any Ecmascript.Intrinsics.LdObjByIndex(u32 a0, any a1) .function any Ecmascript.Intrinsics.StObjByIndex(u32 a0, any a1, any a2) .function any Ecmascript.Intrinsics.getnextpropname(any a0) @@ -143,14 +143,14 @@ .function any Ecmascript.Intrinsics.Call3ThisDyn(any a0, any a1, any a2, any a3, any a4) .function any Ecmascript.Intrinsics.CalliThisRangeDyn(u16 a0, any a1) .function any Ecmascript.Intrinsics.createemptyobject() -.function any Ecmascript.Intrinsics.createobjectwithbuffer(u16 a0, any a1) +.function any Ecmascript.Intrinsics.createobjectwithbuffer(any a0) .function any Ecmascript.Intrinsics.setobjectwithproto(any a0, any a1) .function any Ecmascript.Intrinsics.copydataproperties(any a0, any a1) .function any Ecmascript.Intrinsics.definegettersetterbyvalue(any a0, any a1, any a2, any a3, any a4) .function any Ecmascript.Intrinsics.createemptyarray() -.function any Ecmascript.Intrinsics.createarraywithbuffer(u16 a0, any a1) -.function any Ecmascript.Intrinsics.createregexpwithliteral(u32 a0, u8 a1, any a2) -.function any Ecmascript.Intrinsics.StOwnByName(u32 a0, any a1, any a2, any a3) +.function any Ecmascript.Intrinsics.createarraywithbuffer(any a0) +.function any Ecmascript.Intrinsics.createregexpwithliteral(any a0, u8 a1) +.function any Ecmascript.Intrinsics.StOwnByName(any a0, any a1, any a2) .function any Ecmascript.Intrinsics.StOwnByIndex(u32 a0, any a1, any a2) .function any Ecmascript.Intrinsics.StOwnByValue(any a0, any a1, any a2) .function any Ecmascript.Intrinsics.starrayspread(any a0, any a1, any a2) @@ -161,35 +161,35 @@ .function any Ecmascript.Intrinsics.CreateObjectWithExcludedKeys(u16 a0, any a1, any a2) .function void Ecmascript.Intrinsics.ThrowPatternNonCoercible() .function any Ecmascript.Intrinsics.CloseIterator(any a0, any a1) -.function any Ecmascript.Intrinsics.ImportModule(u32 a0, any a1) -.function void Ecmascript.Intrinsics.StModuleVar(u32 a0, any a1, any a2) +.function any Ecmascript.Intrinsics.ImportModule(any a0) +.function void Ecmascript.Intrinsics.StModuleVar(any a0, any a1) .function void Ecmascript.Intrinsics.CopyModule(any a0) -.function any Ecmascript.Intrinsics.LdModvarByName(u32 a0, any a1, any a2) +.function any Ecmascript.Intrinsics.LdModvarByName(any a0, any a1) .function any Ecmascript.Intrinsics.LoadClassComputedInstanceFields(any a0) .function void Ecmascript.Intrinsics.SetClassComputedFields(any a0, any a1) -.function any Ecmascript.Intrinsics.DefineClassWithBuffer(u32 a0, u16 a1, any a2, any a3, any a4) +.function any Ecmascript.Intrinsics.DefineClassWithBuffer(any a0, u16 a1, any a2, any a3, any a4) .function any Ecmascript.Intrinsics.ClassFieldAdd(any a0, any a1, any a2) -.function void Ecmascript.Intrinsics.DefineClassPrivateFields(u16 a0, any a1, any a2, any a3) +.function void Ecmascript.Intrinsics.DefineClassPrivateFields(any a0, any a1, any a2, any a3) .function any Ecmascript.Intrinsics.ClassPrivateMethodOrAccessorAdd(any a0, any a1) -.function any Ecmascript.Intrinsics.ClassPrivateFieldAdd(u32 a0, any a1, any a2, any a3, any a4) -.function any Ecmascript.Intrinsics.ClassPrivateFieldGet(u32 a0, any a1, any a2, any a3) -.function any Ecmascript.Intrinsics.ClassPrivateFieldSet(u32 a0, any a1, any a2, any a3, any a4) -.function any Ecmascript.Intrinsics.ClassPrivateFieldIn(u32 a0, any a1, any a2, any a3) +.function any Ecmascript.Intrinsics.ClassPrivateFieldAdd(any a0, any a1, any a2, any a3) +.function any Ecmascript.Intrinsics.ClassPrivateFieldGet(any a0, any a1, any a2) +.function any Ecmascript.Intrinsics.ClassPrivateFieldSet(any a0, any a1, any a2, any a3) +.function any Ecmascript.Intrinsics.ClassPrivateFieldIn(any a0, any a1, any a2) .function any Ecmascript.Intrinsics.SuperCall(u16 a0, any a1, any a2, any a3) .function any Ecmascript.Intrinsics.SuperCallSpread(any a0, any a1, any a2) -.function any Ecmascript.Intrinsics.defineMethod(u32 a0, any a1, any a2, any a3) -.function any Ecmascript.Intrinsics.LdSuperByName(u32 a0, any a1, any a2, any a3) -.function any Ecmascript.Intrinsics.StSuperByName(u32 a0, any a1, any a2, any a3, any a4) +.function any Ecmascript.Intrinsics.defineMethod(any a0, any a1, any a2, any a3) +.function any Ecmascript.Intrinsics.LdSuperByName(any a0, any a1, any a2) +.function any Ecmascript.Intrinsics.StSuperByName(any a0, any a1, any a2, any a3) .function any Ecmascript.Intrinsics.StSuperByValue(any a0, any a1, any a2, any a3) .function any Ecmascript.Intrinsics.LdSuperByValue(any a0, any a1, any a2) -.function any Ecmascript.Intrinsics.createobjecthavingmethod(u16 a0, any a1, any a2) +.function any Ecmascript.Intrinsics.createobjecthavingmethod(any a0, any a1, any a2) .function any Ecmascript.Intrinsics.ThrowIfSuperNotCorrectCall(u16 a0, any a1) .function any Ecmascript.Intrinsics.LdHomeObject(any a0) .function void Ecmascript.Intrinsics.ThrowDeleteSuperProperty() -.function any Ecmascript.Intrinsics.LdEvalBindings(u16 a0, any a1) +.function any Ecmascript.Intrinsics.LdEvalBindings(any a0) .function any Ecmascript.Intrinsics.DirectEval(u32 a0, any a1, any a2) -.function any Ecmascript.Intrinsics.LdEvalVar(u32 a0, any a1, any a2) -.function any Ecmascript.Intrinsics.StEvalVar(u32 a0, any a1, any a2, any a3) +.function any Ecmascript.Intrinsics.LdEvalVar(any a0, any a1) +.function any Ecmascript.Intrinsics.StEvalVar(any a0, any a1, any a2) .function void Ecmascript.Intrinsics.debugger() .function void Ecmascript.Intrinsics.NativeMethodWrapper(any a0) diff --git a/irtoc_scripts/common.irt b/irtoc_scripts/common.irt index 9d74887abcef3b3a4ea0ed9c6acfcd80244fc392..c71086cc56b4414605636ca5340e813f76105567 100644 --- a/irtoc_scripts/common.irt +++ b/irtoc_scripts/common.irt @@ -200,6 +200,10 @@ macro(:get_cp) do || LoadI(get_current_env).Imm(Constants::ECMASCRIPT_CONSTANT_POOL_OFFSET).any end +macro(:load_from_cp) do |operand| + LoadArray(get_cp, as_id(operand)).any +end + macro(:get_lex_env) do || LoadI(get_current_env).Imm(Constants::ECMASCRIPT_LEXICAL_ENV_OFFSET).any end diff --git a/irtoc_scripts/interpreter_handlers.irt b/irtoc_scripts/interpreter_handlers.irt index cd20cd9c87f46f5c8aeeb3e38e0a95b490331079..e4c442749b83deb804e66d345768661a226802e5 100644 --- a/irtoc_scripts/interpreter_handlers.irt +++ b/irtoc_scripts/interpreter_handlers.irt @@ -1451,8 +1451,8 @@ macro(:ic_handler_get_offset) do |handler| get_bits(handler, Constants::IC_HANDLER_OFFSET_BIT, Constants::IC_HANDLER_OFFSET_MASK) end -macro(:load_object_dynamic_by_name) do |obj, key, ic_slot, props, this_func, cp| - Intrinsic(:LD_OBJ_DYN_BY_NAME, obj, key, ic_slot, this_func, cp).any +macro(:load_object_dynamic_by_name) do |obj, key, ic_slot, props, this_func| + Intrinsic(:LD_OBJ_DYN_BY_NAME, obj, key, ic_slot, this_func).any end macro(:load_object_dynamic_by_value) do |obj, key, ic_slot, props, this_func| @@ -1462,8 +1462,8 @@ macro(:load_object_dynamic_by_value) do |obj, key, ic_slot, props, this_func| .any end -macro(:store_object_dynamic_by_name) do |obj, key, value, ic_slot, props, this_func, cp| - Intrinsic(:ST_OBJ_DYN_BY_NAME, obj, key, value, ic_slot, this_func, cp).any +macro(:store_object_dynamic_by_name) do |obj, key, value, ic_slot, props, this_func| + Intrinsic(:ST_OBJ_DYN_BY_NAME, obj, key, value, ic_slot, this_func).any end macro(:store_object_dynamic_by_value) do |obj, key, value, ic_slot, props, this_func| @@ -1473,7 +1473,7 @@ macro(:store_object_dynamic_by_value) do |obj, key, value, ic_slot, props, this_ .any end -macro(:handle_load_object_dynamic_by_name) do |obj, key, ic_slot, props, this_func, cp| +macro(:handle_load_object_dynamic_by_name) do |obj, key, ic_slot, props, this_func| handle_access_object_dynamic(obj, key, nil, lambda do |obj, index, _| handle_load_object_dynamic_by_index(obj, index, props) @@ -1482,11 +1482,11 @@ macro(:handle_load_object_dynamic_by_name) do |obj, key, ic_slot, props, this_fu unless ic_slot.nil? r0 := try_load_obj_ic(this_func, obj, ic_slot) IfImm(cmpanyhole(r0)).Imm(0).CC(:CC_NE).b { - r1 := load_object_dynamic_by_name(obj, key, ic_slot, props, this_func, cp) + r1 := load_object_dynamic_by_name(obj, key, ic_slot, props, this_func) } Phi(r0, r1).any else - load_object_dynamic_by_name(obj, key, ic_slot, props, this_func, cp) + load_object_dynamic_by_name(obj, key, ic_slot, props, this_func) end end, props) @@ -1526,7 +1526,7 @@ macro(:handle_load_object_dynamic_by_index) do |obj, key, props| props) end -macro(:handle_store_object_dynamic_by_name) do |obj, key, value, ic_slot, props, this_func, cp| +macro(:handle_store_object_dynamic_by_name) do |obj, key, value, ic_slot, props, this_func| handle_access_object_dynamic(obj, key, value, lambda do |obj, index, value| handle_store_object_dynamic_by_index(obj, index, value, props) @@ -1535,11 +1535,11 @@ macro(:handle_store_object_dynamic_by_name) do |obj, key, value, ic_slot, props, unless ic_slot.nil? r0 := try_store_obj_ic(this_func, obj, value, ic_slot) IfImm(cmpanyhole(r0)).Imm(0).CC(:CC_NE).b { - r1 := store_object_dynamic_by_name(obj, key, value, ic_slot, props, this_func, cp) + r1 := store_object_dynamic_by_name(obj, key, value, ic_slot, props, this_func) } Phi(r0, r1).any else - store_object_dynamic_by_name(obj, key, value, ic_slot, props, this_func, cp) + store_object_dynamic_by_name(obj, key, value, ic_slot, props, this_func) end end, props) @@ -1726,33 +1726,28 @@ end # LD_OBJECT_BY_NAME # -macro(:resolve_id) do |cp, id| - LoadArray(cp, id).any -end - -macro(:handle_ecma_ldobjbyname) do |obj, id, ic_slot, this_func, cp| +macro(:handle_ecma_ldobjbyname) do |obj, key, ic_slot, this_func| props = ObjectAccessProperties.new(:by_name, :unknown, false) - key := resolve_id(cp, id) IfImm(cmpanyheapobj(obj)).Imm(0).CC(:CC_NE).b { - load_res := handle_load_object_dynamic_by_name(obj, key, ic_slot, props, this_func, cp) + load_res := handle_load_object_dynamic_by_name(obj, key, ic_slot, props, this_func) IfImm(cmpanyhole(load_res)).Imm(0).CC(:CC_NE).b { - slow_res := ecma_intrinsic_invoke("LdObjByNameSlow", id, obj, ic_slot, this_func, cp).any + slow_res := ecma_intrinsic_invoke("LdObjByNameSlow", key, obj, ic_slot, this_func).any } res := Phi(load_res, slow_res).any } Else { - slow_res_exception := ecma_intrinsic_invoke("LdObjByNameSlow", id, obj, ic_slot, this_func, cp).any + slow_res_exception := ecma_intrinsic_invoke("LdObjByNameSlow", key, obj, ic_slot, this_func).any } Phi(res, slow_res_exception).any end function(:EcmaLdobjbyname, - params: {'id'=>'i32', 'obj'=>'any','ic_slot'=>'i32', 'this_func'=>'any', 'cp'=>'any'}, + params: {'key'=>'any', 'obj'=>'any','ic_slot'=>'i32', 'this_func'=>'any'}, mode: [:Interpreter, :DynamicMethod, :DynamicStub], enable_builder: true) do - Return(handle_ecma_ldobjbyname(obj, id, ic_slot, this_func, cp)) + Return(handle_ecma_ldobjbyname(obj, key, ic_slot, this_func)) end function(:FastPathLdObjByName, - params: {id: 'i32', obj: 'any', ic_slot: 'i32', this_func: 'any', cp: 'any'}, + params: {key: 'any', obj: 'any', ic_slot: 'i32', this_func: 'any'}, mode: [:FastPath, :DynamicMethod, :DynamicStub], regmap: $full_regmap, regalloc_set: RegMask.new($full_regmap, :arg0, :arg1) + $panda_callees_mask - $panda_regmap) do @@ -1763,43 +1758,41 @@ function(:FastPathLdObjByName, end props = ObjectAccessProperties.new(:by_name, :unknown, false) - key := resolve_id(cp, id) IfImm(cmpanyheapobj(obj)).Imm(0).CC(:CC_NE).b { - load_res := handle_load_object_dynamic_by_name(obj, key, ic_slot, props, this_func, cp) + load_res := handle_load_object_dynamic_by_name(obj, key, ic_slot, props, this_func) IfImm(cmpanyhole(load_res)).Imm(0).CC(:CC_NE).b { - Intrinsic(:SLOW_PATH_ENTRY, id, obj, ic_slot, this_func, cp).Method("LdObjByNameBridge", :AddImm).Relocate.Terminator.ptr + Intrinsic(:SLOW_PATH_ENTRY, key, obj, ic_slot, this_func).Method("LdObjByNameBridge", :AddImm).Relocate.Terminator.ptr } Return(load_res).any } Else { - Intrinsic(:SLOW_PATH_ENTRY, id, obj, ic_slot, this_func, cp).Method("LdObjByNameBridge", :AddImm).Relocate.Terminator.ptr + Intrinsic(:SLOW_PATH_ENTRY, key, obj, ic_slot, this_func).Method("LdObjByNameBridge", :AddImm).Relocate.Terminator.ptr } end #################################################################################### # ST_OBJECT_BY_NAME # -macro(:handle_ecma_stobjbyname) do |obj, id, value, ic_slot, this_func, cp| +macro(:handle_ecma_stobjbyname) do |obj, key, value, ic_slot, this_func| props = ObjectAccessProperties.new(:by_name, :unknown, false) - key := resolve_id(cp, id) IfImm(cmpanyheapobj(obj)).Imm(0).CC(:CC_NE).b { - store_res := handle_store_object_dynamic_by_name(obj, key, value, ic_slot, props, this_func, cp) + store_res := handle_store_object_dynamic_by_name(obj, key, value, ic_slot, props, this_func) IfImm(cmpanyhole(store_res)).Imm(0).CC(:CC_NE).b { - ecma_intrinsic_invoke("StObjByNameSlow", id, obj, value, ic_slot, this_func, cp).any + ecma_intrinsic_invoke("StObjByNameSlow", key, obj, value, ic_slot, this_func).any } } Else { - ecma_intrinsic_invoke("StObjByNameSlow", id, obj, value, ic_slot, this_func, cp).any + ecma_intrinsic_invoke("StObjByNameSlow", key, obj, value, ic_slot, this_func).any } end function(:EcmaStobjbyname, - params: {'id'=>'i32', 'obj'=>'any', 'value'=>'any', 'ic_slot'=>'i32', 'this_func'=>'any', 'cp'=>'any'}, + params: {'key'=>'any', 'obj'=>'any', 'value'=>'any', 'ic_slot'=>'i32', 'this_func'=>'any'}, mode: [:Interpreter, :DynamicMethod, :DynamicStub], enable_builder: true) do - handle_ecma_stobjbyname(obj, id, value, ic_slot, this_func, cp) + handle_ecma_stobjbyname(obj, key, value, ic_slot, this_func) ReturnVoid() end function(:FastPathStObjByName, - params: {id: 'i32', obj: 'any', value: 'any', ic_slot: 'i32', this_func: 'any', cp: 'any'}, + params: {key: 'any', obj: 'any', value: 'any', ic_slot: 'i32', this_func: 'any'}, mode: [:FastPath, :DynamicMethod, :DynamicStub], regmap: $full_regmap, regalloc_set: RegMask.new($full_regmap, :arg0, :arg1) + $panda_callees_mask - $panda_regmap, @@ -1811,14 +1804,13 @@ function(:FastPathStObjByName, end props = ObjectAccessProperties.new(:by_name, :unknown, false) - key := resolve_id(cp, id) IfImm(cmpanyheapobj(obj)).Imm(0).NE.b { - res := handle_store_object_dynamic_by_name(obj, key, value, ic_slot, props, this_func, cp) + res := handle_store_object_dynamic_by_name(obj, key, value, ic_slot, props, this_func) IfImm(cmpanyhole(res)).Imm(0).NE.b { - Intrinsic(:SLOW_PATH_ENTRY, id, obj, value, ic_slot, this_func, cp).Method("StObjByNameBridge", :AddImm).Relocate.Terminator.ptr + Intrinsic(:SLOW_PATH_ENTRY, key, obj, value, ic_slot, this_func).Method("StObjByNameBridge", :AddImm).Relocate.Terminator.ptr } } Else { - Intrinsic(:SLOW_PATH_ENTRY, id, obj, value, ic_slot, this_func, cp).Method("StObjByNameBridge", :AddImm).Relocate.Terminator.ptr + Intrinsic(:SLOW_PATH_ENTRY, key, obj, value, ic_slot, this_func).Method("StObjByNameBridge", :AddImm).Relocate.Terminator.ptr } ReturnVoid() end @@ -1826,45 +1818,43 @@ end #################################################################################### # TRY_LD_GLOBAL_BY_NAME # -macro(:handle_ecma_tryldglobalbyname) do |id, ic_slot, this_func, cp| - key := resolve_id(cp, id) +macro(:handle_ecma_tryldglobalbyname) do |key, ic_slot, this_func| ic_res := load_global_var_ic(this_func, key, ic_slot) IfImm(cmpanyhole(ic_res)).Imm(0).CC(:CC_EQ).b { res0 := ic_res } Else { - res1 := ecma_intrinsic_invoke("TryLdGlobalByNameSlow", id, ic_slot, this_func, cp).any + res1 := ecma_intrinsic_invoke("TryLdGlobalByNameSlow", key, ic_slot, this_func).any } Phi(res0, res1).any end function(:EcmaTryldglobalbyname, - params: {'id'=>'i32', 'ic_slot'=>'i32', 'this_func'=>'any', 'cp'=>'any'}, + params: {'key'=>'any', 'ic_slot'=>'i32', 'this_func'=>'any'}, mode: [:Interpreter, :DynamicMethod, :DynamicStub], enable_builder: true) do - Return(handle_ecma_tryldglobalbyname(id, ic_slot, this_func, cp)) + Return(handle_ecma_tryldglobalbyname(key, ic_slot, this_func)) end #################################################################################### # LD_GLOBAL_VAR # -macro(:handle_ecma_ldglobalvar) do |id, ic_slot, this_func, cp| - key := resolve_id(cp, id) +macro(:handle_ecma_ldglobalvar) do |key, ic_slot, this_func| ic_res := load_global_var_ic(this_func, key, ic_slot) IfImm(cmpanyhole(ic_res)).Imm(0).CC(:CC_EQ).b { res0 := ic_res } Else { - res1 := ecma_intrinsic_invoke("LdGlobalVarSlow", id, ic_slot, this_func, cp).any + res1 := ecma_intrinsic_invoke("LdGlobalVarSlow", key, ic_slot, this_func).any } Phi(res0, res1).any end function(:EcmaLdglobalvar, - params: {'id'=>'i32', 'ic_slot'=>'i32', 'this_func'=>'any', 'cp'=>'any'}, + params: {'key'=>'any', 'ic_slot'=>'i32', 'this_func'=>'any'}, mode: [:Interpreter, :DynamicMethod, :DynamicStub], enable_builder: true) do - Return(handle_ecma_ldglobalvar(id, ic_slot, this_func, cp)) + Return(handle_ecma_ldglobalvar(key, ic_slot, this_func)) end function(:FastPathLdGlobalVar, - params: {id: 'i32', ic_slot: 'i32', this_func: 'any', cp: 'any'}, + params: {key: 'any', ic_slot: 'i32', this_func: 'any'}, mode: [:FastPath, :DynamicMethod, :DynamicStub], regmap: $full_regmap, regalloc_set: RegMask.new($full_regmap, :arg0, :arg1) + $panda_callees_mask - $panda_regmap) do @@ -1874,10 +1864,9 @@ function(:FastPathLdGlobalVar, next end - key := resolve_id(cp, id) ic_res := load_global_var_ic(this_func, key, ic_slot).any IfImm(cmpanyhole(ic_res)).Imm(0).CC(:CC_NE).b { - Intrinsic(:SLOW_PATH_ENTRY, id, ic_slot, this_func, cp).Method("LdGlobalVarBridge", :AddImm).Relocate.Terminator.ptr + Intrinsic(:SLOW_PATH_ENTRY, ic_slot, this_func).Method("LdGlobalVarBridge", :AddImm).Relocate.Terminator.ptr } Return(ic_res).any end @@ -1885,23 +1874,22 @@ end #################################################################################### # ST_GLOBAL_VAR # -macro(:handle_ecma_stglobalvar) do |id, value, ic_slot, this_func, cp| - key := resolve_id(cp, id) +macro(:handle_ecma_stglobalvar) do |key, value, ic_slot, this_func| ic_res := store_global_var_ic(this_func, key, value, ic_slot) IfImm(cmpanyhole(ic_res)).Imm(0).CC(:CC_NE).b { - ecma_intrinsic_invoke("StGlobalVarSlow", id, value, ic_slot, this_func, cp).any + ecma_intrinsic_invoke("StGlobalVarSlow", key, value, ic_slot, this_func).any } end function(:EcmaStglobalvar, - params: {'id'=>'i32', 'value'=>'any', 'ic_slot'=>'i32', 'this_func'=>'any', 'cp'=>'any'}, + params: {'key'=>'any', 'value'=>'any', 'ic_slot'=>'i32', 'this_func'=>'any'}, mode: [:Interpreter, :DynamicMethod, :DynamicStub], enable_builder: true) do - handle_ecma_stglobalvar(id, value, ic_slot, this_func, cp) + handle_ecma_stglobalvar(key, value, ic_slot, this_func) ReturnVoid() end function(:FastPathStGlobalVar, - params: {id: 'i32', value: 'any', ic_slot: 'i32', this_func: 'any', cp: 'any'}, + params: {key: 'any', value: 'any', ic_slot: 'i32', this_func: 'any'}, mode: [:FastPath, :DynamicMethod, :DynamicStub], regmap: $full_regmap, regalloc_set: RegMask.new($full_regmap, :arg0, :arg1) + $panda_callees_mask - $panda_regmap) do @@ -1911,10 +1899,9 @@ function(:FastPathStGlobalVar, next end - key := resolve_id(cp, id) ic_res := store_global_var_ic(this_func, key, value, ic_slot) IfImm(cmpanyhole(ic_res)).Imm(0).CC(:CC_NE).b { - Intrinsic(:SLOW_PATH_ENTRY, id, value, ic_slot, this_func, cp).Method("StGlobalVarBridge", :AddImm).Relocate.Terminator.ptr + Intrinsic(:SLOW_PATH_ENTRY, key, value, ic_slot, this_func).Method("StGlobalVarBridge", :AddImm).Relocate.Terminator.ptr } ReturnVoid() end diff --git a/irtoc_scripts/interpreter_main_loop.irt b/irtoc_scripts/interpreter_main_loop.irt index cb7e02763e5290e25ae8301f0d302ad2f44804be..c4ae078ebf2802455e2893aa03decfa397c8ad50 100644 --- a/irtoc_scripts/interpreter_main_loop.irt +++ b/irtoc_scripts/interpreter_main_loop.irt @@ -93,7 +93,7 @@ when "ECMA_LDINFINITY_PREF_NONE" ecma_intrinsic_setacc("Ldinfinity") when "ECMA_LDBIGINT_PREF_ID32" - ecma_intrinsic_setacc("Ldbigint", as_id(op[0]), get_cp) + ecma_intrinsic_setacc("Ldbigint", load_from_cp(op[0])) when "ECMA_LDNULL_PREF_NONE" handle_ecma_ldconst(Constants::VALUE_NULL) when "ECMA_LDHOLE_PREF_NONE" @@ -125,9 +125,9 @@ when "ECMA_ISCOERCIBLE_PREF_NONE" ecma_intrinsic_setacc("IsCoercible", acc.any) when "ECMA_CREATEOBJECTWITHBUFFER_PREF_ID16" - ecma_intrinsic_setacc("CreateObjectWithBuffer", as_id(op[0]), get_cp) + ecma_intrinsic_setacc("CreateObjectWithBuffer", load_from_cp(op[0])) when "ECMA_CREATEOBJECTHAVINGMETHOD_PREF_ID16" - ecma_intrinsic_setacc("CreateObjectHavingMethod", as_id(op[0]), acc.any, get_cp) + ecma_intrinsic_setacc("CreateObjectHavingMethod", load_from_cp(op[0]), acc.any, get_cp) when "ECMA_CREATEOBJECTWITHEXCLUDEDKEYS_PREF_IMM16_V8_V8" ecma_intrinsic_setacc("CreateObjectWithExcludedKeys", as_imm(op[0]), vreg_value(op[1]).any, vreg_ptr(op[2])) when "ECMA_CREATEEMPTYOBJECT_PREF_NONE" @@ -145,13 +145,13 @@ # ecma runtime when "ECMA_DEFINEFUNCDYN_PREF_ID16_V8" - ecma_intrinsic_setacc("DefinefuncDyn", as_id(op[0]), vreg_value(op[1]).u64, get_cp) + ecma_intrinsic_setacc("DefinefuncDyn", load_from_cp(op[0]), vreg_value(op[1]).u64, get_cp) when "ECMA_DEFINEGENERATORFUNC_PREF_ID16_V8" - ecma_intrinsic_setacc("DefineGeneratorFunc", as_id(op[0]), vreg_value(op[1]).any, get_cp) + ecma_intrinsic_setacc("DefineGeneratorFunc", load_from_cp(op[0]), vreg_value(op[1]).any, get_cp) when "ECMA_DEFINENCFUNCDYN_PREF_ID16_V8" - ecma_intrinsic_setacc("DefineNCFuncDyn", as_id(op[0]), vreg_value(op[1]).any, acc.any, get_cp) + ecma_intrinsic_setacc("DefineNCFuncDyn", load_from_cp(op[0]), vreg_value(op[1]).any, acc.any, get_cp) when "ECMA_DEFINEASYNCFUNC_PREF_ID16_V8" - ecma_intrinsic_setacc("DefineAsyncFunc", as_id(op[0]), vreg_value(op[1]).any, get_cp) + ecma_intrinsic_setacc("DefineAsyncFunc", load_from_cp(op[0]), vreg_value(op[1]).any, get_cp) when "ECMA_ASYNCFUNCTIONENTER_PREF_NONE" ecma_intrinsic_setacc("AsyncFunctionEnter") when "ECMA_ASYNCFUNCTIONRESOLVE_PREF_V8" @@ -161,11 +161,11 @@ when "ECMA_ASYNCFUNCTIONREJECT_PREF_V8" ecma_intrinsic_setacc("AsyncFunctionReject", vreg_value(op[0]).any, acc.any) when "ECMA_DEFINEMETHOD_PREF_ID16_V8" - ecma_intrinsic_setacc("DefineMethod", as_id(op[0]), vreg_value(op[1]).any, acc.any, get_cp) + ecma_intrinsic_setacc("DefineMethod", load_from_cp(op[0]), vreg_value(op[1]).any, acc.any, get_cp) when "ECMA_IMPORTMODULE_PREF_ID32" - ecma_intrinsic_setacc("ImportModule", as_id(op[0]), get_cp) + ecma_intrinsic_setacc("ImportModule", load_from_cp(op[0])) when "ECMA_STMODULEVAR_PREF_ID32" - ecma_intrinsic_setacc("StModuleVar", as_id(op[0]), acc.any, get_cp) + ecma_intrinsic_setacc("StModuleVar", load_from_cp(op[0]), acc.any) when "ECMA_DEFINEGETTERSETTERBYVALUE_PREF_V8_V8_V8_V8" ecma_intrinsic_setacc("DefineGetterSetterByValue", vreg_value(op[0]).any, vreg_value(op[1]).any, vreg_value(op[2]).any, vreg_value(op[3]).any, acc.any) when "ECMA_TYPEOFDYN_PREF_NONE" @@ -175,7 +175,7 @@ when "ECMA_DELOBJPROP_PREF_V8_V8" ecma_intrinsic_setacc("Delobjprop", vreg_value(op[0]).any, vreg_value(op[1]).any) when "ECMA_GETMETHOD_PREF_ID32_V8" - ecma_intrinsic_setacc("GetMethod", as_id(op[0]), vreg_value(op[1]).any, get_cp) + ecma_intrinsic_setacc("GetMethod", load_from_cp(op[0]), vreg_value(op[1]).any) when "ECMA_GETRESUMEMODE_PREF_V8" ecma_intrinsic_setacc("GetResumeMode", vreg_value(op[0]).any) when "ECMA_GETUNMAPPEDARGS_PREF_NONE" @@ -185,7 +185,7 @@ #class when "ECMA_DEFINECLASSWITHBUFFER_PREF_ID16_IMM16_V8_V8" - ecma_intrinsic_setacc("DefineClassWithBuffer", as_id(op[0]), as_imm(op[1]), vreg_value(op[2]).any, vreg_value(op[3]).any, get_cp) + ecma_intrinsic_setacc("DefineClassWithBuffer", load_from_cp(op[0]), as_imm(op[1]), vreg_value(op[2]).any, vreg_value(op[3]).any, get_cp) when "ECMA_LOADCLASSCOMPUTEDINSTANCEFIELDS_PREF_V8" ecma_intrinsic_setacc("LoadClassComputedInstanceFields", vreg_value(op[0]).any) when "ECMA_SETCLASSCOMPUTEDFIELDS_PREF_V8_V8" @@ -193,27 +193,27 @@ when "ECMA_CLASSFIELDADD_PREF_V8_V8" ecma_intrinsic_setacc("ClassFieldAdd", vreg_value(op[0]).any, vreg_value(op[1]).any, acc.any) when "ECMA_DEFINECLASSPRIVATEFIELDS_PREF_ID16_V8" - ecma_intrinsic_invoke("DefineClassPrivateFields", as_id(op[0]), vreg_value(op[1]).any, acc.any, get_cp) + ecma_intrinsic_invoke("DefineClassPrivateFields", load_from_cp(op[0]), vreg_value(op[1]).any, acc.any, get_cp) when "ECMA_CLASSPRIVATEMETHODORACCESSORADD_PREF_V8_V8" ecma_intrinsic_setacc("ClassPrivateMethodOrAccessorAdd", vreg_value(op[0]).any, vreg_value(op[1]).any) when "ECMA_CLASSPRIVATEFIELDADD_PREF_ID32_V8_V8" - ecma_intrinsic_setacc("ClassPrivateFieldAdd", as_id(op[0]), vreg_value(op[1]).any, vreg_value(op[2]).any, acc.any, get_cp) + ecma_intrinsic_setacc("ClassPrivateFieldAdd", load_from_cp(op[0]), vreg_value(op[1]).any, vreg_value(op[2]).any, acc.any) when "ECMA_CLASSPRIVATEFIELDGET_PREF_ID32_V8_V8" - ecma_intrinsic_setacc("ClassPrivateFieldGet", as_id(op[0]), vreg_value(op[1]).any, vreg_value(op[2]).any, get_cp) + ecma_intrinsic_setacc("ClassPrivateFieldGet", load_from_cp(op[0]), vreg_value(op[1]).any, vreg_value(op[2]).any) when "ECMA_CLASSPRIVATEFIELDSET_PREF_ID32_V8_V8" - ecma_intrinsic_setacc("ClassPrivateFieldSet", as_id(op[0]), vreg_value(op[1]).any, vreg_value(op[2]).any, acc.any, get_cp) + ecma_intrinsic_setacc("ClassPrivateFieldSet", load_from_cp(op[0]), vreg_value(op[1]).any, vreg_value(op[2]).any, acc.any) when "ECMA_CLASSPRIVATEFIELDIN_PREF_ID32_V8" - ecma_intrinsic_setacc("ClassPrivateFieldIn", as_id(op[0]), vreg_value(op[1]).any, acc.any, get_cp) + ecma_intrinsic_setacc("ClassPrivateFieldIn", load_from_cp(op[0]), vreg_value(op[1]).any, acc.any) #eval when "ECMA_LDEVALBINDINGS_PREF_ID16" - ecma_intrinsic_setacc("LdEvalBindings", as_id(op[0]), get_cp) + ecma_intrinsic_setacc("LdEvalBindings", load_from_cp(op[0])) when "ECMA_DIRECTEVAL_PREF_IMM32_V8_V8" ecma_intrinsic_setacc("DirectEval", as_imm(op[0]), vreg_value(op[1]).any, vreg_value(op[2]).any) when "ECMA_LDEVALVAR_PREF_ID32" - ecma_intrinsic_setacc("LdEvalVar", as_id(op[0]), acc.any, get_cp) + ecma_intrinsic_setacc("LdEvalVar", load_from_cp(op[0]), acc.any) when "ECMA_STEVALVAR_PREF_ID32_V8" - ecma_intrinsic_setacc("StEvalVar", as_id(op[0]), vreg_value(op[1]).any, acc.any, get_cp) + ecma_intrinsic_setacc("StEvalVar", load_from_cp(op[0]), vreg_value(op[1]).any, acc.any) # ecma frames when "ECMA_CALL0DYN_PREF_NONE" @@ -263,11 +263,11 @@ when "ECMA_STLEXVARDYN_PREF_IMM16_IMM16" ecma_intrinsic_invoke("StLexVarDyn", as_imm(op[0]), as_imm(op[1]), acc.u64, get_lex_env) when "ECMA_STLEXDYN_PREF_ID32_IMM4_IMM4" - ecma_intrinsic_setacc("StLexDyn", as_id(op[0]), i8tou16(as_imm(op[1])), i8tou16(as_imm(op[2])), acc.u64, get_cp, get_lex_env) + ecma_intrinsic_setacc("StLexDyn", load_from_cp(op[0]), i8tou16(as_imm(op[1])), i8tou16(as_imm(op[2])), acc.u64, get_lex_env) when "ECMA_STLEXDYN_PREF_ID32_IMM8_IMM8" - ecma_intrinsic_setacc("StLexDyn", as_id(op[0]), i8tou16(as_imm(op[1])), i8tou16(as_imm(op[2])), acc.u64, get_cp, get_lex_env) + ecma_intrinsic_setacc("StLexDyn", load_from_cp(op[0]), i8tou16(as_imm(op[1])), i8tou16(as_imm(op[2])), acc.u64, get_lex_env) when "ECMA_STLEXDYN_PREF_ID32_IMM16_IMM16" - ecma_intrinsic_setacc("StLexDyn", as_id(op[0]), as_imm(op[1]), as_imm(op[2]), acc.u64, get_cp, get_lex_env) + ecma_intrinsic_setacc("StLexDyn", load_from_cp(op[0]), as_imm(op[1]), as_imm(op[2]), acc.u64, get_lex_env) when "ECMA_LDLEXVARDYN_PREF_IMM4_IMM4" ecma_intrinsic_setacc("LdLexVarDyn", i8tou16(as_imm(op[0])), i8tou16(as_imm(op[1])), get_lex_env) when "ECMA_LDLEXVARDYN_PREF_IMM8_IMM8" @@ -277,11 +277,11 @@ when "ECMA_LDHOMEOBJECT_PREF_NONE" ecma_intrinsic_setacc("LdHomeObject", get_this_func) when "ECMA_LDLEXDYN_PREF_ID32_IMM4_IMM4" - ecma_intrinsic_setacc("LdLexDyn", as_id(op[0]), i8tou16(as_imm(op[1])), i8tou16(as_imm(op[2])), get_cp, get_lex_env) + ecma_intrinsic_setacc("LdLexDyn", load_from_cp(op[0]), i8tou16(as_imm(op[1])), i8tou16(as_imm(op[2])), get_lex_env) when "ECMA_LDLEXDYN_PREF_ID32_IMM8_IMM8" - ecma_intrinsic_setacc("LdLexDyn", as_id(op[0]), i8tou16(as_imm(op[1])), i8tou16(as_imm(op[2])), get_cp, get_lex_env) + ecma_intrinsic_setacc("LdLexDyn", load_from_cp(op[0]), i8tou16(as_imm(op[1])), i8tou16(as_imm(op[2])), get_lex_env) when "ECMA_LDLEXDYN_PREF_ID32_IMM16_IMM16" - ecma_intrinsic_setacc("LdLexDyn", as_id(op[0]), as_imm(op[1]), as_imm(op[2]), get_cp, get_lex_env) + ecma_intrinsic_setacc("LdLexDyn", load_from_cp(op[0]), as_imm(op[1]), as_imm(op[2]), get_lex_env) when "ECMA_CREATEEMPTYOBJECT_PREF_NONE" ecma_intrinsic_setacc("CreateEmptyObject") when "ECMA_RETURNUNDEFINED_PREF_NONE" @@ -291,9 +291,9 @@ when "ECMA_RETURN_DYN_PREF_NONE" Intrinsic(:INTERPRETER_RETURN).ptr when "ECMA_CREATEARRAYWITHBUFFER_PREF_ID16" - ecma_intrinsic_setacc("CreateArrayWithBuffer", as_id(op[0]), get_cp) + ecma_intrinsic_setacc("CreateArrayWithBuffer", load_from_cp(op[0])) when "ECMA_CREATEREGEXPWITHLITERAL_PREF_ID32_IMM8" - ecma_intrinsic_setacc("CreateRegExpWithLiteral", as_id(op[0]), as_imm(op[1]), get_cp) + ecma_intrinsic_setacc("CreateRegExpWithLiteral", load_from_cp(op[0]), as_imm(op[1])) when "ECMA_CREATEEMPTYARRAY_PREF_NONE" ecma_intrinsic_setacc("CreateEmptyArray") when "ECMA_STARRAYSPREAD_PREF_V8_V8" @@ -354,27 +354,27 @@ # ecma load/stores by name when "ECMA_STOBJBYNAME_PREF_ID32_V8" - handle_ecma_stobjbyname(vreg_value(op[1]).any, as_id(op[0]), acc.any, ins_offset, get_this_func, get_cp) + handle_ecma_stobjbyname(vreg_value(op[1]).any, load_from_cp(op[0]), acc.any, ins_offset, get_this_func) when "ECMA_LDOBJBYNAME_PREF_ID32" - acc := handle_ecma_ldobjbyname(acc.any, as_id(op[0]), ins_offset, get_this_func, get_cp) + acc := handle_ecma_ldobjbyname(acc.any, load_from_cp(op[0]), ins_offset, get_this_func) when "ECMA_LDSUPERBYNAME_PREF_ID32" - ecma_intrinsic_setacc("LdSuperByName", as_id(op[0]), acc.any, get_this_func, get_cp) + ecma_intrinsic_setacc("LdSuperByName", load_from_cp(op[0]), acc.any, get_this_func) when "ECMA_STSUPERBYNAME_PREF_ID32_V8" - ecma_intrinsic_invoke("StSuperByName", as_id(op[0]), vreg_value(op[1]).any, acc.any, get_this_func, get_cp) + ecma_intrinsic_invoke("StSuperByName", load_from_cp(op[0]), vreg_value(op[1]).any, acc.any, get_this_func) when "ECMA_STOWNBYNAME_PREF_ID32_V8" - ecma_intrinsic_invoke("StOwnByName", as_id(op[0]), vreg_value(op[1]).any, acc.any, get_cp) + ecma_intrinsic_invoke("StOwnByName", load_from_cp(op[0]), vreg_value(op[1]).any, acc.any) # load/stores from global object when "ECMA_LDGLOBAL_PREF_NONE" ecma_intrinsic_setacc("Ldglobal") when "ECMA_TRYLDGLOBALBYNAME_PREF_ID32" - acc := handle_ecma_tryldglobalbyname(as_id(op[0]), ins_offset, get_this_func, get_cp) + acc := handle_ecma_tryldglobalbyname(load_from_cp(op[0]), ins_offset, get_this_func) when "ECMA_TRYSTGLOBALBYNAME_PREF_ID32" - ecma_intrinsic_invoke("TryStGlobalByName", as_id(op[0]), acc.any, ins_offset, get_this_func, get_cp) + ecma_intrinsic_invoke("TryStGlobalByName", load_from_cp(op[0]), acc.any, ins_offset, get_this_func) when "ECMA_LDGLOBALVAR_PREF_ID32" - acc := handle_ecma_ldglobalvar(as_id(op[0]), ins_offset, get_this_func, get_cp) + acc := handle_ecma_ldglobalvar(load_from_cp(op[0]), ins_offset, get_this_func) when "ECMA_STGLOBALVAR_PREF_ID32" - handle_ecma_stglobalvar(as_id(op[0]), acc.any, ins_offset, get_this_func, get_cp) + handle_ecma_stglobalvar(load_from_cp(op[0]), acc.any, ins_offset, get_this_func) # ecma generators when "ECMA_CREATEGENERATOROBJ_PREF_V8" @@ -392,7 +392,7 @@ when "ECMA_CREATEASYNCGENERATOROBJ_PREF_V8" ecma_intrinsic_setacc("CreateAsyncGeneratorObj", vreg_value(op[0]).any) when "ECMA_DEFINEASYNCGENERATORFUNC_PREF_ID16_V8" - ecma_intrinsic_setacc("DefineAsyncGeneratorFunc", as_id(op[0]), vreg_value(op[1]).any, get_cp) + ecma_intrinsic_setacc("DefineAsyncGeneratorFunc", load_from_cp(op[0]), vreg_value(op[1]).any, get_cp) when "ECMA_GETASYNCITERATOR_PREF_NONE" ecma_intrinsic_setacc("GetAsyncIterator", acc.u64) when "ECMA_ASYNCGENERATORRESOLVE_PREF_V8" @@ -419,7 +419,7 @@ end acc := acc_eh when "ECMA_THROWCONSTASSIGNMENT_PREF_ID32" - ecma_intrinsic_invoke("ThrowConstAssignment", as_id(op[0]), get_cp) + ecma_intrinsic_invoke("ThrowConstAssignment", load_from_cp(op[0])) pc := find_catch_block() frame := frame_eh if Options.arm64? @@ -446,7 +446,7 @@ end acc := acc_eh when "ECMA_THROWTDZ_PREF_ID32" - ecma_intrinsic_invoke("ThrowTdz", as_id(op[0]), get_cp) + ecma_intrinsic_invoke("ThrowTdz", load_from_cp(op[0])) pc := find_catch_block() frame := frame_eh if Options.arm64? diff --git a/irtoc_scripts/object.irt b/irtoc_scripts/object.irt index ea5ea5fcc4a7da9ce99425c2aff9b698364969f8..5489cd7fdc24b2b17c3c9ce8f2e1c12e7efbc7e9 100644 --- a/irtoc_scripts/object.irt +++ b/irtoc_scripts/object.irt @@ -559,7 +559,7 @@ end if access_type == :unknown extra_params.update({this_func: 'any'}) elsif access_type == :by_name - extra_params.update({ic_slot: 'u16', this_func: 'any', cp: 'any'}) + extra_params.update({ic_slot: 'u16', this_func: 'any'}) end function("LoadObjectDynamic#{postfix}", diff --git a/isa/isa.yaml b/isa/isa.yaml index 96605b85feb312409b60594d175a2727ac704b8b..0cc550b5a2b20bcf07366da68bfd0be8d4e08af8 100644 --- a/isa/isa.yaml +++ b/isa/isa.yaml @@ -143,7 +143,7 @@ groups: prefix: ecma format: [pref_op_id_32] intrinsic_name: INTRINSIC_LDBIGINT - properties: [cp, string_id] + properties: [string_id] - sig: ecma.throwdyn acc: in:top @@ -515,14 +515,14 @@ groups: prefix: ecma format: [pref_op_id_32] exceptions: [x_throw] - properties: [string_id, cp] + properties: [string_id] intrinsic_name: INTRINSIC_THROW_CONST_ASSIGNMENT - sig: ecma.getmethod string_id, v:in:top acc: out:top prefix: ecma format: [pref_op_id_32_v_8] - properties: [string_id, cp] + properties: [string_id] intrinsic_name: INTRINSIC_GET_METHOD - sig: ecma.gettemplateobject v:in:top @@ -604,7 +604,7 @@ groups: acc: none prefix: ecma format: [pref_op_id_32] - properties: [string_id, cp] + properties: [string_id] exceptions: [x_throw] intrinsic_name: INTRINSIC_THROW_TDZ @@ -934,14 +934,14 @@ groups: acc: out:top prefix: ecma format: [pref_op_id_32_imm_8] - properties: [string_id, cp] + properties: [string_id] intrinsic_name: INTRINSIC_CREATE_REG_EXP_WITH_LITERAL - sig: ecma.createarraywithbuffer literalarray_id acc: out:top prefix: ecma format: [pref_op_id_16] - properties: [literalarray_id, cp] + properties: [literalarray_id] intrinsic_name: INTRINSIC_CREATE_ARRAY_WITH_BUFFER - sig: ecma.createobjecthavingmethod literalarray_id @@ -961,7 +961,7 @@ groups: acc: out:top prefix: ecma format: [pref_op_id_16] - properties: [literalarray_id, cp] + properties: [literalarray_id] intrinsic_name: INTRINSIC_CREATE_OBJECT_WITH_BUFFER - sig: ecma.ldlexvardyn imm1, imm2 @@ -993,20 +993,20 @@ groups: prefix: ecma format: [pref_op_id_32_imm1_4_imm2_4] intrinsic_name: INTRINSIC_LD_LEX_DYN - properties: [string_id, cp, lex_env] + properties: [string_id, lex_env] - sig: ecma.ldlexdyn string_id, imm1, imm2 acc: out:top prefix: ecma format: [pref_op_id_32_imm1_8_imm2_8] - properties: [string_id, cp, lex_env] + properties: [string_id, lex_env] intrinsic_name: INTRINSIC_LD_LEX_DYN - sig: ecma.ldlexdyn string_id, imm1, imm2 acc: out:top prefix: ecma format: [pref_op_id_32_imm1_16_imm2_16] - properties: [string_id, cp, lex_env] + properties: [string_id, lex_env] intrinsic_name: INTRINSIC_LD_LEX_DYN - sig: ecma.stlexvardyn imm1, imm2 @@ -1046,21 +1046,21 @@ groups: acc: inout:top prefix: ecma format: [pref_op_id_32_imm1_4_imm2_4] - properties: [string_id, cp, lex_env] + properties: [string_id, lex_env] intrinsic_name: INTRINSIC_ST_LEX_DYN - sig: ecma.stlexdyn string_id, imm1, imm2 acc: inout:top prefix: ecma format: [pref_op_id_32_imm1_8_imm2_8] - properties: [string_id, cp, lex_env] + properties: [string_id, lex_env] intrinsic_name: INTRINSIC_ST_LEX_DYN - sig: ecma.stlexdyn string_id, imm1, imm2 acc: inout:top prefix: ecma format: [pref_op_id_32_imm1_16_imm2_16] - properties: [string_id, cp, lex_env] + properties: [string_id, lex_env] intrinsic_name: INTRINSIC_ST_LEX_DYN - sig: ecma.defineclasswithbuffer method_id, imm, v1:in:top, v2:in:top @@ -1094,112 +1094,112 @@ groups: prefix: ecma format: [pref_op_id_32_v1_8_v2_8] intrinsic_name: INTRINSIC_CLASS_PRIVATE_FIELD_ADD - properties: [string_id, cp] + properties: [string_id] - sig: ecma.classprivatefieldget string_id, v1:in:top, v2:in:top acc: out:top prefix: ecma format: [pref_op_id_32_v1_8_v2_8] intrinsic_name: INTRINSIC_CLASS_PRIVATE_FIELD_GET - properties: [string_id, cp] + properties: [string_id] - sig: ecma.classprivatefieldset string_id, v1:in:top, v2:in:top acc: inout:top prefix: ecma format: [pref_op_id_32_v1_8_v2_8] intrinsic_name: INTRINSIC_CLASS_PRIVATE_FIELD_SET - properties: [string_id, cp] + properties: [string_id] - sig: ecma.classprivatefieldin string_id, v:in:top acc: inout:top prefix: ecma format: [pref_op_id_32_v_8] intrinsic_name: INTRINSIC_CLASS_PRIVATE_FIELD_IN - properties: [string_id, cp] + properties: [string_id] - sig: ecma.importmodule string_id acc: out:top prefix: ecma format: [pref_op_id_32] - properties: [string_id, cp] + properties: [string_id] intrinsic_name: INTRINSIC_IMPORT_MODULE - sig: ecma.stmodulevar string_id acc: in:top prefix: ecma format: [pref_op_id_32] - properties: [string_id, cp] + properties: [string_id] intrinsic_name: INTRINSIC_ST_MODULE_VAR - sig: ecma.tryldglobalbyname string_id acc: out:top prefix: ecma format: [pref_op_id_32] - properties: [string_id, use_ic, inlinable, cp, func] + properties: [string_id, use_ic, inlinable, func] intrinsic_name: INTRINSIC_TRY_LD_GLOBAL_BY_NAME - sig: ecma.trystglobalbyname string_id acc: in:top prefix: ecma format: [pref_op_id_32] - properties: [string_id, use_ic, cp, func] + properties: [string_id, use_ic, func] intrinsic_name: INTRINSIC_TRY_ST_GLOBAL_BY_NAME - sig: ecma.ldglobalvar string_id acc: out:top prefix: ecma format: [pref_op_id_32] - properties: [string_id, use_ic, inlinable, cp, func] + properties: [string_id, use_ic, inlinable, func] intrinsic_name: INTRINSIC_LD_GLOBAL_VAR - sig: ecma.stglobalvar string_id acc: in:top prefix: ecma format: [pref_op_id_32] - properties: [string_id, use_ic, inlinable, cp, func] + properties: [string_id, use_ic, inlinable, func] intrinsic_name: INTRINSIC_ST_GLOBAL_VAR - sig: ecma.ldobjbyname string_id acc: inout:top prefix: ecma format: [pref_op_id_32] - properties: [string_id, use_ic, inlinable, cp, func] + properties: [string_id, use_ic, inlinable, func] intrinsic_name: INTRINSIC_LD_OBJ_BY_NAME - sig: ecma.stobjbyname string_id, v:in:top acc: in:top prefix: ecma format: [pref_op_id_32_v_8] - properties: [string_id, use_ic, inlinable, cp, func] + properties: [string_id, use_ic, inlinable, func] intrinsic_name: INTRINSIC_ST_OBJ_BY_NAME - sig: ecma.stownbyname string_id, v:in:top acc: in:top prefix: ecma format: [pref_op_id_32_v_8] - properties: [string_id, cp] + properties: [string_id] intrinsic_name: INTRINSIC_ST_OWN_BY_NAME - sig: ecma.ldsuperbyname string_id acc: inout:top prefix: ecma format: [pref_op_id_32] - properties: [string_id, cp, func] + properties: [string_id, func] intrinsic_name: INTRINSIC_LD_SUPER_BY_NAME - sig: ecma.stsuperbyname string_id, v:in:top acc: in:top prefix: ecma format: [pref_op_id_32_v_8] - properties: [string_id, cp, func] + properties: [string_id, func] intrinsic_name: INTRINSIC_ST_SUPER_BY_NAME - sig: ecma.ldmodvarbyname string_id, v:in:top acc: out:top prefix: ecma format: [pref_op_id_32_v_8] - properties: [string_id, cp] + properties: [string_id] intrinsic_name: INTRINSIC_LD_MODVAR_BY_NAME - sig: ecma.toboolean @@ -1271,7 +1271,7 @@ groups: prefix: ecma format: [pref_op_id_16] intrinsic_name: INTRINSIC_LD_EVAL_BINDINGS - properties: [literalarray_id, skip_literal_id_patch, cp] + properties: [literalarray_id, skip_literal_id_patch] - sig: ecma.directeval imm, v1:in:top, v2:in:top acc: out:top @@ -1283,12 +1283,12 @@ groups: acc: inout:top prefix: ecma format: [pref_op_id_32] - properties: [string_id, cp] + properties: [string_id] intrinsic_name: INTRINSIC_LD_EVAL_VAR - sig: ecma.stevalvar string_id, v:in:top acc: inout:top prefix: ecma format: [pref_op_id_32_v_8] - properties: [string_id, cp] + properties: [string_id] intrinsic_name: INTRINSIC_ST_EVAL_VAR diff --git a/runtime/compiler/ecmascript_runtime_interface.cpp b/runtime/compiler/ecmascript_runtime_interface.cpp index bfefae349415da5a8ab7fb14c67a46fee0d55d71..06d7cb1c70b219e4fb410325f891ddc6ea5a2a9a 100644 --- a/runtime/compiler/ecmascript_runtime_interface.cpp +++ b/runtime/compiler/ecmascript_runtime_interface.cpp @@ -858,4 +858,22 @@ PandaRuntimeInterface::MethodPtr EcmaRuntimeInterface::GetMethodByIdAndSaveJsFun return method; } +void *EcmaRuntimeInterface::GetConstantPool(PandaRuntimeInterface::MethodPtr method) +{ + ScopedMutatorLock lock; + auto func = GetJSFunctionByMethod(method); + if (func == nullptr) { + return nullptr; + } + return func->GetConstantPool().GetHeapObject(); +} + +void *EcmaRuntimeInterface::GetConstantPool(uintptr_t func_address) +{ + ASSERT(func_address != 0); + ScopedMutatorLock lock; + auto js_func = JSTaggedValue(*reinterpret_cast(func_address)); + return JSFunction::Cast(js_func.GetHeapObject())->GetConstantPool().GetHeapObject(); +} + } // namespace panda::ecmascript diff --git a/runtime/compiler/ecmascript_runtime_interface.h b/runtime/compiler/ecmascript_runtime_interface.h index 49b3b509e92713e3684d7bcf3b39036a1108613b..aa7ff56e6584352fe8fc26dc69b3be609b9dbeec 100644 --- a/runtime/compiler/ecmascript_runtime_interface.h +++ b/runtime/compiler/ecmascript_runtime_interface.h @@ -237,6 +237,9 @@ public: return js_method_args::NUM_MANDATORY_ARGS; } + void *GetConstantPool(MethodPtr method) override; + void *GetConstantPool(uintptr_t func_address) override; + private: JSFunction *GetJSFunctionByMethod(PandaRuntimeInterface::MethodPtr m) const; diff --git a/runtime/ecma_entrypoints.cpp b/runtime/ecma_entrypoints.cpp index 8cefcfc1464ed549a50f2184c1476751562deb50..66bbd6ab2c11ca6d93bae12423565b6ec83a9d5e 100644 --- a/runtime/ecma_entrypoints.cpp +++ b/runtime/ecma_entrypoints.cpp @@ -57,9 +57,4 @@ extern "C" uint64_t AllocDynObjectSlowPath(uint64_t ctor_raw) return thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(ctor, new_tgt).GetTaggedValue().GetRawData(); } -extern "C" coretypes::String *ResolveStringDynamicEntrypoint(uint64_t cp, FileEntityId id) -{ - return JSThread::GetCurrent()->GetEcmaVM()->ResolveString(ConstantPool::Cast(cp), panda_file::File::EntityId(id)); -} - } // namespace panda::ecmascript diff --git a/runtime/ecma_entrypoints.yaml b/runtime/ecma_entrypoints.yaml index a20e0017cee987deaa962b275c5de2b1427e2d1b..7bcacb617ccbed14fe791e26efd9a8b06f77ed63 100644 --- a/runtime/ecma_entrypoints.yaml +++ b/runtime/ecma_entrypoints.yaml @@ -62,7 +62,6 @@ - uint64_t - uint16_t - uint64_t - - uint64_t - name: LoadObjectDynamicByName entrypoint: LoadObjectDynamicByName @@ -74,7 +73,6 @@ - uint64_t - uint16_t - uint64_t - - uint64_t - name: StoreObjectDynamicByIndexDictionary entrypoint: StoreObjectDynamicByIndexDictionary @@ -128,15 +126,6 @@ signature: - void -- name: ResolveStringDynamic - entrypoint: ResolveStringDynamicEntrypoint - bridge: entrypoint - properties: [] - signature: - - panda::coretypes::String* - - uint64_t - - panda::FileEntityId - - name: EcmaStringEquals entrypoint: EcmascriptStringEquals bridge: none diff --git a/runtime/ecma_runtime.yaml b/runtime/ecma_runtime.yaml index 20c7aa2c9bee3e7708ea29151a81720e0368ac2b..115f810927de6f6b8e90fb799d5508b176e50e2c 100644 --- a/runtime/ecma_runtime.yaml +++ b/runtime/ecma_runtime.yaml @@ -101,7 +101,7 @@ intrinsics: static: true signature: ret: any - args: [string_id, any] + args: [any] impl: panda::ecmascript::intrinsics::Ldbigint - name: Ldnull @@ -621,7 +621,7 @@ intrinsics: exception: true signature: ret: any - args: [method_id, any, any] + args: [any, any, any] impl: panda::ecmascript::intrinsics::DefinefuncDyn - name: DefineNCFuncDyn @@ -632,7 +632,7 @@ intrinsics: exception: true signature: ret: any - args: [method_id, any, acc, any] + args: [any, any, acc, any] impl: panda::ecmascript::intrinsics::DefineNCFuncDyn - name: NewobjDynrange @@ -868,7 +868,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, u16, u16, acc, any, any] + args: [any, u16, u16, acc, any] impl: panda::ecmascript::intrinsics::StLexDyn set_flags: [heap_inv] codegen_func: StLexDyn @@ -895,7 +895,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, u16, u16, any, any] + args: [any, u16, u16, any] impl: panda::ecmascript::intrinsics::LdLexDyn inline_func: InlineLdLexDyn @@ -1050,7 +1050,7 @@ intrinsics: exception: true signature: ret: any - args: [method_id, any, any] + args: [any, any, any] impl: panda::ecmascript::intrinsics::DefineGeneratorFunc - name: CreateIterResultObj @@ -1175,7 +1175,7 @@ intrinsics: exception: true signature: ret: any - args: [method_id, any, any] + args: [any, any, any] impl: panda::ecmascript::intrinsics::DefineAsyncGeneratorFunc - name: DefineAsyncFunc @@ -1186,7 +1186,7 @@ intrinsics: exception: true signature: ret: any - args: [method_id, any, any] + args: [any, any, any] impl: panda::ecmascript::intrinsics::DefineAsyncFunc - name: AsyncFunctionEnter @@ -1279,7 +1279,7 @@ intrinsics: exception: true signature: ret: void - args: [string_id, any] + args: [any] impl: panda::ecmascript::intrinsics::ThrowConstAssignment - name: ThrowTdz @@ -1290,7 +1290,7 @@ intrinsics: exception: true signature: ret: void - args: [string_id, any] + args: [any] impl: panda::ecmascript::intrinsics::ThrowTdz - name: Copyrestargs @@ -1348,7 +1348,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, any, any] + args: [any, any] impl: panda::ecmascript::intrinsics::GetMethod set_flags: [heap_inv] @@ -1372,7 +1372,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, u16, any, any] + args: [any, u16, any] impl: panda::ecmascript::intrinsics::TryLdGlobalByName inline_func: InlineTryLdGlobalByName set_flags: [heap_inv] @@ -1385,7 +1385,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, acc, u16, any, any] + args: [any, acc, u16, any] impl: panda::ecmascript::intrinsics::TryStGlobalByName set_flags: [heap_inv] @@ -1397,7 +1397,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, u16, any, any] + args: [any, u16, any] impl: panda::ecmascript::intrinsics::LdGlobalVar fast_path: FastPathLdGlobalVar set_flags: [heap_inv] @@ -1410,7 +1410,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, acc, u16, any, any] + args: [any, acc, u16, any] impl: panda::ecmascript::intrinsics::StGlobalVar fast_path: FastPathStGlobalVar set_flags: [heap_inv] @@ -1423,7 +1423,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, acc, u16, any, any] + args: [any, acc, u16, any] impl: panda::ecmascript::intrinsics::LdObjByName fast_path: FastPathLdObjByName inline_func: InlineLdObjByName @@ -1437,7 +1437,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, any, acc, u16, any, any] + args: [any, any, acc, u16, any] impl: panda::ecmascript::intrinsics::StObjByName fast_path: FastPathStObjByName inline_func: InlineStObjByName @@ -1641,7 +1641,7 @@ intrinsics: exception: true signature: ret: any - args: [u16, any] + args: [any] impl: panda::ecmascript::intrinsics::CreateObjectWithBuffer - name: CopyDataProperties @@ -1688,7 +1688,7 @@ intrinsics: exception: true signature: ret: any - args: [u16, any] + args: [any] impl: panda::ecmascript::intrinsics::CreateArrayWithBuffer - name: CreateRegExpWithLiteral @@ -1699,7 +1699,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, u8, any] + args: [any, u8] impl: panda::ecmascript::intrinsics::CreateRegExpWithLiteral @@ -1711,7 +1711,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, any, acc, any] + args: [any, any, acc] impl: panda::ecmascript::intrinsics::StOwnByName set_flags: [heap_inv] @@ -1840,7 +1840,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, any] + args: [any] impl: panda::ecmascript::intrinsics::ImportModule clear_flags: [no_dce] @@ -1852,7 +1852,7 @@ intrinsics: exception: true signature: ret: void - args: [string_id, acc, any] + args: [any, acc] impl: panda::ecmascript::intrinsics::StModuleVar - name: CopyModule @@ -1874,7 +1874,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, any, any] + args: [any, any] impl: panda::ecmascript::intrinsics::LdModvarByName clear_flags: [no_dce] set_flags: [heap_inv] @@ -1909,7 +1909,7 @@ intrinsics: exception: true signature: ret: any - args: [method_id, u16, any, any, any] + args: [any, u16, any, any, any] impl: panda::ecmascript::intrinsics::DefineClassWithBuffer - name: ClassFieldAdd @@ -1931,7 +1931,7 @@ intrinsics: exception: true signature: ret: void - args: [u16, any, acc, any] + args: [any, any, acc, any] impl: panda::ecmascript::intrinsics::DefineClassPrivateFields - name: ClassPrivateMethodOrAccessorAdd @@ -1953,7 +1953,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, any, any, acc, any] + args: [any, any, any, acc] impl: panda::ecmascript::intrinsics::ClassPrivateFieldAdd - name: ClassPrivateFieldGet @@ -1964,7 +1964,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, any, any, any] + args: [any, any, any] impl: panda::ecmascript::intrinsics::ClassPrivateFieldGet - name: ClassPrivateFieldSet @@ -1975,7 +1975,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, any, any, acc, any] + args: [any, any, any, acc] impl: panda::ecmascript::intrinsics::ClassPrivateFieldSet - name: ClassPrivateFieldIn @@ -1986,7 +1986,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, any, acc, any] + args: [any, any, acc] impl: panda::ecmascript::intrinsics::ClassPrivateFieldIn - name: SuperCall @@ -2021,7 +2021,7 @@ intrinsics: exception: true signature: ret: any - args: [method_id, any, acc, any] + args: [any, any, acc, any] impl: panda::ecmascript::intrinsics::DefineMethod - name: LdSuperByName @@ -2032,7 +2032,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, acc, any, any] + args: [any, acc, any] impl: panda::ecmascript::intrinsics::LdSuperByName set_flags: [heap_inv] @@ -2044,7 +2044,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, any, acc, any, any] + args: [any, any, acc, any] impl: panda::ecmascript::intrinsics::StSuperByName set_flags: [heap_inv] @@ -2080,7 +2080,7 @@ intrinsics: exception: true signature: ret: any - args: [u16, acc, any] + args: [any, acc, any] impl: panda::ecmascript::intrinsics::CreateObjectHavingMethod - name: ThrowIfSuperNotCorrectCall @@ -2135,7 +2135,7 @@ intrinsics: exception: true signature: ret: any - args: [u16, any] + args: [any] impl: panda::ecmascript::intrinsics::LdEvalBindings - name: DirectEval @@ -2157,7 +2157,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, acc, any] + args: [any, acc] impl: panda::ecmascript::intrinsics::LdEvalVar - name: StEvalVar @@ -2168,7 +2168,7 @@ intrinsics: exception: true signature: ret: any - args: [string_id, any, acc, any] + args: [any, any, acc] impl: panda::ecmascript::intrinsics::StEvalVar - name: Debugger diff --git a/runtime/interpreter/ecma-interpreter-inl.h b/runtime/interpreter/ecma-interpreter-inl.h index 42aeb1092949e262d80ae5e49a71a6a60dc1c681..99753924f7f45b3d189cb22bc6bd33ab39188b55 100644 --- a/runtime/interpreter/ecma-interpreter-inl.h +++ b/runtime/interpreter/ecma-interpreter-inl.h @@ -277,6 +277,11 @@ public: return JSTaggedValue(GetCurrentEnv()->GetConstantPool()).GetRawData(); } + ALWAYS_INLINE uint64_t LoadFromConstantPool(BytecodeId id) + { + return GetConstantPool()->GetObjectFromCache(id.AsIndex()).GetRawData(); + } + ALWAYS_INLINE LexicalEnv *GetLexicalEnv() { return LexicalEnv::Cast(GetCurrentEnv()->GetLexicalEnv()); @@ -415,12 +420,11 @@ public: return; } + UPDATE_CALL_PROFILE(this_func); if (method->HasCompiledCode()) { // AOT, JIT this->template CallCompiledCode(method); } else { // Interpreter - [[maybe_unused]] EcmaHandleScope scope(js_thread); - UPDATE_CALL_PROFILE(this_func); JSHandle function_handle(js_thread, js_function); method->DecrementHotnessCounter(0, nullptr, false, JSTaggedValue(function)); @@ -829,8 +833,7 @@ public: LOG_INST() << "ld.bigint " << big_int << "n"; auto thread = this->GetJSThread(); - auto cp = GetConstantPoolRawValue(); - INTRINSIC_CALL_SETACC(intrinsics::Ldbigint(thread, big_int.AsIndex(), cp)); + INTRINSIC_CALL_SETACC(intrinsics::Ldbigint(thread, LoadFromConstantPool(big_int))); this->template MoveToNextInst(); } @@ -1139,7 +1142,7 @@ public: ALWAYS_INLINE void HandleEcmaThrowconstassignment() { auto string_id = this->GetInst().template GetId(); - auto prop = GetConstantPool()->GetObjectFromCache(string_id.AsIndex()); + auto prop = JSTaggedValue(LoadFromConstantPool(string_id)); LOG_INST() << "throwconstassignment " << "string_id:" << ConvertToPandaString(EcmaString::Cast(prop.GetHeapObject())); @@ -1525,8 +1528,10 @@ public: << " v" << v0 << std::hex << method_id; uint64_t env = GetRegAsTaggedValue(v0).GetRawData(); - uint64_t cp = GetConstantPoolRawValue(); - INTRINSIC_CALL_CHECK_SETACC(intrinsics::DefinefuncDyn(this->GetJSThread(), method_id.AsIndex(), env, cp)); + auto cp = GetConstantPool(); + uint64_t method = cp->GetObjectFromCache(method_id.AsIndex()).GetRawData(); + INTRINSIC_CALL_CHECK_SETACC( + intrinsics::DefinefuncDyn(this->GetJSThread(), method, env, JSTaggedValue(cp).GetRawData())); this->template MoveToNextInst(); } @@ -1541,9 +1546,10 @@ public: uint64_t env = GetRegAsTaggedValue(v0).GetRawData(); uint64_t home_object = GetAccAsTaggedValue().GetRawData(); - uint64_t cp = GetConstantPoolRawValue(); + auto cp = GetConstantPool(); + uint64_t method = cp->GetObjectFromCache(method_id.AsIndex()).GetRawData(); INTRINSIC_CALL_CHECK_SETACC( - intrinsics::DefineNCFuncDyn(this->GetJSThread(), method_id.AsIndex(), env, home_object, cp)); + intrinsics::DefineNCFuncDyn(this->GetJSThread(), method, env, home_object, JSTaggedValue(cp).GetRawData())); this->template MoveToNextInst(); } @@ -1559,9 +1565,10 @@ public: uint64_t home_object = GetAccAsTaggedValue().GetRawData(); SaveAccToFrame(); - auto cp = GetConstantPoolRawValue(); - INTRINSIC_CALL_CHECK_SETACC( - intrinsics::DefineMethod(this->GetJSThread(), method_id.AsIndex(), tagged_cur_env, home_object, cp)); + auto cp = GetConstantPool(); + uint64_t method = cp->GetObjectFromCache(method_id.AsIndex()).GetRawData(); + INTRINSIC_CALL_CHECK_SETACC(intrinsics::DefineMethod(this->GetJSThread(), method, tagged_cur_env, home_object, + JSTaggedValue(cp).GetRawData())); this->template MoveToNextInst(); } @@ -1669,17 +1676,15 @@ public: ALWAYS_INLINE void HandleEcmaLdlexdyn() { auto string_id = this->GetInst().template GetId(); - auto prop = GetConstantPool()->GetObjectFromCache(string_id.AsIndex()); + auto prop = LoadFromConstantPool(string_id); auto level = this->GetInst().template GetImm(); auto slot = this->GetInst().template GetImm(); LOG_INST() << "ldlexdyn" - << " string_id:" << ConvertToPandaString(EcmaString::Cast(prop.GetHeapObject())) + << " string_id:" << ConvertToPandaString(EcmaString::Cast(JSTaggedValue(prop).GetHeapObject())) << " level:" << level << " slot:" << slot; - auto cp = GetConstantPoolRawValue(); auto lex_env = GetLexicalEnvRawValue(); - INTRINSIC_CALL_CHECK_SETACC( - intrinsics::LdLexDyn(this->GetJSThread(), string_id.AsIndex(), level, slot, cp, lex_env)); + INTRINSIC_CALL_CHECK_SETACC(intrinsics::LdLexDyn(this->GetJSThread(), prop, level, slot, lex_env)); this->template MoveToNextInst(); } @@ -1703,18 +1708,16 @@ public: ALWAYS_INLINE void HandleEcmaStlexdyn() { auto string_id = this->GetInst().template GetId(); - auto prop = GetConstantPool()->GetObjectFromCache(string_id.AsIndex()); + auto prop = LoadFromConstantPool(string_id); auto level = this->GetInst().template GetImm(); auto slot = this->GetInst().template GetImm(); LOG_INST() << "stlexdyn" - << " string_id:" << ConvertToPandaString(EcmaString::Cast(prop.GetHeapObject())) + << " string_id:" << ConvertToPandaString(EcmaString::Cast(JSTaggedValue(prop).GetHeapObject())) << " level:" << level << " slot:" << slot; uint64_t value = GetAccAsTaggedValue().GetRawData(); - uint64_t cp = GetConstantPoolRawValue(); uint64_t lex_env = GetLexicalEnvRawValue(); - INTRINSIC_CALL_CHECK_SETACC( - intrinsics::StLexDyn(this->GetJSThread(), string_id.AsIndex(), level, slot, value, cp, lex_env)); + INTRINSIC_CALL_CHECK_SETACC(intrinsics::StLexDyn(this->GetJSThread(), prop, level, slot, value, lex_env)); this->template MoveToNextInst(); } @@ -1895,7 +1898,7 @@ public: ALWAYS_INLINE void HandleEcmaThrowtdz() { auto string_id = this->GetInst().template GetId(); - auto prop = GetConstantPool()->GetObjectFromCache(string_id.AsIndex()); + auto prop = JSTaggedValue(LoadFromConstantPool(string_id)); LOG_INST() << "intrinsic::throwundefinedifhole " << "string_id:" << ConvertToPandaString(EcmaString::Cast(prop.GetHeapObject())); @@ -1917,8 +1920,7 @@ public: uint64_t value = GetAccAsTaggedValue().GetRawData(); SaveAccToFrame(); - auto cp = GetConstantPoolRawValue(); - INTRINSIC_CALL_CHECK(intrinsics::StOwnByName(this->GetJSThread(), id.AsIndex(), obj, value, cp)); + INTRINSIC_CALL_CHECK(intrinsics::StOwnByName(this->GetJSThread(), LoadFromConstantPool(id), obj, value)); RestoreAccFromFrame(); this->template MoveToNextInst(); } @@ -1948,9 +1950,8 @@ public: LOG_INST() << "createobjectwithbuffer" << " literalArrayId:" << literalarray_id.AsIndex(); - auto cp = GetConstantPoolRawValue(); INTRINSIC_CALL_CHECK_SETACC( - intrinsics::CreateObjectWithBuffer(this->GetJSThread(), literalarray_id.AsIndex(), cp)); + intrinsics::CreateObjectWithBuffer(this->GetJSThread(), LoadFromConstantPool(literalarray_id))); this->template MoveToNextInst(); } @@ -1961,9 +1962,8 @@ public: LOG_INST() << "createarraywithbuffer" << " literalArrayId:" << literalarray_id.AsIndex(); - auto cp = GetConstantPoolRawValue(); INTRINSIC_CALL_CHECK_SETACC( - intrinsics::CreateArrayWithBuffer(this->GetJSThread(), literalarray_id.AsIndex(), cp)); + intrinsics::CreateArrayWithBuffer(this->GetJSThread(), LoadFromConstantPool(literalarray_id))); this->template MoveToNextInst(); } @@ -1975,9 +1975,8 @@ public: LOG_INST() << "createregexpwithliteral" << " string_id: " << string_id << " flags:" << flags; - auto cp = GetConstantPoolRawValue(); INTRINSIC_CALL_CHECK_SETACC( - intrinsics::CreateRegExpWithLiteral(this->GetJSThread(), string_id.AsIndex(), flags, cp)); + intrinsics::CreateRegExpWithLiteral(this->GetJSThread(), LoadFromConstantPool(string_id), flags)); this->template MoveToNextInst(); } @@ -1988,8 +1987,7 @@ public: LOG_INST() << "importmodule " << "string_id:" << std::hex << string_id.AsIndex(); - auto cp = GetConstantPoolRawValue(); - INTRINSIC_CALL_SETACC(intrinsics::ImportModule(this->GetJSThread(), string_id.AsIndex(), cp)); + INTRINSIC_CALL_SETACC(intrinsics::ImportModule(this->GetJSThread(), LoadFromConstantPool(string_id))); this->template MoveToNextInst(); } @@ -2003,8 +2001,7 @@ public: uint64_t value = GetAccAsTaggedValue().GetRawData(); SaveAccToFrame(); - auto cp = GetConstantPoolRawValue(); - intrinsics::StModuleVar(this->GetJSThread(), string_id.AsIndex(), value, cp); + intrinsics::StModuleVar(this->GetJSThread(), LoadFromConstantPool(string_id), value); RestoreAccFromFrame(); this->template MoveToNextInst(); } @@ -2034,8 +2031,8 @@ public: uint64_t module_obj = GetRegAsTaggedValue(v0).GetRawData(); - auto cp = GetConstantPoolRawValue(); - INTRINSIC_CALL_SETACC(intrinsics::LdModvarByName(this->GetJSThread(), string_id.AsIndex(), module_obj, cp)); + INTRINSIC_CALL_SETACC( + intrinsics::LdModvarByName(this->GetJSThread(), LoadFromConstantPool(string_id), module_obj)); this->template MoveToNextInst(); } @@ -2048,8 +2045,7 @@ public: LOG_INST() << "getmethod v" << v0 << " string_id:" << string_id; uint64_t obj = GetRegAsTaggedValue(v0).GetRawData(); - auto cp = GetConstantPoolRawValue(); - INTRINSIC_CALL_CHECK_SETACC(intrinsics::GetMethod(this->GetJSThread(), string_id.AsIndex(), obj, cp)); + INTRINSIC_CALL_CHECK_SETACC(intrinsics::GetMethod(this->GetJSThread(), LoadFromConstantPool(string_id), obj)); this->template MoveToNextInst(); } @@ -2156,8 +2152,10 @@ public: << " v" << v0; uint64_t env = GetRegAsTaggedValue(v0).GetRawData(); - auto cp = GetConstantPoolRawValue(); - INTRINSIC_CALL_CHECK_SETACC(intrinsics::DefineGeneratorFunc(this->GetJSThread(), method_id.AsIndex(), env, cp)); + auto cp = GetConstantPool(); + uint64_t method = cp->GetObjectFromCache(method_id.AsIndex()).GetRawData(); + INTRINSIC_CALL_CHECK_SETACC( + intrinsics::DefineGeneratorFunc(this->GetJSThread(), method, env, JSTaggedValue(cp).GetRawData())); this->template MoveToNextInst(); } @@ -2170,8 +2168,10 @@ public: << " v" << v0; uint64_t env = GetRegAsTaggedValue(v0).GetRawData(); - uint64_t cp = GetConstantPoolRawValue(); - INTRINSIC_CALL_CHECK_SETACC(intrinsics::DefineAsyncFunc(this->GetJSThread(), method_id.AsIndex(), env, cp)); + auto cp = GetConstantPool(); + uint64_t method = cp->GetObjectFromCache(method_id.AsIndex()).GetRawData(); + INTRINSIC_CALL_CHECK_SETACC( + intrinsics::DefineAsyncFunc(this->GetJSThread(), method, env, JSTaggedValue(cp).GetRawData())); this->template MoveToNextInst(); } @@ -2184,9 +2184,10 @@ public: << " v" << v0; uint64_t env = GetRegAsTaggedValue(v0).GetRawData(); - auto cp = GetConstantPoolRawValue(); + auto cp = GetConstantPool(); + uint64_t method = cp->GetObjectFromCache(method_id.AsIndex()).GetRawData(); INTRINSIC_CALL_CHECK_SETACC( - intrinsics::DefineAsyncGeneratorFunc(this->GetJSThread(), method_id.AsIndex(), env, cp)); + intrinsics::DefineAsyncGeneratorFunc(this->GetJSThread(), method, env, JSTaggedValue(cp).GetRawData())); this->template MoveToNextInst(); } @@ -2346,10 +2347,9 @@ public: ALWAYS_INLINE void HandleEcmaTryldglobalbyname() { auto string_id = this->GetInst().template GetId(); - auto cp = GetConstantPoolRawValue(); auto func = GetThisFuncRawValue(); - INTRINSIC_CALL_CHECK_SETACC(intrinsics::TryLdGlobalByName(this->GetJSThread(), string_id.AsIndex(), - this->GetBytecodeOffset(), func, cp)); + INTRINSIC_CALL_CHECK_SETACC(intrinsics::TryLdGlobalByName(this->GetJSThread(), LoadFromConstantPool(string_id), + this->GetBytecodeOffset(), func)); this->template MoveToNextInst(); } @@ -2363,10 +2363,9 @@ public: uint64_t value = GetAccAsTaggedValue().GetRawData(); SaveAccToFrame(); - auto cp = GetConstantPoolRawValue(); auto func = GetThisFuncRawValue(); - INTRINSIC_CALL_CHECK(intrinsics::TryStGlobalByName(this->GetJSThread(), string_id.AsIndex(), value, - this->GetBytecodeOffset(), func, cp)); + INTRINSIC_CALL_CHECK(intrinsics::TryStGlobalByName(this->GetJSThread(), LoadFromConstantPool(string_id), value, + this->GetBytecodeOffset(), func)); RestoreAccFromFrame(); this->template MoveToNextInst(); } @@ -2379,10 +2378,9 @@ public: LOG_INST() << "ldglobalvar " << " string_id:" << string_id; - auto cp = GetConstantPoolRawValue(); auto func = GetThisFuncRawValue(); - INTRINSIC_CALL_CHECK_SETACC( - intrinsics::LdGlobalVar(this->GetJSThread(), string_id.AsIndex(), this->GetBytecodeOffset(), func, cp)); + INTRINSIC_CALL_CHECK_SETACC(intrinsics::LdGlobalVar(this->GetJSThread(), LoadFromConstantPool(string_id), + this->GetBytecodeOffset(), func)); this->template MoveToNextInst(); } @@ -2395,10 +2393,9 @@ public: << " string_id:" << string_id; uint64_t obj = GetAccAsTaggedValue().GetRawData(); - auto cp = GetConstantPoolRawValue(); auto func = GetThisFuncRawValue(); - INTRINSIC_CALL_CHECK_SETACC(intrinsics::LdObjByName(this->GetJSThread(), string_id.AsIndex(), obj, - this->GetBytecodeOffset(), func, cp)); + INTRINSIC_CALL_CHECK_SETACC(intrinsics::LdObjByName(this->GetJSThread(), LoadFromConstantPool(string_id), obj, + this->GetBytecodeOffset(), func)); this->template MoveToNextInst(); } @@ -2415,10 +2412,9 @@ public: uint64_t value = GetAccAsTaggedValue().GetRawData(); SaveAccToFrame(); - auto cp = GetConstantPoolRawValue(); auto func = GetThisFuncRawValue(); - INTRINSIC_CALL_CHECK(intrinsics::StObjByName(this->GetJSThread(), string_id.AsIndex(), obj, value, - this->GetBytecodeOffset(), func, cp)); + INTRINSIC_CALL_CHECK(intrinsics::StObjByName(this->GetJSThread(), LoadFromConstantPool(string_id), obj, value, + this->GetBytecodeOffset(), func)); RestoreAccFromFrame(); this->template MoveToNextInst(); } @@ -2432,9 +2428,9 @@ public: << " string_id:" << string_id.AsIndex(); uint64_t obj = GetAccAsTaggedValue().GetRawData(); - auto cp = GetConstantPoolRawValue(); auto func = GetThisFuncRawValue(); - INTRINSIC_CALL_CHECK_SETACC(intrinsics::LdSuperByName(this->GetJSThread(), string_id.AsIndex(), obj, func, cp)); + INTRINSIC_CALL_CHECK_SETACC( + intrinsics::LdSuperByName(this->GetJSThread(), LoadFromConstantPool(string_id), obj, func)); this->template MoveToNextInst(); } @@ -2452,8 +2448,8 @@ public: SaveAccToFrame(); auto func = GetThisFuncRawValue(); - auto cp = GetConstantPoolRawValue(); - INTRINSIC_CALL_CHECK(intrinsics::StSuperByName(this->GetJSThread(), string_id.AsIndex(), obj, value, func, cp)); + INTRINSIC_CALL_CHECK( + intrinsics::StSuperByName(this->GetJSThread(), LoadFromConstantPool(string_id), obj, value, func)); RestoreAccFromFrame(); this->template MoveToNextInst(); } @@ -2469,10 +2465,9 @@ public: uint64_t value = GetAccAsTaggedValue().GetRawData(); SaveAccToFrame(); - auto cp = GetConstantPoolRawValue(); auto func = GetThisFuncRawValue(); - INTRINSIC_CALL_CHECK(intrinsics::StGlobalVar(this->GetJSThread(), string_id.AsIndex(), value, - this->GetBytecodeOffset(), func, cp)); + INTRINSIC_CALL_CHECK(intrinsics::StGlobalVar(this->GetJSThread(), LoadFromConstantPool(string_id), value, + this->GetBytecodeOffset(), func)); RestoreAccFromFrame(); this->template MoveToNextInst(); } @@ -2573,9 +2568,11 @@ public: uint64_t lexenv = GetRegAsTaggedValue(v0).GetRawData(); uint64_t proto = GetRegAsTaggedValue(v1).GetRawData(); - auto cp = GetConstantPoolRawValue(); - INTRINSIC_CALL_CHECK_SETACC( - intrinsics::DefineClassWithBuffer(this->GetJSThread(), method_id, imm, lexenv, proto, cp)); + auto cp = GetConstantPool(); + uint64_t method = cp->GetObjectFromCache(method_id).GetRawData(); + // uint64_t buffer = cp->GetObjectFromCache(imm).GetRawData(); + INTRINSIC_CALL_CHECK_SETACC(intrinsics::DefineClassWithBuffer(this->GetJSThread(), method, imm, lexenv, proto, + JSTaggedValue(cp).GetRawData())); this->template MoveToNextInst(); } @@ -2608,8 +2605,10 @@ public: uint64_t env = GetRegAsTaggedValue(v0).GetRawData(); uint64_t ctor = GetAccAsTaggedValue().GetRawData(); - auto cp = GetConstantPoolRawValue(); - intrinsics::DefineClassPrivateFields(this->GetJSThread(), literalarray_id.AsIndex(), env, ctor, cp); + auto cp = GetConstantPool(); + uint64_t private_buf = cp->GetObjectFromCache(literalarray_id.AsIndex()).GetRawData(); + intrinsics::DefineClassPrivateFields(this->GetJSThread(), private_buf, env, ctor, + JSTaggedValue(cp).GetRawData()); this->template MoveToNextInst(); } @@ -2640,9 +2639,8 @@ public: uint64_t ctor = GetRegAsTaggedValue(v0).GetRawData(); uint64_t obj = GetRegAsTaggedValue(v1).GetRawData(); uint64_t value = GetAccAsTaggedValue().GetRawData(); - uint64_t cp = GetConstantPoolRawValue(); INTRINSIC_CALL_CHECK_SETACC( - intrinsics::ClassPrivateFieldAdd(this->GetJSThread(), string_id.AsIndex(), ctor, obj, value, cp)); + intrinsics::ClassPrivateFieldAdd(this->GetJSThread(), LoadFromConstantPool(string_id), ctor, obj, value)); this->template MoveToNextInst(); } @@ -2657,9 +2655,8 @@ public: uint64_t ctor = GetRegAsTaggedValue(v0).GetRawData(); uint64_t obj = GetRegAsTaggedValue(v1).GetRawData(); - uint64_t cp = GetConstantPoolRawValue(); INTRINSIC_CALL_CHECK_SETACC( - intrinsics::ClassPrivateFieldGet(this->GetJSThread(), string_id.AsIndex(), ctor, obj, cp)); + intrinsics::ClassPrivateFieldGet(this->GetJSThread(), LoadFromConstantPool(string_id), ctor, obj)); this->template MoveToNextInst(); } @@ -2675,9 +2672,8 @@ public: uint64_t ctor = GetRegAsTaggedValue(v0).GetRawData(); uint64_t obj = GetRegAsTaggedValue(v1).GetRawData(); uint64_t value = GetAccAsTaggedValue().GetRawData(); - uint64_t cp = GetConstantPoolRawValue(); INTRINSIC_CALL_CHECK_SETACC( - intrinsics::ClassPrivateFieldSet(this->GetJSThread(), string_id.AsIndex(), ctor, obj, value, cp)); + intrinsics::ClassPrivateFieldSet(this->GetJSThread(), LoadFromConstantPool(string_id), ctor, obj, value)); this->template MoveToNextInst(); } @@ -2691,9 +2687,8 @@ public: uint64_t ctor = GetRegAsTaggedValue(v0).GetRawData(); uint64_t obj = GetAccAsTaggedValue().GetRawData(); - uint64_t cp = GetConstantPoolRawValue(); INTRINSIC_CALL_CHECK_SETACC( - intrinsics::ClassPrivateFieldIn(this->GetJSThread(), string_id.AsIndex(), ctor, obj, cp)); + intrinsics::ClassPrivateFieldIn(this->GetJSThread(), LoadFromConstantPool(string_id), ctor, obj)); this->template MoveToNextInst(); } @@ -2743,9 +2738,10 @@ public: << " literalArrayId:" << literalarray_id.AsIndex(); uint64_t env = GetAccAsTaggedValue().GetRawData(); - uint64_t cp = GetConstantPoolRawValue(); + auto cp = GetConstantPool(); + uint64_t literal = cp->GetObjectFromCache(literalarray_id.AsIndex()).GetRawData(); INTRINSIC_CALL_CHECK_SETACC( - intrinsics::CreateObjectHavingMethod(this->GetJSThread(), literalarray_id.AsIndex(), env, cp)); + intrinsics::CreateObjectHavingMethod(this->GetJSThread(), literal, env, JSTaggedValue(cp).GetRawData())); this->template MoveToNextInst(); } @@ -2824,8 +2820,7 @@ public: auto literalarray_id = this->GetInst().template GetId(); LOG_INST() << "ldevalbindings" << " literalArrayId:" << literalarray_id.AsIndex(); - uint64_t cp = GetConstantPoolRawValue(); - INTRINSIC_CALL_SETACC(intrinsics::LdEvalBindings(this->GetJSThread(), literalarray_id.AsIndex(), cp)); + INTRINSIC_CALL_SETACC(intrinsics::LdEvalBindings(this->GetJSThread(), LoadFromConstantPool(literalarray_id))); this->template MoveToNextInst(); } @@ -2855,8 +2850,8 @@ public: << " name:" << id.AsIndex(); uint64_t lexical_context = GetAccAsTaggedValue().GetRawData(); - uint64_t cp = GetConstantPoolRawValue(); - INTRINSIC_CALL_CHECK_SETACC(intrinsics::LdEvalVar(this->GetJSThread(), id.AsIndex(), lexical_context, cp)); + INTRINSIC_CALL_CHECK_SETACC( + intrinsics::LdEvalVar(this->GetJSThread(), LoadFromConstantPool(id), lexical_context)); this->template MoveToNextInst(); } @@ -2871,9 +2866,8 @@ public: uint64_t value = GetRegAsTaggedValue(v0).GetRawData(); uint64_t lexical_context = GetAccAsTaggedValue().GetRawData(); - uint64_t cp = GetConstantPoolRawValue(); INTRINSIC_CALL_CHECK_SETACC( - intrinsics::StEvalVar(this->GetJSThread(), id.AsIndex(), value, lexical_context, cp)); + intrinsics::StEvalVar(this->GetJSThread(), LoadFromConstantPool(id), value, lexical_context)); this->template MoveToNextInst(); } diff --git a/runtime/intrinsics-inl.h b/runtime/intrinsics-inl.h index 8ba8a1a83d997e2bdef75e62ed32f8aaf6c14685..8ad484380c8984df2e659d8063a36f62e54d4e30 100644 --- a/runtime/intrinsics-inl.h +++ b/runtime/intrinsics-inl.h @@ -142,13 +142,11 @@ INLINE_ECMA_INTRINSICS uint64_t Ldstring([[maybe_unused]] JSThread *thread, [[ma } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t Ldbigint([[maybe_unused]] JSThread *thread, [[maybe_unused]] uint32_t string_id, - uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t Ldbigint([[maybe_unused]] JSThread *thread, [[maybe_unused]] uint64_t number_big_int) { INTERPRETER_TRACE(thread, Ldbigint); [[maybe_unused]] EcmaHandleScope handle_scope(thread); - JSTaggedValue number_big_int = ConstantPool::Cast(cp)->GetObjectFromCache(string_id); - JSHandle big_int_handle(thread, number_big_int); + JSHandle big_int_handle(thread, JSTaggedValue(number_big_int)); return JSTaggedValue::ToBigInt(thread, big_int_handle).GetRawData(); } @@ -416,14 +414,10 @@ INLINE_ECMA_INTRINSICS void TryStGlobalByValue([[maybe_unused]] JSThread *thread } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t TryLdGlobalByName(JSThread *thread, uint32_t string_id, - [[maybe_unused]] uint16_t slot_id, [[maybe_unused]] uint64_t func, - uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t TryLdGlobalByName(JSThread *thread, uint64_t prop, [[maybe_unused]] uint16_t slot_id, + [[maybe_unused]] uint64_t func) { - auto constpool = ConstantPool::Cast(cp); JSTaggedType global_obj = GetGlobalObject(thread).GetRawData(); - JSTaggedType prop = constpool->GetObjectFromCache(string_id).GetRawData(); - JSTaggedValue result = JSTaggedValue::Hole(); [[maybe_unused]] size_t gc = thread->GetEcmaVM()->GetGC()->GetCounter(); #if ECMASCRIPT_ENABLE_IC @@ -550,18 +544,16 @@ INLINE_ECMA_INTRINSICS uint64_t Definefuncexpr([[maybe_unused]] JSThread *thread } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t DefinefuncDyn(JSThread *thread, uint32_t method_id, uint64_t env, uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t DefinefuncDyn(JSThread *thread, uint64_t method, uint64_t env, uint64_t cp) { - auto constpool = ConstantPool::Cast(cp); - auto result = JSFunction::Cast(constpool->GetObjectFromCache(method_id).GetHeapObject()); + auto result = JSFunction::Cast(JSTaggedValue(method).GetHeapObject()); auto lexenv = JSTaggedValue(env); if (!result->GetLexicalEnv().IsUndefined()) { [[maybe_unused]] EcmaHandleScope handle_scope(thread); - JSHandle constpool_handle(thread, constpool); JSHandle lexenv_handle(thread, lexenv); auto res = SlowRuntimeStub::DefinefuncDyn(thread, result->GetCallTarget()); result = JSFunction::Cast(res.GetHeapObject()); - constpool = *constpool_handle; // May be moved by GC + auto constpool = ConstantPool::Cast(cp); // May not be moved by GC lexenv = lexenv_handle.GetTaggedValue(); // May be moved by GC result->SetConstantPool(thread, JSTaggedValue(constpool)); } @@ -984,11 +976,9 @@ INLINE_ECMA_INTRINSICS uint64_t StObjByValue(JSThread *thread, uint64_t rec, uin } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t TryStGlobalByName(JSThread *thread, uint32_t string_id, uint64_t value, - [[maybe_unused]] uint16_t slot_id, [[maybe_unused]] uint64_t func, - uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t TryStGlobalByName(JSThread *thread, uint64_t prop_key, uint64_t value, + [[maybe_unused]] uint16_t slot_id, [[maybe_unused]] uint64_t func) { - JSTaggedType prop_key = ConstantPool::Cast(cp)->GetObjectFromCache(string_id).GetRawData(); JSTaggedType global_obj = GetGlobalObject(thread).GetRawData(); JSTaggedValue result = JSTaggedValue::Hole(); @@ -1018,14 +1008,13 @@ INLINE_ECMA_INTRINSICS uint64_t TryStGlobalByName(JSThread *thread, uint32_t str } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t LdGlobalVar(JSThread *thread, uint32_t string_id, [[maybe_unused]] uint16_t slot_id, - [[maybe_unused]] uint64_t func, uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t LdGlobalVar(JSThread *thread, uint64_t prop_key, [[maybe_unused]] uint16_t slot_id, + [[maybe_unused]] uint64_t func) { JSTaggedType global_obj = thread->GetGlobalObject().GetRawData(); - JSTaggedType prop_key = ConstantPool::Cast(cp)->GetObjectFromCache(string_id).GetRawData(); - JSTaggedValue result = JSTaggedValue::Hole(); [[maybe_unused]] size_t gc = thread->GetEcmaVM()->GetGC()->GetCounter(); + #if ECMASCRIPT_ENABLE_IC auto js_func = JSFunction::Cast(JSTaggedValue(func).GetHeapObject()); if (ICRuntimeStub::HaveICForFunction(js_func)) { @@ -1048,14 +1037,12 @@ INLINE_ECMA_INTRINSICS uint64_t LdGlobalVar(JSThread *thread, uint32_t string_id } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t StGlobalVar(JSThread *thread, uint32_t string_id, uint64_t value, - [[maybe_unused]] uint16_t slot_id, [[maybe_unused]] uint64_t func, - uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t StGlobalVar(JSThread *thread, uint64_t prop, uint64_t value, + [[maybe_unused]] uint16_t slot_id, [[maybe_unused]] uint64_t func) { JSTaggedType global_obj = thread->GetGlobalObject().GetRawData(); - JSTaggedType prop = ConstantPool::Cast(cp)->GetObjectFromCache(string_id).GetRawData(); - [[maybe_unused]] size_t gc = thread->GetEcmaVM()->GetGC()->GetCounter(); + #if ECMASCRIPT_ENABLE_IC auto js_func = JSFunction::Cast(JSTaggedValue(func).GetHeapObject()); if (ICRuntimeStub::HaveICForFunction(js_func)) { @@ -1072,15 +1059,13 @@ INLINE_ECMA_INTRINSICS uint64_t StGlobalVar(JSThread *thread, uint32_t string_id } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t LdObjByName(JSThread *thread, uint32_t string_id, uint64_t object, - [[maybe_unused]] uint16_t slot_id, [[maybe_unused]] uint64_t func, - uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t LdObjByName(JSThread *thread, uint64_t prop_key, uint64_t object, + [[maybe_unused]] uint16_t slot_id, [[maybe_unused]] uint64_t func) { // CSA reports usage object and prop_key after GC triggered in ICRuntimeStub::LoadICByName. // If ICRuntimeStub::LoadICByName triggers GC it mustn't return Hole. // Using object and prop_key after ICRuntimeStub::LoadICByName is valid. - // To suppress CSA keep pointers in uint64_t and JSTaggedType. - JSTaggedType prop_key = ConstantPool::Cast(cp)->GetObjectFromCache(string_id).GetRawData(); + // To suppress CSA keep pointers in uint64_t. JSTaggedValue res = JSTaggedValue::Hole(); [[maybe_unused]] size_t gc = thread->GetEcmaVM()->GetGC()->GetCounter(); #if ECMASCRIPT_ENABLE_IC @@ -1107,15 +1092,13 @@ INLINE_ECMA_INTRINSICS uint64_t LdObjByName(JSThread *thread, uint32_t string_id } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t StObjByName(JSThread *thread, uint32_t string_id, uint64_t object, uint64_t val, - [[maybe_unused]] uint16_t slot_id, [[maybe_unused]] uint64_t func, - uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t StObjByName(JSThread *thread, uint64_t prop_key, uint64_t object, uint64_t val, + [[maybe_unused]] uint16_t slot_id, [[maybe_unused]] uint64_t func) { // CSA reports usage object, prop_key and val after GC triggered in ICRuntimeStub::StoreICByName. // If ICRuntimeStub::StoreICByName triggers GC it mustn't return Hole. // Using object, prop_key and val after ICRuntimeStub::StoreICByName is valid. - // To suppress CSA keep pointers in uint64_t and JSTaggedType. - JSTaggedType prop_key = ConstantPool::Cast(cp)->GetObjectFromCache(string_id).GetRawData(); + // To suppress CSA keep pointers in uint64_t. JSTaggedValue res = JSTaggedValue::Hole(); [[maybe_unused]] size_t gc = thread->GetEcmaVM()->GetGC()->GetCounter(); #if ECMASCRIPT_ENABLE_IC @@ -1391,28 +1374,26 @@ INLINE_ECMA_INTRINSICS uint64_t Delobjprop(JSThread *thread, uint64_t obj, uint6 // define not constructor function // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t DefineNCFuncDyn(JSThread *thread, uint32_t method_id, uint64_t env, uint64_t home_objv, +INLINE_ECMA_INTRINSICS uint64_t DefineNCFuncDyn(JSThread *thread, uint64_t method, uint64_t env, uint64_t home_objv, uint64_t cp) { auto home_obj = JSTaggedValue(home_objv); - auto constpool = ConstantPool::Cast(cp); - auto result = JSFunction::Cast(constpool->GetObjectFromCache(method_id).GetHeapObject()); + + auto result = JSFunction::Cast(JSTaggedValue(method).GetHeapObject()); auto lexenv = JSTaggedValue(env); if (!result->GetLexicalEnv().IsUndefined()) { [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle home_obj_handle(thread, home_obj); - JSHandle constpool_handle(thread, constpool); JSHandle lexenv_handle(thread, lexenv); auto res = SlowRuntimeStub::DefineNCFuncDyn(thread, result->GetCallTarget()); if (res.IsException()) { return res.GetRawData(); } result = JSFunction::Cast(res.GetHeapObject()); - home_obj = home_obj_handle.GetTaggedValue(); // May be moved by GC - constpool = *constpool_handle; // May be moved by GC - lexenv = lexenv_handle.GetTaggedValue(); // May be moved by GC - result->SetConstantPool(thread, JSTaggedValue(constpool)); + home_obj = home_obj_handle.GetTaggedValue(); // May be moved by GC + lexenv = lexenv_handle.GetTaggedValue(); // May be moved by GC + result->SetConstantPool(thread, JSTaggedValue(cp)); // ConstantPool is non-movable } result->SetLexicalEnv(thread, lexenv); result->SetHomeObject(thread, home_obj); @@ -1433,8 +1414,8 @@ INLINE_ECMA_INTRINSICS uint64_t LdLexVarDyn([[maybe_unused]] JSThread *thread, u } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t LdLexDyn([[maybe_unused]] JSThread *thread, uint32_t string_id, uint16_t level, - uint16_t slot, uint64_t cp, uint64_t lex_env) +INLINE_ECMA_INTRINSICS uint64_t LdLexDyn([[maybe_unused]] JSThread *thread, uint64_t binding_name, uint16_t level, + uint16_t slot, uint64_t lex_env) { JSTaggedValue binding(LdLexVarDyn(level, slot, lex_env)); @@ -1442,8 +1423,7 @@ INLINE_ECMA_INTRINSICS uint64_t LdLexDyn([[maybe_unused]] JSThread *thread, uint return binding.GetRawData(); } - auto binding_name = ConstantPool::Cast(cp)->GetObjectFromCache(string_id); - SlowRuntimeStub::ThrowTdz(GetJSThread(), binding_name); + SlowRuntimeStub::ThrowTdz(GetJSThread(), JSTaggedValue(binding_name)); return JSTaggedValue(JSTaggedValue::VALUE_EXCEPTION).GetRawData(); } @@ -1542,9 +1522,9 @@ INLINE_ECMA_INTRINSICS uint64_t CopylexenvDyn(JSThread *thread, uint64_t lex_env } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS void ThrowTdz(JSThread *thread, uint32_t string_id, uint64_t cp) +INLINE_ECMA_INTRINSICS void ThrowTdz(JSThread *thread, uint64_t prop_key) { - SlowRuntimeStub::ThrowTdz(thread, ConstantPool::Cast(cp)->GetObjectFromCache(string_id)); + SlowRuntimeStub::ThrowTdz(thread, JSTaggedValue(prop_key)); } // NOLINTNEXTLINE(misc-definitions-in-headers) @@ -1563,8 +1543,8 @@ INLINE_ECMA_INTRINSICS void StLexVarDyn(JSThread *thread, uint16_t level, uint16 } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t StLexDyn(JSThread *thread, uint32_t string_id, uint16_t level, uint16_t slot, - uint64_t value, uint64_t cp, uint64_t lex_env) +INLINE_ECMA_INTRINSICS uint64_t StLexDyn(JSThread *thread, uint64_t prop_key, uint16_t level, uint16_t slot, + uint64_t value, uint64_t lex_env) { JSTaggedValue current_lexenv(LexicalEnv::Cast(lex_env)); JSTaggedValue env(current_lexenv); @@ -1578,7 +1558,7 @@ INLINE_ECMA_INTRINSICS uint64_t StLexDyn(JSThread *thread, uint32_t string_id, u LexicalEnv *lexenv = LexicalEnv::Cast(env.GetHeapObject()); if (lexenv->GetProperties(slot).IsHole()) { - ThrowTdz(thread, string_id, cp); + ThrowTdz(thread, prop_key); return JSTaggedValue(JSTaggedValue::VALUE_EXCEPTION).GetRawData(); } @@ -1599,22 +1579,20 @@ INLINE_ECMA_INTRINSICS uint64_t GetPropIterator(JSThread *thread, uint64_t obj) } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t DefineGeneratorFunc(JSThread *thread, uint32_t method_id, uint64_t env, uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t DefineGeneratorFunc(JSThread *thread, uint64_t method, uint64_t env, uint64_t cp) { - auto *constantpool = ConstantPool::Cast(cp); - auto *result = JSFunction::Cast(constantpool->GetObjectFromCache(method_id).GetHeapObject()); + auto *result = JSFunction::Cast(JSTaggedValue(method).GetHeapObject()); auto lexenv = JSTaggedValue(env); if (!result->GetLexicalEnv().IsUndefined()) { [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle lexenv_handle(thread, lexenv); - JSHandle constantpool_handle(thread, JSTaggedValue(constantpool)); auto res = SlowRuntimeStub::DefineGeneratorFunc(thread, result->GetCallTarget()); // Can trigger GC if (res.IsException()) { return res.GetRawData(); } result = JSFunction::Cast(res.GetHeapObject()); - lexenv = lexenv_handle.GetTaggedValue(); // May be moved by GC - result->SetConstantPool(thread, constantpool_handle.GetTaggedValue()); + lexenv = lexenv_handle.GetTaggedValue(); // May be moved by GC + result->SetConstantPool(thread, JSTaggedValue(cp)); // ConstantPool is non-movable } result->SetLexicalEnv(thread, lexenv); return JSTaggedValue(result).GetRawData(); @@ -1659,45 +1637,40 @@ INLINE_ECMA_INTRINSICS uint64_t CreateAsyncGeneratorObj(JSThread *thread, uint64 } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t DefineAsyncFunc(JSThread *thread, uint32_t method_id, uint64_t env, uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t DefineAsyncFunc(JSThread *thread, uint64_t method, uint64_t env, uint64_t cp) { - auto *constantpool = ConstantPool::Cast(cp); - auto *result = JSFunction::Cast(constantpool->GetObjectFromCache(method_id).GetHeapObject()); + auto *result = JSFunction::Cast(JSTaggedValue(method).GetHeapObject()); auto lexenv = JSTaggedValue(env); if (!result->GetLexicalEnv().IsUndefined()) { [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle lexenv_handle(thread, lexenv); - JSHandle constantpool_handle(thread, JSTaggedValue(constantpool)); auto res = SlowRuntimeStub::DefineAsyncFunc(thread, result->GetCallTarget()); // Can trigger GC if (res.IsException()) { return res.GetRawData(); } result = JSFunction::Cast(res.GetHeapObject()); - lexenv = lexenv_handle.GetTaggedValue(); // May be moved by GC - result->SetConstantPool(thread, constantpool_handle.GetTaggedValue()); + lexenv = lexenv_handle.GetTaggedValue(); // May be moved by GC + result->SetConstantPool(thread, JSTaggedValue(cp)); // ConstantPool is non-movable } result->SetLexicalEnv(thread, lexenv); return JSTaggedValue(result).GetRawData(); } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t DefineAsyncGeneratorFunc(JSThread *thread, uint32_t method_id, uint64_t env, - uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t DefineAsyncGeneratorFunc(JSThread *thread, uint64_t method, uint64_t env, uint64_t cp) { - auto *constantpool = ConstantPool::Cast(cp); - auto *result = JSFunction::Cast(constantpool->GetObjectFromCache(method_id).GetHeapObject()); + auto *result = JSFunction::Cast(JSTaggedValue(method).GetHeapObject()); auto lexenv = JSTaggedValue(env); if (!result->GetLexicalEnv().IsUndefined()) { [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle lexenv_handle(thread, lexenv); - JSHandle constantpool_handle(thread, JSTaggedValue(constantpool)); auto res = SlowRuntimeStub::DefineAsyncGeneratorFunc(thread, result->GetCallTarget()); // Can trigger GC if (res.IsException()) { return res.GetRawData(); } result = JSFunction::Cast(res.GetHeapObject()); - lexenv = lexenv_handle.GetTaggedValue(); // May be moved by GC - result->SetConstantPool(thread, constantpool_handle.GetTaggedValue()); + lexenv = lexenv_handle.GetTaggedValue(); // May be moved by GC + result->SetConstantPool(thread, JSTaggedValue(cp)); // ConstantPool is non-movable } result->SetLexicalEnv(thread, lexenv); return JSTaggedValue(result).GetRawData(); @@ -1746,17 +1719,15 @@ INLINE_ECMA_INTRINSICS uint64_t AsyncGeneratorReject(JSThread *thread, uint64_t } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS void ThrowConstAssignment(JSThread *thread, uint32_t string_id, uint64_t cp) +INLINE_ECMA_INTRINSICS void ThrowConstAssignment(JSThread *thread, uint64_t name) { - return SlowRuntimeStub::ThrowConstAssignment(thread, ConstantPool::Cast(cp)->GetObjectFromCache(string_id)); + return SlowRuntimeStub::ThrowConstAssignment(thread, JSTaggedValue(name)); } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t GetMethod(JSThread *thread, uint32_t string_id, uint64_t object, uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t GetMethod(JSThread *thread, uint64_t prop_key, uint64_t object) { - return SlowRuntimeStub::GetMethod(thread, JSTaggedValue(object), - ConstantPool::Cast(cp)->GetObjectFromCache(string_id)) - .GetRawData(); + return SlowRuntimeStub::GetMethod(thread, JSTaggedValue(object), JSTaggedValue(prop_key)).GetRawData(); } // NOLINTNEXTLINE(misc-definitions-in-headers) @@ -1780,9 +1751,9 @@ INLINE_ECMA_INTRINSICS uint64_t CreateEmptyObject(JSThread *thread) } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t CreateObjectWithBuffer(JSThread *thread, uint16_t index, uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t CreateObjectWithBuffer(JSThread *thread, uint64_t literal) { - JSObject *result = JSObject::Cast(ConstantPool::Cast(cp)->GetObjectFromCache(index).GetHeapObject()); + JSObject *result = JSObject::Cast(JSTaggedValue(literal).GetHeapObject()); return SlowRuntimeStub::CreateObjectWithBuffer(thread, thread->GetEcmaVM()->GetFactory(), result).GetRawData(); } @@ -1817,20 +1788,17 @@ INLINE_ECMA_INTRINSICS uint64_t CreateEmptyArray(JSThread *thread) } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t CreateArrayWithBuffer(JSThread *thread, uint16_t index, uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t CreateArrayWithBuffer(JSThread *thread, uint64_t array) { auto factory = thread->GetEcmaVM()->GetFactory(); - JSArray *result = JSArray::Cast(ConstantPool::Cast(cp)->GetObjectFromCache(index).GetHeapObject()); + JSArray *result = JSArray::Cast(JSTaggedValue(array).GetHeapObject()); return SlowRuntimeStub::CreateArrayWithBuffer(thread, factory, result).GetRawData(); } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t CreateRegExpWithLiteral(JSThread *thread, uint32_t string_id, uint8_t flags, - uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t CreateRegExpWithLiteral(JSThread *thread, uint64_t pattern, uint8_t flags) { - return SlowRuntimeStub::CreateRegExpWithLiteral(thread, ConstantPool::Cast(cp)->GetObjectFromCache(string_id), - flags) - .GetRawData(); + return SlowRuntimeStub::CreateRegExpWithLiteral(thread, JSTaggedValue(pattern), flags).GetRawData(); } // NOLINTNEXTLINE(misc-definitions-in-headers) @@ -1851,11 +1819,8 @@ INLINE_ECMA_INTRINSICS uint64_t StOwnByIndex(JSThread *thread, uint64_t object, } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t StOwnByName(JSThread *thread, uint32_t string_id, uint64_t object, uint64_t val, - uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t StOwnByName(JSThread *thread, uint64_t prop, uint64_t object, uint64_t val) { - JSTaggedType prop = ConstantPool::Cast(cp)->GetObjectFromCache(string_id).GetRawData(); - [[maybe_unused]] size_t gc = thread->GetEcmaVM()->GetGC()->GetCounter(); if (JSTaggedValue(object).IsJSObject() && !JSTaggedValue(object).IsClassConstructor() && !JSTaggedValue(object).IsClassPrototype()) { @@ -1956,17 +1921,15 @@ INLINE_ECMA_INTRINSICS uint64_t CloseIterator(JSThread *thread, uint64_t iter, u } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t ImportModule(JSThread *thread, uint32_t string_id, uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t ImportModule(JSThread *thread, uint64_t prop) { - auto prop = ConstantPool::Cast(cp)->GetObjectFromCache(string_id); - return SlowRuntimeStub::ImportModule(thread, prop).GetRawData(); + return SlowRuntimeStub::ImportModule(thread, JSTaggedValue(prop)).GetRawData(); } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS void StModuleVar(JSThread *thread, uint32_t string_id, uint64_t value, uint64_t cp) +INLINE_ECMA_INTRINSICS void StModuleVar(JSThread *thread, uint64_t prop, uint64_t value) { - auto prop = ConstantPool::Cast(cp)->GetObjectFromCache(string_id); - SlowRuntimeStub::StModuleVar(thread, prop, JSTaggedValue(value)); + SlowRuntimeStub::StModuleVar(thread, JSTaggedValue(prop), JSTaggedValue(value)); } // NOLINTNEXTLINE(misc-definitions-in-headers) @@ -1976,10 +1939,9 @@ INLINE_ECMA_INTRINSICS void CopyModule(JSThread *thread, uint64_t module) } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t LdModvarByName(JSThread *thread, uint32_t string_id, uint64_t module_obj, uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t LdModvarByName(JSThread *thread, uint64_t item_name, uint64_t module_obj) { - JSTaggedValue item_name = ConstantPool::Cast(cp)->GetObjectFromCache(string_id); - return SlowRuntimeStub::LdModvarByName(thread, JSTaggedValue(module_obj), item_name).GetRawData(); + return SlowRuntimeStub::LdModvarByName(thread, JSTaggedValue(module_obj), JSTaggedValue(item_name)).GetRawData(); } // NOLINTNEXTLINE(misc-definitions-in-headers) @@ -1990,12 +1952,12 @@ INLINE_ECMA_INTRINSICS uint64_t ClassFieldAdd(JSThread *thread, uint64_t ctor, u } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS void DefineClassPrivateFields(JSThread *thread, uint16_t private_buf_idx, uint64_t env, +INLINE_ECMA_INTRINSICS void DefineClassPrivateFields(JSThread *thread, uint64_t private_buf, uint64_t env, uint64_t ctor, uint64_t cp) { auto *constpool = ConstantPool::Cast(cp); SlowRuntimeStub::DefineClassPrivateFields(thread, constpool, JSTaggedValue(env), JSTaggedValue(ctor), - constpool->GetObjectFromCache(private_buf_idx)); + JSTaggedValue(private_buf)); } // NOLINTNEXTLINE(misc-definitions-in-headers) @@ -2006,54 +1968,49 @@ INLINE_ECMA_INTRINSICS uint64_t ClassPrivateMethodOrAccessorAdd(JSThread *thread } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t ClassPrivateFieldAdd(JSThread *thread, uint32_t string_id, uint64_t ctor, uint64_t obj, - uint64_t value, uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t ClassPrivateFieldAdd(JSThread *thread, uint64_t prop, uint64_t ctor, uint64_t obj, + uint64_t value) { - return SlowRuntimeStub::ClassPrivateFieldAdd(thread, JSTaggedValue(ctor), JSTaggedValue(obj), - ConstantPool::Cast(cp)->GetObjectFromCache(string_id), + return SlowRuntimeStub::ClassPrivateFieldAdd(thread, JSTaggedValue(ctor), JSTaggedValue(obj), JSTaggedValue(prop), JSTaggedValue(value)) .GetRawData(); } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t ClassPrivateFieldGet(JSThread *thread, uint32_t string_id, uint64_t ctor, uint64_t obj, - uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t ClassPrivateFieldGet(JSThread *thread, uint64_t prop, uint64_t ctor, uint64_t obj) { - return SlowRuntimeStub::ClassPrivateFieldGet(thread, JSTaggedValue(ctor), JSTaggedValue(obj), - ConstantPool::Cast(cp)->GetObjectFromCache(string_id)) + return SlowRuntimeStub::ClassPrivateFieldGet(thread, JSTaggedValue(ctor), JSTaggedValue(obj), JSTaggedValue(prop)) .GetRawData(); } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t ClassPrivateFieldSet(JSThread *thread, uint32_t string_id, uint64_t ctor, uint64_t obj, - uint64_t value, uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t ClassPrivateFieldSet(JSThread *thread, uint64_t prop, uint64_t ctor, uint64_t obj, + uint64_t value) { - return SlowRuntimeStub::ClassPrivateFieldSet(thread, JSTaggedValue(ctor), JSTaggedValue(obj), - ConstantPool::Cast(cp)->GetObjectFromCache(string_id), + return SlowRuntimeStub::ClassPrivateFieldSet(thread, JSTaggedValue(ctor), JSTaggedValue(obj), JSTaggedValue(prop), JSTaggedValue(value)) .GetRawData(); } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t ClassPrivateFieldIn(JSThread *thread, uint32_t string_id, uint64_t ctor, uint64_t obj, - uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t ClassPrivateFieldIn(JSThread *thread, uint64_t prop, uint64_t ctor, uint64_t obj) { - return SlowRuntimeStub::ClassPrivateFieldIn(thread, JSTaggedValue(ctor), JSTaggedValue(obj), - ConstantPool::Cast(cp)->GetObjectFromCache(string_id)) + return SlowRuntimeStub::ClassPrivateFieldIn(thread, JSTaggedValue(ctor), JSTaggedValue(obj), JSTaggedValue(prop)) .GetRawData(); } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t DefineClassWithBuffer(JSThread *thread, uint32_t method_id, uint16_t imm, - uint64_t lexenv, uint64_t proto, uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t DefineClassWithBuffer(JSThread *thread, uint64_t ctor, uint16_t imm, uint64_t lexenv, + uint64_t proto, uint64_t cp) { [[maybe_unused]] EcmaHandleScope handle_scope(thread); auto *constpool = ConstantPool::Cast(cp); JSHandle lex_env(thread, JSTaggedValue(lexenv)); - JSFunction *class_template = JSFunction::Cast(constpool->GetObjectFromCache(method_id).GetTaggedObject()); + JSFunction *class_template = JSFunction::Cast(JSTaggedValue(ctor).GetTaggedObject()); ASSERT(class_template != nullptr); TaggedArray *literal_buffer = TaggedArray::Cast(constpool->GetObjectFromCache(imm).GetTaggedObject()); + // TaggedArray *literal_buffer = TaggedArray::Cast(JSTaggedValue(buffer).GetTaggedObject()); JSTaggedValue res; if (LIKELY(!class_template->IsResolved())) { res = SlowRuntimeStub::ResolveClass(thread, JSTaggedValue(class_template), literal_buffer, JSTaggedValue(proto), @@ -2117,16 +2074,14 @@ INLINE_ECMA_INTRINSICS uint64_t SuperCallSpread(JSThread *thread, uint64_t array } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t DefineMethod(JSThread *thread, uint32_t method_id, uint64_t tagged_cur_env, +INLINE_ECMA_INTRINSICS uint64_t DefineMethod(JSThread *thread, uint64_t method, uint64_t tagged_cur_env, uint64_t home_object, uint64_t cp) { - auto constpool = ConstantPool::Cast(cp); - auto result = JSFunction::Cast(constpool->GetObjectFromCache(method_id).GetHeapObject()); + auto result = JSFunction::Cast(JSTaggedValue(method).GetHeapObject()); auto home = JSTaggedValue(home_object); auto env = JSTaggedValue(tagged_cur_env); if (!result->GetLexicalEnv().IsUndefined()) { [[maybe_unused]] EcmaHandleScope handle_scope(thread); - JSHandle constpool_handle(thread, constpool); JSHandle home_handle(thread, home); JSHandle env_handle(thread, env); auto res = SlowRuntimeStub::DefineMethod(thread, result->GetCallTarget(), home_handle); @@ -2134,9 +2089,8 @@ INLINE_ECMA_INTRINSICS uint64_t DefineMethod(JSThread *thread, uint32_t method_i return res.GetRawData(); } result = JSFunction::Cast(res.GetHeapObject()); - constpool = *constpool_handle; // Maybe moved by GC - env = env_handle.GetTaggedValue(); // Maybe moved by GC - result->SetConstantPool(thread, JSTaggedValue(constpool)); + env = env_handle.GetTaggedValue(); // Maybe moved by GC + result->SetConstantPool(thread, JSTaggedValue(cp)); // ConstantPool is non-movable } else { result->SetHomeObject(thread, home); } @@ -2145,22 +2099,19 @@ INLINE_ECMA_INTRINSICS uint64_t DefineMethod(JSThread *thread, uint32_t method_i } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t StSuperByName(JSThread *thread, uint32_t string_id, uint64_t obj, uint64_t value, - uint64_t func, uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t StSuperByName(JSThread *thread, uint64_t prop_key, uint64_t obj, uint64_t value, + uint64_t func) { - JSTaggedValue prop_key = ConstantPool::Cast(cp)->GetObjectFromCache(string_id); - return SlowRuntimeStub::StSuperByValue(thread, JSTaggedValue(obj), prop_key, JSTaggedValue(value), + return SlowRuntimeStub::StSuperByValue(thread, JSTaggedValue(obj), JSTaggedValue(prop_key), JSTaggedValue(value), JSTaggedValue(func)) .GetRawData(); } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t LdSuperByName(JSThread *thread, uint32_t string_id, uint64_t obj, uint64_t func, - uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t LdSuperByName(JSThread *thread, uint64_t prop_key, uint64_t obj, uint64_t func) { - JSTaggedValue prop_key = ConstantPool::Cast(cp)->GetObjectFromCache(string_id); - - return SlowRuntimeStub::LdSuperByValue(thread, JSTaggedValue(obj), prop_key, JSTaggedValue(func)).GetRawData(); + return SlowRuntimeStub::LdSuperByValue(thread, JSTaggedValue(obj), JSTaggedValue(prop_key), JSTaggedValue(func)) + .GetRawData(); } // NOLINTNEXTLINE(misc-definitions-in-headers) @@ -2181,10 +2132,10 @@ INLINE_ECMA_INTRINSICS uint64_t LdSuperByValue(JSThread *thread, uint64_t receiv } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t CreateObjectHavingMethod(JSThread *thread, uint16_t imm, uint64_t env, uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t CreateObjectHavingMethod(JSThread *thread, uint64_t literal, uint64_t env, uint64_t cp) { auto constpool = ConstantPool::Cast(cp); - JSObject *result = JSObject::Cast(constpool->GetObjectFromCache(imm).GetHeapObject()); + JSObject *result = JSObject::Cast(JSTaggedValue(literal).GetHeapObject()); auto factory = GetFactory(thread); return SlowRuntimeStub::CreateObjectHavingMethod(thread, factory, result, JSTaggedValue(env), constpool) @@ -2211,9 +2162,9 @@ INLINE_ECMA_INTRINSICS void ThrowDeleteSuperProperty(JSThread *thread) } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t LdEvalBindings([[maybe_unused]] JSThread *thread, uint16_t index, uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t LdEvalBindings([[maybe_unused]] JSThread *thread, uint64_t result) { - return ConstantPool::Cast(cp)->GetObjectFromCache(index).GetRawData(); + return result; } // NOLINTNEXTLINE(misc-definitions-in-headers) @@ -2223,19 +2174,15 @@ INLINE_ECMA_INTRINSICS uint64_t DirectEval(JSThread *thread, uint32_t status, ui } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t LdEvalVar(JSThread *thread, uint32_t string_id, uint64_t lexical_context, uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t LdEvalVar(JSThread *thread, uint64_t name, uint64_t lexical_context) { - return SlowRuntimeStub::LdEvalVar(thread, ConstantPool::Cast(cp)->GetObjectFromCache(string_id), - JSTaggedValue(lexical_context)) - .GetRawData(); + return SlowRuntimeStub::LdEvalVar(thread, JSTaggedValue(name), JSTaggedValue(lexical_context)).GetRawData(); } // NOLINTNEXTLINE(misc-definitions-in-headers) -INLINE_ECMA_INTRINSICS uint64_t StEvalVar(JSThread *thread, uint32_t string_id, uint64_t value, - uint64_t lexical_context, uint64_t cp) +INLINE_ECMA_INTRINSICS uint64_t StEvalVar(JSThread *thread, uint64_t name, uint64_t value, uint64_t lexical_context) { - return SlowRuntimeStub::StEvalVar(thread, ConstantPool::Cast(cp)->GetObjectFromCache(string_id), - JSTaggedValue(lexical_context), JSTaggedValue(value)) + return SlowRuntimeStub::StEvalVar(thread, JSTaggedValue(name), JSTaggedValue(lexical_context), JSTaggedValue(value)) .GetRawData(); } diff --git a/tests/checked/CMakeLists.txt b/tests/checked/CMakeLists.txt index a427cbe6334df6551a891e0190835434d53896f4..8726d2ce096a1662e52f524cc401dfc087d02b2f 100644 --- a/tests/checked/CMakeLists.txt +++ b/tests/checked/CMakeLists.txt @@ -125,6 +125,7 @@ if (NOT PANDA_TARGET_ARM32) panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/hclass_check_elim.js SUPPORT_RELEASE true) panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/hclass_check_non_callable.js SUPPORT_RELEASE true) panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/hclass_check_constructor.js SUPPORT_RELEASE true) + panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/load_from_constant_pool.js SUPPORT_RELEASE true) # there is flaky bug when turning on TSAN if (NOT PANDA_ENABLE_THREAD_SANITIZER) diff --git a/tests/checked/acc_after_deopt.js b/tests/checked/acc_after_deopt.js index 5e8d898210565c33f21644173ad8e3877cf185b5..087d2ffc5170cfcf1a1d25e0727853ec3d6b1ccc 100644 --- a/tests/checked/acc_after_deopt.js +++ b/tests/checked/acc_after_deopt.js @@ -15,9 +15,8 @@ //! CHECKER Test accumulator value after deoptimization //! RUN options: "--interpreter-type=irtoc --compiler-profiling-threshold=100001 --compiler-regex='_GLOBAL::test_acc'", entry: "_GLOBAL::func_main_0" - -//! EVENT /Compilation,_GLOBAL::test_acc -//! EVENT /Deoptimization,_GLOBAL::func_test_acc_1 +//! EVENT /Compilation,_GLOBAL::test_acc/ +//! EVENT /Deoptimization,_GLOBAL::func_test_acc_1/ function test_acc() { var a = new Number(42); diff --git a/tests/checked/load_from_constant_pool.js b/tests/checked/load_from_constant_pool.js new file mode 100644 index 0000000000000000000000000000000000000000..f946d39764d2314f4997345b2e8bfc1c59f7d8a3 --- /dev/null +++ b/tests/checked/load_from_constant_pool.js @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +//! CHECKER Replace LoadFromConstantPool by LoadObjFromConst, JIT mode +//! RUN options: "--compiler-hotness-threshold=1 --no-async-jit=true --compiler-regex='_GLOBAL::.*define_.'", entry: "_GLOBAL::func_main_0" +//! METHOD "define_f" +//! PASS_AFTER "IrBuilder" +//! INST "LoadConstantPool" +//! INST_NEXT "LoadFromConstantPool" +//! INST_NEXT "Intrinsic.DefineNCFuncDyn" +//! PASS_AFTER "Codegen" +//! INST_NOT "LoadConstantPool" +//! INST_NOT "LoadFromConstantPool" +//! INST_NOT "LoadArrayI" +//! INST /LoadImmediate.*constpool/ +//! INST_NEXT "LoadObjFromConst" +//! INST_NEXT "Intrinsic.DefineNCFuncDyn" +//! +//! METHOD "call_define_f" +//! PASS_AFTER "IrBuilder" +//! INST_COUNT "LoadConstantPool", 1 +//! INST_NOT "LoadFromConstantPool" +//! INST_NOT "Intrinsic.DefineNCFuncDyn" +//! PASS_AFTER "Inline." +//! INST_COUNT "LoadConstantPool", 2 +//! INST "LoadFromConstantPool" +//! INST "Intrinsic.DefineNCFuncDyn" +//! PASS_AFTER "Codegen" +//! INST_NOT "LoadConstantPool" +//! INST_NOT "LoadFromConstantPool" +//! INST_COUNT /LoadImmediate.*constpool/, 1 # VN applied +//! INST "LoadObjFromConst" +//! INST_NEXT "Intrinsic.DefineNCFuncDyn" +//! +//! METHOD "call_define_g" +//! PASS_AFTER "Inline." +//! INST_COUNT "LoadConstantPool", 2 +//! INST "LoadFromConstantPool" +//! INST "Intrinsic.DefineNCFuncDyn" +//! PASS_AFTER "Codegen" +//! INST_NOT "LoadConstantPool" +//! INST_NOT "LoadFromConstantPool" +//! INST_COUNT /LoadImmediate.*constpool/, 2 # VN not applied +//! INST "LoadObjFromConst" +//! INST_NEXT "Intrinsic.DefineNCFuncDyn" + +//! CHECKER Replace LoadFromConstantPool by LoadArrayI, AOT mode +//! RUN_PAOC options: "--compiler-regex='_GLOBAL::define_f'" +//! METHOD "define_f" +//! PASS_AFTER "IrBuilder" +//! INST "LoadConstantPool" +//! INST_COUNT "LoadFromConstantPool", 2 +//! PASS_AFTER "Codegen" +//! INST_NOT "LoadFromConstantPool" +//! INST "LoadConstantPool" +//! INST_NEXT "LoadArrayI" +//! INST_NEXT "Intrinsic.DefineNCFuncDyn" +//! INST_NEXT "LoadArrayI" +//! INST_NEXT "Intrinsic.StObjByName" +//! RUN options: "--compiler-enable-jit=false", entry: "_GLOBAL::func_main_0" + +function define_f(z) { + globalThis.f = (x, y) => x + y + z; +} + +function call_define_f(z) { + define_f(z * 2); +} + +// define function inside eval so it has different panda file and different ConstantPool +eval("function define_g(z) {globalThis.g = (x, y) => x + y - z;}"); + +function call_define_g(z) { + define_g(z * 2); +} + +for (let i = 1; i < 3; i++) { + define_f(i); + if (f(1, 2) != i + 3) { + throw "wrong result for LoadFromConstantPool"; + } +} +for (let i = 1; i < 3; i++) { + call_define_f(i); + if (f(1, 2) != i * 2 + 3) { + throw "wrong result for inlined function"; + } +} +for (let i = 1; i < 3; i++) { + call_define_g(i); + if (g(1, 2) != 3 - i * 2) { + throw "wrong result for inlined function with different ConstantPool"; + } +} diff --git a/tests/checked/try_load_global_by_name.js b/tests/checked/try_load_global_by_name.js index f598fc358554a3e1103dd2ee29efd1de34e6ec8a..3e538ac868a5ef78e3acb77ca69141ff46e7f9bd 100644 --- a/tests/checked/try_load_global_by_name.js +++ b/tests/checked/try_load_global_by_name.js @@ -58,12 +58,12 @@ //! METHOD "get_const" //! PASS_AFTER "IrBuilder" //! INST "Intrinsic.TryLdGlobalByName" -//! INST_COUNT "Constant", 2 +//! INST_COUNT "Constant ", 1 //! PASS_AFTER "InlineIntrinsics" //! INST_NOT "Intrinsic.TryLdGlobalByName" //! INST_NOT "DeoptimizeIf" //! INST_NOT "GetGlobalVarAddress" -//! INST_COUNT "Constant", 3 +//! INST_COUNT "Constant ", 2 //! METHOD "get_always_throw" //! PASS_AFTER "Codegen" //! INST "Intrinsic.TryLdGlobalByName" diff --git a/tests/compiler/inline_intrinsics_ecma_test.cpp b/tests/compiler/inline_intrinsics_ecma_test.cpp index 724dba1939b7083733dab7cfe9cae4ea3f377192..9b604c33b37b13da8c789b69841847b29449ca2a 100644 --- a/tests/compiler/inline_intrinsics_ecma_test.cpp +++ b/tests/compiler/inline_intrinsics_ecma_test.cpp @@ -22,9 +22,9 @@ #include "runtime/include/coretypes/tagged_value.h" namespace panda::compiler { -class TypeResolvingTest : public AsmTest { +class InlineIntrinsicsTest : public AsmTest { public: - TypeResolvingTest() = default; + InlineIntrinsicsTest() = default; Graph *ConstructGraphWithIntrinsic(RuntimeInterface::IntrinsicId id); Graph *ConstructGraphWithIntrinsic(AnyBaseType type, RuntimeInterface::IntrinsicId id, @@ -47,7 +47,7 @@ public: // NOLINTBEGIN(readability-magic-numbers) template -Graph *TypeResolvingTest::ConstructGraphWithConst(AnyBaseType any_type, T cnst) +Graph *InlineIntrinsicsTest::ConstructGraphWithConst(AnyBaseType any_type, T cnst) { auto graph = CreateGraphDynWithDefaultRuntime(); GRAPH(graph) @@ -62,7 +62,7 @@ Graph *TypeResolvingTest::ConstructGraphWithConst(AnyBaseType any_type, T cnst) return graph; } -Graph *TypeResolvingTest::ConstructGraphWithConst(DataType::Any cnst) +Graph *InlineIntrinsicsTest::ConstructGraphWithConst(DataType::Any cnst) { auto graph = CreateGraphDynWithDefaultRuntime(); GRAPH(graph) @@ -77,7 +77,7 @@ Graph *TypeResolvingTest::ConstructGraphWithConst(DataType::Any cnst) } template -void TypeResolvingTest::TestLdConsts(TestArray tests) +void InlineIntrinsicsTest::TestLdConsts(TestArray tests) { for (auto [id, any_type, cnst] : tests) { auto graph = ConstructGraphWithIntrinsic(id); @@ -94,7 +94,7 @@ void TypeResolvingTest::TestLdConsts(TestArray tests) } } -Graph *TypeResolvingTest::ConstructGraphWithIntrinsic(RuntimeInterface::IntrinsicId id) +Graph *InlineIntrinsicsTest::ConstructGraphWithIntrinsic(RuntimeInterface::IntrinsicId id) { auto graph = CreateGraphDynWithDefaultRuntime(); GRAPH(graph) @@ -109,8 +109,8 @@ Graph *TypeResolvingTest::ConstructGraphWithIntrinsic(RuntimeInterface::Intrinsi return graph; } -Graph *TypeResolvingTest::ConstructGraphWithIntrinsic(AnyBaseType type, RuntimeInterface::IntrinsicId id, - profiling::AnyInputType allowed_type) +Graph *InlineIntrinsicsTest::ConstructGraphWithIntrinsic(AnyBaseType type, RuntimeInterface::IntrinsicId id, + profiling::AnyInputType allowed_type) { auto graph = CreateGraphDynWithDefaultRuntime(); GRAPH(graph) @@ -129,7 +129,7 @@ Graph *TypeResolvingTest::ConstructGraphWithIntrinsic(AnyBaseType type, RuntimeI return graph; } -Graph *TypeResolvingTest::ConstructGraphWithOpcode1(AnyBaseType type, Opcode opcode) +Graph *InlineIntrinsicsTest::ConstructGraphWithOpcode1(AnyBaseType type, Opcode opcode) { auto graph = CreateGraphDynWithDefaultRuntime(); auto date_type = AnyBaseTypeToDataType(type); @@ -151,7 +151,7 @@ Graph *TypeResolvingTest::ConstructGraphWithOpcode1(AnyBaseType type, Opcode opc return graph; } -Graph *TypeResolvingTest::ConstructGraphWithOpcode2(AnyBaseType type, Opcode opcode) +Graph *InlineIntrinsicsTest::ConstructGraphWithOpcode2(AnyBaseType type, Opcode opcode) { auto graph = CreateGraphDynWithDefaultRuntime(); auto date_type = AnyBaseTypeToDataType(type); @@ -175,8 +175,8 @@ Graph *TypeResolvingTest::ConstructGraphWithOpcode2(AnyBaseType type, Opcode opc return graph; } -Graph *TypeResolvingTest::ConstructGraphWithIntrinsic(AnyBaseType type1, AnyBaseType type2, - RuntimeInterface::IntrinsicId id) +Graph *InlineIntrinsicsTest::ConstructGraphWithIntrinsic(AnyBaseType type1, AnyBaseType type2, + RuntimeInterface::IntrinsicId id) { auto graph = CreateGraphDynWithDefaultRuntime(); GRAPH(graph) @@ -199,7 +199,7 @@ Graph *TypeResolvingTest::ConstructGraphWithIntrinsic(AnyBaseType type1, AnyBase return graph; } -TEST_F(TypeResolvingTest, LdConst) +TEST_F(InlineIntrinsicsTest, LdConst) { using TaggedValue = panda::coretypes::TaggedValue; { @@ -231,7 +231,7 @@ TEST_F(TypeResolvingTest, LdConst) } } -TEST_F(TypeResolvingTest, ToNumber) +TEST_F(InlineIntrinsicsTest, ToNumber) { // Case with Int { @@ -360,7 +360,7 @@ TEST_F(TypeResolvingTest, ToNumber) } } -TEST_F(TypeResolvingTest, ResolveLoopPhi) +TEST_F(InlineIntrinsicsTest, ResolveLoopPhi) { auto graph = CreateGraphDynWithDefaultRuntime(); @@ -430,7 +430,7 @@ TEST_F(TypeResolvingTest, ResolveLoopPhi) ASSERT_EQ(phi.GetInput(1U).GetInst(), &phi); } -TEST_F(TypeResolvingTest, LdLexVarDynApply) +TEST_F(InlineIntrinsicsTest, LdLexVarDynApply) { constexpr uint32_t SLOT = 10U; @@ -491,7 +491,7 @@ TEST_F(TypeResolvingTest, LdLexVarDynApply) } } -TEST_F(TypeResolvingTest, LdLexVarDynSkip) +TEST_F(InlineIntrinsicsTest, LdLexVarDynSkip) { constexpr uint32_t LEVEL = InlineIntrinsics::GetLdStLexVarDynLevelThreshold() + 1U; constexpr uint32_t SLOT = 10U; @@ -537,7 +537,7 @@ TEST_F(TypeResolvingTest, LdLexVarDynSkip) ASSERT_TRUE(GraphComparator().Compare(graph, graph_opt)); } -TEST_F(TypeResolvingTest, LdLexDyn) +TEST_F(InlineIntrinsicsTest, LdLexDyn) { constexpr uint32_t STRING_ID = 0xABCDU; constexpr uint32_t LEVEL = InlineIntrinsics::GetLdStLexVarDynLevelThreshold() + 1U; @@ -552,11 +552,11 @@ TEST_F(TypeResolvingTest, LdLexDyn) INST(1, Opcode::LoadConstantPool).any().Inputs(0); INST(2, Opcode::LoadLexicalEnv).any().Inputs(0); INST(3, Opcode::SaveState).NoVregs(); + INST(6, Opcode::LoadFromConstantPool).any().Inputs(1).TypeId(STRING_ID); INST(4, Opcode::Intrinsic) .IntrinsicId(RuntimeInterface::IntrinsicId::INTRINSIC_LD_LEX_DYN) .any() - .Inputs({{DataType::ANY, 1}, {DataType::ANY, 2}, {DataType::NO_TYPE, 3}}) - .AddImm(STRING_ID) + .Inputs({{DataType::ANY, 6}, {DataType::ANY, 2}, {DataType::NO_TYPE, 3}}) .AddImm(LEVEL) .AddImm(SLOT); INST(5, Opcode::Return).any().Inputs(4); @@ -593,7 +593,7 @@ TEST_F(TypeResolvingTest, LdLexDyn) ASSERT_TRUE(GraphComparator().Compare(graph, graph_opt)); } -TEST_F(TypeResolvingTest, InlineLdlexenvDyn) +TEST_F(InlineIntrinsicsTest, InlineLdlexenvDyn) { auto graph = CreateGraphDynStubWithDefaultRuntime(); GRAPH(graph) @@ -627,7 +627,7 @@ TEST_F(TypeResolvingTest, InlineLdlexenvDyn) ASSERT_TRUE(GraphComparator().Compare(graph, graph_opt)); } -TEST_F(TypeResolvingTest, StLexVarDyn) +TEST_F(InlineIntrinsicsTest, StLexVarDyn) { constexpr uint32_t SLOT = 10U; @@ -831,7 +831,7 @@ TEST_F(TypeResolvingTest, StLexVarDyn) ASSERT_TRUE(GraphComparator().Compare(graph, graph_opt)); } -TEST_F(TypeResolvingTest, PopLexenvDyn) +TEST_F(InlineIntrinsicsTest, PopLexenvDyn) { auto graph = CreateGraphDynStubWithDefaultRuntime(); GRAPH(graph) diff --git a/tests/compiler/peepholes_ecma_test.cpp b/tests/compiler/peepholes_ecma_test.cpp index 5a28f92cbe1b966ed5a4a18e8de69ba2ad2e43e6..9bf395fe7b251bb16d7c4d7c35db06e081c4c490 100644 --- a/tests/compiler/peepholes_ecma_test.cpp +++ b/tests/compiler/peepholes_ecma_test.cpp @@ -252,6 +252,65 @@ TEST_F(PeepholesTest, CastBoolToAnyToInt) EXPECT_TRUE(GraphComparator().Compare(graph, graph_opt)); } +TEST_F(PeepholesTest, CastAnyToValueAndBack) +{ + auto graph = CreateGraphDynStubWithDefaultRuntime(); + graph->SetUnrollComplete(); + GRAPH(graph) + { + PARAMETER(0, 0).any(); + + BASIC_BLOCK(2, -1) + { + INST(1, Opcode::CastAnyTypeValue).ref().AnyType(AnyBaseType::ECMASCRIPT_STRING_TYPE).Inputs(0); + INST(2, Opcode::CastValueToAnyType).any().AnyType(AnyBaseType::ECMASCRIPT_STRING_TYPE).Inputs(1); + INST(3, Opcode::Return).any().Inputs(2); + } + } + + ASSERT_TRUE(graph->RunPass()); + ASSERT_TRUE(graph->RunPass()); + GraphChecker(graph).Check(); + + auto graph_opt = CreateGraphDynStubWithDefaultRuntime(); + GRAPH(graph_opt) + { + PARAMETER(0, 0).any(); + + BASIC_BLOCK(2, -1) + { + INST(3, Opcode::Return).any().Inputs(0); + } + } + + EXPECT_TRUE(GraphComparator().Compare(graph, graph_opt)); +} + +TEST_F(PeepholesTest, CastAnyToValueAndBackNotApplied) +{ + auto graph = CreateGraphDynStubWithDefaultRuntime(); + graph->SetUnrollComplete(); + GRAPH(graph) + { + PARAMETER(0, 0).any(); + + BASIC_BLOCK(2, -1) + { + INST(1, Opcode::CastAnyTypeValue) + .f64() + .AnyType(AnyBaseType::ECMASCRIPT_DOUBLE_TYPE) + .AllowedInputType(profiling::AnyInputType::INTEGER) + .Inputs(0); + INST(2, Opcode::CastValueToAnyType).any().AnyType(AnyBaseType::ECMASCRIPT_DOUBLE_TYPE).Inputs(1); + INST(3, Opcode::Return).any().Inputs(2); + } + } + + auto graph_opt = GraphCloner(graph, graph->GetAllocator(), graph->GetLocalAllocator()).CloneGraph(); + ASSERT_FALSE(graph->RunPass()); + ASSERT_TRUE(GraphComparator().Compare(graph, graph_opt)); +} + TEST_F(PeepholesTest, CompareCastToAnyAndCastToAny) { auto graph = CreateGraphDynWithDefaultRuntime();