From ee6a0a0c687b5a721be490c2818cb3bffa866199 Mon Sep 17 00:00:00 2001 From: wupengyong Date: Thu, 13 Jan 2022 14:54:37 +0800 Subject: [PATCH] add mov and storeown and ldfunction Signed-off-by: wupengyong Change-Id: I0c1661fc8f5945962dc082b697f886554f0ca7bb --- ecmascript/compiler/fast_stub_define.h | 4 + ecmascript/compiler/interpreter_stub.cpp | 225 +++++++++++++++++- ecmascript/compiler/interpreter_stub_define.h | 74 +++--- ecmascript/compiler/stub-inl.h | 40 ++++ ecmascript/compiler/stub.h | 2 + ecmascript/compiler/stub_descriptor.cpp | 67 +++++- ecmascript/js_thread.cpp | 12 + ecmascript/runtime_trampolines.cpp | 24 ++ ecmascript/runtime_trampolines.h | 4 + 9 files changed, 408 insertions(+), 44 deletions(-) diff --git a/ecmascript/compiler/fast_stub_define.h b/ecmascript/compiler/fast_stub_define.h index b72cc39883..0357baf025 100644 --- a/ecmascript/compiler/fast_stub_define.h +++ b/ecmascript/compiler/fast_stub_define.h @@ -48,6 +48,10 @@ namespace panda::ecmascript::kungfu { V(JumpToCInterpreter, 7) \ V(DebugPrint, 1) \ V(StGlobalRecord, 4) \ + V(SetPropertyByValue, 4) \ + V(SetFunctionNameNoPrefix, 3) \ + V(StOwnByValueWithNameSet, 4) \ + V(StOwnByNameWithNameSet, 7) \ V(NegDyn, 2) \ V(IncDyn, 2) \ V(DecDyn, 2) \ diff --git a/ecmascript/compiler/interpreter_stub.cpp b/ecmascript/compiler/interpreter_stub.cpp index fc7e5332e5..f53c803585 100644 --- a/ecmascript/compiler/interpreter_stub.cpp +++ b/ecmascript/compiler/interpreter_stub.cpp @@ -873,7 +873,6 @@ void HandleStConstToGlobalRecordPrefId32Stub::GenerateCircuit(const CompilationC Label notException(env); GateRef stringId = ReadInst32_1(pc); GateRef propKey = GetValueFromTaggedArray(MachineType::TAGGED, constpool, stringId); - SaveAcc(glue, sp, *acc); StubDescriptor *stGlobalRecord = GET_STUBDESCRIPTOR(StGlobalRecord); GateRef result = CallRuntime(stGlobalRecord, glue, GetWord64Constant(FAST_STUB_ID(StGlobalRecord)), { glue, propKey, *acc, TrueConstant() }); @@ -884,7 +883,6 @@ void HandleStConstToGlobalRecordPrefId32Stub::GenerateCircuit(const CompilationC DispatchLast(glue, pc, sp, constpool, profileTypeInfo, *acc, hotnessCounter, GetArchRelateConstant(6)); } Bind(¬Exception); - acc = RestoreAcc(sp); Dispatch(glue, pc, sp, constpool, profileTypeInfo, *acc, hotnessCounter, GetArchRelateConstant(BytecodeInstruction::Size(BytecodeInstruction::Format::PREF_ID32))); } @@ -904,7 +902,6 @@ void HandleStLetToGlobalRecordPrefId32Stub::GenerateCircuit(const CompilationCon Label notException(env); GateRef stringId = ReadInst32_1(pc); GateRef propKey = GetValueFromTaggedArray(MachineType::TAGGED, constpool, stringId); - SaveAcc(glue, sp, *acc); StubDescriptor *stGlobalRecord = GET_STUBDESCRIPTOR(StGlobalRecord); GateRef result = CallRuntime(stGlobalRecord, glue, GetWord64Constant(FAST_STUB_ID(StGlobalRecord)), { glue, propKey, *acc, FalseConstant() }); @@ -915,7 +912,6 @@ void HandleStLetToGlobalRecordPrefId32Stub::GenerateCircuit(const CompilationCon DispatchLast(glue, pc, sp, constpool, profileTypeInfo, *acc, hotnessCounter, GetArchRelateConstant(6)); } Bind(¬Exception); - acc = RestoreAcc(sp); Dispatch(glue, pc, sp, constpool, profileTypeInfo, *acc, hotnessCounter, GetArchRelateConstant(BytecodeInstruction::Size(BytecodeInstruction::Format::PREF_ID32))); } @@ -935,7 +931,6 @@ void HandleStClassToGlobalRecordPrefId32Stub::GenerateCircuit(const CompilationC Label notException(env); GateRef stringId = ReadInst32_1(pc); GateRef propKey = GetValueFromTaggedArray(MachineType::TAGGED, constpool, stringId); - SaveAcc(glue, sp, *acc); StubDescriptor *stGlobalRecord = GET_STUBDESCRIPTOR(StGlobalRecord); GateRef result = CallRuntime(stGlobalRecord, glue, GetWord64Constant(FAST_STUB_ID(StGlobalRecord)), { glue, propKey, *acc, FalseConstant() }); @@ -946,7 +941,6 @@ void HandleStClassToGlobalRecordPrefId32Stub::GenerateCircuit(const CompilationC DispatchLast(glue, pc, sp, constpool, profileTypeInfo, *acc, hotnessCounter, GetArchRelateConstant(6)); } Bind(¬Exception); - acc = RestoreAcc(sp); Dispatch(glue, pc, sp, constpool, profileTypeInfo, *acc, hotnessCounter, GetArchRelateConstant(BytecodeInstruction::Size(BytecodeInstruction::Format::PREF_ID32))); } @@ -1086,4 +1080,223 @@ void HandleDefineClassWithBufferPrefId16Imm16Imm16V8V8Stub::GenerateCircuit(cons Dispatch(glue, pc, sp, constpool, profileTypeInfo, *acc, hotnessCounter, GetArchRelateConstant(BytecodeInstruction::Size(BytecodeInstruction::Format::PREF_ID16_IMM16_IMM16_V8_V8))); } + +void HandleStOwnByValueWithNameSetPrefV8V8Stub::GenerateCircuit(const CompilationConfig *cfg) +{ + Stub::GenerateCircuit(cfg); + auto env = GetEnvironment(); + GateRef glue = PtrArgument(0); + GateRef pc = PtrArgument(1); + GateRef sp = PtrArgument(2); /* 2 : 3rd parameter is value */ + GateRef constpool = TaggedPointerArgument(3); /* 3 : 4th parameter is value */ + GateRef profileTypeInfo = TaggedPointerArgument(4); /* 4 : 5th parameter is value */ + GateRef acc = TaggedArgument(5); /* 5: 6th parameter is value */ + GateRef hotnessCounter = Int32Argument(6); /* 6 : 7th parameter is value */ + GateRef v0 = ZExtInt8ToPtr(ReadInst8_1(pc)); + GateRef v1 = ZExtInt8ToPtr(ReadInst8_2(pc)); + DEFVARIABLE(receiver, MachineType::TAGGED, GetVregValue(sp, v0)); + Label isHeapObject(env); + Label notHeapObject(env); + Label notClassConstructor(env); + Label notClassPrototype(env); + Label notHole(env); + Label isException(env); + Label notException(env); + Label isException1(env); + Label notException1(env); + Branch(TaggedIsHeapObject(*receiver), &isHeapObject, ¬HeapObject); + Bind(&isHeapObject); + { + Branch(IsClassConstructor(*receiver), ¬HeapObject, ¬ClassConstructor); + Bind(¬ClassConstructor); + { + Branch(IsClassPrototype(*receiver), ¬HeapObject, ¬ClassPrototype); + Bind(¬ClassPrototype); + { + DEFVARIABLE(propKey, MachineType::TAGGED, GetVregValue(sp, v1)); + StubDescriptor *setPropertyByValue = GET_STUBDESCRIPTOR(SetPropertyByValue); + GateRef res = CallRuntime(setPropertyByValue, glue, GetWord64Constant(FAST_STUB_ID(SetPropertyByValue)), + { glue, *receiver, *propKey, acc }); + propKey = GetVregValue(sp, v1); + Branch(TaggedIsHole(res), ¬HeapObject, ¬Hole); + Bind(¬Hole); + { + Branch(TaggedIsException(res), &isException, ¬Exception); + Bind(&isException); + { + SavePc(glue, sp, pc); + DispatchLast(glue, pc, sp, constpool, profileTypeInfo, acc, hotnessCounter, GetArchRelateConstant(0)); + } + Bind(¬Exception); + StubDescriptor *setFunctionNameNoPrefix = GET_STUBDESCRIPTOR(SetFunctionNameNoPrefix); + CallRuntime(setFunctionNameNoPrefix, glue, GetWord64Constant(FAST_STUB_ID(SetFunctionNameNoPrefix)), + { glue, acc, *propKey }); + Dispatch(glue, pc, sp, constpool, profileTypeInfo, acc, hotnessCounter, + GetArchRelateConstant(BytecodeInstruction::Size(BytecodeInstruction::Format::PREF_V8_V8))); + } + } + } + } + Bind(¬HeapObject); + { + receiver = GetVregValue(sp, v0); + GateRef propKey1 = GetVregValue(sp, v1); + StubDescriptor *stOwnByValueWithNameSet = GET_STUBDESCRIPTOR(StOwnByValueWithNameSet); + GateRef res = CallRuntime(stOwnByValueWithNameSet, glue, GetWord64Constant(FAST_STUB_ID(StOwnByValueWithNameSet)), + { glue, *receiver, propKey1, acc }); + Branch(TaggedIsException(res), &isException1, ¬Exception1); + Bind(&isException1); + { + SavePc(glue, sp, pc); + DispatchLast(glue, pc, sp, constpool, profileTypeInfo, acc, hotnessCounter, GetArchRelateConstant(0)); + } + Bind(¬Exception1); + Dispatch(glue, pc, sp, constpool, profileTypeInfo, acc, hotnessCounter, + GetArchRelateConstant(BytecodeInstruction::Size(BytecodeInstruction::Format::PREF_V8_V8))); + Return(); + } +} + +void HandleStOwnByNameWithNameSetPrefId32V8Stub::GenerateCircuit(const CompilationConfig *cfg) +{ + Stub::GenerateCircuit(cfg); + auto env = GetEnvironment(); + GateRef glue = PtrArgument(0); + GateRef pc = PtrArgument(1); + GateRef sp = PtrArgument(2); /* 2 : 3rd parameter is value */ + GateRef constpool = TaggedPointerArgument(3); /* 3 : 4th parameter is value */ + GateRef profileTypeInfo = TaggedPointerArgument(4); /* 4 : 5th parameter is value */ + GateRef acc = TaggedArgument(5); /* 5: 6th parameter is value */ + GateRef hotnessCounter = Int32Argument(6); /* 6 : 7th parameter is value */ + GateRef stringId = ReadInst32_1(pc); + GateRef v0 = ZExtInt8ToPtr(ReadInst8_5(pc)); + DEFVARIABLE(receiver, MachineType::TAGGED, GetVregValue(sp, v0)); + Label isJSObject(env); + Label notJSObject(env); + Label notClassConstructor(env); + Label notClassPrototype(env); + Label notHole(env); + Label isException(env); + Label notException(env); + Label isException1(env); + Label notException1(env); + Branch(IsJSObject(*receiver), &isJSObject, ¬JSObject); + Bind(&isJSObject); + { + Branch(IsClassConstructor(*receiver), ¬JSObject, ¬ClassConstructor); + Bind(¬ClassConstructor); + { + Branch(IsClassPrototype(*receiver), ¬JSObject, ¬ClassPrototype); + Bind(¬ClassPrototype); + { + GateRef propKey = GetValueFromTaggedArray(MachineType::TAGGED, constpool, stringId); + GateRef res = SetPropertyByNameWithOwn(glue, *receiver, propKey, acc); + Branch(TaggedIsHole(res), ¬JSObject, ¬Hole); + Bind(¬Hole); + { + Branch(TaggedIsException(res), &isException, ¬Exception); + Bind(&isException); + { + SavePc(glue, sp, pc); + DispatchLast(glue, pc, sp, constpool, profileTypeInfo, acc, hotnessCounter, GetArchRelateConstant(0)); + } + Bind(¬Exception); + StubDescriptor *setFunctionNameNoPrefix = GET_STUBDESCRIPTOR(SetFunctionNameNoPrefix); + CallRuntime(setFunctionNameNoPrefix, glue, GetWord64Constant(FAST_STUB_ID(SetFunctionNameNoPrefix)), + { glue, acc, propKey }); + Dispatch(glue, pc, sp, constpool, profileTypeInfo, acc, hotnessCounter, + GetArchRelateConstant(BytecodeInstruction::Size(BytecodeInstruction::Format::PREF_ID32_V8))); + } + } + } + } + Bind(¬JSObject); + { + receiver = GetVregValue(sp, v0); + GateRef propKey1 = GetValueFromTaggedArray(MachineType::TAGGED, constpool, stringId); + StubDescriptor *stOwnByNameWithNameSet = GET_STUBDESCRIPTOR(StOwnByNameWithNameSet); + GateRef res = CallRuntime(stOwnByNameWithNameSet, glue, GetWord64Constant(FAST_STUB_ID(StOwnByNameWithNameSet)), + { glue, *receiver, propKey1, acc }); + Branch(TaggedIsException(res), &isException1, ¬Exception1); + Bind(&isException1); + { + SavePc(glue, sp, pc); + DispatchLast(glue, pc, sp, constpool, profileTypeInfo, acc, hotnessCounter, GetArchRelateConstant(0)); + } + Bind(¬Exception1); + Dispatch(glue, pc, sp, constpool, profileTypeInfo, acc, hotnessCounter, + GetArchRelateConstant(BytecodeInstruction::Size(BytecodeInstruction::Format::PREF_ID32_V8))); + Return(); + } +} + +void HandleLdFunctionPrefStub::GenerateCircuit(const CompilationConfig *cfg) +{ + Stub::GenerateCircuit(cfg); + // auto env = GetEnvironment(); + GateRef glue = PtrArgument(0); + GateRef pc = PtrArgument(1); + GateRef sp = PtrArgument(2); /* 2 : 3rd parameter is value */ + GateRef constpool = TaggedPointerArgument(3); /* 3 : 4th parameter is value */ + GateRef profileTypeInfo = TaggedPointerArgument(4); /* 4 : 5th parameter is value */ + DEFVARIABLE(acc, MachineType::TAGGED, TaggedArgument(5)); /* 5: 6th parameter is value */ + GateRef hotnessCounter = Int32Argument(6); /* 6 : 7th parameter is value */ + acc = GetFunctionFromFrame(GetFrame(sp)); + Dispatch(glue, pc, sp, constpool, profileTypeInfo, *acc, hotnessCounter, + GetArchRelateConstant(BytecodeInstruction::Size(BytecodeInstruction::Format::PREF_NONE))); +} + +void HandleMovV4V4Stub::GenerateCircuit(const CompilationConfig *cfg) +{ + Stub::GenerateCircuit(cfg); + GateRef glue = PtrArgument(0); + GateRef pc = PtrArgument(1); + GateRef sp = PtrArgument(2); /* 2 : 3rd parameter is value */ + GateRef constpool = TaggedPointerArgument(3); /* 3 : 4th parameter is value */ + GateRef profileTypeInfo = TaggedPointerArgument(4); /* 4 : 5th parameter is value */ + GateRef acc = TaggedArgument(5); /* 5: 6th parameter is value */ + GateRef hotnessCounter = Int32Argument(6); /* 6 : 7th parameter is value */ + GateRef vdst = ZExtInt8ToPtr(ReadInst4_0(pc)); + GateRef vsrc = ZExtInt8ToPtr(ReadInst4_1(pc)); + GateRef value = GetVregValue(sp, vsrc); + SetVregValue(glue, sp, vdst, value); + Dispatch(glue, pc, sp, constpool, profileTypeInfo, acc, hotnessCounter, + GetArchRelateConstant(BytecodeInstruction::Size(BytecodeInstruction::Format::V4_V4))); +} + +void HandleMovDynV8V8Stub::GenerateCircuit(const CompilationConfig *cfg) +{ + Stub::GenerateCircuit(cfg); + GateRef glue = PtrArgument(0); + GateRef pc = PtrArgument(1); + GateRef sp = PtrArgument(2); /* 2 : 3rd parameter is value */ + GateRef constpool = TaggedPointerArgument(3); /* 3 : 4th parameter is value */ + GateRef profileTypeInfo = TaggedPointerArgument(4); /* 4 : 5th parameter is value */ + GateRef acc = TaggedArgument(5); /* 5: 6th parameter is value */ + GateRef hotnessCounter = Int32Argument(6); /* 6 : 7th parameter is value */ + GateRef vdst = ZExtInt8ToPtr(ReadInst8_0(pc)); + GateRef vsrc = ZExtInt8ToPtr(ReadInst8_1(pc)); + GateRef value = GetVregValue(sp, vsrc); + SetVregValue(glue, sp, vdst, value); + Dispatch(glue, pc, sp, constpool, profileTypeInfo, acc, hotnessCounter, + GetArchRelateConstant(BytecodeInstruction::Size(BytecodeInstruction::Format::V8_V8))); +} + +void HandleMovDynV16V16Stub::GenerateCircuit(const CompilationConfig *cfg) +{ + Stub::GenerateCircuit(cfg); + GateRef glue = PtrArgument(0); + GateRef pc = PtrArgument(1); + GateRef sp = PtrArgument(2); /* 2 : 3rd parameter is value */ + GateRef constpool = TaggedPointerArgument(3); /* 3 : 4th parameter is value */ + GateRef profileTypeInfo = TaggedPointerArgument(4); /* 4 : 5th parameter is value */ + GateRef acc = TaggedArgument(5); /* 5: 6th parameter is value */ + GateRef hotnessCounter = Int32Argument(6); /* 6 : 7th parameter is value */ + GateRef vdst = ZExtInt16ToPtr(ReadInst16_0(pc)); + GateRef vsrc = ZExtInt16ToPtr(ReadInst16_2(pc)); + GateRef value = GetVregValue(sp, vsrc); + SetVregValue(glue, sp, vdst, value); + Dispatch(glue, pc, sp, constpool, profileTypeInfo, acc, hotnessCounter, + GetArchRelateConstant(BytecodeInstruction::Size(BytecodeInstruction::Format::V16_V16))); +} } // namespace panda::ecmascript::kungfu diff --git a/ecmascript/compiler/interpreter_stub_define.h b/ecmascript/compiler/interpreter_stub_define.h index 1a3a70e0c4..c5d7e599ae 100644 --- a/ecmascript/compiler/interpreter_stub_define.h +++ b/ecmascript/compiler/interpreter_stub_define.h @@ -6,40 +6,46 @@ namespace panda::ecmascript::kungfu { #define INTERPRETER_STUB_HELPER_LIST(V) \ V(AsmInterpreterEntry, 7) -#define INTERPRETER_STUB_LIST(V) \ - V(SingleStepDebugging, 7) \ - V(HandleLdnanPref, 7) \ - V(HandleLdInfinityPref, 7) \ - V(HandleLdUndefinedPref, 7) \ - V(HandleLdNullPref, 7) \ - V(HandleLdTruePref, 7) \ - V(HandleLdFalsePref, 7) \ - V(HandleLdaDynV8, 7) \ - V(HandleStaDynV8, 7) \ - V(HandleJmpImm8, 7) \ - V(HandleJmpImm16, 7) \ - V(HandleJmpImm32, 7) \ - V(HandleLdLexVarDynPrefImm4Imm4, 7) \ - V(HandleLdLexVarDynPrefImm8Imm8, 7) \ - V(HandleLdLexVarDynPrefImm16Imm16, 7) \ - V(HandleStLexVarDynPrefImm4Imm4V8, 7) \ - V(HandleStLexVarDynPrefImm8Imm8V8, 7) \ - V(HandleStLexVarDynPrefImm16Imm16V8, 7) \ - V(HandleNegDynPrefV8, 7) \ - V(HandleIncdynPrefV8, 7) \ - V(HandleDecdynPrefV8, 7) \ - V(HandleExpdynPrefV8, 7) \ - V(HandleIsindynPrefV8, 7) \ - V(HandleInstanceofdynPrefV8, 7) \ - V(HandleStrictnoteqdynPrefV8, 7) \ - V(HandleStricteqdynPrefV8, 7) \ - V(HandleResumegeneratorPrefV8, 7) \ - V(HandleGetresumemodePrefV8, 7) \ - V(HandleCreategeneratorobjPrefV8, 7) \ - V(HandleStConstToGlobalRecordPrefId32, 7) \ - V(HandleStLetToGlobalRecordPrefId32, 7) \ - V(HandleStClassToGlobalRecordPrefId32, 7) \ - V(HandleDefineClassWithBufferPrefId16Imm16Imm16V8V8, 7) +#define INTERPRETER_STUB_LIST(V) \ + V(SingleStepDebugging, 7) \ + V(HandleLdnanPref, 7) \ + V(HandleLdInfinityPref, 7) \ + V(HandleLdUndefinedPref, 7) \ + V(HandleLdNullPref, 7) \ + V(HandleLdTruePref, 7) \ + V(HandleLdFalsePref, 7) \ + V(HandleLdaDynV8, 7) \ + V(HandleStaDynV8, 7) \ + V(HandleJmpImm8, 7) \ + V(HandleJmpImm16, 7) \ + V(HandleJmpImm32, 7) \ + V(HandleLdLexVarDynPrefImm4Imm4, 7) \ + V(HandleLdLexVarDynPrefImm8Imm8, 7) \ + V(HandleLdLexVarDynPrefImm16Imm16, 7) \ + V(HandleStLexVarDynPrefImm4Imm4V8, 7) \ + V(HandleStLexVarDynPrefImm8Imm8V8, 7) \ + V(HandleStLexVarDynPrefImm16Imm16V8, 7) \ + V(HandleIncdynPrefV8, 7) \ + V(HandleNegDynPrefV8, 7) \ + V(HandleDecdynPrefV8, 7) \ + V(HandleExpdynPrefV8, 7) \ + V(HandleIsindynPrefV8, 7) \ + V(HandleInstanceofdynPrefV8, 7) \ + V(HandleStrictnoteqdynPrefV8, 7) \ + V(HandleStricteqdynPrefV8, 7) \ + V(HandleResumegeneratorPrefV8, 7) \ + V(HandleGetresumemodePrefV8, 7) \ + V(HandleCreategeneratorobjPrefV8, 7) \ + V(HandleStConstToGlobalRecordPrefId32, 7) \ + V(HandleStLetToGlobalRecordPrefId32, 7) \ + V(HandleStClassToGlobalRecordPrefId32, 7) \ + V(HandleDefineClassWithBufferPrefId16Imm16Imm16V8V8, 7) \ + V(HandleStOwnByValueWithNameSetPrefV8V8, 7) \ + V(HandleStOwnByNameWithNameSetPrefId32V8, 7) \ + V(HandleLdFunctionPref, 7) \ + V(HandleMovV4V4, 7) \ + V(HandleMovDynV8V8, 7) \ + V(HandleMovDynV16V16, 7) enum InterpreterStubId { #define DEF_STUB(name, counter) name##Id, diff --git a/ecmascript/compiler/stub-inl.h b/ecmascript/compiler/stub-inl.h index 49587350f7..ab23214483 100644 --- a/ecmascript/compiler/stub-inl.h +++ b/ecmascript/compiler/stub-inl.h @@ -1009,6 +1009,19 @@ GateRef Stub::IsClassConstructor(GateRef object) GetInt32Constant(0)); } +GateRef Stub::IsClassPrototype(GateRef object) +{ + GateRef hClass = LoadHClass(object); + GateRef bitfieldOffset = GetArchRelateConstant(JSHClass::BIT_FIELD_OFFSET); + + GateRef bitfield = Load(MachineType::UINT32, hClass, bitfieldOffset); + // decode + return Word32NotEqual( + Word32And(Word32LSR(bitfield, GetInt32Constant(JSHClass::ClassPrototypeBit::START_BIT)), + GetInt32Constant((1LU << JSHClass::ClassPrototypeBit::SIZE) - 1)), + GetInt32Constant(0)); +} + GateRef Stub::IsExtensible(GateRef object) { GateRef hClass = LoadHClass(object); @@ -1049,6 +1062,33 @@ GateRef Stub::IsEcmaObject(GateRef obj) return ret; } +GateRef Stub::IsJSObject(GateRef obj) +{ + auto env = GetEnvironment(); + Label subentry(env); + env->PushCurrentLabel(&subentry); + Label exit(env); + Label isHeapObject(env); + DEFVARIABLE(result, MachineType::BOOL, FalseConstant()); + Branch(TaggedIsHeapObject(obj), &isHeapObject, &exit); + Bind(&isHeapObject); + { + GateRef objectType = GetObjectType(LoadHClass(obj)); + auto ret1 = Word32And( + ZExtInt1ToInt32( + Int32LessThanOrEqual(objectType, GetInt32Constant(static_cast(JSType::JS_OBJECT_END)))), + ZExtInt1ToInt32( + Int32GreaterThanOrEqual(objectType, + GetInt32Constant(static_cast(JSType::JS_OBJECT_BEGIN))))); + result = TruncInt32ToInt1(ret1); + Jump(&exit); + } + Bind(&exit); + auto ret = *result; + env->PopCurrentLabel(); + return ret; +} + GateRef Stub::IsSymbol(GateRef obj) { GateRef objectType = GetObjectType(LoadHClass(obj)); diff --git a/ecmascript/compiler/stub.h b/ecmascript/compiler/stub.h index 361517e053..45749f75c0 100644 --- a/ecmascript/compiler/stub.h +++ b/ecmascript/compiler/stub.h @@ -605,12 +605,14 @@ public: inline GateRef IsDictionaryElement(GateRef hClass); inline GateRef NotBuiltinsConstructor(GateRef object); inline GateRef IsClassConstructor(GateRef object); + inline GateRef IsClassPrototype(GateRef object); inline GateRef IsExtensible(GateRef object); inline GateRef IsEcmaObject(GateRef obj); inline GateRef IsSymbol(GateRef obj); inline GateRef IsString(GateRef obj); inline GateRef IsJsProxy(GateRef obj); inline GateRef IsJsArray(GateRef obj); + inline GateRef IsJSObject(GateRef obj); inline GateRef IsWritable(GateRef attr); inline GateRef IsAccessor(GateRef attr); inline GateRef IsInlinedProperty(GateRef attr); diff --git a/ecmascript/compiler/stub_descriptor.cpp b/ecmascript/compiler/stub_descriptor.cpp index 150d117385..5e9108360f 100644 --- a/ecmascript/compiler/stub_descriptor.cpp +++ b/ecmascript/compiler/stub_descriptor.cpp @@ -223,10 +223,6 @@ CALL_STUB_INIT_DESCRIPTOR(JSHClassAddProperty) descriptor->SetParameters(params.data()); } -CALL_STUB_INIT_DESCRIPTOR(SetPropertyByValue) -{ -} - CALL_STUB_INIT_DESCRIPTOR(TryLoadICByName) { // 4 : 4 input parameters @@ -993,6 +989,69 @@ CALL_STUB_INIT_DESCRIPTOR(LoopTest1) } #endif +CALL_STUB_INIT_DESCRIPTOR(SetPropertyByValue) +{ + // 4 : 4 input parameters + StubDescriptor setPropertyByValue("SetPropertyByValue", 0, 4, + ArgumentsOrder::DEFAULT_ORDER, MachineType::TAGGED); + *descriptor = setPropertyByValue; + std::array params = { // 7 : 7 input parameters + MachineType::NATIVE_POINTER, + MachineType::TAGGED, + MachineType::TAGGED, + MachineType::TAGGED, + }; + descriptor->SetParameters(params.data()); + descriptor->SetStubKind(StubDescriptor::CallStubKind::RUNTIME_STUB); +} + +CALL_STUB_INIT_DESCRIPTOR(SetFunctionNameNoPrefix) +{ + // 3 : 3 input parameters + StubDescriptor setFunctionNameNoPrefix("SetFunctionNameNoPrefix", 0, 3, + ArgumentsOrder::DEFAULT_ORDER, MachineType::TAGGED); + *descriptor = setFunctionNameNoPrefix; + std::array params = { // 3 : 3 input parameters + MachineType::NATIVE_POINTER, + MachineType::TAGGED, + MachineType::TAGGED, + }; + descriptor->SetParameters(params.data()); + descriptor->SetStubKind(StubDescriptor::CallStubKind::RUNTIME_STUB); +} + +CALL_STUB_INIT_DESCRIPTOR(StOwnByNameWithNameSet) +{ + // 4 : 4 input parameters + StubDescriptor stOwnByNameWithNameSet("StOwnByNameWithNameSet", 0, 4, + ArgumentsOrder::DEFAULT_ORDER, MachineType::TAGGED); + *descriptor = stOwnByNameWithNameSet; + std::array params = { // 7 : 7 input parameters + MachineType::NATIVE_POINTER, + MachineType::TAGGED, + MachineType::TAGGED, + MachineType::TAGGED, + }; + descriptor->SetParameters(params.data()); + descriptor->SetStubKind(StubDescriptor::CallStubKind::RUNTIME_STUB); +} + +CALL_STUB_INIT_DESCRIPTOR(StOwnByValueWithNameSet) +{ + // 4 : 4 input parameters + StubDescriptor stOwnByValueWithNameSet("StOwnByValueWithNameSet", 0, 4, + ArgumentsOrder::DEFAULT_ORDER, MachineType::TAGGED); + *descriptor = stOwnByValueWithNameSet; + std::array params = { // 4 : 4 input parameters + MachineType::NATIVE_POINTER, + MachineType::TAGGED, + MachineType::TAGGED, + MachineType::TAGGED, + }; + descriptor->SetParameters(params.data()); + descriptor->SetStubKind(StubDescriptor::CallStubKind::RUNTIME_STUB); +} + void FastStubDescriptors::InitializeStubDescriptors() { // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) diff --git a/ecmascript/js_thread.cpp b/ecmascript/js_thread.cpp index b21495d8c6..878ad0638b 100644 --- a/ecmascript/js_thread.cpp +++ b/ecmascript/js_thread.cpp @@ -279,6 +279,18 @@ void JSThread::LoadStubModule(const char *moduleFile) bytecodeHandlers_[EcmaOpcode::JMP_IMM8] = stubModule.GetStubEntry(kungfu::StubId::STUB_HandleJmpImm8); bytecodeHandlers_[EcmaOpcode::JMP_IMM16] = stubModule.GetStubEntry(kungfu::StubId::STUB_HandleJmpImm16); bytecodeHandlers_[EcmaOpcode::JMP_IMM32] = stubModule.GetStubEntry(kungfu::StubId::STUB_HandleJmpImm32); + bytecodeHandlers_[EcmaOpcode::STOWNBYVALUEWITHNAMESET_PREF_V8_V8] = + stubModule.GetStubEntry(kungfu::StubId::STUB_HandleStOwnByValueWithNameSetPrefV8V8); + // bytecodeHandlers_[EcmaOpcode::STOWNBYNAMEWITHNAMESET_PREF_ID32_V8] = + // stubModule.GetStubEntry(kungfu::StubId::STUB_HandleStOwnByNameWithNameSetPrefId32V8); + bytecodeHandlers_[EcmaOpcode::LDFUNCTION_PREF] = + stubModule.GetStubEntry(kungfu::StubId::STUB_HandleLdFunctionPref); + bytecodeHandlers_[EcmaOpcode::MOV_V4_V4] = + stubModule.GetStubEntry(kungfu::StubId::STUB_HandleMovV4V4); + bytecodeHandlers_[EcmaOpcode::MOV_DYN_V8_V8] = + stubModule.GetStubEntry(kungfu::StubId::STUB_HandleMovDynV8V8); + bytecodeHandlers_[EcmaOpcode::MOV_DYN_V16_V16] = + stubModule.GetStubEntry(kungfu::StubId::STUB_HandleMovDynV16V16); #ifdef NDEBUG kungfu::LLVMStackMapParser::GetInstance().Print(); #endif diff --git a/ecmascript/runtime_trampolines.cpp b/ecmascript/runtime_trampolines.cpp index 874ffe7f0b..a989d8f9a8 100644 --- a/ecmascript/runtime_trampolines.cpp +++ b/ecmascript/runtime_trampolines.cpp @@ -515,4 +515,28 @@ JSTaggedType RuntimeTrampolines::UpdateHotnessCounter(uintptr_t argGlue, uintptr } return state->profileTypeInfo.GetRawData(); } + +JSTaggedType RuntimeTrampolines::SetPropertyByValue(uintptr_t argGlue, JSTaggedType argRreceiver, JSTaggedType argKey, JSTaggedType argValue) +{ + auto thread = JSThread::GlueToJSThread(argGlue); + return FastRuntimeStub::SetPropertyByValue(thread, JSTaggedValue(argRreceiver), JSTaggedValue(argKey), JSTaggedValue(argValue)).GetRawData(); +} + +void RuntimeTrampolines::SetFunctionNameNoPrefix(uintptr_t argGlue, JSTaggedType argFunc, JSTaggedType argName) +{ + auto thread = JSThread::GlueToJSThread(argGlue); + JSFunction::SetFunctionNameNoPrefix(thread, reinterpret_cast(argFunc), JSTaggedValue(argName)); +} + +JSTaggedType RuntimeTrampolines::StOwnByValueWithNameSet(uintptr_t argGlue, JSTaggedType obj, JSTaggedType key, JSTaggedType value) +{ + auto thread = JSThread::GlueToJSThread(argGlue); + return SlowRuntimeStub::StOwnByValueWithNameSet(thread, JSTaggedValue(obj), JSTaggedValue(key), JSTaggedValue(value)).GetRawData(); +} + +JSTaggedType RuntimeTrampolines::StOwnByNameWithNameSet(uintptr_t argGlue, JSTaggedType obj, JSTaggedType prop, JSTaggedType value) +{ + auto thread = JSThread::GlueToJSThread(argGlue); + return SlowRuntimeStub::StOwnByValueWithNameSet(thread, JSTaggedValue(obj), JSTaggedValue(prop), JSTaggedValue(value)).GetRawData(); +} } // namespace panda::ecmascript diff --git a/ecmascript/runtime_trampolines.h b/ecmascript/runtime_trampolines.h index 779f4030c6..72e0298cfc 100644 --- a/ecmascript/runtime_trampolines.h +++ b/ecmascript/runtime_trampolines.h @@ -95,6 +95,10 @@ public: JSTaggedType lexenv, JSTaggedType constpool); static JSTaggedType SetClassConstructorLength(uintptr_t argGlue, JSTaggedType ctor, JSTaggedType length); static JSTaggedType UpdateHotnessCounter(uintptr_t argGlue, uintptr_t sp); + static JSTaggedType SetPropertyByValue(uintptr_t argGlue, JSTaggedType argRreceiver, JSTaggedType argKey, JSTaggedType argValue); + static void SetFunctionNameNoPrefix(uintptr_t argGlue, JSTaggedType argFunc, JSTaggedType argName); + static JSTaggedType StOwnByValueWithNameSet(uintptr_t argGlue, JSTaggedType obj, JSTaggedType key, JSTaggedType value); + static JSTaggedType StOwnByNameWithNameSet(uintptr_t argGlue, JSTaggedType obj, JSTaggedType key, JSTaggedType value); }; } // namespace panda::ecmascript #endif -- Gitee