From 1590d4f4138c2c5aa197d1b6cf0703a0564a2298 Mon Sep 17 00:00:00 2001 From: wanghuan Date: Thu, 13 Jan 2022 14:25:03 +0800 Subject: [PATCH] add ldlexenvdyn, poplexenvdyn, ldhole, ldhomeobject, debugger handle Signed-off-by: wanghuan Change-Id: I9f07d812e9d886ceaeb7aeee7b78c2e3997461f3 --- ecmascript/compiler/interpreter_stub.cpp | 89 +++++++++++++++++++ ecmascript/compiler/interpreter_stub_define.h | 5 ++ ecmascript/compiler/stub-inl.h | 11 +++ ecmascript/compiler/stub.h | 2 + ecmascript/js_thread.cpp | 5 ++ 5 files changed, 112 insertions(+) diff --git a/ecmascript/compiler/interpreter_stub.cpp b/ecmascript/compiler/interpreter_stub.cpp index 002d0c28d3..9ec39007d8 100644 --- a/ecmascript/compiler/interpreter_stub.cpp +++ b/ecmascript/compiler/interpreter_stub.cpp @@ -112,6 +112,95 @@ void HandleLdFalsePrefStub::GenerateCircuit(const CompilationConfig *cfg) GetArchRelateConstant(BytecodeInstruction::Size(BytecodeInstruction::Format::PREF_NONE))); } +void HandleLdLexEnvDynPrefStub::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 : 5rd parameter is value */ + DEFVARIABLE(acc, MachineType::TAGGED, TaggedArgument(5)); /* 5: 6th parameter is value */ + GateRef hotnessCounter = Int32Argument(6); /* 6 : 7th parameter is value */ + + GateRef state = GetFrame(sp); + acc = GetEnvFromFrame(state); + Dispatch(glue, pc, sp, constpool, profileTypeInfo, *acc, hotnessCounter, + GetArchRelateConstant(BytecodeInstruction::Size(BytecodeInstruction::Format::PREF_NONE))); +} + +void HandlePopLexEnvDynPrefStub::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 : 5rd parameter is value */ + GateRef acc = TaggedArgument(5); /* 5: 6th parameter is value */ + GateRef hotnessCounter = Int32Argument(6); /* 6 : 7th parameter is value */ + + GateRef state = GetFrame(sp); + GateRef currentLexEnv = GetEnvFromFrame(state); + GateRef parentLexEnv = GetParentEnv(currentLexEnv); + SetEnvToFrame(glue, state, parentLexEnv); + Dispatch(glue, pc, sp, constpool, profileTypeInfo, acc, hotnessCounter, + GetArchRelateConstant(BytecodeInstruction::Size(BytecodeInstruction::Format::PREF_NONE))); +} + +void HandleLdHolePrefStub::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 : 5rd parameter is value */ + DEFVARIABLE(acc, MachineType::TAGGED, TaggedArgument(5)); /* 5: 6th parameter is value */ + GateRef hotnessCounter = Int32Argument(6); /* 6 : 7th parameter is value */ + + acc = GetHoleConstant(); + Dispatch(glue, pc, sp, constpool, profileTypeInfo, *acc, hotnessCounter, + GetArchRelateConstant(BytecodeInstruction::Size(BytecodeInstruction::Format::PREF_NONE))); +} + +void HandleLdHomeObjectPrefStub::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 : 5rd parameter is value */ + DEFVARIABLE(acc, MachineType::TAGGED, TaggedArgument(5)); /* 5: 6th parameter is value */ + GateRef hotnessCounter = Int32Argument(6); /* 6 : 7th parameter is value */ + + GateRef thisFunc = GetFunctionFromFrame(GetFrame(sp)); + acc = GetHomeObjectFromJSFunction(thisFunc); + Dispatch(glue, pc, sp, constpool, profileTypeInfo, *acc, hotnessCounter, + GetArchRelateConstant(BytecodeInstruction::Size(BytecodeInstruction::Format::PREF_NONE))); +} + +void HandleDebuggerPrefStub::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 : 5rd parameter is value */ + GateRef acc = TaggedArgument(5); + GateRef hotnessCounter = Int32Argument(6); /* 6 : 7th parameter is value */ + + Dispatch(glue, pc, sp, constpool, profileTypeInfo, acc, hotnessCounter, + GetArchRelateConstant(BytecodeInstruction::Size(BytecodeInstruction::Format::PREF_NONE))); +} + void SingleStepDebuggingStub::GenerateCircuit(const CompilationConfig *cfg) { Stub::GenerateCircuit(cfg); diff --git a/ecmascript/compiler/interpreter_stub_define.h b/ecmascript/compiler/interpreter_stub_define.h index 16fd6a9fb8..ef5688a59a 100644 --- a/ecmascript/compiler/interpreter_stub_define.h +++ b/ecmascript/compiler/interpreter_stub_define.h @@ -14,6 +14,11 @@ namespace panda::ecmascript::kungfu { V(HandleLdNullPref, 7) \ V(HandleLdTruePref, 7) \ V(HandleLdFalsePref, 7) \ + V(HandleLdLexEnvDynPref, 7) \ + V(HandlePopLexEnvDynPref, 7) \ + V(HandleLdHolePref, 7) \ + V(HandleLdHomeObjectPref, 7) \ + V(HandleDebuggerPref, 7) \ V(HandleLdaDynV8, 7) \ V(HandleStaDynV8, 7) \ V(HandleJmpImm8, 7) \ diff --git a/ecmascript/compiler/stub-inl.h b/ecmascript/compiler/stub-inl.h index ab23214483..cd59f515ee 100644 --- a/ecmascript/compiler/stub-inl.h +++ b/ecmascript/compiler/stub-inl.h @@ -2004,6 +2004,11 @@ GateRef Stub::GetEnvFromFrame(GateRef frame) return Load(MachineType::TAGGED, frame, GetArchRelateConstant(InterpretedFrame::GetEnvOffset(env_.IsArm32()))); } +void Stub::SetEnvToFrame(GateRef glue, GateRef frame, GateRef env) +{ + Store(MachineType::UINT64, glue, frame, GetArchRelateConstant(InterpretedFrame::GetEnvOffset(env_.IsArm32())), env); +} + GateRef Stub::LoadAccFromSp(GateRef glue, GateRef CurrentSp) { return Load(MachineType::TAGGED, CurrentSp, GetArchRelateConstant(InterpretedFrame::GetAccOffset(env_.IsArm32()))); @@ -2115,6 +2120,12 @@ GateRef Stub::GetFunctionInfoFlagFromJSFunction(GateRef object) return Load(MachineType::TAGGED, object, offset); } +GateRef Stub::GetHomeObjectFromJSFunction(GateRef object) +{ + GateRef offset = GetArchRelateConstant(JSFunction::HOME_OBJECT_OFFSET); + return Load(MachineType::TAGGED, object, offset); +} + void Stub::SetLexicalEnvToFunction(GateRef glue, GateRef object, GateRef lexicalEnv) { GateRef offset = GetArchRelateConstant(JSFunction::LEXICAL_ENV_OFFSET); diff --git a/ecmascript/compiler/stub.h b/ecmascript/compiler/stub.h index 45749f75c0..966334fc9d 100644 --- a/ecmascript/compiler/stub.h +++ b/ecmascript/compiler/stub.h @@ -792,6 +792,7 @@ public: inline GateRef GetProfileTypeInfoFromFrame(GateRef frame); inline GateRef GetAccFromFrame(GateRef frame); inline GateRef GetEnvFromFrame(GateRef frame); + inline void SetEnvToFrame(GateRef glue, GateRef frame, GateRef env); inline GateRef ReadInst32_0(GateRef pc); inline GateRef ReadInst32_1(GateRef pc); inline GateRef ReadInst32_2(GateRef pc); @@ -810,6 +811,7 @@ public: inline void SetPropertiesToLexicalEnv(GateRef glue, GateRef object, GateRef index, GateRef value); inline GateRef GetObjectFromConstPool(GateRef constpool, GateRef index); inline GateRef GetFunctionInfoFlagFromJSFunction(GateRef object); + inline GateRef GetHomeObjectFromJSFunction(GateRef object); inline void SetLexicalEnvToFunction(GateRef glue, GateRef object, GateRef lexicalEnv); inline GateRef FunctionIsResolved(GateRef object); diff --git a/ecmascript/js_thread.cpp b/ecmascript/js_thread.cpp index 2121369a36..36e880375c 100644 --- a/ecmascript/js_thread.cpp +++ b/ecmascript/js_thread.cpp @@ -237,6 +237,11 @@ void JSThread::LoadStubModule(const char *moduleFile) bytecodeHandlers_[EcmaOpcode::LDNULL_PREF] = stubModule.GetStubEntry(kungfu::StubId::STUB_HandleLdNullPref); bytecodeHandlers_[EcmaOpcode::LDTRUE_PREF] = stubModule.GetStubEntry(kungfu::StubId::STUB_HandleLdTruePref); bytecodeHandlers_[EcmaOpcode::LDFALSE_PREF] = stubModule.GetStubEntry(kungfu::StubId::STUB_HandleLdFalsePref); + bytecodeHandlers_[EcmaOpcode::LDLEXENVDYN_PREF] = stubModule.GetStubEntry(kungfu::StubId::STUB_HandleLdLexEnvDynPref); + bytecodeHandlers_[EcmaOpcode::POPLEXENVDYN_PREF] = stubModule.GetStubEntry(kungfu::StubId::STUB_HandlePopLexEnvDynPref); + bytecodeHandlers_[EcmaOpcode::LDHOLE_PREF] = stubModule.GetStubEntry(kungfu::StubId::STUB_HandleLdHolePref); + bytecodeHandlers_[EcmaOpcode::LDHOMEOBJECT_PREF] = stubModule.GetStubEntry(kungfu::StubId::STUB_HandleLdHomeObjectPref); + bytecodeHandlers_[EcmaOpcode::DEBUGGER_PREF] = stubModule.GetStubEntry(kungfu::StubId::STUB_HandleDebuggerPref); bytecodeHandlers_[EcmaOpcode::LDA_DYN_V8] = stubModule.GetStubEntry(kungfu::StubId::STUB_HandleLdaDynV8); bytecodeHandlers_[EcmaOpcode::STA_DYN_V8] = stubModule.GetStubEntry(kungfu::StubId::STUB_HandleStaDynV8); bytecodeHandlers_[EcmaOpcode::LDLEXVARDYN_PREF_IMM4_IMM4] = -- Gitee