mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-26 19:50:55 +00:00
Support sendable env
Signed-off-by: lijiamin2019 <lijiamin24@huawei.com> Change-Id: I12c98e977e9338cbe811cdd65b8e6b80bc8f4872
This commit is contained in:
parent
d5f37e9ed9
commit
25076981de
@ -5359,5 +5359,45 @@ BYTECODE_BASELINE_HANDLER_IMPLEMENT(CALLRUNTIME_WIDELDSENDABLEEXTERNALMODULEVAR_
|
||||
{
|
||||
(void)bytecodeArray;
|
||||
}
|
||||
|
||||
BYTECODE_BASELINE_HANDLER_IMPLEMENT(CALLRUNTIME_NEWSENDABLEENV_PREF_IMM8)
|
||||
{
|
||||
(void)bytecodeArray;
|
||||
}
|
||||
|
||||
BYTECODE_BASELINE_HANDLER_IMPLEMENT(CALLRUNTIME_WIDENEWSENDABLEENV_PREF_IMM16)
|
||||
{
|
||||
(void)bytecodeArray;
|
||||
}
|
||||
|
||||
BYTECODE_BASELINE_HANDLER_IMPLEMENT(CALLRUNTIME_STSENDABLEVAR_PREF_IMM4_IMM4)
|
||||
{
|
||||
(void)bytecodeArray;
|
||||
}
|
||||
|
||||
BYTECODE_BASELINE_HANDLER_IMPLEMENT(CALLRUNTIME_STSENDABLEVAR_PREF_IMM8_IMM8)
|
||||
{
|
||||
(void)bytecodeArray;
|
||||
}
|
||||
|
||||
BYTECODE_BASELINE_HANDLER_IMPLEMENT(CALLRUNTIME_WIDESTSENDABLEVAR_PREF_IMM16_IMM16)
|
||||
{
|
||||
(void)bytecodeArray;
|
||||
}
|
||||
|
||||
BYTECODE_BASELINE_HANDLER_IMPLEMENT(CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4)
|
||||
{
|
||||
(void)bytecodeArray;
|
||||
}
|
||||
|
||||
BYTECODE_BASELINE_HANDLER_IMPLEMENT(CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8)
|
||||
{
|
||||
(void)bytecodeArray;
|
||||
}
|
||||
|
||||
BYTECODE_BASELINE_HANDLER_IMPLEMENT(CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16)
|
||||
{
|
||||
(void)bytecodeArray;
|
||||
}
|
||||
#undef LOG_INST
|
||||
} // namespace panda::ecmascript::kungfu
|
@ -382,7 +382,15 @@ namespace panda::ecmascript::kungfu {
|
||||
T(HandleCallRuntimeDefineSendableClassPrefImm16Id16Id16Imm16V8) \
|
||||
T(HandleCallRuntimeLdSendableClassPrefImm16) \
|
||||
T(HandleCallRuntimeLdsendableexternalmodulevarImm8) \
|
||||
T(HandleCallRuntimeWideLdsendableexternalmodulevarPrefImm16)
|
||||
T(HandleCallRuntimeWideLdsendableexternalmodulevarPrefImm16) \
|
||||
T(HandleCallRuntimeNewSendableEnvImm8) \
|
||||
T(HandleCallRuntimeNewSendableEnvImm16) \
|
||||
T(HandleCallRuntimeStSendableVarImm4Imm4) \
|
||||
T(HandleCallRuntimeStSendableVarImm8Imm8) \
|
||||
T(HandleCallRuntimeStSendableVarImm16Imm16) \
|
||||
T(HandleCallRuntimeLdSendableVarImm4Imm4) \
|
||||
T(HandleCallRuntimeLdSendableVarImm8Imm8) \
|
||||
T(HandleCallRuntimeLdSendableVarImm16Imm16)
|
||||
|
||||
#define ASM_INTERPRETER_BC_HELPER_STUB_LIST(V) \
|
||||
V(SingleStepDebugging) \
|
||||
|
@ -49,6 +49,9 @@ BytecodeMetaData BytecodeMetaData::InitBytecodeMetaData(const uint8_t *pc)
|
||||
case EcmaOpcode::LDLEXVAR_IMM4_IMM4:
|
||||
case EcmaOpcode::LDLEXVAR_IMM8_IMM8:
|
||||
case EcmaOpcode::WIDE_LDLEXVAR_PREF_IMM16_IMM16:
|
||||
case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4:
|
||||
case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8:
|
||||
case EcmaOpcode::CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16:
|
||||
case EcmaOpcode::WIDE_LDPATCHVAR_PREF_IMM16:
|
||||
case EcmaOpcode::LDLOCALMODULEVAR_IMM8:
|
||||
case EcmaOpcode::WIDE_LDLOCALMODULEVAR_PREF_IMM16:
|
||||
@ -84,6 +87,9 @@ BytecodeMetaData BytecodeMetaData::InitBytecodeMetaData(const uint8_t *pc)
|
||||
case EcmaOpcode::LDLEXVAR_IMM4_IMM4:
|
||||
case EcmaOpcode::LDLEXVAR_IMM8_IMM8:
|
||||
case EcmaOpcode::WIDE_LDLEXVAR_PREF_IMM16_IMM16:
|
||||
case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4:
|
||||
case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8:
|
||||
case EcmaOpcode::CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16:
|
||||
case EcmaOpcode::WIDE_LDPATCHVAR_PREF_IMM16:
|
||||
case EcmaOpcode::LDA_STR_ID16:
|
||||
case EcmaOpcode::CALLRUNTIME_LDSENDABLECLASS_PREF_IMM16:
|
||||
@ -131,6 +137,8 @@ BytecodeMetaData BytecodeMetaData::InitBytecodeMetaData(const uint8_t *pc)
|
||||
case EcmaOpcode::WIDE_LDEXTERNALMODULEVAR_PREF_IMM16:
|
||||
case EcmaOpcode::NEWLEXENV_IMM8:
|
||||
case EcmaOpcode::WIDE_NEWLEXENV_PREF_IMM16:
|
||||
case EcmaOpcode::CALLRUNTIME_NEWSENDABLEENV_PREF_IMM8:
|
||||
case EcmaOpcode::CALLRUNTIME_WIDENEWSENDABLEENV_PREF_IMM16:
|
||||
case EcmaOpcode::POPLEXENV:
|
||||
case EcmaOpcode::NEWLEXENVWITHNAME_IMM8_ID16:
|
||||
case EcmaOpcode::WIDE_NEWLEXENVWITHNAME_PREF_IMM16_ID16:
|
||||
@ -143,9 +151,15 @@ BytecodeMetaData BytecodeMetaData::InitBytecodeMetaData(const uint8_t *pc)
|
||||
case EcmaOpcode::LDLEXVAR_IMM4_IMM4:
|
||||
case EcmaOpcode::LDLEXVAR_IMM8_IMM8:
|
||||
case EcmaOpcode::WIDE_LDLEXVAR_PREF_IMM16_IMM16:
|
||||
case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4:
|
||||
case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8:
|
||||
case EcmaOpcode::CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16:
|
||||
case EcmaOpcode::STLEXVAR_IMM4_IMM4:
|
||||
case EcmaOpcode::STLEXVAR_IMM8_IMM8:
|
||||
case EcmaOpcode::WIDE_STLEXVAR_PREF_IMM16_IMM16:
|
||||
case EcmaOpcode::CALLRUNTIME_STSENDABLEVAR_PREF_IMM4_IMM4:
|
||||
case EcmaOpcode::CALLRUNTIME_STSENDABLEVAR_PREF_IMM8_IMM8:
|
||||
case EcmaOpcode::CALLRUNTIME_WIDESTSENDABLEVAR_PREF_IMM16_IMM16:
|
||||
case EcmaOpcode::STRICTNOTEQ_IMM8_V8:
|
||||
case EcmaOpcode::STRICTEQ_IMM8_V8:
|
||||
case EcmaOpcode::CREATEEMPTYARRAY_IMM8:
|
||||
@ -449,6 +463,14 @@ BytecodeMetaData BytecodeMetaData::InitBytecodeMetaData(const uint8_t *pc)
|
||||
case EcmaOpcode::CALLRUNTIME_DEFINESENDABLECLASS_PREF_IMM16_ID16_ID16_IMM16_V8:
|
||||
case EcmaOpcode::CALLRUNTIME_LDSENDABLEEXTERNALMODULEVAR_PREF_IMM8:
|
||||
case EcmaOpcode::CALLRUNTIME_WIDELDSENDABLEEXTERNALMODULEVAR_PREF_IMM16:
|
||||
case EcmaOpcode::CALLRUNTIME_STSENDABLEVAR_PREF_IMM4_IMM4:
|
||||
case EcmaOpcode::CALLRUNTIME_STSENDABLEVAR_PREF_IMM8_IMM8:
|
||||
case EcmaOpcode::CALLRUNTIME_WIDESTSENDABLEVAR_PREF_IMM16_IMM16:
|
||||
case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4:
|
||||
case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8:
|
||||
case EcmaOpcode::CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16:
|
||||
case EcmaOpcode::CALLRUNTIME_NEWSENDABLEENV_PREF_IMM8:
|
||||
case EcmaOpcode::CALLRUNTIME_WIDENEWSENDABLEENV_PREF_IMM16:
|
||||
flags |= BytecodeFlags::READ_FUNC;
|
||||
break;
|
||||
case EcmaOpcode::SUPERCALLTHISRANGE_IMM8_IMM8_V8:
|
||||
@ -917,6 +939,27 @@ void BytecodeInfo::InitBytecodeInfo(BytecodeCircuitBuilder *builder,
|
||||
info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
|
||||
break;
|
||||
}
|
||||
case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4: {
|
||||
uint16_t level = READ_INST_4_2();
|
||||
uint16_t slot = READ_INST_4_3();
|
||||
info.inputs.emplace_back(Immediate(level));
|
||||
info.inputs.emplace_back(Immediate(slot));
|
||||
break;
|
||||
}
|
||||
case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8: {
|
||||
uint16_t level = READ_INST_8_1();
|
||||
uint16_t slot = READ_INST_8_2();
|
||||
info.inputs.emplace_back(Immediate(level));
|
||||
info.inputs.emplace_back(Immediate(slot));
|
||||
break;
|
||||
}
|
||||
case EcmaOpcode::CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16: {
|
||||
uint16_t level = READ_INST_16_1();
|
||||
uint16_t slot = READ_INST_16_3();
|
||||
info.inputs.emplace_back(Immediate(level));
|
||||
info.inputs.emplace_back(Immediate(slot));
|
||||
break;
|
||||
}
|
||||
case EcmaOpcode::STLEXVAR_IMM4_IMM4: {
|
||||
uint16_t level = READ_INST_4_0();
|
||||
uint16_t slot = READ_INST_4_1();
|
||||
@ -941,6 +984,27 @@ void BytecodeInfo::InitBytecodeInfo(BytecodeCircuitBuilder *builder,
|
||||
info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
|
||||
break;
|
||||
}
|
||||
case EcmaOpcode::CALLRUNTIME_STSENDABLEVAR_PREF_IMM4_IMM4: {
|
||||
uint16_t level = READ_INST_4_2();
|
||||
uint16_t slot = READ_INST_4_3();
|
||||
info.inputs.emplace_back(Immediate(level));
|
||||
info.inputs.emplace_back(Immediate(slot));
|
||||
break;
|
||||
}
|
||||
case EcmaOpcode::CALLRUNTIME_STSENDABLEVAR_PREF_IMM8_IMM8: {
|
||||
uint16_t level = READ_INST_8_1();
|
||||
uint16_t slot = READ_INST_8_2();
|
||||
info.inputs.emplace_back(Immediate(level));
|
||||
info.inputs.emplace_back(Immediate(slot));
|
||||
break;
|
||||
}
|
||||
case EcmaOpcode::CALLRUNTIME_WIDESTSENDABLEVAR_PREF_IMM16_IMM16: {
|
||||
uint16_t level = READ_INST_16_1();
|
||||
uint16_t slot = READ_INST_16_3();
|
||||
info.inputs.emplace_back(Immediate(level));
|
||||
info.inputs.emplace_back(Immediate(slot));
|
||||
break;
|
||||
}
|
||||
case EcmaOpcode::NEWLEXENV_IMM8: {
|
||||
uint8_t numVars = READ_INST_8_0();
|
||||
info.inputs.emplace_back(Immediate(numVars));
|
||||
@ -955,6 +1019,16 @@ void BytecodeInfo::InitBytecodeInfo(BytecodeCircuitBuilder *builder,
|
||||
info.vregOut.emplace_back(builder->GetEnvVregIdx());
|
||||
break;
|
||||
}
|
||||
case EcmaOpcode::CALLRUNTIME_NEWSENDABLEENV_PREF_IMM8: {
|
||||
uint8_t numVars = READ_INST_8_1();
|
||||
info.inputs.emplace_back(Immediate(numVars));
|
||||
break;
|
||||
}
|
||||
case EcmaOpcode::CALLRUNTIME_WIDENEWSENDABLEENV_PREF_IMM16: {
|
||||
uint16_t numVars = READ_INST_16_1();
|
||||
info.inputs.emplace_back(Immediate(numVars));
|
||||
break;
|
||||
}
|
||||
case EcmaOpcode::NEWLEXENVWITHNAME_IMM8_ID16: {
|
||||
uint16_t numVars = READ_INST_8_0();
|
||||
uint16_t scopeId = READ_INST_16_1();
|
||||
|
@ -282,7 +282,7 @@ public:
|
||||
static constexpr uint32_t LAST_THROW_OPCODE =
|
||||
static_cast<uint32_t>(EcmaOpcode::THROW_UNDEFINEDIFHOLEWITHNAME_PREF_ID16);
|
||||
static constexpr uint32_t LAST_CALLRUNTIME_OPCODE =
|
||||
static_cast<uint32_t>(EcmaOpcode::CALLRUNTIME_LDSENDABLECLASS_PREF_IMM16);
|
||||
static_cast<uint32_t>(EcmaOpcode::CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16);
|
||||
|
||||
static_assert(CALLRUNTIME_PREFIX_OPCODE_INDEX ==
|
||||
static_cast<uint32_t>(EcmaOpcode::CALLRUNTIME_NOTIFYCONCURRENTRESULT_PREF_NONE));
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "ecmascript/jspandafile/program_object.h"
|
||||
#include "ecmascript/mem/region.h"
|
||||
#include "ecmascript/method.h"
|
||||
#include "ecmascript/sendable_env.h"
|
||||
|
||||
namespace panda::ecmascript::kungfu {
|
||||
|
||||
@ -548,6 +549,17 @@ GateRef CircuitBuilder::GetModuleFromFunction(GateRef function)
|
||||
return Load(VariableType::JS_POINTER(), function, offset);
|
||||
}
|
||||
|
||||
GateRef CircuitBuilder::GetSendableEnvFromModule(GateRef module)
|
||||
{
|
||||
return Load(VariableType::JS_POINTER(), module, IntPtr(SourceTextModule::SENDABLE_ENV_OFFSET));
|
||||
}
|
||||
|
||||
void CircuitBuilder::SetSendableEnvToModule(GateRef glue, GateRef module, GateRef value)
|
||||
{
|
||||
GateRef offset = IntPtr(SourceTextModule::SENDABLE_ENV_OFFSET);
|
||||
Store(VariableType::JS_POINTER(), glue, module, offset, value);
|
||||
}
|
||||
|
||||
GateRef CircuitBuilder::GetHomeObjectFromFunction(GateRef function)
|
||||
{
|
||||
GateRef offset = IntPtr(JSFunction::HOME_OBJECT_OFFSET);
|
||||
@ -1054,9 +1066,21 @@ GateRef CircuitBuilder::GetParentEnv(GateRef object)
|
||||
return GetValueFromTaggedArray(object, index);
|
||||
}
|
||||
|
||||
GateRef CircuitBuilder::GetSendableParentEnv(GateRef object)
|
||||
{
|
||||
GateRef index = Int32(SendableEnv::SENDABLE_PARENT_ENV_INDEX);
|
||||
return GetValueFromTaggedArray(object, index);
|
||||
}
|
||||
|
||||
GateRef CircuitBuilder::GetPropertiesFromLexicalEnv(GateRef object, GateRef index)
|
||||
{
|
||||
GateRef valueIndex = Int32Add(index, Int32(LexicalEnv::RESERVED_ENV_LENGTH));
|
||||
return GetValueFromTaggedArray(object, valueIndex);
|
||||
}
|
||||
|
||||
GateRef CircuitBuilder::GetPropertiesFromSendableEnv(GateRef object, GateRef index)
|
||||
{
|
||||
GateRef valueIndex = Int32Add(index, Int32(SendableEnv::SENDABLE_RESERVED_ENV_LENGTH));
|
||||
return GetValueFromTaggedArray(object, valueIndex);
|
||||
}
|
||||
} // namespace panda::ecmascript::kungfu
|
||||
|
@ -293,6 +293,7 @@ public:
|
||||
GateRef GetGlobalObject(GateRef glue);
|
||||
GateRef GetMethodFromFunction(GateRef function);
|
||||
GateRef GetModuleFromFunction(GateRef function);
|
||||
GateRef GetSendableEnvFromModule(GateRef module);
|
||||
GateRef GetHomeObjectFromFunction(GateRef function);
|
||||
GateRef GetHClassGateFromIndex(GateRef gate, int32_t index);
|
||||
inline GateRef GetExpectedNumOfArgs(GateRef method);
|
||||
@ -326,6 +327,7 @@ public:
|
||||
void SetLexicalEnvToFunction(GateRef glue, GateRef function, GateRef value);
|
||||
void SetHomeObjectToFunction(GateRef glue, GateRef function, GateRef value);
|
||||
void SetModuleToFunction(GateRef glue, GateRef function, GateRef value);
|
||||
void SetSendableEnvToModule(GateRef glue, GateRef module, GateRef value);
|
||||
|
||||
inline GateRef LogicAnd(GateRef x, GateRef y);
|
||||
inline GateRef LogicOr(GateRef x, GateRef y);
|
||||
@ -401,7 +403,9 @@ public:
|
||||
inline GateRef IsAOTLiteralInfo(GateRef x);
|
||||
GateRef GetKeyFromLexivalEnv(GateRef lexicalEnv, GateRef levelIndex, GateRef slotIndex);
|
||||
GateRef GetParentEnv(GateRef object);
|
||||
GateRef GetSendableParentEnv(GateRef object);
|
||||
GateRef GetPropertiesFromLexicalEnv(GateRef object, GateRef index);
|
||||
GateRef GetPropertiesFromSendableEnv(GateRef object, GateRef index);
|
||||
|
||||
// call operation
|
||||
GateRef CallPrivateGetter(GateRef hirGate, GateRef receiver, GateRef accessor, const char* comment = nullptr);
|
||||
|
@ -329,6 +329,14 @@ namespace panda::ecmascript::kungfu {
|
||||
V(CALLRUNTIME_LDSENDABLECLASS_PREF_IMM16) \
|
||||
V(CALLRUNTIME_LDSENDABLEEXTERNALMODULEVAR_PREF_IMM8) \
|
||||
V(CALLRUNTIME_WIDELDSENDABLEEXTERNALMODULEVAR_PREF_IMM16) \
|
||||
V(CALLRUNTIME_NEWSENDABLEENV_PREF_IMM8) \
|
||||
V(CALLRUNTIME_WIDENEWSENDABLEENV_PREF_IMM16) \
|
||||
V(CALLRUNTIME_STSENDABLEVAR_PREF_IMM4_IMM4) \
|
||||
V(CALLRUNTIME_STSENDABLEVAR_PREF_IMM8_IMM8) \
|
||||
V(CALLRUNTIME_WIDESTSENDABLEVAR_PREF_IMM16_IMM16) \
|
||||
V(CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4) \
|
||||
V(CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8) \
|
||||
V(CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16) \
|
||||
|
||||
inline std::string GetEcmaOpcodeStr(EcmaOpcode opcode)
|
||||
{
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "ecmascript/compiler/interpreter_stub.h"
|
||||
#include "ecmascript/compiler/share_gate_meta_data.h"
|
||||
#include "ecmascript/module/js_module_source_text.h"
|
||||
#include "ecmascript/global_env.h"
|
||||
#include "ecmascript/js_async_generator_object.h"
|
||||
#include "ecmascript/js_arguments.h"
|
||||
@ -281,6 +282,11 @@ GateRef InterpreterStubBuilder::GetModuleFromFunction(GateRef function)
|
||||
return Load(VariableType::JS_POINTER(), function, IntPtr(JSFunction::ECMA_MODULE_OFFSET));
|
||||
}
|
||||
|
||||
GateRef InterpreterStubBuilder::GetSendableEnvFromModule(GateRef module)
|
||||
{
|
||||
return Load(VariableType::JS_POINTER(), module, IntPtr(SourceTextModule::SENDABLE_ENV_OFFSET));
|
||||
}
|
||||
|
||||
GateRef InterpreterStubBuilder::GetHomeObjectFromFunction(GateRef function)
|
||||
{
|
||||
return Load(VariableType::JS_POINTER(), function, IntPtr(JSFunction::HOME_OBJECT_OFFSET));
|
||||
@ -321,6 +327,12 @@ void InterpreterStubBuilder::SetModuleToFunction(GateRef glue, GateRef function,
|
||||
Store(VariableType::JS_POINTER(), glue, function, offset, value);
|
||||
}
|
||||
|
||||
void InterpreterStubBuilder::SetSendableEnvToModule(GateRef glue, GateRef module, GateRef value)
|
||||
{
|
||||
GateRef offset = IntPtr(SourceTextModule::SENDABLE_ENV_OFFSET);
|
||||
Store(VariableType::JS_POINTER(), glue, module, offset, value);
|
||||
}
|
||||
|
||||
void InterpreterStubBuilder::SetPcToFrame(GateRef glue, GateRef frame, GateRef value)
|
||||
{
|
||||
Store(VariableType::INT64(), glue, frame,
|
||||
|
@ -5441,6 +5441,210 @@ DECLARE_ASM_HANDLER(HandleCallRuntimeWideLdsendableexternalmodulevarPrefImm16)
|
||||
}
|
||||
}
|
||||
|
||||
DECLARE_ASM_HANDLER(HandleCallRuntimeNewSendableEnvImm8)
|
||||
{
|
||||
auto env = GetEnvironment();
|
||||
DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
|
||||
GateRef numVars = ZExtInt8ToInt16(ReadInst8_1(pc));
|
||||
GateRef res = CallRuntime(glue, RTSTUB_ID(NewSendableEnv),
|
||||
{ Int16ToTaggedInt(numVars) });
|
||||
Label notException(env);
|
||||
CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception);
|
||||
Bind(¬Exception);
|
||||
varAcc = res;
|
||||
GateRef currentFunc = GetFunctionFromFrame(GetFrame(sp));
|
||||
GateRef module = GetModuleFromFunction(currentFunc);
|
||||
SetSendableEnvToModule(glue, module, res);
|
||||
DISPATCH_WITH_ACC(CALLRUNTIME_NEWSENDABLEENV_PREF_IMM8);
|
||||
}
|
||||
|
||||
DECLARE_ASM_HANDLER(HandleCallRuntimeNewSendableEnvImm16)
|
||||
{
|
||||
auto env = GetEnvironment();
|
||||
DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
|
||||
GateRef numVars = ReadInst16_1(pc);
|
||||
GateRef res = CallRuntime(glue, RTSTUB_ID(NewSendableEnv),
|
||||
{ Int16ToTaggedInt(numVars) });
|
||||
Label notException(env);
|
||||
CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception);
|
||||
Bind(¬Exception);
|
||||
varAcc = res;
|
||||
GateRef currentFunc = GetFunctionFromFrame(GetFrame(sp));
|
||||
GateRef module = GetModuleFromFunction(currentFunc);
|
||||
SetSendableEnvToModule(glue, module, res);
|
||||
DISPATCH_WITH_ACC(CALLRUNTIME_WIDENEWSENDABLEENV_PREF_IMM16);
|
||||
}
|
||||
|
||||
DECLARE_ASM_HANDLER(HandleCallRuntimeStSendableVarImm4Imm4)
|
||||
{
|
||||
auto env = GetEnvironment();
|
||||
GateRef level = ZExtInt8ToInt32(ReadInst4_2(pc));
|
||||
GateRef slot = ZExtInt8ToInt32(ReadInst4_3(pc));
|
||||
|
||||
GateRef value = acc;
|
||||
GateRef currentFunc = GetFunctionFromFrame(GetFrame(sp));
|
||||
GateRef module = GetModuleFromFunction(currentFunc);
|
||||
DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetSendableEnvFromModule(module));
|
||||
DEFVARIABLE(i, VariableType::INT32(), Int32(0));
|
||||
|
||||
Label loopHead(env);
|
||||
Label loopEnd(env);
|
||||
Label afterLoop(env);
|
||||
BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
|
||||
LoopBegin(&loopHead);
|
||||
currentEnv = GetSendableParentEnv(*currentEnv);
|
||||
i = Int32Add(*i, Int32(1));
|
||||
BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
|
||||
Bind(&loopEnd);
|
||||
LoopEnd(&loopHead, env, glue);
|
||||
Bind(&afterLoop);
|
||||
SetPropertiesToSendableEnv(glue, *currentEnv, slot, value);
|
||||
DISPATCH(CALLRUNTIME_STSENDABLEVAR_PREF_IMM4_IMM4);
|
||||
}
|
||||
|
||||
DECLARE_ASM_HANDLER(HandleCallRuntimeStSendableVarImm8Imm8)
|
||||
{
|
||||
auto env = GetEnvironment();
|
||||
GateRef level = ZExtInt8ToInt32(ReadInst8_1(pc));
|
||||
GateRef slot = ZExtInt8ToInt32(ReadInst8_2(pc));
|
||||
|
||||
GateRef value = acc;
|
||||
GateRef currentFunc = GetFunctionFromFrame(GetFrame(sp));
|
||||
GateRef module = GetModuleFromFunction(currentFunc);
|
||||
DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetSendableEnvFromModule(module));
|
||||
DEFVARIABLE(i, VariableType::INT32(), Int32(0));
|
||||
|
||||
Label loopHead(env);
|
||||
Label loopEnd(env);
|
||||
Label afterLoop(env);
|
||||
BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
|
||||
LoopBegin(&loopHead);
|
||||
currentEnv = GetSendableParentEnv(*currentEnv);
|
||||
i = Int32Add(*i, Int32(1));
|
||||
BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
|
||||
Bind(&loopEnd);
|
||||
LoopEnd(&loopHead, env, glue);
|
||||
Bind(&afterLoop);
|
||||
SetPropertiesToSendableEnv(glue, *currentEnv, slot, value);
|
||||
DISPATCH(CALLRUNTIME_STSENDABLEVAR_PREF_IMM8_IMM8);
|
||||
}
|
||||
|
||||
DECLARE_ASM_HANDLER(HandleCallRuntimeStSendableVarImm16Imm16)
|
||||
{
|
||||
auto env = GetEnvironment();
|
||||
GateRef level = ZExtInt16ToInt32(ReadInst16_1(pc));
|
||||
GateRef slot = ZExtInt16ToInt32(ReadInst16_3(pc));
|
||||
|
||||
GateRef value = acc;
|
||||
GateRef currentFunc = GetFunctionFromFrame(GetFrame(sp));
|
||||
GateRef module = GetModuleFromFunction(currentFunc);
|
||||
DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetSendableEnvFromModule(module));
|
||||
DEFVARIABLE(i, VariableType::INT32(), Int32(0));
|
||||
|
||||
Label loopHead(env);
|
||||
Label loopEnd(env);
|
||||
Label afterLoop(env);
|
||||
BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
|
||||
LoopBegin(&loopHead);
|
||||
currentEnv = GetSendableParentEnv(*currentEnv);
|
||||
i = Int32Add(*i, Int32(1));
|
||||
BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
|
||||
Bind(&loopEnd);
|
||||
LoopEnd(&loopHead, env, glue);
|
||||
Bind(&afterLoop);
|
||||
SetPropertiesToSendableEnv(glue, *currentEnv, slot, value);
|
||||
DISPATCH(CALLRUNTIME_WIDESTSENDABLEVAR_PREF_IMM16_IMM16);
|
||||
}
|
||||
|
||||
DECLARE_ASM_HANDLER(HandleCallRuntimeLdSendableVarImm4Imm4)
|
||||
{
|
||||
auto env = GetEnvironment();
|
||||
DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
|
||||
|
||||
GateRef level = ZExtInt8ToInt32(ReadInst4_2(pc));
|
||||
GateRef slot = ZExtInt8ToInt32(ReadInst4_3(pc));
|
||||
GateRef currentFunc = GetFunctionFromFrame(GetFrame(sp));
|
||||
GateRef module = GetModuleFromFunction(currentFunc);
|
||||
DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetSendableEnvFromModule(module));
|
||||
DEFVARIABLE(i, VariableType::INT32(), Int32(0));
|
||||
|
||||
Label loopHead(env);
|
||||
Label loopEnd(env);
|
||||
Label afterLoop(env);
|
||||
BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
|
||||
LoopBegin(&loopHead);
|
||||
currentEnv = GetSendableParentEnv(*currentEnv);
|
||||
i = Int32Add(*i, Int32(1));
|
||||
BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
|
||||
Bind(&loopEnd);
|
||||
LoopEnd(&loopHead, env, glue);
|
||||
Bind(&afterLoop);
|
||||
GateRef variable = GetPropertiesFromSendableEnv(*currentEnv, slot);
|
||||
varAcc = variable;
|
||||
|
||||
DISPATCH_WITH_ACC(CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4);
|
||||
}
|
||||
|
||||
DECLARE_ASM_HANDLER(HandleCallRuntimeLdSendableVarImm8Imm8)
|
||||
{
|
||||
auto env = GetEnvironment();
|
||||
DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
|
||||
|
||||
GateRef level = ZExtInt8ToInt32(ReadInst8_1(pc));
|
||||
GateRef slot = ZExtInt8ToInt32(ReadInst8_2(pc));
|
||||
|
||||
GateRef currentFunc = GetFunctionFromFrame(GetFrame(sp));
|
||||
GateRef module = GetModuleFromFunction(currentFunc);
|
||||
DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetSendableEnvFromModule(module));
|
||||
DEFVARIABLE(i, VariableType::INT32(), Int32(0));
|
||||
|
||||
Label loopHead(env);
|
||||
Label loopEnd(env);
|
||||
Label afterLoop(env);
|
||||
BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
|
||||
LoopBegin(&loopHead);
|
||||
currentEnv = GetSendableParentEnv(*currentEnv);
|
||||
i = Int32Add(*i, Int32(1));
|
||||
BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
|
||||
Bind(&loopEnd);
|
||||
LoopEnd(&loopHead, env, glue);
|
||||
Bind(&afterLoop);
|
||||
GateRef variable = GetPropertiesFromSendableEnv(*currentEnv, slot);
|
||||
varAcc = variable;
|
||||
|
||||
DISPATCH_WITH_ACC(CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8);
|
||||
}
|
||||
|
||||
DECLARE_ASM_HANDLER(HandleCallRuntimeLdSendableVarImm16Imm16)
|
||||
{
|
||||
auto env = GetEnvironment();
|
||||
DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
|
||||
|
||||
GateRef level = ZExtInt16ToInt32(ReadInst16_1(pc));
|
||||
GateRef slot = ZExtInt16ToInt32(ReadInst16_3(pc));
|
||||
|
||||
GateRef currentFunc = GetFunctionFromFrame(GetFrame(sp));
|
||||
GateRef module = GetModuleFromFunction(currentFunc);
|
||||
DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetSendableEnvFromModule(module));
|
||||
DEFVARIABLE(i, VariableType::INT32(), Int32(0));
|
||||
|
||||
Label loopHead(env);
|
||||
Label loopEnd(env);
|
||||
Label afterLoop(env);
|
||||
BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
|
||||
LoopBegin(&loopHead);
|
||||
currentEnv = GetSendableParentEnv(*currentEnv);
|
||||
i = Int32Add(*i, Int32(1));
|
||||
BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
|
||||
Bind(&loopEnd);
|
||||
LoopEnd(&loopHead, env, glue);
|
||||
Bind(&afterLoop);
|
||||
GateRef variable = GetPropertiesFromSendableEnv(*currentEnv, slot);
|
||||
varAcc = variable;
|
||||
|
||||
DISPATCH_WITH_ACC(CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16);
|
||||
}
|
||||
|
||||
ASM_INTERPRETER_BC_TYPE_PROFILER_STUB_LIST(DECLARE_ASM_HANDLER_PROFILE)
|
||||
ASM_INTERPRETER_BC_LAYOUT_PROFILER_STUB_LIST(DECLARE_ASM_HANDLER_PROFILE)
|
||||
ASM_INTERPRETER_BC_FUNC_HOT_PROFILER_STUB_LIST(DECLARE_ASM_HANDLER_PROFILE)
|
||||
|
@ -156,6 +156,7 @@ public:
|
||||
inline GateRef GetModule(GateRef sp);
|
||||
inline GateRef GetProfileTypeInfoFromFunction(GateRef function);
|
||||
inline GateRef GetModuleFromFunction(GateRef function);
|
||||
inline GateRef GetSendableEnvFromModule(GateRef function);
|
||||
inline GateRef GetHomeObjectFromFunction(GateRef function);
|
||||
inline GateRef GetResumeModeFromGeneratorObject(GateRef obj);
|
||||
inline GateRef GetResumeModeFromAsyncGeneratorObject(GateRef obj);
|
||||
@ -170,6 +171,7 @@ public:
|
||||
inline void SetEnvToFrame(GateRef glue, GateRef frame, GateRef value);
|
||||
inline void SetHomeObjectToFunction(GateRef glue, GateRef function, GateRef value);
|
||||
inline void SetModuleToFunction(GateRef glue, GateRef function, GateRef value);
|
||||
inline void SetSendableEnvToModule(GateRef glue, GateRef module, GateRef value);
|
||||
inline void SetFrameState(GateRef glue, GateRef sp, GateRef function, GateRef acc,
|
||||
GateRef env, GateRef pc, GateRef prev, GateRef type);
|
||||
|
||||
|
@ -755,6 +755,20 @@ void SlowPathLowering::Lower(GateRef gate)
|
||||
case EcmaOpcode::CALLRUNTIME_WIDELDSENDABLEEXTERNALMODULEVAR_PREF_IMM16:
|
||||
LowerSendableExternalModule(gate);
|
||||
break;
|
||||
case EcmaOpcode::CALLRUNTIME_NEWSENDABLEENV_PREF_IMM8:
|
||||
case EcmaOpcode::CALLRUNTIME_WIDENEWSENDABLEENV_PREF_IMM16:
|
||||
LowerNewSendableEnv(gate);
|
||||
break;
|
||||
case EcmaOpcode::CALLRUNTIME_STSENDABLEVAR_PREF_IMM4_IMM4:
|
||||
case EcmaOpcode::CALLRUNTIME_STSENDABLEVAR_PREF_IMM8_IMM8:
|
||||
case EcmaOpcode::CALLRUNTIME_WIDESTSENDABLEVAR_PREF_IMM16_IMM16:
|
||||
LowerStSendableVar(gate);
|
||||
break;
|
||||
case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4:
|
||||
case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8:
|
||||
case EcmaOpcode::CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16:
|
||||
LowerLdSendableVar(gate);
|
||||
break;
|
||||
case EcmaOpcode::LDA_STR_ID16:
|
||||
LowerLdStr(gate);
|
||||
break;
|
||||
@ -2009,6 +2023,18 @@ void SlowPathLowering::LowerNewLexicalEnvWithName(GateRef gate)
|
||||
ReplaceHirWithValue(gate, result, true);
|
||||
}
|
||||
|
||||
void SlowPathLowering::LowerNewSendableEnv(GateRef gate)
|
||||
{
|
||||
// 2: number of value inputs
|
||||
ASSERT(acc_.GetNumValueIn(gate) == 1);
|
||||
auto args = { builder_.ToTaggedInt(acc_.GetValueIn(gate, 0)) };
|
||||
GateRef result = LowerCallRuntime(gate, RTSTUB_ID(NewSendableEnv), args, true);
|
||||
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
|
||||
GateRef module = builder_.GetModuleFromFunction(jsFunc);
|
||||
builder_.SetSendableEnvToModule(glue_, module, result);
|
||||
ReplaceHirWithValue(gate, result);
|
||||
}
|
||||
|
||||
void SlowPathLowering::LowerPopLexicalEnv(GateRef gate)
|
||||
{
|
||||
GateRef currentEnv = acc_.GetValueIn(gate, 0);
|
||||
@ -2328,6 +2354,41 @@ void SlowPathLowering::LowerLdLexVar(GateRef gate)
|
||||
ReplaceHirWithValue(gate, result, true);
|
||||
}
|
||||
|
||||
void SlowPathLowering::LowerLdSendableVar(GateRef gate)
|
||||
{
|
||||
// 2: number of value inputs
|
||||
ASSERT(acc_.GetNumValueIn(gate) == 2);
|
||||
GateRef level = builder_.TruncInt64ToInt32(acc_.GetValueIn(gate, 0));
|
||||
GateRef slot = builder_.TruncInt64ToInt32(acc_.GetValueIn(gate, 1));
|
||||
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
|
||||
GateRef module = builder_.GetModuleFromFunction(jsFunc);
|
||||
DEFVALUE(currentEnv, (&builder_), VariableType::JS_ANY(), builder_.GetSendableEnvFromModule(module));
|
||||
GateRef index = builder_.Int32(SendableEnv::SENDABLE_PARENT_ENV_INDEX);
|
||||
Label exit(&builder_);
|
||||
uint64_t constLevel = acc_.TryGetValue(acc_.GetValueIn(gate, 0));
|
||||
if (constLevel == 0) {
|
||||
builder_.Jump(&exit);
|
||||
} else if (constLevel == 1) {
|
||||
currentEnv = builder_.GetValueFromTaggedArray(*currentEnv, index);
|
||||
builder_.Jump(&exit);
|
||||
} else {
|
||||
DEFVALUE(i, (&builder_), VariableType::INT32(), builder_.Int32(0));
|
||||
Label loopHead(&builder_);
|
||||
Label loopEnd(&builder_);
|
||||
BRANCH_CIR(builder_.Int32LessThan(*i, level), &loopHead, &exit);
|
||||
builder_.LoopBegin(&loopHead);
|
||||
currentEnv = builder_.GetValueFromTaggedArray(*currentEnv, index);
|
||||
i = builder_.Int32Add(*i, builder_.Int32(1));
|
||||
BRANCH_CIR(builder_.Int32LessThan(*i, level), &loopEnd, &exit);
|
||||
builder_.Bind(&loopEnd);
|
||||
builder_.LoopEnd(&loopHead);
|
||||
}
|
||||
builder_.Bind(&exit);
|
||||
GateRef valueIndex = builder_.Int32Add(slot, builder_.Int32(SendableEnv::SENDABLE_RESERVED_ENV_LENGTH));
|
||||
GateRef result = builder_.GetValueFromTaggedArray(*currentEnv, valueIndex);
|
||||
ReplaceHirWithValue(gate, result, true);
|
||||
}
|
||||
|
||||
void SlowPathLowering::LowerStLexVar(GateRef gate)
|
||||
{
|
||||
// 4: number of value inputs
|
||||
@ -2363,6 +2424,43 @@ void SlowPathLowering::LowerStLexVar(GateRef gate)
|
||||
ReplaceHirWithValue(gate, result, true);
|
||||
}
|
||||
|
||||
void SlowPathLowering::LowerStSendableVar(GateRef gate)
|
||||
{
|
||||
// 3: number of value inputs
|
||||
ASSERT(acc_.GetNumValueIn(gate) == 3);
|
||||
GateRef level = builder_.TruncInt64ToInt32(acc_.GetValueIn(gate, 0));
|
||||
GateRef slot = builder_.TruncInt64ToInt32(acc_.GetValueIn(gate, 1));
|
||||
GateRef value = acc_.GetValueIn(gate, 2);
|
||||
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
|
||||
GateRef module = builder_.GetModuleFromFunction(jsFunc);
|
||||
DEFVALUE(currentEnv, (&builder_), VariableType::JS_ANY(), builder_.GetSendableEnvFromModule(module));
|
||||
GateRef index = builder_.Int32(SendableEnv::SENDABLE_PARENT_ENV_INDEX);
|
||||
Label exit(&builder_);
|
||||
uint64_t constLevel = acc_.TryGetValue(acc_.GetValueIn(gate, 0));
|
||||
if (constLevel == 0) {
|
||||
builder_.Jump(&exit);
|
||||
} else if (constLevel == 1) {
|
||||
currentEnv = builder_.GetValueFromTaggedArray(*currentEnv, index);
|
||||
builder_.Jump(&exit);
|
||||
} else {
|
||||
DEFVALUE(i, (&builder_), VariableType::INT32(), builder_.Int32(0));
|
||||
Label loopHead(&builder_);
|
||||
Label loopEnd(&builder_);
|
||||
BRANCH_CIR(builder_.Int32LessThan(*i, level), &loopHead, &exit);
|
||||
builder_.LoopBegin(&loopHead);
|
||||
currentEnv = builder_.GetValueFromTaggedArray(*currentEnv, index);
|
||||
i = builder_.Int32Add(*i, builder_.Int32(1));
|
||||
BRANCH_CIR(builder_.Int32LessThan(*i, level), &loopEnd, &exit);
|
||||
builder_.Bind(&loopEnd);
|
||||
builder_.LoopEnd(&loopHead);
|
||||
}
|
||||
builder_.Bind(&exit);
|
||||
GateRef valueIndex = builder_.Int32Add(slot, builder_.Int32(SendableEnv::SENDABLE_RESERVED_ENV_LENGTH));
|
||||
builder_.SetValueToTaggedArray(VariableType::JS_ANY(), glue_, *currentEnv, valueIndex, value);
|
||||
auto result = *currentEnv;
|
||||
ReplaceHirWithValue(gate, result, true);
|
||||
}
|
||||
|
||||
void SlowPathLowering::LowerDefineClassWithBuffer(GateRef gate)
|
||||
{
|
||||
// 5: number of value inputs
|
||||
|
@ -256,6 +256,7 @@ private:
|
||||
void LowerDefineFunc(GateRef gate);
|
||||
void LowerNewLexicalEnv(GateRef gate);
|
||||
void LowerNewLexicalEnvWithName(GateRef gate);
|
||||
void LowerNewSendableEnv(GateRef gate);
|
||||
void LowerPopLexicalEnv(GateRef gate);
|
||||
void LowerLdSuperByValue(GateRef gate);
|
||||
void LowerStSuperByValue(GateRef gate);
|
||||
@ -276,7 +277,9 @@ private:
|
||||
void LowerCreateGeneratorObj(GateRef gate);
|
||||
void LowerStArraySpread(GateRef gate);
|
||||
void LowerLdLexVar(GateRef gate);
|
||||
void LowerLdSendableVar(GateRef gate);
|
||||
void LowerStLexVar(GateRef gate);
|
||||
void LowerStSendableVar(GateRef gate);
|
||||
void LowerDefineClassWithBuffer(GateRef gate);
|
||||
void LowerAsyncFunctionEnter(GateRef gate);
|
||||
void LowerTypeof(GateRef gate);
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "ecmascript/mem/slots.h"
|
||||
#include "ecmascript/mem/visitor.h"
|
||||
#include "ecmascript/property_attributes.h"
|
||||
#include "ecmascript/sendable_env.h"
|
||||
|
||||
namespace panda::ecmascript::kungfu {
|
||||
using JSFunction = panda::ecmascript::JSFunction;
|
||||
@ -2726,11 +2727,21 @@ inline GateRef StubBuilder::GetParentEnv(GateRef object)
|
||||
return env_->GetBuilder()->GetParentEnv(object);
|
||||
}
|
||||
|
||||
inline GateRef StubBuilder::GetSendableParentEnv(GateRef object)
|
||||
{
|
||||
return env_->GetBuilder()->GetSendableParentEnv(object);
|
||||
}
|
||||
|
||||
inline GateRef StubBuilder::GetPropertiesFromLexicalEnv(GateRef object, GateRef index)
|
||||
{
|
||||
return env_->GetBuilder()->GetPropertiesFromLexicalEnv(object, index);
|
||||
}
|
||||
|
||||
inline GateRef StubBuilder::GetPropertiesFromSendableEnv(GateRef object, GateRef index)
|
||||
{
|
||||
return env_->GetBuilder()->GetPropertiesFromSendableEnv(object, index);
|
||||
}
|
||||
|
||||
inline GateRef StubBuilder::GetKeyFromLexivalEnv(GateRef lexicalEnv, GateRef levelIndex, GateRef slotIndex)
|
||||
{
|
||||
return env_->GetBuilder()->GetKeyFromLexivalEnv(lexicalEnv, levelIndex, slotIndex);
|
||||
@ -2742,6 +2753,12 @@ inline void StubBuilder::SetPropertiesToLexicalEnv(GateRef glue, GateRef object,
|
||||
SetValueToTaggedArray(VariableType::JS_ANY(), glue, object, valueIndex, value);
|
||||
}
|
||||
|
||||
inline void StubBuilder::SetPropertiesToSendableEnv(GateRef glue, GateRef object, GateRef index, GateRef value)
|
||||
{
|
||||
GateRef valueIndex = Int32Add(index, Int32(SendableEnv::SENDABLE_RESERVED_ENV_LENGTH));
|
||||
SetValueToTaggedArray(VariableType::JS_ANY(), glue, object, valueIndex, value);
|
||||
}
|
||||
|
||||
inline GateRef StubBuilder::GetHomeObjectFromJSFunction(GateRef object)
|
||||
{
|
||||
GateRef offset = IntPtr(JSFunction::HOME_OBJECT_OFFSET);
|
||||
|
@ -674,9 +674,12 @@ public:
|
||||
GateRef SetPropertyByValue(GateRef glue, GateRef receiver, GateRef key, GateRef value, bool useOwn,
|
||||
ProfileOperation callback = ProfileOperation(), bool defineSemantics = false);
|
||||
GateRef GetParentEnv(GateRef object);
|
||||
GateRef GetSendableParentEnv(GateRef object);
|
||||
GateRef GetPropertiesFromLexicalEnv(GateRef object, GateRef index);
|
||||
GateRef GetPropertiesFromSendableEnv(GateRef object, GateRef index);
|
||||
GateRef GetKeyFromLexivalEnv(GateRef lexicalEnv, GateRef levelIndex, GateRef slotIndex);
|
||||
void SetPropertiesToLexicalEnv(GateRef glue, GateRef object, GateRef index, GateRef value);
|
||||
void SetPropertiesToSendableEnv(GateRef glue, GateRef object, GateRef index, GateRef value);
|
||||
GateRef GetHomeObjectFromJSFunction(GateRef object);
|
||||
GateRef GetCallFieldFromMethod(GateRef method);
|
||||
inline GateRef GetBuiltinId(GateRef method);
|
||||
|
@ -245,6 +245,8 @@ CString *HeapSnapshot::GenerateNodeName(TaggedObject *entry)
|
||||
return GetArrayString(TaggedArray::Cast(entry), "ArkInternalArray[");
|
||||
case JSType::LEXICAL_ENV:
|
||||
return GetArrayString(TaggedArray::Cast(entry), "LexicalEnv[");
|
||||
case JSType::SENDABLE_ENV:
|
||||
return GetArrayString(TaggedArray::Cast(entry), "SendableEnv[");
|
||||
case JSType::CONSTANT_POOL:
|
||||
return GetArrayString(TaggedArray::Cast(entry), "ArkInternalConstantPool[");
|
||||
case JSType::PROFILE_TYPE_INFO:
|
||||
|
@ -117,6 +117,7 @@
|
||||
#include "ecmascript/shared_objects/js_shared_set.h"
|
||||
#include "ecmascript/shared_objects/js_shared_set_iterator.h"
|
||||
#include "ecmascript/shared_objects/js_shared_typed_array.h"
|
||||
#include "ecmascript/sendable_env.h"
|
||||
#include "ecmascript/tagged_array.h"
|
||||
#include "ecmascript/tagged_dictionary.h"
|
||||
#include "ecmascript/tagged_hash_array.h"
|
||||
@ -194,6 +195,8 @@ CString JSHClass::DumpJSType(JSType type)
|
||||
return "TaggedArray";
|
||||
case JSType::LEXICAL_ENV:
|
||||
return "LexicalEnv";
|
||||
case JSType::SENDABLE_ENV:
|
||||
return "SendableEnv";
|
||||
case JSType::TAGGED_DICTIONARY:
|
||||
return "TaggedDictionary";
|
||||
case JSType::CONSTANT_POOL:
|
||||
@ -792,6 +795,7 @@ static void DumpObject(TaggedObject *obj, std::ostream &os)
|
||||
case JSType::TAGGED_DICTIONARY:
|
||||
case JSType::TEMPLATE_MAP:
|
||||
case JSType::LEXICAL_ENV:
|
||||
case JSType::SENDABLE_ENV:
|
||||
case JSType::COW_TAGGED_ARRAY:
|
||||
case JSType::AOT_LITERAL_INFO:
|
||||
DumpArrayClass(TaggedArray::Cast(obj), os);
|
||||
@ -2664,6 +2668,11 @@ void LexicalEnv::Dump(std::ostream &os) const
|
||||
DumpArrayClass(this, os);
|
||||
}
|
||||
|
||||
void SendableEnv::Dump(std::ostream &os) const
|
||||
{
|
||||
DumpArrayClass(this, os);
|
||||
}
|
||||
|
||||
void COWTaggedArray::Dump(std::ostream &os) const
|
||||
{
|
||||
DumpArrayClass(this, os);
|
||||
@ -3680,6 +3689,9 @@ void SourceTextModule::Dump(std::ostream &os) const
|
||||
os << " - AsyncParentModules: ";
|
||||
GetAsyncParentModules().Dump(os);
|
||||
os << "\n";
|
||||
os << " - SendableEnv: ";
|
||||
GetSendableEnv().Dump(os);
|
||||
os << "\n";
|
||||
os << " - HasTLA: ";
|
||||
os << GetHasTLA();
|
||||
os << "\n";
|
||||
@ -3959,6 +3971,7 @@ static void DumpObject(TaggedObject *obj, std::vector<Reference> &vec, bool isVm
|
||||
case JSType::TAGGED_ARRAY:
|
||||
case JSType::TAGGED_DICTIONARY:
|
||||
case JSType::LEXICAL_ENV:
|
||||
case JSType::SENDABLE_ENV:
|
||||
case JSType::COW_TAGGED_ARRAY:
|
||||
case JSType::AOT_LITERAL_INFO:
|
||||
DumpArrayClass(TaggedArray::Cast(obj), vec);
|
||||
@ -5296,6 +5309,11 @@ void LexicalEnv::DumpForSnapshot(std::vector<Reference> &vec) const
|
||||
DumpArrayClass(this, vec);
|
||||
}
|
||||
|
||||
void SendableEnv::DumpForSnapshot(std::vector<Reference> &vec) const
|
||||
{
|
||||
DumpArrayClass(this, vec);
|
||||
}
|
||||
|
||||
void GlobalEnv::DumpForSnapshot(std::vector<Reference> &vec) const
|
||||
{
|
||||
auto globalConst = GetJSThread()->GlobalConstants();
|
||||
@ -5832,6 +5850,7 @@ void SourceTextModule::DumpForSnapshot(std::vector<Reference> &vec) const
|
||||
vec.emplace_back(CString("CycleRoot"), GetCycleRoot());
|
||||
vec.emplace_back(CString("TopLevelCapability"), GetTopLevelCapability());
|
||||
vec.emplace_back(CString("AsyncParentModules"), GetAsyncParentModules());
|
||||
vec.emplace_back(CString("SendableEnv"), GetSendableEnv());
|
||||
vec.emplace_back(CString("HasTLA"), JSTaggedValue(GetHasTLA()));
|
||||
vec.emplace_back(CString("AsyncEvaluatingOrdinal"), JSTaggedValue(GetAsyncEvaluatingOrdinal()));
|
||||
vec.emplace_back(CString("PendingAsyncDependencies"), JSTaggedValue(GetPendingAsyncDependencies()));
|
||||
|
@ -313,6 +313,7 @@ Expected<JSTaggedValue, bool> EcmaContext::CommonInvokeEcmaEntrypoint(const JSPa
|
||||
module = moduleManager_->HostGetImportedModule(moduleName);
|
||||
}
|
||||
// esm -> SourceTextModule; cjs or script -> string of recordName
|
||||
module->SetSendableEnv(thread_, JSTaggedValue::Undefined());
|
||||
func->SetModule(thread_, module);
|
||||
} else {
|
||||
// if it is Cjs at present, the module slot of the function is not used. We borrow it to store the recordName,
|
||||
|
@ -245,6 +245,8 @@ void GlobalEnvConstants::InitSharedRootsClasses(ObjectFactory *factory)
|
||||
JSType::RESOLVEDRECORDINDEXBINDING_RECORD));
|
||||
SetConstant(ConstantIndex::RESOLVED_RECORD_BINDING_CLASS_INDEX,
|
||||
factory->NewSEcmaReadOnlyHClass(hClass, ResolvedRecordBinding::SIZE, JSType::RESOLVEDRECORDBINDING_RECORD));
|
||||
SetConstant(ConstantIndex::SENDABLE_ENV_CLASS_INDEX,
|
||||
factory->NewSEcmaReadOnlyHClass(hClass, 0, JSType::SENDABLE_ENV));
|
||||
}
|
||||
|
||||
void GlobalEnvConstants::InitSharedMiscellanious(JSThread *thread, ObjectFactory *factory)
|
||||
|
@ -94,6 +94,7 @@ class ObjectFactory;
|
||||
V(JSTaggedValue, VTableClass, VTABLE_CLASS_INDEX, ecma_roots_class) \
|
||||
V(JSTaggedValue, ResolvedRecordIndexBindingClass, RESOLVED_RECORD_INEDX_BINDING_CLASS_INDEX, ecma_roots_class) \
|
||||
V(JSTaggedValue, ResolvedRecordBindingClass, RESOLVED_RECORD_BINDING_CLASS_INDEX, ecma_roots_class) \
|
||||
V(JSTaggedValue, SendableEnvClass, SENDABLE_ENV_CLASS_INDEX, ecma_roots_class) \
|
||||
|
||||
#define GLOBAL_ENV_CONSTANT_CLASS(V) \
|
||||
V(JSTaggedValue, JSProxyCallableClass, JS_PROXY_CALLABLE_CLASS_INDEX, ecma_roots_class) \
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "ecmascript/module/js_module_source_text.h"
|
||||
#include "ecmascript/runtime_call_id.h"
|
||||
#include "ecmascript/stubs/runtime_stubs.h"
|
||||
#include "ecmascript/sendable_env.h"
|
||||
#include "ecmascript/template_string.h"
|
||||
#include "ecmascript/checkpoint/thread_state_transition.h"
|
||||
#if defined(ECMASCRIPT_SUPPORT_CPUPROFILER)
|
||||
@ -1021,7 +1022,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
|
||||
constexpr size_t numOps = 0x100;
|
||||
constexpr size_t numThrowOps = 10;
|
||||
constexpr size_t numWideOps = 20;
|
||||
constexpr size_t numCallRuntimeOps = 11;
|
||||
constexpr size_t numCallRuntimeOps = 19;
|
||||
constexpr size_t numDeprecatedOps = 47;
|
||||
|
||||
static std::array<const void *, numOps> instDispatchTable {
|
||||
@ -7607,6 +7608,134 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
|
||||
SET_ACC(moduleVar);
|
||||
DISPATCH(CALLRUNTIME_WIDELDSENDABLEEXTERNALMODULEVAR_PREF_IMM16);
|
||||
}
|
||||
HANDLE_OPCODE(CALLRUNTIME_NEWSENDABLEENV_PREF_IMM8) {
|
||||
uint8_t numVars = READ_INST_8_1();
|
||||
LOG_INST() << "intrinsics::newsendableenv8"
|
||||
<< " imm " << numVars;
|
||||
|
||||
SAVE_PC();
|
||||
JSTaggedValue res = SlowRuntimeStub::NewSendableEnv(thread, numVars);
|
||||
INTERPRETER_RETURN_IF_ABRUPT(res);
|
||||
SET_ACC(res);
|
||||
SourceTextModule *moduleRecord = SourceTextModule::Cast(GetEcmaModule(sp));
|
||||
moduleRecord->SetSendableEnv(thread, res);
|
||||
DISPATCH(CALLRUNTIME_NEWSENDABLEENV_PREF_IMM8);
|
||||
}
|
||||
HANDLE_OPCODE(CALLRUNTIME_WIDENEWSENDABLEENV_PREF_IMM16) {
|
||||
uint16_t numVars = READ_INST_16_1();
|
||||
LOG_INST() << "intrinsics::newsendableenv16"
|
||||
<< " imm " << numVars;
|
||||
|
||||
SAVE_PC();
|
||||
JSTaggedValue res = SlowRuntimeStub::NewSendableEnv(thread, numVars);
|
||||
INTERPRETER_RETURN_IF_ABRUPT(res);
|
||||
SET_ACC(res);
|
||||
SourceTextModule *moduleRecord = SourceTextModule::Cast(GetEcmaModule(sp));
|
||||
moduleRecord->SetSendableEnv(thread, res);
|
||||
DISPATCH(CALLRUNTIME_WIDENEWSENDABLEENV_PREF_IMM16);
|
||||
}
|
||||
HANDLE_OPCODE(CALLRUNTIME_STSENDABLEVAR_PREF_IMM4_IMM4) {
|
||||
uint16_t level = READ_INST_4_2();
|
||||
uint16_t slot = READ_INST_4_3();
|
||||
LOG_INST() << "intrinsics::stsendablevar4"
|
||||
<< " level:" << level << " slot:" << slot;
|
||||
|
||||
JSTaggedValue value = GET_ACC();
|
||||
SourceTextModule *moduleRecord = SourceTextModule::Cast(GetEcmaModule(sp));
|
||||
JSTaggedValue env = moduleRecord->GetSendableEnv();
|
||||
for (uint32_t i = 0; i < level; i++) {
|
||||
JSTaggedValue taggedParentEnv = SendableEnv::Cast(env.GetTaggedObject())->GetParentEnv();
|
||||
ASSERT(!taggedParentEnv.IsUndefined());
|
||||
env = taggedParentEnv;
|
||||
}
|
||||
SendableEnv::Cast(env.GetTaggedObject())->SetProperties(thread, slot, value);
|
||||
|
||||
DISPATCH(CALLRUNTIME_STSENDABLEVAR_PREF_IMM4_IMM4);
|
||||
}
|
||||
HANDLE_OPCODE(CALLRUNTIME_STSENDABLEVAR_PREF_IMM8_IMM8) {
|
||||
uint16_t level = READ_INST_8_1();
|
||||
uint16_t slot = READ_INST_8_2();
|
||||
LOG_INST() << "intrinsics::stsendablevar8"
|
||||
<< " level:" << level << " slot:" << slot;
|
||||
|
||||
JSTaggedValue value = GET_ACC();
|
||||
SourceTextModule *moduleRecord = SourceTextModule::Cast(GetEcmaModule(sp));
|
||||
JSTaggedValue env = moduleRecord->GetSendableEnv();
|
||||
for (uint32_t i = 0; i < level; i++) {
|
||||
JSTaggedValue taggedParentEnv = SendableEnv::Cast(env.GetTaggedObject())->GetParentEnv();
|
||||
ASSERT(!taggedParentEnv.IsUndefined());
|
||||
env = taggedParentEnv;
|
||||
}
|
||||
SendableEnv::Cast(env.GetTaggedObject())->SetProperties(thread, slot, value);
|
||||
|
||||
DISPATCH(CALLRUNTIME_STSENDABLEVAR_PREF_IMM8_IMM8);
|
||||
}
|
||||
HANDLE_OPCODE(CALLRUNTIME_WIDESTSENDABLEVAR_PREF_IMM16_IMM16) {
|
||||
uint16_t level = READ_INST_16_1();
|
||||
uint16_t slot = READ_INST_16_3();
|
||||
LOG_INST() << "intrinsics::stsendablevar16"
|
||||
<< " level:" << level << " slot:" << slot;
|
||||
|
||||
JSTaggedValue value = GET_ACC();
|
||||
SourceTextModule *moduleRecord = SourceTextModule::Cast(GetEcmaModule(sp));
|
||||
JSTaggedValue env = moduleRecord->GetSendableEnv();
|
||||
for (uint32_t i = 0; i < level; i++) {
|
||||
JSTaggedValue taggedParentEnv = SendableEnv::Cast(env.GetTaggedObject())->GetParentEnv();
|
||||
ASSERT(!taggedParentEnv.IsUndefined());
|
||||
env = taggedParentEnv;
|
||||
}
|
||||
SendableEnv::Cast(env.GetTaggedObject())->SetProperties(thread, slot, value);
|
||||
|
||||
DISPATCH(CALLRUNTIME_WIDESTSENDABLEVAR_PREF_IMM16_IMM16);
|
||||
}
|
||||
HANDLE_OPCODE(CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4) {
|
||||
uint16_t level = READ_INST_4_2();
|
||||
uint16_t slot = READ_INST_4_3();
|
||||
|
||||
LOG_INST() << "intrinsics::ldsendablevar4"
|
||||
<< " level:" << level << " slot:" << slot;
|
||||
SourceTextModule *moduleRecord = SourceTextModule::Cast(GetEcmaModule(sp));
|
||||
JSTaggedValue env = moduleRecord->GetSendableEnv();
|
||||
for (uint32_t i = 0; i < level; i++) {
|
||||
JSTaggedValue taggedParentEnv = SendableEnv::Cast(env.GetTaggedObject())->GetParentEnv();
|
||||
ASSERT(!taggedParentEnv.IsUndefined());
|
||||
env = taggedParentEnv;
|
||||
}
|
||||
SET_ACC(SendableEnv::Cast(env.GetTaggedObject())->GetProperties(slot));
|
||||
DISPATCH(CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4);
|
||||
}
|
||||
HANDLE_OPCODE(CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8) {
|
||||
uint16_t level = READ_INST_8_1();
|
||||
uint16_t slot = READ_INST_8_2();
|
||||
|
||||
LOG_INST() << "intrinsics::ldsendablevar8"
|
||||
<< " level:" << level << " slot:" << slot;
|
||||
SourceTextModule *moduleRecord = SourceTextModule::Cast(GetEcmaModule(sp));
|
||||
JSTaggedValue env = moduleRecord->GetSendableEnv();
|
||||
for (uint32_t i = 0; i < level; i++) {
|
||||
JSTaggedValue taggedParentEnv = SendableEnv::Cast(env.GetTaggedObject())->GetParentEnv();
|
||||
ASSERT(!taggedParentEnv.IsUndefined());
|
||||
env = taggedParentEnv;
|
||||
}
|
||||
SET_ACC(SendableEnv::Cast(env.GetTaggedObject())->GetProperties(slot));
|
||||
DISPATCH(CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8);
|
||||
}
|
||||
HANDLE_OPCODE(CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16) {
|
||||
uint16_t level = READ_INST_16_1();
|
||||
uint16_t slot = READ_INST_16_3();
|
||||
|
||||
LOG_INST() << "intrinsics::ldsendablevar16"
|
||||
<< " level:" << level << " slot:" << slot;
|
||||
SourceTextModule *moduleRecord = SourceTextModule::Cast(GetEcmaModule(sp));
|
||||
JSTaggedValue env = moduleRecord->GetSendableEnv();
|
||||
for (uint32_t i = 0; i < level; i++) {
|
||||
JSTaggedValue taggedParentEnv = SendableEnv::Cast(env.GetTaggedObject())->GetParentEnv();
|
||||
ASSERT(!taggedParentEnv.IsUndefined());
|
||||
env = taggedParentEnv;
|
||||
}
|
||||
SET_ACC(SendableEnv::Cast(env.GetTaggedObject())->GetProperties(slot));
|
||||
DISPATCH(CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16);
|
||||
}
|
||||
#include "templates/debugger_instruction_handler.inl"
|
||||
}
|
||||
#endif
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "ecmascript/js_tagged_value.h"
|
||||
#include "ecmascript/mem/concurrent_marker.h"
|
||||
#include "ecmascript/runtime_call_id.h"
|
||||
#include "ecmascript/sendable_env.h"
|
||||
#include "ecmascript/template_string.h"
|
||||
#include "ecmascript/debugger/js_debugger_manager.h"
|
||||
|
||||
@ -6623,6 +6624,164 @@ void InterpreterAssembly::HandleCallRuntimeLdsendableexternalmodulevarImm8(
|
||||
DISPATCH(CALLRUNTIME_LDSENDABLEEXTERNALMODULEVAR_PREF_IMM8);
|
||||
}
|
||||
|
||||
void InterpreterAssembly::HandleCallRuntimeNewSendableEnvImm8(
|
||||
JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo,
|
||||
JSTaggedValue acc, int16_t hotnessCounter)
|
||||
{
|
||||
uint8_t numVars = READ_INST_8_1();
|
||||
LOG_INST() << "intrinsics::newsendableenv"
|
||||
<< " imm " << numVars;
|
||||
JSTaggedValue res = SlowRuntimeStub::NewSendableEnv(thread, numVars);
|
||||
INTERPRETER_RETURN_IF_ABRUPT(res);
|
||||
SET_ACC(res);
|
||||
SourceTextModule *moduleRecord = SourceTextModule::Cast(GetModule(sp));
|
||||
moduleRecord->SetSendableEnv(thread, res);
|
||||
DISPATCH(CALLRUNTIME_NEWSENDABLEENV_PREF_IMM8);
|
||||
}
|
||||
|
||||
void InterpreterAssembly::HandleCallRuntimeNewSendableEnvImm16(
|
||||
JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo,
|
||||
JSTaggedValue acc, int16_t hotnessCounter)
|
||||
{
|
||||
uint16_t numVars = READ_INST_16_1();
|
||||
LOG_INST() << "intrinsics::newsendableenv"
|
||||
<< " imm " << numVars;
|
||||
|
||||
SAVE_PC();
|
||||
JSTaggedValue res = SlowRuntimeStub::NewSendableEnv(thread, numVars);
|
||||
INTERPRETER_RETURN_IF_ABRUPT(res);
|
||||
SET_ACC(res);
|
||||
SourceTextModule *moduleRecord = SourceTextModule::Cast(GetModule(sp));
|
||||
moduleRecord->SetSendableEnv(thread, res);
|
||||
DISPATCH(CALLRUNTIME_WIDENEWSENDABLEENV_PREF_IMM16);
|
||||
}
|
||||
|
||||
void InterpreterAssembly::HandleCallRuntimeStSendableVarImm4Imm4(
|
||||
JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo,
|
||||
JSTaggedValue acc, int16_t hotnessCounter)
|
||||
{
|
||||
uint16_t level = READ_INST_4_2();
|
||||
uint16_t slot = READ_INST_4_3();
|
||||
LOG_INST() << "intrinsics::stsendablevar"
|
||||
<< " level:" << level << " slot:" << slot;
|
||||
|
||||
JSTaggedValue value = GET_ACC();
|
||||
SourceTextModule *moduleRecord = SourceTextModule::Cast(GetModule(sp));
|
||||
JSTaggedValue env = moduleRecord->GetSendableEnv();
|
||||
for (uint32_t i = 0; i < level; i++) {
|
||||
JSTaggedValue taggedParentEnv = SendableEnv::Cast(env.GetTaggedObject())->GetParentEnv();
|
||||
ASSERT(!taggedParentEnv.IsUndefined());
|
||||
env = taggedParentEnv;
|
||||
}
|
||||
SendableEnv::Cast(env.GetTaggedObject())->SetProperties(thread, slot, value);
|
||||
|
||||
DISPATCH(CALLRUNTIME_STSENDABLEVAR_PREF_IMM4_IMM4);
|
||||
}
|
||||
|
||||
void InterpreterAssembly::HandleCallRuntimeStSendableVarImm8Imm8(
|
||||
JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo,
|
||||
JSTaggedValue acc, int16_t hotnessCounter)
|
||||
{
|
||||
uint16_t level = READ_INST_8_1();
|
||||
uint16_t slot = READ_INST_8_2();
|
||||
LOG_INST() << "intrinsics::stsendablevar"
|
||||
<< " level:" << level << " slot:" << slot;
|
||||
|
||||
JSTaggedValue value = GET_ACC();
|
||||
SourceTextModule *moduleRecord = SourceTextModule::Cast(GetModule(sp));
|
||||
JSTaggedValue env = moduleRecord->GetSendableEnv();
|
||||
for (uint32_t i = 0; i < level; i++) {
|
||||
JSTaggedValue taggedParentEnv = SendableEnv::Cast(env.GetTaggedObject())->GetParentEnv();
|
||||
ASSERT(!taggedParentEnv.IsUndefined());
|
||||
env = taggedParentEnv;
|
||||
}
|
||||
SendableEnv::Cast(env.GetTaggedObject())->SetProperties(thread, slot, value);
|
||||
|
||||
DISPATCH(CALLRUNTIME_STSENDABLEVAR_PREF_IMM8_IMM8);
|
||||
}
|
||||
|
||||
void InterpreterAssembly::HandleCallRuntimeStSendableVarImm16Imm16(
|
||||
JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo,
|
||||
JSTaggedValue acc, int16_t hotnessCounter)
|
||||
{
|
||||
uint16_t level = READ_INST_16_1();
|
||||
uint16_t slot = READ_INST_16_3();
|
||||
LOG_INST() << "intrinsics::stsendablevar"
|
||||
<< " level:" << level << " slot:" << slot;
|
||||
|
||||
JSTaggedValue value = GET_ACC();
|
||||
SourceTextModule *moduleRecord = SourceTextModule::Cast(GetModule(sp));
|
||||
JSTaggedValue env = moduleRecord->GetSendableEnv();
|
||||
for (uint32_t i = 0; i < level; i++) {
|
||||
JSTaggedValue taggedParentEnv = SendableEnv::Cast(env.GetTaggedObject())->GetParentEnv();
|
||||
ASSERT(!taggedParentEnv.IsUndefined());
|
||||
env = taggedParentEnv;
|
||||
}
|
||||
SendableEnv::Cast(env.GetTaggedObject())->SetProperties(thread, slot, value);
|
||||
|
||||
DISPATCH(CALLRUNTIME_WIDESTSENDABLEVAR_PREF_IMM16_IMM16);
|
||||
}
|
||||
|
||||
void InterpreterAssembly::HandleCallRuntimeLdSendableVarImm4Imm4(
|
||||
JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo,
|
||||
JSTaggedValue acc, int16_t hotnessCounter)
|
||||
{
|
||||
uint16_t level = READ_INST_4_2();
|
||||
uint16_t slot = READ_INST_4_3();
|
||||
|
||||
LOG_INST() << "intrinsics::ldsendablevar"
|
||||
<< " level:" << level << " slot:" << slot;
|
||||
SourceTextModule *moduleRecord = SourceTextModule::Cast(GetModule(sp));
|
||||
JSTaggedValue env = moduleRecord->GetSendableEnv();
|
||||
for (uint32_t i = 0; i < level; i++) {
|
||||
JSTaggedValue taggedParentEnv = SendableEnv::Cast(env.GetTaggedObject())->GetParentEnv();
|
||||
ASSERT(!taggedParentEnv.IsUndefined());
|
||||
env = taggedParentEnv;
|
||||
}
|
||||
SET_ACC(SendableEnv::Cast(env.GetTaggedObject())->GetProperties(slot));
|
||||
DISPATCH(CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4);
|
||||
}
|
||||
|
||||
void InterpreterAssembly::HandleCallRuntimeLdSendableVarImm8Imm8(
|
||||
JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo,
|
||||
JSTaggedValue acc, int16_t hotnessCounter)
|
||||
{
|
||||
uint16_t level = READ_INST_8_1();
|
||||
uint16_t slot = READ_INST_8_2();
|
||||
|
||||
LOG_INST() << "intrinsics::ldsendablevar"
|
||||
<< " level:" << level << " slot:" << slot;
|
||||
SourceTextModule *moduleRecord = SourceTextModule::Cast(GetModule(sp));
|
||||
JSTaggedValue env = moduleRecord->GetSendableEnv();
|
||||
for (uint32_t i = 0; i < level; i++) {
|
||||
JSTaggedValue taggedParentEnv = SendableEnv::Cast(env.GetTaggedObject())->GetParentEnv();
|
||||
ASSERT(!taggedParentEnv.IsUndefined());
|
||||
env = taggedParentEnv;
|
||||
}
|
||||
SET_ACC(SendableEnv::Cast(env.GetTaggedObject())->GetProperties(slot));
|
||||
DISPATCH(CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8);
|
||||
}
|
||||
|
||||
void InterpreterAssembly::HandleCallRuntimeLdSendableVarImm16Imm16(
|
||||
JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo,
|
||||
JSTaggedValue acc, int16_t hotnessCounter)
|
||||
{
|
||||
uint16_t level = READ_INST_16_1();
|
||||
uint16_t slot = READ_INST_16_3();
|
||||
|
||||
LOG_INST() << "intrinsics::ldsendablevar"
|
||||
<< " level:" << level << " slot:" << slot;
|
||||
SourceTextModule *moduleRecord = SourceTextModule::Cast(GetModule(sp));
|
||||
JSTaggedValue env = moduleRecord->GetSendableEnv();
|
||||
for (uint32_t i = 0; i < level; i++) {
|
||||
JSTaggedValue taggedParentEnv = SendableEnv::Cast(env.GetTaggedObject())->GetParentEnv();
|
||||
ASSERT(!taggedParentEnv.IsUndefined());
|
||||
env = taggedParentEnv;
|
||||
}
|
||||
SET_ACC(SendableEnv::Cast(env.GetTaggedObject())->GetProperties(slot));
|
||||
DISPATCH(CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16);
|
||||
}
|
||||
|
||||
void InterpreterAssembly::HandleDefinemethodImm16Id16Imm8(
|
||||
JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo,
|
||||
JSTaggedValue acc, int16_t hotnessCounter)
|
||||
|
@ -409,6 +409,14 @@ JSTaggedValue SlowRuntimeStub::NewLexicalEnv(JSThread *thread, uint16_t numVars)
|
||||
return RuntimeStubs::RuntimeNewLexicalEnv(thread, numVars);
|
||||
}
|
||||
|
||||
JSTaggedValue SlowRuntimeStub::NewSendableEnv(JSThread *thread, uint16_t numVars)
|
||||
{
|
||||
INTERPRETER_TRACE(thread, NewSendableEnv);
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
|
||||
return RuntimeStubs::RuntimeNewSendableEnv(thread, numVars);
|
||||
}
|
||||
|
||||
JSTaggedValue SlowRuntimeStub::NewLexicalEnvWithName(JSThread *thread, uint16_t numVars, uint16_t scopeId)
|
||||
{
|
||||
INTERPRETER_TRACE(thread, NewlexenvwithName);
|
||||
|
@ -70,6 +70,7 @@ public:
|
||||
JSTaggedValue instOfHandler);
|
||||
|
||||
static JSTaggedValue NewLexicalEnv(JSThread *thread, uint16_t numVars);
|
||||
static JSTaggedValue NewSendableEnv(JSThread *thread, uint16_t numVars);
|
||||
static JSTaggedValue NewLexicalEnvWithName(JSThread *thread, uint16_t numVars, uint16_t scopeId);
|
||||
static JSTaggedValue CreateIterResultObj(JSThread *thread, JSTaggedValue value, JSTaggedValue flag);
|
||||
|
||||
|
@ -23,4 +23,12 @@
|
||||
&&HANDLE_CALLRUNTIME_DEFINESENDABLECLASS_PREF_IMM16_ID16_ID16_IMM16_V8,
|
||||
&&HANDLE_CALLRUNTIME_LDSENDABLECLASS_PREF_IMM16,
|
||||
&&HANDLE_CALLRUNTIME_LDSENDABLEEXTERNALMODULEVAR_PREF_IMM8,
|
||||
&&HANDLE_CALLRUNTIME_WIDELDSENDABLEEXTERNALMODULEVAR_PREF_IMM16,
|
||||
&&HANDLE_CALLRUNTIME_WIDELDSENDABLEEXTERNALMODULEVAR_PREF_IMM16,
|
||||
&&HANDLE_CALLRUNTIME_NEWSENDABLEENV_PREF_IMM8,
|
||||
&&HANDLE_CALLRUNTIME_WIDENEWSENDABLEENV_PREF_IMM16,
|
||||
&&HANDLE_CALLRUNTIME_STSENDABLEVAR_PREF_IMM4_IMM4,
|
||||
&&HANDLE_CALLRUNTIME_STSENDABLEVAR_PREF_IMM8_IMM8,
|
||||
&&HANDLE_CALLRUNTIME_WIDESTSENDABLEVAR_PREF_IMM16_IMM16,
|
||||
&&HANDLE_CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4,
|
||||
&&HANDLE_CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8,
|
||||
&&HANDLE_CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16,
|
@ -194,6 +194,7 @@ inline size_t JSHClass::SizeFromJSHClass(TaggedObject *header)
|
||||
case JSType::TAGGED_ARRAY:
|
||||
case JSType::TAGGED_DICTIONARY:
|
||||
case JSType::LEXICAL_ENV:
|
||||
case JSType::SENDABLE_ENV:
|
||||
case JSType::CONSTANT_POOL:
|
||||
case JSType::AOT_LITERAL_INFO:
|
||||
case JSType::VTABLE:
|
||||
|
@ -234,6 +234,7 @@ struct Reference;
|
||||
MUTANT_TAGGED_ARRAY, /* ///////////////////////////////////////////////////////////////////////////-PADDING */ \
|
||||
BYTE_ARRAY, /* //////////////////////////////////////////////////////////////////////////////////-PADDING */ \
|
||||
LEXICAL_ENV, /* //////////////////////////////////////////////////////////////////////////////////-PADDING */ \
|
||||
SENDABLE_ENV, /* //////////////////////////////////////////////////////////////////////////////////-PADDING */\
|
||||
TAGGED_DICTIONARY, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \
|
||||
CONSTANT_POOL, /* /////////////////////////////////////////////////////////////////////////////////-PADDING */ \
|
||||
PROFILE_TYPE_INFO, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \
|
||||
@ -647,6 +648,7 @@ public:
|
||||
case JSType::TAGGED_ARRAY:
|
||||
case JSType::TAGGED_DICTIONARY:
|
||||
case JSType::LEXICAL_ENV:
|
||||
case JSType::SENDABLE_ENV:
|
||||
case JSType::CONSTANT_POOL:
|
||||
case JSType::PROFILE_TYPE_INFO:
|
||||
case JSType::AOT_LITERAL_INFO:
|
||||
|
@ -200,6 +200,12 @@ JSTaggedValue JSThread::GetCurrentLexenv() const
|
||||
return frameHandler.GetEnv();
|
||||
}
|
||||
|
||||
JSTaggedValue JSThread::GetCurrentFunction() const
|
||||
{
|
||||
FrameHandler frameHandler(this);
|
||||
return frameHandler.GetFunction();
|
||||
}
|
||||
|
||||
const JSTaggedType *JSThread::GetCurrentFrame() const
|
||||
{
|
||||
if (IsAsmInterpreter()) {
|
||||
|
@ -343,6 +343,7 @@ public:
|
||||
}
|
||||
|
||||
JSTaggedValue GetCurrentLexenv() const;
|
||||
JSTaggedValue GetCurrentFunction() const;
|
||||
|
||||
void RegisterRTInterface(size_t id, Address addr)
|
||||
{
|
||||
|
@ -435,8 +435,7 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::LazyExecuteModule(
|
||||
LOG_FULL(INFO) << "recordName : " << recordName << ", in abc : " << filename;
|
||||
CString traceInfo = "JSPandaFileExecutor::LazyExecuteModule " + filename;
|
||||
ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, traceInfo.c_str());
|
||||
EcmaVM *vm = thread->GetEcmaVM();
|
||||
CString newFileName = ModulePathHelper::ParseUrl(vm, recordName);
|
||||
CString newFileName = filename;
|
||||
if (newFileName.empty()) {
|
||||
newFileName = filename;
|
||||
}
|
||||
|
@ -284,6 +284,7 @@ JSHandle<JSFunction> LiteralDataExtractor::DefineMethodInLiteral(JSThread *threa
|
||||
FunctionKind kind, uint16_t length,
|
||||
const CString &entryPoint,
|
||||
bool isLoadedAOT, uint32_t entryIndex,
|
||||
JSHandle<JSTaggedValue> sendableEnv,
|
||||
ClassKind classKind)
|
||||
{
|
||||
EcmaVM *vm = thread->GetEcmaVM();
|
||||
@ -304,6 +305,10 @@ JSHandle<JSFunction> LiteralDataExtractor::DefineMethodInLiteral(JSThread *threa
|
||||
JSHandle<JSFunction> jsFunc = CreateJSFunctionInLiteral(vm, method, kind, classKind);
|
||||
JSHandle<JSTaggedValue> module = SharedModuleManager::GetInstance()->GenerateFuncModule(thread, jsPandaFile,
|
||||
entryPoint, classKind);
|
||||
if (module->GetTaggedObject()->GetClass()->IsSourceTextModule()) {
|
||||
SourceTextModule::Cast(module->GetTaggedObject())->SetSendableEnv(thread, sendableEnv);
|
||||
}
|
||||
|
||||
jsFunc->SetModule(thread, module.GetTaggedValue());
|
||||
if (thread->GetCurrentEcmaContext()->GetStageOfColdReload() == StageOfColdReload::COLD_RELOADING) {
|
||||
QuickFixManager::SetPatchModule(thread, method, jsFunc);
|
||||
@ -472,7 +477,9 @@ JSHandle<TaggedArray> LiteralDataExtractor::GetDatasIgnoreType(JSThread *thread,
|
||||
EntityId id, JSHandle<ConstantPool> constpool,
|
||||
const CString &entryPoint, bool isLoadedAOT,
|
||||
JSHandle<AOTLiteralInfo> entryIndexes,
|
||||
ElementsKind *newKind, ClassKind classKind)
|
||||
ElementsKind *newKind,
|
||||
JSHandle<JSTaggedValue> sendableEnv,
|
||||
ClassKind classKind)
|
||||
{
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
LiteralDataAccessor lda = jsPandaFile->GetLiteralDataAccessor();
|
||||
@ -488,8 +495,8 @@ JSHandle<TaggedArray> LiteralDataExtractor::GetDatasIgnoreType(JSThread *thread,
|
||||
FunctionKind kind;
|
||||
int index = 0;
|
||||
lda.EnumerateLiteralVals(
|
||||
id, [literals, &pos, factory, thread, jsPandaFile,
|
||||
&methodId, &kind, &constpool, &entryPoint, &entryIndexes, &index, isLoadedAOT, newKind, classKind]
|
||||
id, [literals, &pos, factory, thread, jsPandaFile, &methodId, &kind, &constpool,
|
||||
&entryPoint, &entryIndexes, &index, isLoadedAOT, newKind, classKind, &sendableEnv]
|
||||
(const LiteralValue &value, const LiteralTag &tag) {
|
||||
JSTaggedValue jt = JSTaggedValue::Null();
|
||||
switch (tag) {
|
||||
@ -548,7 +555,7 @@ JSHandle<TaggedArray> LiteralDataExtractor::GetDatasIgnoreType(JSThread *thread,
|
||||
}
|
||||
JSHandle<JSFunction> jsFunc =
|
||||
DefineMethodInLiteral(thread, jsPandaFile, methodId, constpool,
|
||||
kind, length, entryPoint, needSetAotFlag, entryIndex, classKind);
|
||||
kind, length, entryPoint, needSetAotFlag, entryIndex, sendableEnv, classKind);
|
||||
jt = jsFunc.GetTaggedValue();
|
||||
break;
|
||||
}
|
||||
|
@ -47,7 +47,8 @@ public:
|
||||
static PUBLIC_API JSHandle<TaggedArray> GetDatasIgnoreType(JSThread *thread, const JSPandaFile *jsPandaFile,
|
||||
EntityId id, JSHandle<ConstantPool> constpool, const CString &entryPoint = "",
|
||||
bool isLoadedAOT = false, JSHandle<AOTLiteralInfo> entryIndexes = JSHandle<AOTLiteralInfo>(),
|
||||
ElementsKind *newKind = nullptr, ClassKind classKind = ClassKind::NON_SENDABLE);
|
||||
ElementsKind *newKind = nullptr, JSHandle<JSTaggedValue> sendableEnv = JSHandle<JSTaggedValue>(),
|
||||
ClassKind classKind = ClassKind::NON_SENDABLE);
|
||||
static JSHandle<TaggedArray> GetDatasIgnoreTypeForClass(JSThread *thread, const JSPandaFile *jsPandaFile,
|
||||
size_t index, JSHandle<ConstantPool> constpool,
|
||||
const CString &entryPoint = "");
|
||||
@ -57,6 +58,7 @@ public:
|
||||
FunctionKind kind, uint16_t length,
|
||||
const CString &entryPoint = "",
|
||||
bool isLoadedAOT = false, uint32_t entryIndex = 0,
|
||||
JSHandle<JSTaggedValue> sendableEnv = JSHandle<JSTaggedValue>(),
|
||||
ClassKind classKind = ClassKind::NON_SENDABLE);
|
||||
|
||||
static void PUBLIC_API GetMethodOffsets(const JSPandaFile *jsPandaFile, size_t index,
|
||||
|
@ -494,7 +494,8 @@ public:
|
||||
static JSTaggedValue PUBLIC_API GetMethodFromCache(JSTaggedValue constpool, uint32_t index);
|
||||
|
||||
static JSTaggedValue GetClassLiteralFromCache(JSThread *thread, JSHandle<ConstantPool> constpool,
|
||||
uint32_t literal, CString entry, ClassKind kind = ClassKind::NON_SENDABLE)
|
||||
uint32_t literal, CString entry, JSHandle<JSTaggedValue> sendableEnv = JSHandle<JSTaggedValue>(),
|
||||
ClassKind kind = ClassKind::NON_SENDABLE)
|
||||
{
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
// Do not use cache when sendable for get wrong obj from cache,
|
||||
@ -516,8 +517,8 @@ public:
|
||||
ASSERT(jsPandaFile->IsNewVersion());
|
||||
panda_file::File::EntityId literalId = constpool->GetEntityId(literal);
|
||||
bool needSetAotFlag = isLoadedAOT && !entryIndexes.GetTaggedValue().IsUndefined();
|
||||
JSHandle<TaggedArray> literalArray = LiteralDataExtractor::GetDatasIgnoreType(
|
||||
thread, jsPandaFile, literalId, constpool, entry, needSetAotFlag, entryIndexes, nullptr, kind);
|
||||
JSHandle<TaggedArray> literalArray = LiteralDataExtractor::GetDatasIgnoreType(thread,
|
||||
jsPandaFile, literalId, constpool, entry, needSetAotFlag, entryIndexes, nullptr, sendableEnv, kind);
|
||||
JSHandle<ClassLiteral> classLiteral;
|
||||
if (kind == ClassKind::SENDABLE) {
|
||||
classLiteral = factory->NewSClassLiteral();
|
||||
|
@ -428,6 +428,7 @@ public:
|
||||
case JSType::TAGGED_DICTIONARY:
|
||||
case JSType::TEMPLATE_MAP:
|
||||
case JSType::LEXICAL_ENV:
|
||||
case JSType::SENDABLE_ENV:
|
||||
case JSType::AOT_LITERAL_INFO:
|
||||
case JSType::VTABLE:
|
||||
case JSType::COW_TAGGED_ARRAY:
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "ecmascript/module/js_module_record.h"
|
||||
#include "ecmascript/module/js_module_entry.h"
|
||||
#include "ecmascript/tagged_array.h"
|
||||
#include "ecmascript/sendable_env.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
struct StateVisit;
|
||||
@ -227,7 +228,8 @@ public:
|
||||
ACCESSORS(NameDictionary, NAME_DICTIONARY_OFFSET, CYCLE_ROOT_OFFSET);
|
||||
ACCESSORS(CycleRoot, CYCLE_ROOT_OFFSET, TOP_LEVEL_CAPABILITY_OFFSET);
|
||||
ACCESSORS(TopLevelCapability, TOP_LEVEL_CAPABILITY_OFFSET, ASYNC_PARENT_MODULES_OFFSET);
|
||||
ACCESSORS(AsyncParentModules, ASYNC_PARENT_MODULES_OFFSET, EVALUATION_ERROR_OFFSET);
|
||||
ACCESSORS(AsyncParentModules, ASYNC_PARENT_MODULES_OFFSET, SENDABLE_ENV_OFFSET);
|
||||
ACCESSORS(SendableEnv, SENDABLE_ENV_OFFSET, EVALUATION_ERROR_OFFSET);
|
||||
ACCESSORS_PRIMITIVE_FIELD(EvaluationError, int32_t, EVALUATION_ERROR_OFFSET, DFS_ANCESTOR_INDEX_OFFSET);
|
||||
ACCESSORS_PRIMITIVE_FIELD(DFSAncestorIndex, int32_t, DFS_ANCESTOR_INDEX_OFFSET, DFS_INDEX_OFFSET);
|
||||
ACCESSORS_PRIMITIVE_FIELD(DFSIndex, int32_t, DFS_INDEX_OFFSET, ASYNC_EVALUATION_OFFSET);
|
||||
|
@ -43,6 +43,7 @@ JSHandle<JSTaggedValue> SendableClassModule::GenerateSendableFuncModule(JSThread
|
||||
sModule->SetEnvironment(thread, sendableEnvironment);
|
||||
sModule->SetEcmaModuleFilename(thread, currentModule->GetEcmaModuleFilename());
|
||||
sModule->SetEcmaModuleRecordName(thread, currentModule->GetEcmaModuleRecordName());
|
||||
sModule->SetSendableEnv(thread, JSTaggedValue::Undefined());
|
||||
return JSHandle<JSTaggedValue>(sModule);
|
||||
}
|
||||
|
||||
|
@ -4580,6 +4580,7 @@ JSHandle<SourceTextModule> ObjectFactory::NewSourceTextModule()
|
||||
obj->SetIsNewBcVersion(false);
|
||||
obj->SetRegisterCounts(UINT16_MAX);
|
||||
obj->SetSharedType(SharedTypes::UNSENDABLE_MODULE);
|
||||
obj->SetSendableEnv(thread_, undefinedValue);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@ class GlobalEnvConstants;
|
||||
class AccessorData;
|
||||
class JSGlobalObject;
|
||||
class LexicalEnv;
|
||||
class SendableEnv;
|
||||
class JSDate;
|
||||
class JSProxy;
|
||||
class JSRealm;
|
||||
@ -846,6 +847,7 @@ public:
|
||||
JSHandle<JSSymbol> NewSPublicSymbolWithChar(std::string_view description);
|
||||
JSHandle<JSSymbol> NewSPublicSymbol(const JSHandle<JSTaggedValue> &name);
|
||||
JSHandle<Method> CloneMethodTemporaryForJIT(JSHandle<Method> method);
|
||||
JSHandle<SendableEnv> NewSendableEnv(int numSlots);
|
||||
|
||||
private:
|
||||
friend class GlobalEnv;
|
||||
|
@ -95,6 +95,7 @@ namespace panda::ecmascript {
|
||||
V(CallSpread) \
|
||||
V(Newlexenv) \
|
||||
V(NewlexenvwithName) \
|
||||
V(NewSendableEnv) \
|
||||
V(Stlexvar) \
|
||||
V(Ldlexvar) \
|
||||
V(Ldlexenv) \
|
||||
|
73
ecmascript/sendable_env.h
Normal file
73
ecmascript/sendable_env.h
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef ECMASCRIPT_SENDABLEENV_H
|
||||
#define ECMASCRIPT_SENDABLEENV_H
|
||||
|
||||
#include "ecmascript/js_object.h"
|
||||
#include "ecmascript/tagged_array-inl.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
class SendableEnv : public TaggedArray {
|
||||
public:
|
||||
static constexpr uint32_t SENDABLE_PARENT_ENV_INDEX = 0;
|
||||
static constexpr uint32_t SENDABLE_SCOPE_INFO_INDEX = 1;
|
||||
static constexpr uint32_t SENDABLE_RESERVED_ENV_LENGTH = 2;
|
||||
|
||||
static SendableEnv *Cast(TaggedObject *object)
|
||||
{
|
||||
ASSERT(JSTaggedValue(object).IsTaggedArray());
|
||||
return static_cast<SendableEnv *>(object);
|
||||
}
|
||||
|
||||
static size_t ComputeSize(uint32_t numSlots)
|
||||
{
|
||||
return TaggedArray::ComputeSize(JSTaggedValue::TaggedTypeSize(), numSlots + SENDABLE_RESERVED_ENV_LENGTH);
|
||||
}
|
||||
|
||||
void SetParentEnv(JSThread *thread, JSTaggedValue value)
|
||||
{
|
||||
Set(thread, SENDABLE_PARENT_ENV_INDEX, value);
|
||||
}
|
||||
|
||||
JSTaggedValue GetParentEnv() const
|
||||
{
|
||||
return Get(SENDABLE_PARENT_ENV_INDEX);
|
||||
}
|
||||
|
||||
JSTaggedValue GetProperties(uint32_t index) const
|
||||
{
|
||||
return Get(index + SENDABLE_RESERVED_ENV_LENGTH);
|
||||
}
|
||||
|
||||
void SetProperties(JSThread *thread, uint32_t index, JSTaggedValue value)
|
||||
{
|
||||
Set(thread, index + SENDABLE_RESERVED_ENV_LENGTH, value);
|
||||
}
|
||||
|
||||
JSTaggedValue GetScopeInfo() const
|
||||
{
|
||||
return Get(SENDABLE_SCOPE_INFO_INDEX);
|
||||
}
|
||||
|
||||
void SetScopeInfo(JSThread *thread, JSTaggedValue value)
|
||||
{
|
||||
Set(thread, SENDABLE_SCOPE_INFO_INDEX, value);
|
||||
}
|
||||
|
||||
DECL_DUMP()
|
||||
};
|
||||
} // namespace panda::ecmascript
|
||||
#endif // ECMASCRIPT_SENDABLEENV_H
|
@ -115,6 +115,9 @@ bool BaseSerializer::SerializeSpecialObjIndividually(JSType objectType, TaggedOb
|
||||
case JSType::LEXICAL_ENV:
|
||||
SerializeLexicalEnvFieldIndividually(root, start, end);
|
||||
return true;
|
||||
case JSType::SENDABLE_ENV:
|
||||
SerializeSendableEnvFieldIndividually(root, start, end);
|
||||
return true;
|
||||
case JSType::JS_SHARED_FUNCTION:
|
||||
SerializeSFunctionFieldIndividually(root, start, end);
|
||||
return true;
|
||||
@ -250,6 +253,29 @@ void BaseSerializer::SerializeLexicalEnvFieldIndividually(TaggedObject *root, Ob
|
||||
}
|
||||
}
|
||||
|
||||
void BaseSerializer::SerializeSendableEnvFieldIndividually(TaggedObject *root, ObjectSlot start, ObjectSlot end)
|
||||
{
|
||||
ASSERT(root->GetClass()->GetObjectType() == JSType::SENDABLE_ENV);
|
||||
ObjectSlot slot = start;
|
||||
while (slot < end) {
|
||||
size_t fieldOffset = slot.SlotAddress() - ToUintPtr(root);
|
||||
switch (fieldOffset) {
|
||||
case PARENT_ENV_SLOT:
|
||||
case SCOPE_INFO_SLOT: {
|
||||
data_->WriteEncodeFlag(EncodeFlag::PRIMITIVE);
|
||||
data_->WriteJSTaggedValue(JSTaggedValue::Hole());
|
||||
slot++;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
SerializeJSTaggedValue(JSTaggedValue(slot.GetTaggedType()));
|
||||
slot++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BaseSerializer::SerializeAsyncFunctionFieldIndividually(TaggedObject *root, ObjectSlot start, ObjectSlot end)
|
||||
{
|
||||
ASSERT(root->GetClass()->GetObjectType() == JSType::JS_ASYNC_FUNCTION);
|
||||
|
@ -58,6 +58,7 @@ protected:
|
||||
void SerializeSFunctionFieldIndividually(TaggedObject *root, ObjectSlot start, ObjectSlot end);
|
||||
void SerializeSFunctionModule(JSFunction *func);
|
||||
void SerializeLexicalEnvFieldIndividually(TaggedObject *root, ObjectSlot start, ObjectSlot end);
|
||||
void SerializeSendableEnvFieldIndividually(TaggedObject *root, ObjectSlot start, ObjectSlot end);
|
||||
void SerializeAsyncFunctionFieldIndividually(TaggedObject *root, ObjectSlot start, ObjectSlot end);
|
||||
void SerializeObjectProto(JSHClass *kclass, JSTaggedValue proto);
|
||||
void SerializeTaggedObjField(SerializeType serializeType, TaggedObject *root, ObjectSlot start, ObjectSlot end);
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "ecmascript/jspandafile/program_object.h"
|
||||
#include "ecmascript/module/js_module_source_text.h"
|
||||
#include "ecmascript/module/js_shared_module.h"
|
||||
#include "ecmascript/sendable_env.h"
|
||||
|
||||
// class Object;
|
||||
namespace panda::ecmascript {
|
||||
@ -667,6 +668,7 @@ JSHandle<SourceTextModule> ObjectFactory::NewSSourceTextModule()
|
||||
obj->SetIsNewBcVersion(false);
|
||||
obj->SetRegisterCounts(UINT16_MAX);
|
||||
obj->SetSharedType(SharedTypes::UNSENDABLE_MODULE);
|
||||
obj->SetSendableEnv(thread_, undefinedValue);
|
||||
return obj;
|
||||
}
|
||||
|
||||
@ -826,4 +828,15 @@ JSHandle<AOTLiteralInfo> ObjectFactory::NewSAOTLiteralInfo(uint32_t length, JSTa
|
||||
aotLiteralInfo->InitializeWithSpecialValue(initVal, length);
|
||||
return aotLiteralInfo;
|
||||
}
|
||||
|
||||
JSHandle<SendableEnv> ObjectFactory::NewSendableEnv(int numSlots)
|
||||
{
|
||||
NewObjectHook();
|
||||
size_t size = SendableEnv::ComputeSize(numSlots);
|
||||
auto header = sHeap_->AllocateOldOrHugeObject(thread_,
|
||||
JSHClass::Cast(sHeap_->GetGlobalConst()->GetSendableEnvClass().GetTaggedObject()), size);
|
||||
JSHandle<SendableEnv> array(thread_, header);
|
||||
array->InitializeWithSpecialValue(JSTaggedValue::Hole(), numSlots + SendableEnv::SENDABLE_RESERVED_ENV_LENGTH);
|
||||
return array;
|
||||
}
|
||||
} // namespace panda::ecmascript
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "ecmascript/platform/file.h"
|
||||
#include "ecmascript/runtime.h"
|
||||
#include "ecmascript/stackmap/llvm/llvm_stackmap_parser.h"
|
||||
#include "ecmascript/sendable_env.h"
|
||||
#include "ecmascript/template_string.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
@ -896,7 +897,12 @@ JSTaggedValue RuntimeStubs::RuntimeCreateClassWithBuffer(JSThread *thread,
|
||||
chc.Update(aotLiteralInfo->GetChc());
|
||||
}
|
||||
|
||||
JSTaggedValue literalObj = ConstantPool::GetClassLiteralFromCache(thread, cp, literalId, entry);
|
||||
JSHandle<JSTaggedValue> sendableEnv(thread, JSTaggedValue::Undefined());
|
||||
if (module->GetTaggedObject()->GetClass()->IsSourceTextModule()) {
|
||||
JSHandle<SourceTextModule> moduleRecord = JSHandle<SourceTextModule>::Cast(module);
|
||||
sendableEnv = JSHandle<JSTaggedValue>(thread, moduleRecord->GetSendableEnv());
|
||||
}
|
||||
JSTaggedValue literalObj = ConstantPool::GetClassLiteralFromCache(thread, cp, literalId, entry, sendableEnv);
|
||||
|
||||
JSHandle<ClassLiteral> classLiteral(thread, literalObj);
|
||||
JSHandle<TaggedArray> arrayHandle(thread, classLiteral->GetArray());
|
||||
@ -946,8 +952,13 @@ JSTaggedValue RuntimeStubs::RuntimeCreateSharedClass(JSThread *thread,
|
||||
JSHandle<JSTaggedValue> method(thread, methodObj);
|
||||
JSHandle<ConstantPool> constpoolHandle = JSHandle<ConstantPool>::Cast(constpool);
|
||||
|
||||
auto literalObj =
|
||||
ConstantPool::GetClassLiteralFromCache(thread, constpoolHandle, literalId, entry, ClassKind::SENDABLE);
|
||||
JSHandle<JSTaggedValue> sendableEnv(thread, JSTaggedValue::Undefined());
|
||||
if (module->GetTaggedObject()->GetClass()->IsSourceTextModule()) {
|
||||
JSHandle<SourceTextModule> moduleRecord = JSHandle<SourceTextModule>::Cast(module);
|
||||
sendableEnv = JSHandle<JSTaggedValue>(thread, moduleRecord->GetSendableEnv());
|
||||
}
|
||||
auto literalObj = ConstantPool::GetClassLiteralFromCache(
|
||||
thread, constpoolHandle, literalId, entry, sendableEnv, ClassKind::SENDABLE);
|
||||
JSHandle<ClassLiteral> classLiteral(thread, literalObj);
|
||||
JSHandle<TaggedArray> arrayHandle(thread, classLiteral->GetArray());
|
||||
auto literalLength = arrayHandle->GetLength();
|
||||
@ -965,6 +976,8 @@ JSTaggedValue RuntimeStubs::RuntimeCreateSharedClass(JSThread *thread,
|
||||
SendableClassDefiner::DefineSendableClassFromExtractor(thread, extractor, staticFieldArray);
|
||||
ModuleManager *moduleManager = thread->GetCurrentEcmaContext()->GetModuleManager();
|
||||
JSHandle<JSTaggedValue> sendableClsModule = moduleManager->GenerateSendableFuncModule(module);
|
||||
JSHandle<SourceTextModule> sendableClsModuleRecord(sendableClsModule);
|
||||
sendableClsModuleRecord->SetSendableEnv(thread, sendableEnv);
|
||||
cls->SetModule(thread, sendableClsModule.GetTaggedValue());
|
||||
RuntimeSetClassConstructorLength(thread, cls.GetTaggedValue(), JSTaggedValue(length));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
@ -2079,6 +2092,19 @@ JSTaggedValue RuntimeStubs::RuntimeNewLexicalEnv(JSThread *thread, uint16_t numV
|
||||
return newEnv.GetTaggedValue();
|
||||
}
|
||||
|
||||
JSTaggedValue RuntimeStubs::RuntimeNewSendableEnv(JSThread *thread, uint16_t numVars)
|
||||
{
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<SendableEnv> newEnv = factory->NewSendableEnv(numVars);
|
||||
|
||||
JSTaggedValue module = JSFunction::Cast(thread->GetCurrentFunction())->GetModule();
|
||||
JSHandle<SourceTextModule> moduleHandle(thread, module);
|
||||
newEnv->SetParentEnv(thread, moduleHandle->GetSendableEnv());
|
||||
newEnv->SetScopeInfo(thread, JSTaggedValue::Hole());
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
return newEnv.GetTaggedValue();
|
||||
}
|
||||
|
||||
JSTaggedValue RuntimeStubs::RuntimeNewObjRange(JSThread *thread, const JSHandle<JSTaggedValue> &func,
|
||||
const JSHandle<JSTaggedValue> &newTarget, uint16_t firstArgIdx, uint16_t length)
|
||||
{
|
||||
|
@ -2681,6 +2681,13 @@ DEF_RUNTIME_STUBS(NewLexicalEnvWithName)
|
||||
static_cast<uint16_t>(scopeId.GetInt())).GetRawData();
|
||||
}
|
||||
|
||||
DEF_RUNTIME_STUBS(NewSendableEnv)
|
||||
{
|
||||
RUNTIME_STUBS_HEADER(NewSendableEnv);
|
||||
JSTaggedValue numVars = GetArg(argv, argc, 0); // 0: means the zeroth parameter
|
||||
return RuntimeNewSendableEnv(thread, static_cast<uint16_t>(numVars.GetInt())).GetRawData();
|
||||
}
|
||||
|
||||
DEF_RUNTIME_STUBS(OptGetUnmapedArgs)
|
||||
{
|
||||
RUNTIME_STUBS_HEADER(OptGetUnmapedArgs);
|
||||
|
@ -408,6 +408,7 @@ using FastCallAotEntryType = JSTaggedValue (*)(uintptr_t glue, uint32_t argc, co
|
||||
V(AsyncGeneratorResolve) \
|
||||
V(AsyncGeneratorReject) \
|
||||
V(NewLexicalEnvWithName) \
|
||||
V(NewSendableEnv) \
|
||||
V(OptGetUnmapedArgs) \
|
||||
V(OptCopyRestArgs) \
|
||||
V(NotifyBytecodePcChanged) \
|
||||
@ -815,6 +816,7 @@ private:
|
||||
static inline JSTaggedValue RuntimeCreateObjectWithBuffer(JSThread *thread, ObjectFactory *factory,
|
||||
const JSHandle<JSObject> &literal);
|
||||
static inline JSTaggedValue RuntimeNewLexicalEnv(JSThread *thread, uint16_t numVars);
|
||||
static inline JSTaggedValue RuntimeNewSendableEnv(JSThread *thread, uint16_t numVars);
|
||||
static inline JSTaggedValue RuntimeNewObjRange(JSThread *thread, const JSHandle<JSTaggedValue> &func,
|
||||
const JSHandle<JSTaggedValue> &newTarget, uint16_t firstArgIdx,
|
||||
uint16_t length);
|
||||
|
@ -941,6 +941,7 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump)
|
||||
case JSType::TAGGED_ARRAY:
|
||||
case JSType::VTABLE:
|
||||
case JSType::LEXICAL_ENV:
|
||||
case JSType::SENDABLE_ENV:
|
||||
case JSType::AOT_LITERAL_INFO: {
|
||||
JSHandle<TaggedArray> taggedArray = factory->NewTaggedArray(4);
|
||||
DUMP_FOR_HANDLE(taggedArray);
|
||||
@ -1377,7 +1378,7 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump)
|
||||
break;
|
||||
}
|
||||
case JSType::SOURCE_TEXT_MODULE_RECORD: {
|
||||
CHECK_DUMP_FIELDS(ModuleRecord::SIZE, SourceTextModule::SIZE, 16U);
|
||||
CHECK_DUMP_FIELDS(ModuleRecord::SIZE, SourceTextModule::SIZE, 17U);
|
||||
JSHandle<SourceTextModule> moduleSourceRecord = factory->NewSourceTextModule();
|
||||
DUMP_FOR_HANDLE(moduleSourceRecord);
|
||||
break;
|
||||
|
@ -287,6 +287,7 @@ group("ark_aot_ts_test") {
|
||||
"sharedJSON",
|
||||
"sharedset",
|
||||
"definesendableclass",
|
||||
"sendableenv",
|
||||
"sendablecontext",
|
||||
]
|
||||
|
||||
|
21
test/aottest/sendableenv/BUILD.gn
Normal file
21
test/aottest/sendableenv/BUILD.gn
Normal file
@ -0,0 +1,21 @@
|
||||
# Copyright (c) 2024 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.
|
||||
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
|
||||
host_aot_test_action("sendableenv") {
|
||||
deps = []
|
||||
src_dir = "$js_root/test/sharedtest/sendableenv"
|
||||
is_enable_pgo = true
|
||||
use_one_expect_path = true
|
||||
}
|
@ -174,6 +174,7 @@ group("ark_js_moduletest") {
|
||||
"sharedtypedarray",
|
||||
"sharedcollectionsexception",
|
||||
"definesendableclass",
|
||||
"sendableenv",
|
||||
"sendablecontext",
|
||||
"sendableclassuseimport",
|
||||
"sharedmodule",
|
||||
@ -361,6 +362,7 @@ group("ark_asm_test") {
|
||||
"sharedtypedarray",
|
||||
"sharedcollectionsexception",
|
||||
"definesendableclass",
|
||||
"sendableenv",
|
||||
"sendablecontext",
|
||||
"sendableclassuseimport",
|
||||
"sharedmodule",
|
||||
@ -526,6 +528,7 @@ group("ark_asm_single_step_test") {
|
||||
"sharedtypedarray",
|
||||
"sharedcollectionsexception",
|
||||
"definesendableclass",
|
||||
"sendableenv",
|
||||
"sendablecontext",
|
||||
"sendableclassuseimport",
|
||||
"sharedmodule",
|
||||
|
23
test/moduletest/sendableenv/BUILD.gn
Normal file
23
test/moduletest/sendableenv/BUILD.gn
Normal file
@ -0,0 +1,23 @@
|
||||
# Copyright (c) 2023 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.
|
||||
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
|
||||
host_moduletest_action("sendableenv") {
|
||||
deps = []
|
||||
entry_point = "--entry-point=sendableenv"
|
||||
is_module = true
|
||||
is_merge = true
|
||||
src_dir = "$js_root/test/sharedtest/sendableenv"
|
||||
src_postfix = "ts"
|
||||
}
|
16
test/sharedtest/sendableenv/expect_output.txt
Normal file
16
test/sharedtest/sendableenv/expect_output.txt
Normal file
@ -0,0 +1,16 @@
|
||||
# Copyright (c) 2024 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.
|
||||
|
||||
sObj A:a :1
|
||||
sObj A:c :2
|
||||
|
43
test/sharedtest/sendableenv/sendableenv.ts
Normal file
43
test/sharedtest/sendableenv/sendableenv.ts
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @tc.name:sendableenv
|
||||
* @tc.desc:test sendableenv
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI8R6LC
|
||||
*/
|
||||
|
||||
// @ts-nocheck
|
||||
declare function print(str: any): string;
|
||||
class A {
|
||||
constructor() {
|
||||
"use sendable";
|
||||
}
|
||||
a:number = 1;
|
||||
static c:number = 2;
|
||||
}
|
||||
|
||||
class B {
|
||||
constructor() {
|
||||
"use sendable";
|
||||
}
|
||||
b:A = new A();
|
||||
d:number = A.c;
|
||||
}
|
||||
|
||||
let sObj = new B();
|
||||
print("sObj A:a :" + sObj.b.a);
|
||||
print("sObj A:c :" + sObj.d);
|
Loading…
Reference in New Issue
Block a user