From 2434f0b872396811aca4155c1835cfdba70d9949 Mon Sep 17 00:00:00 2001 From: xwcai98 Date: Mon, 7 Jul 2025 21:59:10 +0800 Subject: [PATCH] Revert "Refactor CallRuntime with globalEnv" This reverts commit 06223bb43d18d7546079a6d4dffd9fa8f1fa5853. Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/ICKLZ0 Signed-off-by: xwcai98 Change-Id: I4da46f3439ada717e878da1b3f804d0426042e62 --- .../compiler/access_object_stub_builder.cpp | 36 +- .../compiler/baseline/baseline_stubs.cpp | 4 +- .../compiler/builtins/builtins_stubs.cpp | 14 +- ecmascript/compiler/interpreter_stub.cpp | 503 ++++++++------ ecmascript/compiler/slowpath_lowering.cpp | 5 +- ecmascript/compiler/stub_builder-inl.h | 74 --- ecmascript/compiler/stub_builder.cpp | 41 +- ecmascript/compiler/stub_builder.h | 8 +- ecmascript/message_string.h | 134 ++-- ecmascript/napi/jsnapi_expo.cpp | 10 +- ecmascript/stubs/runtime_stub_list.h | 621 +++++++++--------- ecmascript/stubs/runtime_stubs.cpp | 17 + 12 files changed, 770 insertions(+), 697 deletions(-) diff --git a/ecmascript/compiler/access_object_stub_builder.cpp b/ecmascript/compiler/access_object_stub_builder.cpp index 552eb75fad..ff55bd053b 100644 --- a/ecmascript/compiler/access_object_stub_builder.cpp +++ b/ecmascript/compiler/access_object_stub_builder.cpp @@ -528,8 +528,9 @@ GateRef AccessObjectStubBuilder::TryLoadGlobalByName(GateRef glue, GateRef prop, Bind(&slowPath); { GateRef propKey = ResolvePropKey(glue, prop, info); - result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(TryLdGlobalICByName), - { profileTypeInfo, propKey, IntToTaggedInt(slotId) }); + SetGlueGlobalEnv(glue, globalEnv); + result = CallRuntime(glue, RTSTUB_ID(TryLdGlobalICByName), + { profileTypeInfo, propKey, IntToTaggedInt(slotId) }); Jump(&exit); } @@ -565,7 +566,8 @@ GateRef AccessObjectStubBuilder::TryStoreGlobalByName(GateRef glue, GateRef prop BRANCH(TaggedIsUndefined(record), ¬FoundInRecord, &foundInRecord); Bind(&foundInRecord); { - result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(TryUpdateGlobalRecord), { propKey, value }); + SetGlueGlobalEnv(glue, globalEnv); + result = CallRuntime(glue, RTSTUB_ID(TryUpdateGlobalRecord), { propKey, value }); Jump(&exit); } Bind(¬FoundInRecord); @@ -577,12 +579,14 @@ GateRef AccessObjectStubBuilder::TryStoreGlobalByName(GateRef glue, GateRef prop BRANCH(TaggedIsHole(*result), ¬FoundInGlobal, &isFoundInGlobal); Bind(&isFoundInGlobal); { - result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StGlobalVar), { propKey, value }); + SetGlueGlobalEnv(glue, globalEnv); + result = CallRuntime(glue, RTSTUB_ID(StGlobalVar), { propKey, value }); Jump(&exit); } Bind(¬FoundInGlobal); { - result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(ThrowReferenceError), { propKey }); + SetGlueGlobalEnv(glue, globalEnv); + result = CallRuntime(glue, RTSTUB_ID(ThrowReferenceError), { propKey }); Jump(&exit); } } @@ -591,9 +595,10 @@ GateRef AccessObjectStubBuilder::TryStoreGlobalByName(GateRef glue, GateRef prop { GateRef propKey = ResolvePropKey(glue, prop, info); GateRef globalObject = GetGlobalObject(glue, globalEnv); - result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StoreMiss), - { profileTypeInfo, globalObject, propKey, value, IntToTaggedInt(slotId), - IntToTaggedInt(Int32(static_cast(ICKind::NamedGlobalTryStoreIC))) }); + SetGlueGlobalEnv(glue, globalEnv); + result = CallRuntime(glue, RTSTUB_ID(StoreMiss), + { profileTypeInfo, globalObject, propKey, value, IntToTaggedInt(slotId), + IntToTaggedInt(Int32(static_cast(ICKind::NamedGlobalTryStoreIC))) }); Jump(&exit); } @@ -631,8 +636,9 @@ GateRef AccessObjectStubBuilder::LoadGlobalVar(GateRef glue, GateRef prop, const { GateRef globalObject = GetGlobalObject(glue, globalEnv); GateRef propKey = ResolvePropKey(glue, prop, info); - result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(LdGlobalICVar), - { globalObject, propKey, profileTypeInfo, IntToTaggedInt(slotId) }); + SetGlueGlobalEnv(glue, globalEnv); + result = CallRuntime(glue, RTSTUB_ID(LdGlobalICVar), + { globalObject, propKey, profileTypeInfo, IntToTaggedInt(slotId) }); Jump(&exit); } @@ -662,16 +668,18 @@ GateRef AccessObjectStubBuilder::StoreGlobalVar(GateRef glue, GateRef prop, cons { GateRef propKey = ResolvePropKey(glue, prop, info); // IR later - result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StGlobalVar), { propKey, value }); + SetGlueGlobalEnv(glue, globalEnv); + result = CallRuntime(glue, RTSTUB_ID(StGlobalVar), { propKey, value }); Jump(&exit); } Bind(&slowPath); { GateRef propKey = ResolvePropKey(glue, prop, info); GateRef globalObject = GetGlobalObject(glue, globalEnv); - result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StoreMiss), - { profileTypeInfo, globalObject, propKey, value, IntToTaggedInt(slotId), - IntToTaggedInt(Int32(static_cast(ICKind::NamedGlobalStoreIC))) }); + SetGlueGlobalEnv(glue, globalEnv); + result = CallRuntime(glue, RTSTUB_ID(StoreMiss), + { profileTypeInfo, globalObject, propKey, value, IntToTaggedInt(slotId), + IntToTaggedInt(Int32(static_cast(ICKind::NamedGlobalStoreIC))) }); Jump(&exit); } diff --git a/ecmascript/compiler/baseline/baseline_stubs.cpp b/ecmascript/compiler/baseline/baseline_stubs.cpp index baa95f3f05..37a7db68b6 100644 --- a/ecmascript/compiler/baseline/baseline_stubs.cpp +++ b/ecmascript/compiler/baseline/baseline_stubs.cpp @@ -368,8 +368,8 @@ void BaselineLdaStrID16StubBuilder::GenerateCircuit() void BaselineLdsymbolStubBuilder::GenerateCircuit() { GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdsymbol, GLUE)); - GateRef globalEnv = GetGlobalEnv(glue); - GateRef result = GetGlobalEnvValue(VariableType::JS_POINTER(), glue, globalEnv, GlobalEnv::SYMBOL_FUNCTION_INDEX); + + GateRef result = CallRuntime(glue, RTSTUB_ID(GetSymbolFunction), {}); Return(result); } diff --git a/ecmascript/compiler/builtins/builtins_stubs.cpp b/ecmascript/compiler/builtins/builtins_stubs.cpp index 37ab2a0300..ab8e23aa64 100644 --- a/ecmascript/compiler/builtins/builtins_stubs.cpp +++ b/ecmascript/compiler/builtins/builtins_stubs.cpp @@ -155,8 +155,7 @@ GateRef BuiltinsStubBuilder::GetCallArg2(GateRef numArg) return res; } -GateRef BuiltinsStubBuilder::GetGlobalEnvFromFunction(GateRef glue, GateRef func) -{ +GateRef BuiltinsStubBuilder::GetGlobalEnvFromFunction(GateRef glue, GateRef func) { auto env0 = GetEnvironment(); Label subentry(env0); env0->SubCfgEntry(&subentry); @@ -165,11 +164,12 @@ GateRef BuiltinsStubBuilder::GetGlobalEnvFromFunction(GateRef glue, GateRef func DEFVARIABLE(result, VariableType::JS_ANY(), Undefined()); GateRef lexicalEnv = GetFunctionLexicalEnv(glue, func); { - ASM_ASSERT(GET_MESSAGE_STRING_ID(LexicalEnvIsInvalid), - BitOr(TaggedIsUndefined(lexicalEnv), - LogicAndBuilder(env0).And(TaggedIsHeapObject(lexicalEnv)) - .And(IsGlobalEnv(glue, lexicalEnv)) - .Done())); + ASM_ASSERT(GET_MESSAGE_STRING_ID(LexicalEnvIsUndefined), + BitOr(TaggedIsSharedObj(glue, func), + LogicAndBuilder(env0). + And(TaggedIsHeapObject(lexicalEnv)). + And(IsGlobalEnv(glue, lexicalEnv)). + Done())); } result = lexicalEnv; BRANCH_UNLIKELY(TaggedIsUndefined(lexicalEnv), &isUndefined, &exit); diff --git a/ecmascript/compiler/interpreter_stub.cpp b/ecmascript/compiler/interpreter_stub.cpp index 80e7ee62e6..a0c0ce49b8 100644 --- a/ecmascript/compiler/interpreter_stub.cpp +++ b/ecmascript/compiler/interpreter_stub.cpp @@ -488,8 +488,8 @@ DECLARE_ASM_HANDLER(HandleLdsymbol) { DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv); - varAcc = GetGlobalEnvValue(VariableType::JS_POINTER(), glue, globalEnv, GlobalEnv::SYMBOL_FUNCTION_INDEX); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + varAcc = CallRuntime(glue, RTSTUB_ID(GetSymbolFunction), {}); DISPATCH_WITH_ACC(LDSYMBOL); } @@ -586,7 +586,8 @@ DECLARE_ASM_HANDLER(HandleGetunmappedargs) Bind(&slowPath); { - GateRef res = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(GetUnmapedArgs), {}); + SetGlueGlobalEnv(glue, globalEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(GetUnmapedArgs), {}); CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(GETUNMAPPEDARGS)); } } @@ -642,8 +643,8 @@ DECLARE_ASM_HANDLER(HandleCopyrestargsImm8) Bind(&slowPath); { - GateRef result2 = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(CopyRestArgs), - { IntToTaggedInt(restIdx) }); + SetGlueGlobalEnv(glue, globalEnv); + GateRef result2 = CallRuntime(glue, RTSTUB_ID(CopyRestArgs), { IntToTaggedInt(restIdx) }); CHECK_EXCEPTION_WITH_ACC(result2, INT_PTR(COPYRESTARGS_IMM8)); } } @@ -652,7 +653,8 @@ DECLARE_ASM_HANDLER(HandleWideCopyrestargsPrefImm16) { GateRef restIdx = ZExtInt16ToInt32(ReadInst16_1(pc)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CopyRestArgs), { IntToTaggedInt(restIdx) }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(CopyRestArgs), { IntToTaggedInt(restIdx) }); CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(WIDE_COPYRESTARGS_PREF_IMM16)); } @@ -662,7 +664,8 @@ DECLARE_ASM_HANDLER(HandleCreateobjectwithexcludedkeysImm8V8V8) GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc))); GateRef firstArgRegIdx = ZExtInt8ToInt16(ReadInst8_2(pc)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateObjectWithExcludedKeys), + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(CreateObjectWithExcludedKeys), { Int16ToTaggedInt(numKeys), obj, Int16ToTaggedInt(firstArgRegIdx) }); CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(CREATEOBJECTWITHEXCLUDEDKEYS_IMM8_V8_V8)); } @@ -673,7 +676,8 @@ DECLARE_ASM_HANDLER(HandleWideCreateobjectwithexcludedkeysPrefImm16V8V8) GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_3(pc))); GateRef firstArgRegIdx = ZExtInt8ToInt16(ReadInst8_4(pc)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateObjectWithExcludedKeys), + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(CreateObjectWithExcludedKeys), { Int16ToTaggedInt(numKeys), obj, Int16ToTaggedInt(firstArgRegIdx) }); CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(WIDE_CREATEOBJECTWITHEXCLUDEDKEYS_PREF_IMM16_V8_V8)); } @@ -682,7 +686,8 @@ DECLARE_ASM_HANDLER(HandleThrowIfsupernotcorrectcallPrefImm16) { GateRef imm = ReadInst16_1(pc); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowIfSuperNotCorrectCall), + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(ThrowIfSuperNotCorrectCall), { Int16ToTaggedInt(imm), acc }); // acc is thisValue CHECK_EXCEPTION(res, INT_PTR(THROW_IFSUPERNOTCORRECTCALL_PREF_IMM16)); } @@ -691,8 +696,9 @@ DECLARE_ASM_HANDLER(HandleThrowIfsupernotcorrectcallPrefImm8) { GateRef imm = ReadInst8_1(pc); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowIfSuperNotCorrectCall), - { Int8ToTaggedInt(imm), acc }); // acc is thisValue + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(ThrowIfSuperNotCorrectCall), + { Int8ToTaggedInt(imm), acc }); // acc is thisValue CHECK_EXCEPTION(res, INT_PTR(THROW_IFSUPERNOTCORRECTCALL_PREF_IMM8)); } @@ -701,8 +707,9 @@ DECLARE_ASM_HANDLER(HandleAsyncfunctionresolveV8) GateRef asyncFuncObj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_0(pc))); GateRef value = acc; GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncFunctionResolveOrReject), - { asyncFuncObj, value, TaggedTrue() }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(AsyncFunctionResolveOrReject), + { asyncFuncObj, value, TaggedTrue() }); CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(ASYNCFUNCTIONRESOLVE_V8)); } @@ -711,8 +718,9 @@ DECLARE_ASM_HANDLER(HandleDeprecatedAsyncfunctionresolvePrefV8V8V8) GateRef asyncFuncObj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc))); GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_3(pc))); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncFunctionResolveOrReject), - { asyncFuncObj, value, TaggedTrue() }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(AsyncFunctionResolveOrReject), + { asyncFuncObj, value, TaggedTrue() }); CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(DEPRECATED_ASYNCFUNCTIONRESOLVE_PREF_V8_V8_V8)); } @@ -721,8 +729,9 @@ DECLARE_ASM_HANDLER(HandleAsyncfunctionrejectV8) GateRef asyncFuncObj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_0(pc))); GateRef value = acc; GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncFunctionResolveOrReject), - { asyncFuncObj, value, TaggedFalse() }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(AsyncFunctionResolveOrReject), + { asyncFuncObj, value, TaggedFalse() }); CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(ASYNCFUNCTIONREJECT_V8)); } @@ -731,8 +740,9 @@ DECLARE_ASM_HANDLER(HandleDeprecatedAsyncfunctionrejectPrefV8V8V8) GateRef asyncFuncObj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc))); GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_3(pc))); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncFunctionResolveOrReject), - { asyncFuncObj, value, TaggedFalse() }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(AsyncFunctionResolveOrReject), + { asyncFuncObj, value, TaggedFalse() }); CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(DEPRECATED_ASYNCFUNCTIONREJECT_PREF_V8_V8_V8)); } @@ -750,8 +760,9 @@ DECLARE_ASM_HANDLER(HandleDefinegettersetterbyvalueV8V8V8V8) LoadPrimitive(VariableType::NATIVE_POINTER(), method, IntPtr(Method::NATIVE_POINTER_OR_BYTECODE_ARRAY_OFFSET)); GateRef offset = TaggedPtrToTaggedIntPtr(PtrSub(pc, firstPC)); GateRef currentEnv = GetEnvFromFrame(glue, frame); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(DefineGetterSetterByValue), - { obj, prop, getter, setter, acc, func, offset }); // acc is flag + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(DefineGetterSetterByValue), + { obj, prop, getter, setter, acc, func, offset }); // acc is flag CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(DEFINEGETTERSETTERBYVALUE_V8_V8_V8_V8)); } @@ -769,7 +780,8 @@ DECLARE_ASM_HANDLER(HandleAsyncfunctionenter) { DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncFunctionEnter), {}); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(AsyncFunctionEnter), {}); CHECK_EXCEPTION_WITH_VARACC(res, INT_PTR(ASYNCFUNCTIONENTER)); } @@ -842,7 +854,8 @@ DECLARE_ASM_HANDLER(HandleGetasynciteratorImm8) { DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(GetAsyncIterator), { *varAcc }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(GetAsyncIterator), { *varAcc }); CHECK_PENDING_EXCEPTION(res, INT_PTR(GETASYNCITERATOR_IMM8)); } @@ -853,8 +866,10 @@ DECLARE_ASM_HANDLER(HandleLdPrivatePropertyImm8Imm16Imm16) GateRef slotIndex = ReadInst16_3(pc); DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); - result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdPrivateProperty), - {currentEnv, IntToTaggedInt(levelIndex), IntToTaggedInt(slotIndex), acc}); // acc as obj + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + result = CallRuntime(glue, + RTSTUB_ID(LdPrivateProperty), + {currentEnv, IntToTaggedInt(levelIndex), IntToTaggedInt(slotIndex), acc}); // acc as obj CHECK_EXCEPTION_WITH_ACC(*result, INT_PTR(LDPRIVATEPROPERTY_IMM8_IMM16_IMM16)); } @@ -865,8 +880,11 @@ DECLARE_ASM_HANDLER(HandleStPrivatePropertyImm8Imm16Imm16V8) GateRef slotIndex = ReadInst16_3(pc); GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_5(pc))); DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); - result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StPrivateProperty), - {currentEnv, IntToTaggedInt(levelIndex), IntToTaggedInt(slotIndex), obj, acc}); // acc as value + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + result = + CallRuntime(glue, + RTSTUB_ID(StPrivateProperty), + {currentEnv, IntToTaggedInt(levelIndex), IntToTaggedInt(slotIndex), obj, acc}); // acc as value CHECK_EXCEPTION_WITH_ACC(*result, INT_PTR(STPRIVATEPROPERTY_IMM8_IMM16_IMM16_V8)); } @@ -876,7 +894,8 @@ DECLARE_ASM_HANDLER(HandleTestInImm8Imm16Imm16) [[maybe_unused]] GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc)); GateRef levelIndex = ReadInst16_1(pc); GateRef slotIndex = ReadInst16_3(pc); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(TestIn), {currentEnv, + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(TestIn), {currentEnv, IntToTaggedInt(levelIndex), IntToTaggedInt(slotIndex), acc}); // acc as obj CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(TESTIN_IMM8_IMM16_IMM16)); } @@ -884,14 +903,16 @@ DECLARE_ASM_HANDLER(HandleTestInImm8Imm16Imm16) DECLARE_ASM_HANDLER(HandleThrowPatternnoncoerciblePrefNone) { GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowPatternNonCoercible), {}); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + CallRuntime(glue, RTSTUB_ID(ThrowPatternNonCoercible), {}); DISPATCH_LAST(); } DECLARE_ASM_HANDLER(HandleThrowDeletesuperpropertyPrefNone) { GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowDeleteSuperProperty), {}); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + CallRuntime(glue, RTSTUB_ID(ThrowDeleteSuperProperty), {}); DISPATCH_LAST(); } @@ -1332,6 +1353,7 @@ DECLARE_ASM_HANDLER(HandleExpImm8V8) GateRef v0 = ReadInst8_1(pc); GateRef base = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); GateRef result = CallRuntime(glue, RTSTUB_ID(Exp), { base, acc }); CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(EXP_IMM8_V8)); } @@ -1346,7 +1368,8 @@ DECLARE_ASM_HANDLER(HandleIsinImm8V8) #if ENABLE_NEXT_OPTIMIZATION GateRef result = IsIn(glue, prop, acc); // acc is obj #else - GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(IsIn), {prop, acc}); // acc is obj + SetGlueGlobalEnv(glue, globalEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(IsIn), {prop, acc}); // acc is obj #endif CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(ISIN_IMM8_V8)); } @@ -1513,7 +1536,8 @@ DECLARE_ASM_HANDLER(HandleCreategeneratorobjV8) GateRef v0 = ReadInst8_0(pc); GateRef genFunc = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateGeneratorObj), { genFunc }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(CreateGeneratorObj), { genFunc }); CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(CREATEGENERATOROBJ_V8)); } @@ -1522,7 +1546,8 @@ DECLARE_ASM_HANDLER(HandleThrowConstassignmentPrefV8) GateRef v0 = ReadInst8_1(pc); GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowConstAssignment), { value }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + CallRuntime(glue, RTSTUB_ID(ThrowConstAssignment), { value }); DISPATCH_LAST(); } @@ -1530,7 +1555,8 @@ DECLARE_ASM_HANDLER(HandleGettemplateobjectImm8) { GateRef literal = acc; GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(GetTemplateObject), { literal }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(GetTemplateObject), { literal }); CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(GETTEMPLATEOBJECT_IMM8)); } @@ -1538,7 +1564,8 @@ DECLARE_ASM_HANDLER(HandleGettemplateobjectImm16) { GateRef literal = acc; GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(GetTemplateObject), { literal }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(GetTemplateObject), { literal }); CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(GETTEMPLATEOBJECT_IMM16)); } @@ -1546,7 +1573,8 @@ DECLARE_ASM_HANDLER(HandleDeprecatedGettemplateobjectPrefV8) { GateRef literal = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc))); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(GetTemplateObject), { literal }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(GetTemplateObject), { literal }); CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_GETTEMPLATEOBJECT_PREF_V8)); } @@ -1576,7 +1604,8 @@ DECLARE_ASM_HANDLER(HandleThrowIfnotobjectPrefV8) } Bind(¬EcmaObject); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowIfNotObject), {}); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + CallRuntime(glue, RTSTUB_ID(ThrowIfNotObject), {}); DISPATCH_LAST(); } @@ -1585,7 +1614,8 @@ DECLARE_ASM_HANDLER(HandleCloseiteratorImm8V8) GateRef v0 = ReadInst8_1(pc); GateRef iter = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CloseIterator), { iter }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(CloseIterator), { iter }); CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(CLOSEITERATOR_IMM8_V8)); } @@ -1594,7 +1624,8 @@ DECLARE_ASM_HANDLER(HandleCloseiteratorImm16V8) GateRef v0 = ReadInst8_2(pc); GateRef iter = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CloseIterator), { iter }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(CloseIterator), { iter }); CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(CLOSEITERATOR_IMM16_V8)); } @@ -1656,7 +1687,8 @@ DECLARE_ASM_HANDLER(HandleSupercallspreadImm8V8) } Bind(&slowPath); { - res = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(SuperCallSpread), { thisFunc, array }); + SetGlueGlobalEnv(glue, globalEnv); + res = CallRuntime(glue, RTSTUB_ID(SuperCallSpread), { thisFunc, array }); Jump(&threadCheck); } Bind(&threadCheck); @@ -1693,7 +1725,8 @@ DECLARE_ASM_HANDLER(HandleDeprecatedDelobjpropPrefV8V8) GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc))); GateRef prop = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc))); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(DelObjProp), { obj, prop }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(DelObjProp), { obj, prop }); CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_DELOBJPROP_PREF_V8_V8)); } @@ -1702,7 +1735,8 @@ DECLARE_ASM_HANDLER(HandleNewobjapplyImm8V8) GateRef v0 = ReadInst8_1(pc); GateRef func = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(NewObjApply), { func, acc }); // acc is array + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(NewObjApply), { func, acc }); // acc is array CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(NEWOBJAPPLY_IMM8_V8)); } @@ -1711,7 +1745,8 @@ DECLARE_ASM_HANDLER(HandleNewobjapplyImm16V8) GateRef v0 = ReadInst8_2(pc); GateRef func = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(NewObjApply), { func, acc }); // acc is array + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(NewObjApply), { func, acc }); // acc is array CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(NEWOBJAPPLY_IMM16_V8)); } @@ -1722,7 +1757,8 @@ DECLARE_ASM_HANDLER(HandleCreateiterresultobjV8V8) GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef flag = GetVregValue(glue, sp, ZExtInt8ToPtr(v1)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateIterResultObj), { value, flag }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(CreateIterResultObj), { value, flag }); CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(CREATEITERRESULTOBJ_V8_V8)); } @@ -1732,8 +1768,8 @@ DECLARE_ASM_HANDLER(HandleAsyncfunctionawaituncaughtV8) GateRef asyncFuncObj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef value = acc; GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncFunctionAwaitUncaught), - { asyncFuncObj, value }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(AsyncFunctionAwaitUncaught), { asyncFuncObj, value }); CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(ASYNCFUNCTIONAWAITUNCAUGHT_V8)); } @@ -1742,8 +1778,8 @@ DECLARE_ASM_HANDLER(HandleDeprecatedAsyncfunctionawaituncaughtPrefV8V8) GateRef asyncFuncObj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc))); GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc))); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncFunctionAwaitUncaught), - { asyncFuncObj, value }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(AsyncFunctionAwaitUncaught), { asyncFuncObj, value }); CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_ASYNCFUNCTIONAWAITUNCAUGHT_PREF_V8_V8)); } @@ -1765,7 +1801,8 @@ DECLARE_ASM_HANDLER(HandleThrowUndefinedifholePrefV8V8) GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v1)); // assert obj.IsString() GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowUndefinedIfHole), { obj }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + CallRuntime(glue, RTSTUB_ID(ThrowUndefinedIfHole), { obj }); DISPATCH_LAST(); } @@ -1786,7 +1823,8 @@ DECLARE_ASM_HANDLER(HandleThrowUndefinedifholewithnamePrefId16) GateRef str = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId)); // assert obj.IsString() GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowUndefinedIfHole), { str }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + CallRuntime(glue, RTSTUB_ID(ThrowUndefinedIfHole), { str }); DISPATCH_LAST(); } @@ -1796,7 +1834,8 @@ DECLARE_ASM_HANDLER(HandleCopydatapropertiesV8) GateRef dst = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef src = acc; GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CopyDataProperties), { dst, src }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(CopyDataProperties), { dst, src }); CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(COPYDATAPROPERTIES_V8)); } @@ -1805,7 +1844,8 @@ DECLARE_ASM_HANDLER(HandleDeprecatedCopydatapropertiesPrefV8V8) GateRef dst = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc))); GateRef src = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc))); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CopyDataProperties), { dst, src }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(CopyDataProperties), { dst, src }); CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_COPYDATAPROPERTIES_PREF_V8_V8)); } @@ -1816,8 +1856,8 @@ DECLARE_ASM_HANDLER(HandleStarrayspreadV8V8) GateRef dst = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef index = GetVregValue(glue, sp, ZExtInt8ToPtr(v1)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StArraySpread), - { dst, index, acc }); // acc is res + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(StArraySpread), { dst, index, acc }); // acc is res CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(STARRAYSPREAD_V8_V8)); } @@ -1830,7 +1870,8 @@ DECLARE_ASM_HANDLER(HandleSetobjectwithprotoImm8V8) GateRef proto = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef obj = *varAcc; GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SetObjectWithProto), { proto, obj }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(SetObjectWithProto), { proto, obj }); Label notException(env); CHECK_EXCEPTION_WITH_JUMP(result, ¬Exception); Bind(¬Exception); @@ -1846,7 +1887,8 @@ DECLARE_ASM_HANDLER(HandleSetobjectwithprotoImm16V8) GateRef proto = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef obj = *varAcc; GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SetObjectWithProto), { proto, obj }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(SetObjectWithProto), { proto, obj }); Label notException(env); CHECK_EXCEPTION_WITH_JUMP(result, ¬Exception); Bind(¬Exception); @@ -1861,7 +1903,8 @@ DECLARE_ASM_HANDLER(HandleDeprecatedSetobjectwithprotoPrefV8V8) GateRef proto = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc))); GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc))); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SetObjectWithProto), { proto, obj }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(SetObjectWithProto), { proto, obj }); Label notException(env); CHECK_EXCEPTION_WITH_JUMP(result, ¬Exception); Bind(¬Exception); @@ -1931,7 +1974,8 @@ DECLARE_ASM_HANDLER(HandleStownbyvalueImm8V8V8) } Bind(&slowPath); { - GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StOwnByValue), { receiver, propKey, acc }); + SetGlueGlobalEnv(glue, globalEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(StOwnByValue), { receiver, propKey, acc }); CHECK_EXCEPTION(result, INT_PTR(STOWNBYVALUE_IMM8_V8_V8)); } } @@ -1967,7 +2011,8 @@ DECLARE_ASM_HANDLER(HandleStownbyvalueImm16V8V8) } Bind(&slowPath); { - GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StOwnByValue), { receiver, propKey, acc }); + SetGlueGlobalEnv(glue, globalEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(StOwnByValue), { receiver, propKey, acc }); CHECK_EXCEPTION(result, INT_PTR(STOWNBYVALUE_IMM16_V8_V8)); } } @@ -1980,7 +2025,8 @@ DECLARE_ASM_HANDLER(HandleStsuperbyvalueImm8V8V8) GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(v1)); // acc is value, sp for thisFunc GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StSuperByValue), { receiver, propKey, acc }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(StSuperByValue), { receiver, propKey, acc }); CHECK_EXCEPTION(result, INT_PTR(STSUPERBYVALUE_IMM8_V8_V8)); } @@ -1992,7 +2038,8 @@ DECLARE_ASM_HANDLER(HandleStsuperbyvalueImm16V8V8) GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(v1)); // acc is value, sp for thisFunc GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StSuperByValue), { receiver, propKey, acc }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(StSuperByValue), { receiver, propKey, acc }); CHECK_EXCEPTION(result, INT_PTR(STSUPERBYVALUE_IMM16_V8_V8)); } @@ -2003,7 +2050,8 @@ DECLARE_ASM_HANDLER(HandleStsuperbynameImm8Id16V8) GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef propKey = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StSuperByValue), { receiver, propKey, acc }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(StSuperByValue), { receiver, propKey, acc }); CHECK_EXCEPTION(result, INT_PTR(STSUPERBYNAME_IMM8_ID16_V8)); } @@ -2014,7 +2062,8 @@ DECLARE_ASM_HANDLER(HandleStsuperbynameImm16Id16V8) GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef propKey = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StSuperByValue), { receiver, propKey, acc }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(StSuperByValue), { receiver, propKey, acc }); CHECK_EXCEPTION(result, INT_PTR(STSUPERBYNAME_IMM16_ID16_V8)); } @@ -2041,8 +2090,9 @@ DECLARE_ASM_HANDLER(HandleStobjbyindexImm8V8Imm16) } Bind(&slowPath); { - GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StObjByIndex), - { receiver, IntToTaggedInt(index), acc }); + SetGlueGlobalEnv(glue, globalEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(StObjByIndex), + { receiver, IntToTaggedInt(index), acc }); CHECK_EXCEPTION(result, INT_PTR(STOBJBYINDEX_IMM8_V8_IMM16)); } } @@ -2070,8 +2120,9 @@ DECLARE_ASM_HANDLER(HandleStobjbyindexImm16V8Imm16) } Bind(&slowPath); { - GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StObjByIndex), - { receiver, IntToTaggedInt(index), acc }); + SetGlueGlobalEnv(glue, globalEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(StObjByIndex), + { receiver, IntToTaggedInt(index), acc }); CHECK_EXCEPTION(result, INT_PTR(STOBJBYINDEX_IMM16_V8_IMM16)); } } @@ -2098,8 +2149,9 @@ DECLARE_ASM_HANDLER(HandleWideStobjbyindexPrefV8Imm32) } Bind(&slowPath); { - GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StObjByIndex), - { receiver, IntToTaggedInt(index), acc }); + SetGlueGlobalEnv(glue, globalEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(StObjByIndex), + { receiver, IntToTaggedInt(index), acc }); CHECK_EXCEPTION(result, INT_PTR(WIDE_STOBJBYINDEX_PREF_V8_IMM32)); } } @@ -2163,8 +2215,9 @@ DECLARE_ASM_HANDLER(HandleWideStownbyindexPrefV8Imm32) } Bind(&slowPath); { - GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StOwnByIndex), - { receiver, IntToTaggedInt(index), acc }); + SetGlueGlobalEnv(glue, globalEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(StOwnByIndex), + { receiver, IntToTaggedInt(index), acc }); CHECK_EXCEPTION(result, INT_PTR(WIDE_STOWNBYINDEX_PREF_V8_IMM32)); } } @@ -2309,7 +2362,8 @@ DECLARE_ASM_HANDLER(HandleStownbyvaluewithnamesetImm16V8V8) { CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception); Bind(¬Exception); - CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(SetFunctionNameNoPrefix), { acc, propKey }); + SetGlueGlobalEnv(glue, globalEnv); + CallRuntime(glue, RTSTUB_ID(SetFunctionNameNoPrefix), { acc, propKey }); DISPATCH(STOWNBYVALUEWITHNAMESET_IMM16_V8_V8); } } @@ -2317,8 +2371,8 @@ DECLARE_ASM_HANDLER(HandleStownbyvaluewithnamesetImm16V8V8) } Bind(&slowPath); { - GateRef res = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StOwnByValueWithNameSet), - { receiver, propKey, acc }); + SetGlueGlobalEnv(glue, globalEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(StOwnByValueWithNameSet), { receiver, propKey, acc }); CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception1); Bind(¬Exception1); DISPATCH(STOWNBYVALUEWITHNAMESET_IMM16_V8_V8); @@ -2355,7 +2409,8 @@ DECLARE_ASM_HANDLER(HandleStownbyvaluewithnamesetImm8V8V8) { CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception); Bind(¬Exception); - CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(SetFunctionNameNoPrefix), { acc, propKey }); + SetGlueGlobalEnv(glue, globalEnv); + CallRuntime(glue, RTSTUB_ID(SetFunctionNameNoPrefix), { acc, propKey }); DISPATCH(STOWNBYVALUEWITHNAMESET_IMM8_V8_V8); } } @@ -2363,8 +2418,8 @@ DECLARE_ASM_HANDLER(HandleStownbyvaluewithnamesetImm8V8V8) } Bind(&slowPath); { - GateRef res = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StOwnByValueWithNameSet), - { receiver, propKey, acc }); + SetGlueGlobalEnv(glue, globalEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(StOwnByValueWithNameSet), { receiver, propKey, acc }); CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception1); Bind(¬Exception1); DISPATCH(STOWNBYVALUEWITHNAMESET_IMM8_V8_V8); @@ -2401,7 +2456,8 @@ DECLARE_ASM_HANDLER(HandleStownbynameImm8Id16V8) Bind(&slowPath); { GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StOwnByName), { receiver, propKey, acc }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + result = CallRuntime(glue, RTSTUB_ID(StOwnByName), { receiver, propKey, acc }); Jump(&checkResult); } Bind(&checkResult); @@ -2440,7 +2496,8 @@ DECLARE_ASM_HANDLER(HandleStownbynameImm16Id16V8) Bind(&slowPath); { GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StOwnByName), { receiver, propKey, acc }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + result = CallRuntime(glue, RTSTUB_ID(StOwnByName), { receiver, propKey, acc }); Jump(&checkResult); } Bind(&checkResult); @@ -2478,7 +2535,8 @@ DECLARE_ASM_HANDLER(HandleStownbynamewithnamesetImm8Id16V8) CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception); Bind(¬Exception); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SetFunctionNameNoPrefix), { acc, propKey }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + CallRuntime(glue, RTSTUB_ID(SetFunctionNameNoPrefix), { acc, propKey }); DISPATCH(STOWNBYNAMEWITHNAMESET_IMM8_ID16_V8); } } @@ -2487,8 +2545,8 @@ DECLARE_ASM_HANDLER(HandleStownbynamewithnamesetImm8Id16V8) Bind(¬JSObject); { GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StOwnByNameWithNameSet), - { receiver, propKey, acc }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(StOwnByNameWithNameSet), { receiver, propKey, acc }); CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception1); Bind(¬Exception1); DISPATCH(STOWNBYNAMEWITHNAMESET_IMM8_ID16_V8); @@ -2523,7 +2581,8 @@ DECLARE_ASM_HANDLER(HandleStownbynamewithnamesetImm16Id16V8) CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception); Bind(¬Exception); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SetFunctionNameNoPrefix), { acc, propKey }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + CallRuntime(glue, RTSTUB_ID(SetFunctionNameNoPrefix), { acc, propKey }); DISPATCH(STOWNBYNAMEWITHNAMESET_IMM16_ID16_V8); } } @@ -2532,8 +2591,8 @@ DECLARE_ASM_HANDLER(HandleStownbynamewithnamesetImm16Id16V8) Bind(¬JSObject); { GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StOwnByNameWithNameSet), - { receiver, propKey, acc }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(StOwnByNameWithNameSet), { receiver, propKey, acc }); CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception1); Bind(¬Exception1); DISPATCH(STOWNBYNAMEWITHNAMESET_IMM16_ID16_V8); @@ -3075,7 +3134,8 @@ DECLARE_ASM_HANDLER(HandleSuspendgeneratorV8) GateRef value = *varAcc; GateRef frame = GetFrame(*varSp); GateRef currentEnv = GetEnvFromFrame(glue, frame); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SuspendGenerator), { genObj, value }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(SuspendGenerator), { genObj, value }); Label isException(env); Label notException(env); BRANCH(TaggedIsException(res), &isException, ¬Exception); @@ -3181,7 +3241,8 @@ DECLARE_ASM_HANDLER(HandleDeprecatedSuspendgeneratorPrefV8V8) GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc))); GateRef frame = GetFrame(*varSp); GateRef currentEnv = GetEnvFromFrame(glue, frame); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SuspendGenerator), { genObj, value }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(SuspendGenerator), { genObj, value }); Label isException(env); Label notException(env); BRANCH(TaggedIsException(res), &isException, ¬Exception); @@ -3337,8 +3398,9 @@ DECLARE_ASM_HANDLER(HandleCreateregexpwithliteralImm8Id16Imm8) GateRef pattern = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId)); GateRef flags = ReadInst8_3(pc); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateRegExpWithLiteral), - { pattern, Int8ToTaggedInt(flags) }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(CreateRegExpWithLiteral), + { pattern, Int8ToTaggedInt(flags) }); CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(CREATEREGEXPWITHLITERAL_IMM8_ID16_IMM8)); } @@ -3348,8 +3410,9 @@ DECLARE_ASM_HANDLER(HandleCreateregexpwithliteralImm16Id16Imm8) GateRef pattern = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId)); GateRef flags = ReadInst8_4(pc); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateRegExpWithLiteral), - { pattern, Int8ToTaggedInt(flags) }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(CreateRegExpWithLiteral), + { pattern, Int8ToTaggedInt(flags) }); CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(CREATEREGEXPWITHLITERAL_IMM16_ID16_IMM8)); } @@ -3397,7 +3460,8 @@ DECLARE_ASM_HANDLER(HandleTonumberImm8) Bind(&valueNotNumber); { GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ToNumber), { value }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(ToNumber), { value }); CHECK_EXCEPTION_WITH_VARACC(res, INT_PTR(TONUMBER_IMM8)); } } @@ -3418,7 +3482,8 @@ DECLARE_ASM_HANDLER(HandleDeprecatedTonumberPrefV8) Bind(&valueNotNumber); { GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ToNumber), { value }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(ToNumber), { value }); CHECK_EXCEPTION_WITH_VARACC(res, INT_PTR(DEPRECATED_TONUMBER_PREF_V8)); } } @@ -3450,7 +3515,8 @@ DECLARE_ASM_HANDLER(HandleLdbigintId16) GateRef stringId = ReadInst16_0(pc); GateRef numberBigInt = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdBigInt), { numberBigInt }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(LdBigInt), { numberBigInt }); CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(LDBIGINT_ID16)); } @@ -3492,7 +3558,8 @@ DECLARE_ASM_HANDLER(HandleTonumericImm8) Bind(&valueNotNumeric); { GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ToNumeric), { value }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(ToNumeric), { value }); CHECK_EXCEPTION_WITH_VARACC(res, INT_PTR(TONUMERIC_IMM8)); } } @@ -3513,7 +3580,8 @@ DECLARE_ASM_HANDLER(HandleDeprecatedTonumericPrefV8) Bind(&valueNotNumeric); { GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ToNumeric), { value }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(ToNumeric), { value }); CHECK_EXCEPTION_WITH_VARACC(res, INT_PTR(DEPRECATED_TONUMERIC_PREF_V8)); } } @@ -3525,7 +3593,8 @@ DECLARE_ASM_HANDLER(HandleDynamicimport) GateRef frame = GetFrame(sp); GateRef currentFunc = GetFunctionFromFrame(glue, frame); GateRef currentEnv = GetEnvFromFrame(glue, frame); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(DynamicImport), { specifier, currentFunc }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(DynamicImport), { specifier, currentFunc }); CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(DYNAMICIMPORT)); } @@ -3536,7 +3605,8 @@ DECLARE_ASM_HANDLER(HandleDeprecatedDynamicimportPrefV8) GateRef frame = GetFrame(sp); GateRef currentFunc = GetFunctionFromFrame(glue, frame); GateRef currentEnv = GetEnvFromFrame(glue, frame); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(DynamicImport), { specifier, currentFunc }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(DynamicImport), { specifier, currentFunc }); CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(DEPRECATED_DYNAMICIMPORT_PREF_V8)); } @@ -3548,7 +3618,8 @@ DECLARE_ASM_HANDLER(HandleCreateasyncgeneratorobjV8) GateRef v0 = ReadInst8_0(pc); GateRef genFunc = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateAsyncGeneratorObj), { genFunc }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(CreateAsyncGeneratorObj), { genFunc }); Label isException(env); Label notException(env); BRANCH(TaggedIsException(result), &isException, ¬Exception); @@ -3590,8 +3661,9 @@ DECLARE_ASM_HANDLER(HandleAsyncgeneratorresolveV8V8V8) GateRef flag = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc))); GateRef frame = GetFrame(*varSp); GateRef currentEnv = GetEnvFromFrame(glue, frame); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncGeneratorResolve), - { asyncGenerator, value, flag }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(AsyncGeneratorResolve), + { asyncGenerator, value, flag }); Label isException(env); Label notException(env); BRANCH(TaggedIsException(res), &isException, ¬Exception); @@ -3675,8 +3747,9 @@ DECLARE_ASM_HANDLER(HandleAsyncgeneratorrejectV8) DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc); GateRef asyncGenerator = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_0(pc))); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncGeneratorReject), - { asyncGenerator, acc }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(AsyncGeneratorReject), + { asyncGenerator, acc }); CHECK_EXCEPTION_VARACC(res, INT_PTR(ASYNCGENERATORREJECT_V8)); } @@ -3694,8 +3767,9 @@ DECLARE_ASM_HANDLER(HandleDeprecatedAsyncgeneratorrejectPrefV8V8) GateRef asyncGenerator = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc))); GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc))); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncGeneratorReject), - { asyncGenerator, value }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(AsyncGeneratorReject), + { asyncGenerator, value }); CHECK_EXCEPTION_VARACC(res, INT_PTR(DEPRECATED_ASYNCGENERATORREJECT_PREF_V8_V8)); } @@ -3756,7 +3830,8 @@ DECLARE_ASM_HANDLER(HandleSupercallthisrangeImm8Imm8V8) } Bind(&slowPath); GateRef currentEnv = GetEnvFromFrame(glue, frame); - res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SuperCall), + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + res = CallRuntime(glue, RTSTUB_ID(SuperCall), { thisFunc, Int16ToTaggedInt(v0), Int16ToTaggedInt(range) }); Jump(&checkResult); Bind(&checkResult); @@ -3781,8 +3856,9 @@ DECLARE_ASM_HANDLER(HandleSupercallarrowrangeImm8Imm8V8) GateRef range = ReadInst8_1(pc); GateRef v0 = ZExtInt8ToInt16(ReadInst8_2(pc)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SuperCall), - { acc, Int16ToTaggedInt(v0), Int8ToTaggedInt(range) }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(SuperCall), + { acc, Int16ToTaggedInt(v0), Int8ToTaggedInt(range) }); CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(SUPERCALLARROWRANGE_IMM8_IMM8_V8)); } @@ -3793,8 +3869,9 @@ DECLARE_ASM_HANDLER(HandleWideSupercallthisrangePrefImm16V8) GateRef frame = GetFrame(sp); GateRef currentFunc = GetFunctionFromFrame(glue, frame); GateRef currentEnv = GetEnvFromFrame(glue, frame); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SuperCall), - { currentFunc, Int16ToTaggedInt(v0), Int16ToTaggedInt(range) }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(SuperCall), + { currentFunc, Int16ToTaggedInt(v0), Int16ToTaggedInt(range) }); CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(WIDE_SUPERCALLTHISRANGE_PREF_IMM16_V8)); } @@ -3803,8 +3880,9 @@ DECLARE_ASM_HANDLER(HandleWideSupercallarrowrangePrefImm16V8) GateRef range = ReadInst16_1(pc); GateRef v0 = ZExtInt8ToInt16(ReadInst8_3(pc)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SuperCall), - { acc, Int16ToTaggedInt(v0), Int16ToTaggedInt(range) }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(SuperCall), + { acc, Int16ToTaggedInt(v0), Int16ToTaggedInt(range) }); CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(WIDE_SUPERCALLARROWRANGE_PREF_IMM16_V8)); } @@ -3814,8 +3892,8 @@ DECLARE_ASM_HANDLER(HandleLdsuperbyvalueImm8V8) GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef propKey = acc; GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdSuperByValue), - { receiver, propKey }); // sp for thisFunc + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(LdSuperByValue), { receiver, propKey }); // sp for thisFunc CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(LDSUPERBYVALUE_IMM8_V8)); } DECLARE_ASM_HANDLER(HandleLdsuperbyvalueImm16V8) @@ -3824,8 +3902,8 @@ DECLARE_ASM_HANDLER(HandleLdsuperbyvalueImm16V8) GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef propKey = acc; GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdSuperByValue), - { receiver, propKey }); // sp for thisFunc + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(LdSuperByValue), { receiver, propKey }); // sp for thisFunc CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(LDSUPERBYVALUE_IMM16_V8)); } @@ -3836,8 +3914,8 @@ DECLARE_ASM_HANDLER(HandleDeprecatedLdsuperbyvaluePrefV8V8) GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(v1)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdSuperByValue), - { receiver, propKey }); // sp for thisFunc + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(LdSuperByValue), { receiver, propKey }); // sp for thisFunc CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_LDSUPERBYVALUE_PREF_V8_V8)); } @@ -3848,7 +3926,8 @@ DECLARE_ASM_HANDLER(HandleDeprecatedGetiteratornextPrefV8V8) GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef method = GetVregValue(glue, sp, ZExtInt8ToPtr(v1)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(GetIteratorNext), { obj, method }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(GetIteratorNext), { obj, method }); CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_GETITERATORNEXT_PREF_V8_V8)); } @@ -3908,7 +3987,8 @@ DECLARE_ASM_HANDLER(HandleLdsuperbynameImm8Id16) GateRef receiver = acc; GateRef propKey = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdSuperByValue), { receiver, propKey }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(LdSuperByValue), { receiver, propKey }); CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(LDSUPERBYNAME_IMM8_ID16)); } @@ -3920,7 +4000,8 @@ DECLARE_ASM_HANDLER(HandleLdsuperbynameImm16Id16) GateRef receiver = acc; GateRef propKey = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdSuperByValue), { receiver, propKey }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(LdSuperByValue), { receiver, propKey }); CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(LDSUPERBYNAME_IMM16_ID16)); } @@ -3933,7 +4014,8 @@ DECLARE_ASM_HANDLER(HandleDeprecatedLdsuperbynamePrefId32V8) GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); GateRef propKey = GetStringFromConstPool(glue, constpool, stringId); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdSuperByValue), { receiver, propKey }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(LdSuperByValue), { receiver, propKey }); CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(DEPRECATED_LDSUPERBYNAME_PREF_ID32_V8)); } @@ -3959,8 +4041,9 @@ DECLARE_ASM_HANDLER(HandleLdobjbyindexImm8Imm16) } Bind(&slowPath); { - GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(LdObjByIndex), - { receiver, IntToTaggedInt(index), TaggedFalse(), Undefined() }); + SetGlueGlobalEnv(glue, globalEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(LdObjByIndex), + { receiver, IntToTaggedInt(index), TaggedFalse(), Undefined() }); CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(LDOBJBYINDEX_IMM8_IMM16)); } } @@ -3987,8 +4070,9 @@ DECLARE_ASM_HANDLER(HandleLdobjbyindexImm16Imm16) } Bind(&slowPath); { - GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(LdObjByIndex), - { receiver, IntToTaggedInt(index), TaggedFalse(), Undefined() }); + SetGlueGlobalEnv(glue, globalEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(LdObjByIndex), + { receiver, IntToTaggedInt(index), TaggedFalse(), Undefined() }); CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(LDOBJBYINDEX_IMM16_IMM16)); } } @@ -4015,8 +4099,9 @@ DECLARE_ASM_HANDLER(HandleWideLdobjbyindexPrefImm32) } Bind(&slowPath); { - GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(LdObjByIndex), - { receiver, IntToTaggedInt(index), TaggedFalse(), Undefined() }); + SetGlueGlobalEnv(glue, globalEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(LdObjByIndex), + { receiver, IntToTaggedInt(index), TaggedFalse(), Undefined() }); CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(WIDE_LDOBJBYINDEX_PREF_IMM32)); } } @@ -4044,8 +4129,9 @@ DECLARE_ASM_HANDLER(HandleDeprecatedLdobjbyindexPrefV8Imm32) } Bind(&slowPath); { - GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(LdObjByIndex), - { receiver, IntToTaggedInt(index), TaggedFalse(), Undefined() }); + SetGlueGlobalEnv(glue, globalEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(LdObjByIndex), + { receiver, IntToTaggedInt(index), TaggedFalse(), Undefined() }); CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_LDOBJBYINDEX_PREF_V8_IMM32)); } } @@ -4057,8 +4143,9 @@ DECLARE_ASM_HANDLER(HandleStconsttoglobalrecordImm16Id16) GateRef stringId = ReadInst16_2(pc); GateRef propKey = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StGlobalRecord), - { propKey, *varAcc, TaggedTrue() }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(StGlobalRecord), + { propKey, *varAcc, TaggedTrue() }); CHECK_EXCEPTION_VARACC(result, INT_PTR(STCONSTTOGLOBALRECORD_IMM16_ID16)); } @@ -4069,8 +4156,9 @@ DECLARE_ASM_HANDLER(HandleSttoglobalrecordImm16Id16) GateRef stringId = ReadInst16_2(pc); GateRef propKey = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId)); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StGlobalRecord), - { propKey, *varAcc, TaggedFalse() }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(StGlobalRecord), + { propKey, *varAcc, TaggedFalse() }); CHECK_EXCEPTION_VARACC(result, INT_PTR(STTOGLOBALRECORD_IMM16_ID16)); } @@ -4081,8 +4169,9 @@ DECLARE_ASM_HANDLER(HandleDeprecatedStconsttoglobalrecordPrefId32) GateRef stringId = ReadInst32_1(pc); GateRef propKey = GetStringFromConstPool(glue, constpool, stringId); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StGlobalRecord), - { propKey, *varAcc, TaggedTrue() }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(StGlobalRecord), + { propKey, *varAcc, TaggedTrue() }); CHECK_EXCEPTION_VARACC(result, INT_PTR(DEPRECATED_STCONSTTOGLOBALRECORD_PREF_ID32)); } @@ -4093,8 +4182,9 @@ DECLARE_ASM_HANDLER(HandleDeprecatedStlettoglobalrecordPrefId32) GateRef stringId = ReadInst32_1(pc); GateRef propKey = GetStringFromConstPool(glue, constpool, stringId); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StGlobalRecord), - { propKey, *varAcc, TaggedFalse() }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(StGlobalRecord), + { propKey, *varAcc, TaggedFalse() }); CHECK_EXCEPTION_VARACC(result, INT_PTR(DEPRECATED_STLETTOGLOBALRECORD_PREF_ID32)); } @@ -4105,8 +4195,9 @@ DECLARE_ASM_HANDLER(HandleDeprecatedStclasstoglobalrecordPrefId32) GateRef stringId = ReadInst32_1(pc); GateRef propKey = GetStringFromConstPool(glue, constpool, stringId); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StGlobalRecord), - { propKey, *varAcc, TaggedFalse() }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(StGlobalRecord), + { propKey, *varAcc, TaggedFalse() }); CHECK_EXCEPTION_VARACC(result, INT_PTR(DEPRECATED_STCLASSTOGLOBALRECORD_PREF_ID32)); } @@ -4121,8 +4212,8 @@ DECLARE_ASM_HANDLER(HandleGetmodulenamespaceImm8) GateRef moduleRef = LoadModuleNamespaceByIndex(glue, ZExtInt8ToInt32(index), module); #else GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef moduleRef = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(GetModuleNamespaceByIndex), - { IntToTaggedInt(index) }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef moduleRef = CallRuntime(glue, RTSTUB_ID(GetModuleNamespaceByIndex), { IntToTaggedInt(index) }); #endif varAcc = moduleRef; DISPATCH_WITH_ACC(GETMODULENAMESPACE_IMM8); @@ -4139,8 +4230,8 @@ DECLARE_ASM_HANDLER(HandleWideGetmodulenamespacePrefImm16) GateRef moduleRef = LoadModuleNamespaceByIndex(glue, ZExtInt16ToInt32(index), module); #else GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef moduleRef = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(GetModuleNamespaceByIndex), - { Int16ToTaggedInt(index) }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef moduleRef = CallRuntime(glue, RTSTUB_ID(GetModuleNamespaceByIndex), { Int16ToTaggedInt(index) }); #endif varAcc = moduleRef; DISPATCH_WITH_ACC(WIDE_GETMODULENAMESPACE_PREF_IMM16); @@ -4153,7 +4244,8 @@ DECLARE_ASM_HANDLER(HandleDeprecatedGetmodulenamespacePrefId32) GateRef stringId = ReadInst32_1(pc); GateRef prop = GetStringFromConstPool(glue, constpool, stringId); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef moduleRef = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(GetModuleNamespace), { prop }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef moduleRef = CallRuntime(glue, RTSTUB_ID(GetModuleNamespace), { prop }); varAcc = moduleRef; DISPATCH_WITH_ACC(DEPRECATED_GETMODULENAMESPACE_PREF_ID32); } @@ -4194,8 +4286,8 @@ DECLARE_ASM_HANDLER(HandleLdexternalmodulevarImm8) GateRef indexInt32 = ZExtInt8ToInt32(index); varAcc = LoadExternalmodulevar(glue, indexInt32, module); #else - varAcc = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(LdExternalModuleVarByIndexWithModule), - {Int8ToTaggedInt(index), module}); + SetGlueGlobalEnv(glue, globalEnv); + varAcc = CallRuntime(glue, RTSTUB_ID(LdExternalModuleVarByIndexWithModule), {Int8ToTaggedInt(index), module}); #endif DISPATCH_WITH_ACC(LDEXTERNALMODULEVAR_IMM8); } @@ -4214,8 +4306,8 @@ DECLARE_ASM_HANDLER(HandleWideLdexternalmodulevarPrefImm16) GateRef indexInt32 = ZExtInt16ToInt32(index); varAcc = LoadExternalmodulevar(glue, indexInt32, module); #else - varAcc = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(LdExternalModuleVarByIndexWithModule), - {Int16ToTaggedInt(index), module}); + SetGlueGlobalEnv(glue, globalEnv); + varAcc = CallRuntime(glue, RTSTUB_ID(LdExternalModuleVarByIndexWithModule), {Int16ToTaggedInt(index), module}); #endif DISPATCH_WITH_ACC(WIDE_LDEXTERNALMODULEVAR_PREF_IMM16); } @@ -4228,8 +4320,8 @@ DECLARE_ASM_HANDLER(HandleDeprecatedLdmodulevarPrefId32Imm8) GateRef flag = ZExtInt8ToInt32(ReadInst8_5(pc)); GateRef key = GetStringFromConstPool(glue, constpool, stringId); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef moduleRef = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdModuleVar), - { key, IntToTaggedInt(flag) }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef moduleRef = CallRuntime(glue, RTSTUB_ID(LdModuleVar), { key, IntToTaggedInt(flag) }); varAcc = moduleRef; DISPATCH_WITH_ACC(DEPRECATED_LDMODULEVAR_PREF_ID32_IMM8); } @@ -4239,7 +4331,8 @@ DECLARE_ASM_HANDLER(HandleStmodulevarImm8) GateRef index = ReadInst8_0(pc); GateRef value = acc; GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StModuleVarByIndex), { IntToTaggedInt(index), value }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + CallRuntime(glue, RTSTUB_ID(StModuleVarByIndex), { IntToTaggedInt(index), value }); DISPATCH(STMODULEVAR_IMM8); } @@ -4248,7 +4341,8 @@ DECLARE_ASM_HANDLER(HandleWideStmodulevarPrefImm16) GateRef index = ReadInst16_1(pc); GateRef value = acc; GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StModuleVarByIndex), { Int16ToTaggedInt(index), value }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + CallRuntime(glue, RTSTUB_ID(StModuleVarByIndex), { Int16ToTaggedInt(index), value }); DISPATCH(WIDE_STMODULEVAR_PREF_IMM16); } @@ -4258,7 +4352,8 @@ DECLARE_ASM_HANDLER(HandleDeprecatedStmodulevarPrefId32) GateRef prop = GetStringFromConstPool(glue, constpool, stringId); GateRef value = acc; GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StModuleVar), { prop, value }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + CallRuntime(glue, RTSTUB_ID(StModuleVar), { prop, value }); DISPATCH(DEPRECATED_STMODULEVAR_PREF_ID32); } @@ -4312,8 +4407,9 @@ DECLARE_ASM_HANDLER(HandleNewlexenvwithnameImm8Id16) GateRef scopeId = ReadInst16_1(pc); GateRef state = GetFrame(sp); GateRef currentEnv = GetEnvFromFrame(glue, state); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(NewLexicalEnvWithName), - { Int16ToTaggedInt(numVars), Int16ToTaggedInt(scopeId) }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(NewLexicalEnvWithName), + { Int16ToTaggedInt(numVars), Int16ToTaggedInt(scopeId) }); Label notException(env); CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception); Bind(¬Exception); @@ -4330,8 +4426,9 @@ DECLARE_ASM_HANDLER(HandleWideNewlexenvwithnamePrefImm16Id16) GateRef scopeId = ReadInst16_3(pc); GateRef state = GetFrame(sp); GateRef currentEnv = GetEnvFromFrame(glue, state); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(NewLexicalEnvWithName), - { Int16ToTaggedInt(numVars), Int16ToTaggedInt(scopeId) }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(NewLexicalEnvWithName), + { Int16ToTaggedInt(numVars), Int16ToTaggedInt(scopeId) }); Label notException(env); CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception); Bind(¬Exception); @@ -4354,9 +4451,12 @@ DECLARE_ASM_HANDLER(HandleDefineclasswithbufferImm8Id16Id16Imm16V8) GateRef currentEnv = GetEnvFromFrame(glue, frame); GateRef currentFunc = GetFunctionFromFrame(glue, frame); GateRef module = GetModuleFromFunction(glue, currentFunc); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateClassWithBuffer), - { proto, currentEnv, constpool, Int16ToTaggedInt(methodId), Int16ToTaggedInt(literalId), - module, Int16ToTaggedInt(length) }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(CreateClassWithBuffer), + { proto, currentEnv, constpool, + Int16ToTaggedInt(methodId), + Int16ToTaggedInt(literalId), module, + Int16ToTaggedInt(length)}); Label isException(env); Label isNotException(env); @@ -4389,9 +4489,12 @@ DECLARE_ASM_HANDLER(HandleDefineclasswithbufferImm16Id16Id16Imm16V8) GateRef currentEnv = GetEnvFromFrame(glue, frame); GateRef currentFunc = GetFunctionFromFrame(glue, frame); GateRef module = GetModuleFromFunction(glue, currentFunc); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateClassWithBuffer), - { proto, currentEnv, constpool, Int16ToTaggedInt(methodId), - Int16ToTaggedInt(literalId), module, Int16ToTaggedInt(length) }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(CreateClassWithBuffer), + { proto, currentEnv, constpool, + Int16ToTaggedInt(methodId), + Int16ToTaggedInt(literalId), module, + Int16ToTaggedInt(length)}); Label isException(env); Label isNotException(env); @@ -4427,9 +4530,12 @@ DECLARE_ASM_HANDLER(HandleDeprecatedDefineclasswithbufferPrefId16Imm16Imm16V8V8) GateRef currentFunc = GetFunctionFromFrame(glue, frame); GateRef module = GetModuleFromFunction(glue, currentFunc); GateRef currentEnv = GetEnvFromFrame(glue, frame); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateClassWithBuffer), - { proto, lexicalEnv, constpool, Int16ToTaggedInt(methodId), - Int16ToTaggedInt(literalId), module, Int16ToTaggedInt(length) }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(CreateClassWithBuffer), + { proto, lexicalEnv, constpool, + Int16ToTaggedInt(methodId), + Int16ToTaggedInt(literalId), module, + Int16ToTaggedInt(length)}); Label isException(env); Label isNotException(env); @@ -4879,7 +4985,8 @@ DECLARE_ASM_HANDLER(HandleDeprecatedCreateobjectwithbufferPrefImm16) GateRef module = GetModuleFromFunction(glue, currentFunc); GateRef result = GetObjectLiteralFromConstPool(glue, constpool, imm, module); GateRef currentEnv = GetEnvFromFrame(glue, frame); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateObjectWithBuffer), { result }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(CreateObjectWithBuffer), { result }); CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(DEPRECATED_CREATEOBJECTWITHBUFFER_PREF_IMM16)); } @@ -4940,7 +5047,8 @@ DECLARE_ASM_HANDLER(HandleNewobjrangeImm8Imm8V8) GateRef firstArgIdx = Int16Add(firstArgRegIdx, firstArgOffset); GateRef length = Int16Sub(numArgs, firstArgOffset); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(NewObjRange), + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + res = CallRuntime(glue, RTSTUB_ID(NewObjRange), { ctor, ctor, Int16ToTaggedInt(firstArgIdx), Int16ToTaggedInt(length) }); Jump(&checkResult); Bind(&checkResult); @@ -5018,7 +5126,8 @@ DECLARE_ASM_HANDLER(HandleNewobjrangeImm16Imm8V8) GateRef firstArgIdx = Int16Add(firstArgRegIdx, firstArgOffset); GateRef length = Int16Sub(numArgs, firstArgOffset); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(NewObjRange), + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + res = CallRuntime(glue, RTSTUB_ID(NewObjRange), { ctor, ctor, Int16ToTaggedInt(firstArgIdx), Int16ToTaggedInt(length) }); Jump(&checkResult); Bind(&checkResult); @@ -5090,7 +5199,8 @@ DECLARE_ASM_HANDLER(HandleWideNewobjrangePrefImm16V8) GateRef firstArgIdx = Int16Add(firstArgRegIdx, firstArgOffset); GateRef length = Int16Sub(numArgs, firstArgOffset); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(NewObjRange), + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + res = CallRuntime(glue, RTSTUB_ID(NewObjRange), { ctor, ctor, Int16ToTaggedInt(firstArgIdx), Int16ToTaggedInt(length) }); Jump(&checkResult); Bind(&checkResult); @@ -5246,7 +5356,8 @@ DECLARE_ASM_HANDLER(HandleDefinemethodImm8Id16Imm8) NewObjectStubBuilder newBuilder(this, globalEnv); result = newBuilder.DefineMethod(glue, *result, acc, ZExtInt8ToInt32(length), currentEnv, GetModule(glue, sp)); #else - result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(DefineMethod), { *result, acc, Int8ToTaggedInt(length), + SetGlueGlobalEnv(glue, globalEnv); + result = CallRuntime(glue, RTSTUB_ID(DefineMethod), { *result, acc, Int8ToTaggedInt(length), currentEnv, GetModule(glue, sp) }); #endif @@ -5278,8 +5389,9 @@ DECLARE_ASM_HANDLER(HandleDefinemethodImm16Id16Imm8) NewObjectStubBuilder newBuilder(this, globalEnv); result = newBuilder.DefineMethod(glue, *result, acc, ZExtInt8ToInt32(length), currentEnv, GetModule(glue, sp)); #else - result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(DefineMethod), { *result, acc, Int8ToTaggedInt(length), - currentEnv, GetModule(glue, sp) }); + SetGlueGlobalEnv(glue, globalEnv); + result = CallRuntime(glue, RTSTUB_ID(DefineMethod), { *result, acc, Int8ToTaggedInt(length), + currentEnv, GetModule(glue, sp) }); #endif #if ECMASCRIPT_ENABLE_IC @@ -5301,7 +5413,8 @@ DECLARE_ASM_HANDLER(HandleApplyImm8V8V8) GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc))); GateRef array = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc))); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CallSpread), { func, obj, array }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(CallSpread), { func, obj, array }); CHECK_PENDING_EXCEPTION(res, INT_PTR(APPLY_IMM8_V8_V8)); } @@ -5311,14 +5424,16 @@ DECLARE_ASM_HANDLER(HandleDeprecatedCallspreadPrefV8V8V8) GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc))); GateRef array = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_3(pc))); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CallSpread), { func, obj, array }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(CallSpread), { func, obj, array }); CHECK_PENDING_EXCEPTION(res, INT_PTR(DEPRECATED_CALLSPREAD_PREF_V8_V8_V8)); } DECLARE_ASM_HANDLER(HandleThrowNotexistsPrefNone) { GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowThrowNotExists), {}); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + CallRuntime(glue, RTSTUB_ID(ThrowThrowNotExists), {}); DISPATCH_LAST(); } DECLARE_ASM_HANDLER(HandleThrowPrefNone) @@ -5828,14 +5943,16 @@ DECLARE_ASM_HANDLER(BCDebuggerExceptionEntry) DECLARE_ASM_HANDLER(NewObjectRangeThrowException) { GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowDerivedMustReturnException), {}); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + CallRuntime(glue, RTSTUB_ID(ThrowDerivedMustReturnException), {}); DISPATCH_LAST(); } DECLARE_ASM_HANDLER(ThrowStackOverflowException) { GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowStackOverflowException), {}); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + CallRuntime(glue, RTSTUB_ID(ThrowStackOverflowException), {}); DISPATCH_LAST(); } @@ -5907,7 +6024,8 @@ DECLARE_ASM_HANDLER(HandleWideLdpatchvarPrefImm16) GateRef index = ReadInst16_1(pc); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdPatchVar), { Int16ToTaggedInt(index) }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(LdPatchVar), { Int16ToTaggedInt(index) }); CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(WIDE_LDPATCHVAR_PREF_IMM16)); } @@ -5915,8 +6033,8 @@ DECLARE_ASM_HANDLER(HandleWideStpatchvarPrefImm16) { GateRef index = ReadInst16_1(pc); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StPatchVar), - { Int16ToTaggedInt(index), acc }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef result = CallRuntime(glue, RTSTUB_ID(StPatchVar), { Int16ToTaggedInt(index), acc }); CHECK_EXCEPTION(result, INT_PTR(WIDE_STPATCHVAR_PREF_IMM16)); } @@ -5986,8 +6104,9 @@ DECLARE_ASM_HANDLER(HandleCallRuntimeCreatePrivatePropertyPrefImm16Id16) GateRef module = GetModuleFromFunction(glue, currentFunc); GateRef count = ZExtInt16ToInt32(ReadInst16_1(pc)); GateRef literalId = ZExtInt16ToInt32(ReadInst16_3(pc)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreatePrivateProperty), - { currentEnv, IntToTaggedInt(count), constpool, IntToTaggedInt(literalId), module }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(CreatePrivateProperty), {currentEnv, + IntToTaggedInt(count), constpool, IntToTaggedInt(literalId), module}); CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(CALLRUNTIME_CREATEPRIVATEPROPERTY_PREF_IMM16_ID16)); } @@ -5998,8 +6117,9 @@ DECLARE_ASM_HANDLER(HandleCallRuntimeDefinePrivatePropertyPrefImm8Imm16Imm16V8) GateRef slotIndex = ReadInst16_4(pc); GateRef v0 = ReadInst8_6(pc); GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0)); - GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(DefinePrivateProperty), - { currentEnv, IntToTaggedInt(levelIndex), IntToTaggedInt(slotIndex), obj, acc }); // acc as value + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + GateRef res = CallRuntime(glue, RTSTUB_ID(DefinePrivateProperty), {currentEnv, + IntToTaggedInt(levelIndex), IntToTaggedInt(slotIndex), obj, acc}); // acc as value CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(CALLRUNTIME_DEFINEPRIVATEPROPERTY_PREF_IMM8_IMM16_IMM16_V8)); } @@ -6311,8 +6431,8 @@ DECLARE_ASM_HANDLER(HandleCallRuntimeLdLazyModuleVarPrefImm8) GateRef frame = GetFrame(sp); GateRef currentFunc = GetFunctionFromFrame(glue, frame); GateRef currentEnv = GetEnvFromFrame(glue, frame); - moduleRef = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdLazyExternalModuleVarByIndex), - { Int8ToTaggedInt(index), currentFunc }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + moduleRef = CallRuntime(glue, RTSTUB_ID(LdLazyExternalModuleVarByIndex), { Int8ToTaggedInt(index), currentFunc }); auto env = GetEnvironment(); Label notException(env); @@ -6333,8 +6453,8 @@ DECLARE_ASM_HANDLER(HandleCallRuntimeWideLdLazyModuleVarPrefImm16) GateRef frame = GetFrame(sp); GateRef currentFunc = GetFunctionFromFrame(glue, frame); GateRef currentEnv = GetEnvFromFrame(glue, frame); - moduleRef = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdLazyExternalModuleVarByIndex), - { Int16ToTaggedInt(index), currentFunc }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + moduleRef = CallRuntime(glue, RTSTUB_ID(LdLazyExternalModuleVarByIndex), { Int16ToTaggedInt(index), currentFunc }); auto env = GetEnvironment(); Label notException(env); @@ -6399,7 +6519,8 @@ DECLARE_ASM_HANDLER(HandleCallRuntimeSuperCallForwardAllArgsV8) GateRef thisFunc = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc))); GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); - res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SuperCallForwardAllArgs), { thisFunc }); + SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); + res = CallRuntime(glue, RTSTUB_ID(SuperCallForwardAllArgs), { thisFunc }); BRANCH(TaggedIsException(*res), &resIsException, &dispatch); Bind(&resIsException); diff --git a/ecmascript/compiler/slowpath_lowering.cpp b/ecmascript/compiler/slowpath_lowering.cpp index ba43fad24f..0fecc1410d 100644 --- a/ecmascript/compiler/slowpath_lowering.cpp +++ b/ecmascript/compiler/slowpath_lowering.cpp @@ -1370,9 +1370,8 @@ void SlowPathLowering::LowerExceptionHandler(GateRef hirGate) void SlowPathLowering::LowerLdSymbol(GateRef gate) { - GateRef globalEnv = circuit_->GetGlobalEnvCache(); - GateRef newGate = builder_.GetGlobalEnvValue(VariableType::JS_POINTER(), glue_, - globalEnv, GlobalEnv::SYMBOL_FUNCTION_INDEX); + const int id = RTSTUB_ID(GetSymbolFunction); + GateRef newGate = LowerCallRuntime(gate, id, {}); ReplaceHirWithValue(gate, newGate); } diff --git a/ecmascript/compiler/stub_builder-inl.h b/ecmascript/compiler/stub_builder-inl.h index a6df5cc620..64338a049d 100644 --- a/ecmascript/compiler/stub_builder-inl.h +++ b/ecmascript/compiler/stub_builder-inl.h @@ -238,41 +238,6 @@ inline GateRef StubBuilder::CallRuntime(GateRef glue, int index, GateRef argc, G return result; } -inline GateRef StubBuilder::CallRuntimeWithGlobalEnv(GateRef glue, GateRef globalEnv, - int index, const std::vector& args) -{ - SavePcIfNeeded(glue); - SetGlueGlobalEnv(glue, globalEnv); - const std::string name = RuntimeStubCSigns::GetRTName(index); - GateRef result = env_->GetBuilder()->CallRuntime(glue, index, Gate::InvalidGateRef, args, - glue, name.c_str()); - return result; -} - -inline GateRef StubBuilder::CallRuntimeWithGlobalEnv(GateRef glue, GateRef globalEnv, - int index, GateRef argc, GateRef argv) -{ - SavePcIfNeeded(glue); - SetGlueGlobalEnv(glue, globalEnv); - const std::string name = RuntimeStubCSigns::GetRTName(index); - GateRef result = env_->GetBuilder()->CallRuntimeVarargs(glue, index, argc, argv, name.c_str()); - return result; -} - -// To reduce overhead, we provide an additional interface for -// bytecode that directly CallRuntime and requires globalEnv, -// which is essentially the same as CallRuntimeWithGlobalEnv. -inline GateRef StubBuilder::CallRuntimeWithCurrentEnv(GateRef glue, GateRef currentEnv, - int index, const std::vector& args) -{ - SavePcIfNeeded(glue); - SetGlueGlobalEnvFromCurrentEnv(glue, currentEnv); - const std::string name = RuntimeStubCSigns::GetRTName(index); - GateRef result = env_->GetBuilder()->CallRuntime(glue, index, Gate::InvalidGateRef, args, - glue, name.c_str()); - return result; -} - inline GateRef StubBuilder::CallNGCRuntime(GateRef glue, int index, const std::vector& args, GateRef hir) { @@ -1644,18 +1609,6 @@ inline GateRef StubBuilder::IsGlobalEnv(GateRef glue, GateRef obj) return Int32Equal(objectType, Int32(static_cast(JSType::GLOBAL_ENV))); } -inline GateRef StubBuilder::IsLexicalEnv(GateRef glue, GateRef obj) -{ - GateRef objectType = GetObjectType(LoadHClass(glue, obj)); - return Int32Equal(objectType, Int32(static_cast(JSType::LEXICAL_ENV))); -} - -inline GateRef StubBuilder::IsSFunctionEnv(GateRef glue, GateRef obj) -{ - GateRef objectType = GetObjectType(LoadHClass(glue, obj)); - return Int32Equal(objectType, Int32(static_cast(JSType::SFUNCTION_ENV))); -} - inline GateRef StubBuilder::IsNativeModuleFailureInfo(GateRef glue, GateRef obj) { GateRef objectType = GetObjectType(LoadHClass(glue, obj)); @@ -3679,33 +3632,6 @@ inline void StubBuilder::SetGlueGlobalEnv(GateRef glue, GateRef globalEnv) StoreWithoutBarrier(VariableType::JS_POINTER(), glue, globalEnvOffset, globalEnv); } -inline void StubBuilder::SetGlueGlobalEnvFromCurrentEnv(GateRef glue, GateRef currentEnv) -{ - auto env0 = GetEnvironment(); - { - ASM_ASSERT(GET_MESSAGE_STRING_ID(CurrentEnvIsInvalid), - LogicAndBuilder(env0).And(TaggedIsHeapObject(currentEnv)) - .And(LogicOrBuilder(env0).Or(IsGlobalEnv(glue, currentEnv)) - .Or(IsLexicalEnv(glue, currentEnv)) - .Or(IsSFunctionEnv(glue, currentEnv)).Done()) - .Done()); - } - Label entry(env0); - env0->SubCfgEntry(&entry); - Label setGlue(env0); - Label exit(env0); - GateRef globalEnv = GetValueFromTaggedArray(glue, currentEnv, Int32(BaseEnv::GLOBAL_ENV_INDEX)); - BRANCH_UNLIKELY(TaggedIsHole(globalEnv), &exit, &setGlue); - Bind(&setGlue); - { - GateRef globalEnvOffset = IntPtr(JSThread::GlueData::GetCurrentEnvOffset(env0->IsArch32Bit())); - StoreWithoutBarrier(VariableType::JS_POINTER(), glue, globalEnvOffset, globalEnv); - Jump(&exit); - } - Bind(&exit); - env0->SubCfgExit(); -} - inline GateRef StubBuilder::GetGlobalObject(GateRef glue, GateRef globalEnv) { return env_->GetBuilder()->GetGlobalObject(glue, globalEnv); diff --git a/ecmascript/compiler/stub_builder.cpp b/ecmascript/compiler/stub_builder.cpp index 1097851a39..04d131fd13 100644 --- a/ecmascript/compiler/stub_builder.cpp +++ b/ecmascript/compiler/stub_builder.cpp @@ -13165,19 +13165,12 @@ GateRef StubBuilder::ComputeStringHashcode(GateRef glue, GateRef str) GateRef StubBuilder::GetCurrentGlobalEnv(GateRef glue, GateRef currentEnv) { - auto env0 = GetEnvironment(); - { - ASM_ASSERT(GET_MESSAGE_STRING_ID(CurrentEnvIsInvalid), - LogicAndBuilder(env0).And(TaggedIsHeapObject(currentEnv)) - .And(LogicOrBuilder(env0).Or(IsGlobalEnv(glue, currentEnv)) - .Or(IsLexicalEnv(glue, currentEnv)) - .Or(IsSFunctionEnv(glue, currentEnv)).Done()) - .Done()); - } - Label entry(env0); - env0->SubCfgEntry(&entry); - Label fromGlue(env0); - Label exit(env0); + ASM_ASSERT(GET_MESSAGE_STRING_ID(CurrenEnvIsUndefined), BoolNot(TaggedIsUndefined(currentEnv))); + auto env = GetEnvironment(); + Label entry(env); + env->SubCfgEntry(&entry); + Label fromGlue(env); + Label exit(env); DEFVARIABLE(globalEnv, VariableType::JS_ANY(), Undefined()); globalEnv = GetValueFromTaggedArray(glue, currentEnv, Int32(BaseEnv::GLOBAL_ENV_INDEX)); @@ -13189,7 +13182,27 @@ GateRef StubBuilder::GetCurrentGlobalEnv(GateRef glue, GateRef currentEnv) } Bind(&exit); auto ret = *globalEnv; - env0->SubCfgExit(); + env->SubCfgExit(); return ret; } + +void StubBuilder::SetGlueGlobalEnvFromCurrentEnv(GateRef glue, GateRef currentEnv) +{ + ASM_ASSERT(GET_MESSAGE_STRING_ID(CurrenEnvIsUndefined), BoolNot(TaggedIsUndefined(currentEnv))); + auto env = GetEnvironment(); + Label entry(env); + env->SubCfgEntry(&entry); + Label setGlue(env); + Label exit(env); + GateRef globalEnv = GetValueFromTaggedArray(glue, currentEnv, Int32(BaseEnv::GLOBAL_ENV_INDEX)); + BRANCH_UNLIKELY(TaggedIsHole(globalEnv), &exit, &setGlue); + Bind(&setGlue); + { + GateRef globalEnvOffset = IntPtr(JSThread::GlueData::GetCurrentEnvOffset(env->IsArch32Bit())); + StoreWithoutBarrier(VariableType::JS_POINTER(), glue, globalEnvOffset, globalEnv); + Jump(&exit); + } + Bind(&exit); + env->SubCfgExit(); +} } // namespace panda::ecmascript::kungfu diff --git a/ecmascript/compiler/stub_builder.h b/ecmascript/compiler/stub_builder.h index 1065dc7836..27d290d312 100644 --- a/ecmascript/compiler/stub_builder.h +++ b/ecmascript/compiler/stub_builder.h @@ -185,10 +185,6 @@ public: // call operation GateRef CallRuntime(GateRef glue, int index, const std::vector& args); GateRef CallRuntime(GateRef glue, int index, GateRef argc, GateRef argv); - GateRef CallRuntimeWithGlobalEnv(GateRef glue, GateRef globalEnv, int index, const std::vector& args); - GateRef CallRuntimeWithGlobalEnv(GateRef glue, GateRef globalEnv, int index, GateRef argc, GateRef argv); - GateRef CallRuntimeWithCurrentEnv(GateRef glue, GateRef currentEnv, int index, const std::vector& args); - GateRef CallNGCRuntime(GateRef glue, int index, const std::vector& args, GateRef hir = Circuit::NullGate()); GateRef FastCallOptimized(GateRef glue, GateRef code, @@ -488,8 +484,6 @@ public: GateRef IsMutantTaggedArray(GateRef glue, GateRef elements); GateRef IsJSObject(GateRef glue, GateRef obj); GateRef IsGlobalEnv(GateRef glue, GateRef obj); - GateRef IsLexicalEnv(GateRef glue, GateRef obj); - GateRef IsSFunctionEnv(GateRef glue, GateRef obj); GateRef IsEnumerable(GateRef attr); GateRef IsWritable(GateRef attr); GateRef IsConfigable(GateRef attr); @@ -944,8 +938,8 @@ public: GateRef GetGlobalEnv(GateRef glue); GateRef GetGlobalObject(GateRef glue, GateRef globalEnv); GateRef GetCurrentGlobalEnv(GateRef glue, GateRef currentEnv); - void SetGlueGlobalEnv(GateRef glue, GateRef globalEnv); void SetGlueGlobalEnvFromCurrentEnv(GateRef glue, GateRef currentEnv); + void SetGlueGlobalEnv(GateRef glue, GateRef globalEnv); GateRef GetMethodFromFunction(GateRef glue, GateRef function); GateRef GetModuleFromFunction(GateRef glue, GateRef function); GateRef GetLengthFromFunction(GateRef function); diff --git a/ecmascript/message_string.h b/ecmascript/message_string.h index 23abd8d258..bd299f0c2c 100644 --- a/ecmascript/message_string.h +++ b/ecmascript/message_string.h @@ -23,73 +23,73 @@ namespace panda::ecmascript { // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define COMMON_MESSAGE_STRING_LIST(V) \ - V(SetReadOnlyProperty, "Cannot assign to read only property") \ - V(SetTypeMismatchedSharedProperty, "Cannot set sendable property with mismatched type") \ - V(CreateObjectWithSendableProto, "Cannot create object with sendable proto") \ - V(UpdateSendableAttributes, "Cannot update sendable object's attributes") \ - V(SetProtoWithSendable, "Cannot set proto with sendable object") \ - V(ClassNotDerivedFromShared, "Class not derived from a sendable object") \ - V(NotSendableSubClass, "The subclass of sendable class must be a sendable class") \ - V(FunctionCallNotConstructor, "class constructor cannot call") \ - V(SetPropertyWhenNotExtensible, "Cannot add property in prevent extensions") \ - V(GetPropertyOutOfBounds, "Get Property index out-of-bounds") \ - V(CanNotSetPropertyOnContainer, "Cannot set property on Container") \ - V(NonCallable, "CallObj is NonCallable") \ - V(ASM_INTERPRETER_STUB_NAME, "ASM_INTERPRETER stub name: ") \ - V(OPCODE_OVERFLOW, "opcode overflow!") \ - V(INT32_VALUE, "value: %ld") \ - V(TargetTypeNotObject, "Type of target is not Object") \ - V(TargetTypeNotTypedArray, "The O is not a TypedArray.") \ - V(CanNotGetNotEcmaObject, "Can not get Prototype on non ECMA Object") \ - V(SendableArrayForJson, "Array not supported for SENDABLE_JSON") \ - V(InstanceOfErrorTargetNotCallable, "InstanceOf error when target is not Callable") \ - V(ApplyTargetNotCallable, "apply target is not callable") \ - V(TargetNotStableJSArray, "target not stable JSArray") \ - V(LenGreaterThanMax, "len is bigger than 2^32 - 1") \ - V(ElementTypeNoElementTypes, "CreateListFromArrayLike: not an element of elementTypes") \ - V(TargetIsDetachedBuffer, "Is Detached Buffer") \ - V(ThisBranchIsUnreachable, "this branch is unreachable") \ - V(CanNotConvertNotUndefinedObject, "Cannot convert a UNDEFINED value to a JSObject") \ - V(CanNotConvertNotNullObject, "Cannot convert a NULL value to a JSObject") \ - V(CanNotConvertNotHoleObject, "Cannot convert a HOLE value to a JSObject") \ - V(CanNotConvertUnknowObject, "Cannot convert a Unknown object value to a JSObject") \ - V(CanNotConvertNotValidObject, "Obj is not a valid object") \ - V(CanNotConvertContainerObject, "Can not delete property in Container Object") \ - V(InvalidStringLength, "Invalid string length") \ - V(InvalidNewTarget, "new.target is not an object") \ - V(ObjIsNotCallable, "obj is not Callable") \ - V(SharedObjectRefersLocalObject, "shared object refers a local object") \ - V(InvalidRadixLength, "radix must be 2 to 36") \ - V(SetPrototypeOfFailed, "SetPrototypeOf: prototype set failed") \ - V(ReviverOnlySupportUndefined, "reviver only supports undefined for SENDABLE_JSON") \ - V(DefineFieldField, "DefineField: obj is not Object") \ - V(IsNotPropertyKey, "key is not a property key") \ - V(CreateDataPropertyFailed, "failed to create data property") \ - V(ValueIsNonSObject, "value is not a shared object") \ - V(MapIteratorTypeError, "this value is not a map iterator") \ - V(SetIteratorTypeError, "this value is not a set iterator") \ - V(LengthError, "length must be positive integer") \ - V(IterNotObject, "JSIterator::GetIterator: iter is not object") \ - V(CanNotConvertObjectToPrimitiveValue, "Cannot convert object to primitive value") \ - V(CanNotConvertIllageValueToString, "Cannot convert a illegal value to a String") \ - V(CanNotConvertIllageValueToPrimitive, "Cannot convert a illegal value to a Primitive") \ - V(ProxyGetPropertyHandlerIsNull, "JSProxy::GetProperty: handler is Null") \ - V(ProxyGetPropertyResultTypeError, "JSProxy::GetProperty: TypeError of trapResult") \ - V(ProxyGetPropertyResultNotUndefined, "JSProxy::GetProperty: trapResult is not undefined") \ - V(ProxySetPropertyHandlerIsNull, "JSProxy::SetProperty: handler is Null") \ - V(ProxySetPropertyReturnFalse, "JSProxy::SetProperty: 'set' return false") \ - V(ProxySetPropertyResultTypeError, "JSProxy::SetProperty: TypeError of trapResult") \ - V(ProxySetPropertyResultNotAccessor, "JSProxy::SetProperty: TypeError of AccessorDescriptor") \ - V(InOperatorOnNonObject, "Cannot use 'in' operator in Non-Object") \ - V(CurrentModuleUndefined, "GetModuleValueOutter currentModule failed") \ - V(MisstakenResolvedBinding, "Get module value failed, mistaken ResolvedBinding") \ - V(CurrentModuleNotSourceTextModule, "Current module is not SourceTextModule") \ - V(ModuleEnvMustBeDefined, "Environment of current module must not be undefined") \ - V(CheckIsResolvedIndexBinding, "Current resolution must be ResolvedIndexBinding") \ - V(RecordNameMustBeString, "RecordName must be string") \ - V(LexicalEnvIsInvalid, "LexicalEnv of native JSFunction is invalid, it should be GlobalEnv or Undefined") \ - V(CurrentEnvIsInvalid, "CurrentEnv is invalid, it should be GlobalEnv, LexicalEnv or SFunctionEnv") \ +#define COMMON_MESSAGE_STRING_LIST(V) \ + V(SetReadOnlyProperty, "Cannot assign to read only property") \ + V(SetTypeMismatchedSharedProperty, "Cannot set sendable property with mismatched type") \ + V(CreateObjectWithSendableProto, "Cannot create object with sendable proto") \ + V(UpdateSendableAttributes, "Cannot update sendable object's attributes") \ + V(SetProtoWithSendable, "Cannot set proto with sendable object") \ + V(ClassNotDerivedFromShared, "Class not derived from a sendable object") \ + V(NotSendableSubClass, "The subclass of sendable class must be a sendable class") \ + V(FunctionCallNotConstructor, "class constructor cannot call") \ + V(SetPropertyWhenNotExtensible, "Cannot add property in prevent extensions") \ + V(GetPropertyOutOfBounds, "Get Property index out-of-bounds") \ + V(CanNotSetPropertyOnContainer, "Cannot set property on Container") \ + V(NonCallable, "CallObj is NonCallable") \ + V(ASM_INTERPRETER_STUB_NAME, "ASM_INTERPRETER stub name: ") \ + V(OPCODE_OVERFLOW, "opcode overflow!") \ + V(INT32_VALUE, "value: %ld") \ + V(TargetTypeNotObject, "Type of target is not Object") \ + V(TargetTypeNotTypedArray, "The O is not a TypedArray.") \ + V(CanNotGetNotEcmaObject, "Can not get Prototype on non ECMA Object") \ + V(SendableArrayForJson, "Array not supported for SENDABLE_JSON") \ + V(InstanceOfErrorTargetNotCallable, "InstanceOf error when target is not Callable") \ + V(ApplyTargetNotCallable, "apply target is not callable") \ + V(TargetNotStableJSArray, "target not stable JSArray") \ + V(LenGreaterThanMax, "len is bigger than 2^32 - 1") \ + V(ElementTypeNoElementTypes, "CreateListFromArrayLike: not an element of elementTypes") \ + V(TargetIsDetachedBuffer, "Is Detached Buffer") \ + V(ThisBranchIsUnreachable, "this branch is unreachable") \ + V(CanNotConvertNotUndefinedObject, "Cannot convert a UNDEFINED value to a JSObject") \ + V(CanNotConvertNotNullObject, "Cannot convert a NULL value to a JSObject") \ + V(CanNotConvertNotHoleObject, "Cannot convert a HOLE value to a JSObject") \ + V(CanNotConvertUnknowObject, "Cannot convert a Unknown object value to a JSObject") \ + V(CanNotConvertNotValidObject, "Obj is not a valid object") \ + V(CanNotConvertContainerObject, "Can not delete property in Container Object") \ + V(InvalidStringLength, "Invalid string length") \ + V(InvalidNewTarget, "new.target is not an object") \ + V(ObjIsNotCallable, "obj is not Callable") \ + V(SharedObjectRefersLocalObject, "shared object refers a local object") \ + V(InvalidRadixLength, "radix must be 2 to 36") \ + V(SetPrototypeOfFailed, "SetPrototypeOf: prototype set failed") \ + V(ReviverOnlySupportUndefined, "reviver only supports undefined for SENDABLE_JSON") \ + V(DefineFieldField, "DefineField: obj is not Object") \ + V(IsNotPropertyKey, "key is not a property key") \ + V(CreateDataPropertyFailed, "failed to create data property") \ + V(ValueIsNonSObject, "value is not a shared object") \ + V(MapIteratorTypeError, "this value is not a map iterator") \ + V(SetIteratorTypeError, "this value is not a set iterator") \ + V(LengthError, "length must be positive integer") \ + V(IterNotObject, "JSIterator::GetIterator: iter is not object") \ + V(CanNotConvertObjectToPrimitiveValue, "Cannot convert object to primitive value") \ + V(CanNotConvertIllageValueToString, "Cannot convert a illegal value to a String") \ + V(CanNotConvertIllageValueToPrimitive, "Cannot convert a illegal value to a Primitive") \ + V(ProxyGetPropertyHandlerIsNull, "JSProxy::GetProperty: handler is Null") \ + V(ProxyGetPropertyResultTypeError, "JSProxy::GetProperty: TypeError of trapResult") \ + V(ProxyGetPropertyResultNotUndefined, "JSProxy::GetProperty: trapResult is not undefined") \ + V(ProxySetPropertyHandlerIsNull, "JSProxy::SetProperty: handler is Null") \ + V(ProxySetPropertyReturnFalse, "JSProxy::SetProperty: 'set' return false") \ + V(ProxySetPropertyResultTypeError, "JSProxy::SetProperty: TypeError of trapResult") \ + V(ProxySetPropertyResultNotAccessor, "JSProxy::SetProperty: TypeError of AccessorDescriptor") \ + V(InOperatorOnNonObject, "Cannot use 'in' operator in Non-Object") \ + V(CurrentModuleUndefined, "GetModuleValueOutter currentModule failed") \ + V(MisstakenResolvedBinding, "Get module value failed, mistaken ResolvedBinding") \ + V(CurrentModuleNotSourceTextModule, "Current module is not SourceTextModule") \ + V(ModuleEnvMustBeDefined, "Environment of current module must not be undefined") \ + V(CheckIsResolvedIndexBinding, "Current resolution must be ResolvedIndexBinding") \ + V(RecordNameMustBeString, "RecordName must be string") \ + V(LexicalEnvIsUndefined, "LexicalEnv is undefined for builtin function") \ + V(CurrenEnvIsUndefined, "CurrentEnv is undefined") \ V(AccessCompositeClassField, "this field of CompositeClass is unavailable") #define DEBUG_CHECK_MESSAGE_STRING_LIST(V) \ diff --git a/ecmascript/napi/jsnapi_expo.cpp b/ecmascript/napi/jsnapi_expo.cpp index 4141ca0dd9..caa3640de7 100644 --- a/ecmascript/napi/jsnapi_expo.cpp +++ b/ecmascript/napi/jsnapi_expo.cpp @@ -116,6 +116,7 @@ using ecmascript::OperationResult; using ecmascript::PromiseCapability; using ecmascript::PropertyDescriptor; using ecmascript::Region; +using ecmascript::SFunctionEnv; using ecmascript::TaggedArray; using ecmascript::base::BuiltinsBase; using ecmascript::base::JsonStringifier; @@ -3611,8 +3612,8 @@ Local FunctionRef::NewSendable(EcmaVM *vm, JSHandle current(factory->NewSFunction(env, reinterpret_cast(nativeFunc))); JSFunction::SetSFunctionExtraInfo(thread, current, nullptr, deleter, data, nativeBindingsize); current->SetCallNapi(callNapi); - // for naive SendableFunction, it's lexicalEnv should be undefined - ASSERT(current->GetLexicalEnv(thread) == JSTaggedValue::Undefined()); + JSTaggedValue sFunctionEnv = thread->GlobalConstants()->GetEmptySFunctionEnv(); + current->SetLexicalEnv(thread, JSHandle(thread, sFunctionEnv)); return JSNApiHelper::ToLocal(JSHandle(current)); } @@ -3837,8 +3838,9 @@ Local FunctionRef::NewSendableClassFunction(const EcmaVM *vm, prototypeHClass->SetExtensible(false); constructor->SetHomeObject(thread, prototype); constructor->SetProtoOrHClass(thread, prototype); - // for naive SendableClassFunction, it doesn't need to store itself to lexicalEnv - ASSERT(constructor->GetLexicalEnv(thread) == JSTaggedValue::Undefined()); + JSHandle sFunctionEnv = factory->NewSFunctionEnv(); + sFunctionEnv->SetConstructor(thread, constructor.GetTaggedValue()); + constructor->SetLexicalEnv(thread, sFunctionEnv); constructor->SetCallNapi(callNapi); JSFunction::SetSFunctionExtraInfo(thread, constructor, nullptr, deleter, data, nativeBindingSize); diff --git a/ecmascript/stubs/runtime_stub_list.h b/ecmascript/stubs/runtime_stub_list.h index 3ac03e6eb0..f00faf0b01 100644 --- a/ecmascript/stubs/runtime_stub_list.h +++ b/ecmascript/stubs/runtime_stub_list.h @@ -232,324 +232,317 @@ namespace panda::ecmascript { // When ASM enters C++ via CallNGCRuntime, if the C++ process requires GetGlobalEnv(), // the current globalenv in ASM must be set to glue before CallNGCRuntime! -// None of the current NGC stubs are related to globalenv and are not distinguished. -#define RUNTIME_STUB_WITH_GC_WITH_GLOBALENV_LIST(V) \ - V(TypedArraySpeciesCreate) \ - V(TypedArrayCreateSameType) \ - V(CallInternalGetter) \ - V(CallInternalSetter) \ - V(CallInternalSetterNoThrow) \ - V(CallGetPrototype) \ - V(RegularJSObjDeletePrototype) \ - V(CallJSObjDeletePrototype) \ - V(ToPropertyKey) \ - V(ThrowTypeError) \ - V(MismatchError) \ - V(NotifyArrayPrototypeChanged) \ - V(NumberToString) \ - V(NameDictPutIfAbsent) \ - V(JSArrayReduceUnStable) \ - V(JSArrayFilterUnStable) \ - V(JSArrayMapUnStable) \ - V(CheckAndCopyArray) \ - V(UpdateHClassForElementsKind) \ - V(StGlobalRecord) \ - V(SetFunctionNameNoPrefix) \ - V(StOwnByValueWithNameSet) \ - V(StOwnByName) \ - V(StOwnByNameWithNameSet) \ - V(SuspendGenerator) \ - V(IsIn) \ - V(InstanceOf) \ - V(CreateGeneratorObj) \ - V(ThrowConstAssignment) \ - V(GetTemplateObject) \ - V(CreateStringIterator) \ - V(NewJSArrayIterator) \ - V(NewJSTypedArrayIterator) \ - V(StringIteratorNext) \ - V(ArrayIteratorNext) \ - V(IteratorReturn) \ - V(GetNextPropNameSlowpath) \ - V(ThrowIfNotObject) \ - V(CloseIterator) \ - V(SuperCallSpread) \ - V(OptSuperCallSpread) \ - V(GetCallSpreadArgs) \ - V(DelObjProp) \ - V(NewObjApply) \ - V(CreateIterResultObj) \ - V(AsyncFunctionAwaitUncaught) \ - V(AsyncFunctionResolveOrReject) \ - V(ThrowUndefinedIfHole) \ - V(CopyDataProperties) \ - V(StArraySpread) \ - V(GetIteratorNext) \ - V(SetObjectWithProto) \ - V(LoadICByValue) \ - V(StoreICByValue) \ - V(StoreOwnICByValue) \ - V(StOwnByValue) \ - V(LdSuperByValue) \ - V(StSuperByValue) \ - V(StObjByValue) \ - V(LdObjByIndex) \ - V(StObjByIndex) \ - V(StOwnByIndex) \ - V(CreateClassWithBuffer) \ - V(LoadICByName) \ - V(StoreICByName) \ - V(StoreOwnICByName) \ - V(GetModuleNamespaceByIndex) \ - V(GetModuleNamespaceByIndexOnJSFunc) \ - V(GetModuleNamespace) \ - V(StModuleVarByIndex) \ - V(StModuleVarByIndexOnJSFunc) \ - V(StModuleVar) \ - V(LdLocalModuleVarByIndex) \ - V(LdLocalModuleVarByIndexWithModule) \ - V(LdExternalModuleVarByIndex) \ - V(LdExternalModuleVarByIndexWithModule) \ - V(LdLazyExternalModuleVarByIndex) \ - V(LdLocalModuleVarByIndexOnJSFunc) \ - V(LdExternalModuleVarByIndexOnJSFunc) \ - V(LdModuleVar) \ - V(GetModuleValueOuterInternal) \ - V(ThrowExportsIsHole) \ - V(HandleResolutionIsNullOrString) \ - V(CheckAndThrowModuleError) \ - V(GetResolvedRecordIndexBindingModule) \ - V(GetResolvedRecordBindingModule) \ - V(GetPropIteratorSlowpath) \ - V(PrimitiveStringCreate) \ - V(AsyncFunctionEnter) \ - V(GetAsyncIterator) \ - V(ThrowThrowNotExists) \ - V(ThrowPatternNonCoercible) \ - V(ThrowDeleteSuperProperty) \ - V(TryLdGlobalICByName) \ - V(LoadMiss) \ - V(StoreMiss) \ - V(TryUpdateGlobalRecord) \ - V(ThrowReferenceError) \ - V(StGlobalVar) \ - V(LdGlobalICVar) \ - V(ToIndex) \ - V(NewJSObjectByConstructor) \ - V(AllocateTypedArrayBuffer) \ - V(ToNumber) \ - V(CreateEmptyObject) \ - V(GetUnmapedArgs) \ - V(CopyRestArgs) \ - V(CreateArrayWithBuffer) \ - V(CreateObjectWithBuffer) \ - V(NewThisObject) \ - V(NewObjRange) \ - V(DefineFunc) \ - V(CreateRegExpWithLiteral) \ - V(ThrowIfSuperNotCorrectCall) \ - V(CreateObjectHavingMethod) \ - V(CreateObjectWithExcludedKeys) \ - V(DefineMethod) \ - V(ThrowSetterIsUndefinedException) \ - V(ThrowNotCallableException) \ - V(ThrowCallConstructorException) \ - V(ThrowNonConstructorException) \ - V(ThrowStackOverflowException) \ - V(ThrowDerivedMustReturnException) \ - V(CallSpread) \ - V(DefineGetterSetterByValue) \ - V(SuperCall) \ - V(OptSuperCall) \ - V(LdBigInt) \ - V(ToNumeric) \ - V(ToNumericConvertBigInt) \ - V(CallBigIntAsIntN) \ - V(CallBigIntAsUintN) \ - V(DynamicImport) \ - V(CreateAsyncGeneratorObj) \ - V(AsyncGeneratorResolve) \ - V(AsyncGeneratorReject) \ - V(OptGetUnmapedArgs) \ - V(OptCopyRestArgs) \ - V(OptSuspendGenerator) \ - V(OptAsyncGeneratorResolve) \ - V(OptCreateObjectWithExcludedKeys) \ - V(OptNewObjRange) \ - V(SetTypeArrayPropertyByIndex) \ - V(FastCopyElementToArray) \ - V(GetPropertyByName) \ - V(JSObjectGetMethod) \ - V(OptLdSuperByValue) \ - V(OptStSuperByValue) \ - V(LdPatchVar) \ - V(StPatchVar) \ - V(ContainerRBTreeForEach) \ - V(DefineField) \ - V(CreatePrivateProperty) \ - V(DefinePrivateProperty) \ - V(LdPrivateProperty) \ - V(StPrivateProperty) \ - V(TestIn) \ - V(LocaleCompare) \ - V(ArraySort) \ - V(FastStringify) \ - V(ObjectSlowAssign) \ - V(LocaleCompareWithGc) \ - V(ParseInt) \ - V(LocaleCompareCacheable) \ - V(ArrayForEachContinue) \ - V(NumberDictionaryPut) \ - V(ThrowRangeError) \ - V(InitializeGeneratorFunction) \ - V(FunctionDefineOwnProperty) \ - V(DefineOwnProperty) \ - V(AOTEnableProtoChangeMarker) \ - V(CheckGetTrapResult) \ - V(CheckSetTrapResult) \ - V(JSProxyGetProperty) \ - V(JSProxySetProperty) \ - V(JSProxyHasProperty) \ - V(JSTypedArrayHasProperty) \ - V(ModuleNamespaceHasProperty) \ - V(JSObjectHasProperty) \ - V(HasProperty) \ - V(FastCopyFromArrayToTypedArray) \ - V(BigIntConstructor) \ - V(ObjectPrototypeHasOwnProperty) \ - V(ReflectHas) \ - V(ReflectConstruct) \ - V(ReflectApply) \ - V(FunctionPrototypeApply) \ - V(FunctionPrototypeBind) \ - V(FunctionPrototypeCall) \ - V(SuperCallForwardAllArgs) \ - V(OptSuperCallForwardAllArgs) +#define RUNTIME_STUB_WITH_GC_LIST(V) \ + V(HeapAlloc) \ + V(AllocateInYoung) \ + V(AllocateInOld) \ + V(AllocateInSOld) \ + V(AllocateInSNonMovable) \ + V(TypedArraySpeciesCreate) \ + V(TypedArrayCreateSameType) \ + V(CallInternalGetter) \ + V(CallInternalSetter) \ + V(CallInternalSetterNoThrow) \ + V(CallGetPrototype) \ + V(RegularJSObjDeletePrototype) \ + V(CallJSObjDeletePrototype) \ + V(ToPropertyKey) \ + V(ThrowTypeError) \ + V(MismatchError) \ + V(GetHash32) \ + V(NewInternalString) \ + V(NewTaggedArray) \ + V(NewCOWTaggedArray) \ + V(NewMutantTaggedArray) \ + V(NewCOWMutantTaggedArray) \ + V(NotifyArrayPrototypeChanged) \ + V(CopyArray) \ + V(NumberToString) \ + V(IntToString) \ + V(RTSubstitution) \ + V(NameDictPutIfAbsent) \ + V(NameDictionaryGetAllEnumKeys) \ + V(NumberDictionaryGetAllEnumKeys) \ + V(PropertiesSetValue) \ + V(JSArrayReduceUnStable) \ + V(JSArrayFilterUnStable) \ + V(JSArrayMapUnStable) \ + V(CheckAndCopyArray) \ + V(NewEcmaHClass) \ + V(UpdateLayOutAndAddTransition) \ + V(CopyAndUpdateObjLayout) \ + V(UpdateHClassForElementsKind) \ + V(RuntimeDump) \ + V(ForceGC) \ + V(NoticeThroughChainAndRefreshUser) \ + V(JumpToCInterpreter) \ + V(StGlobalRecord) \ + V(SetFunctionNameNoPrefix) \ + V(StOwnByValueWithNameSet) \ + V(StOwnByName) \ + V(StOwnByNameWithNameSet) \ + V(SuspendGenerator) \ + V(UpFrame) \ + V(Neg) \ + V(Not) \ + V(Inc) \ + V(Dec) \ + V(Shl2) \ + V(Shr2) \ + V(Ashr2) \ + V(Or2) \ + V(Xor2) \ + V(And2) \ + V(Exp) \ + V(IsIn) \ + V(InstanceOf) \ + V(CreateGeneratorObj) \ + V(ThrowConstAssignment) \ + V(GetTemplateObject) \ + V(CreateStringIterator) \ + V(NewJSArrayIterator) \ + V(NewJSTypedArrayIterator) \ + V(StringIteratorNext) \ + V(ArrayIteratorNext) \ + V(IteratorReturn) \ + V(GetNextPropNameSlowpath) \ + V(ThrowIfNotObject) \ + V(CloseIterator) \ + V(SuperCallSpread) \ + V(OptSuperCallSpread) \ + V(GetCallSpreadArgs) \ + V(DelObjProp) \ + V(NewObjApply) \ + V(CreateIterResultObj) \ + V(AsyncFunctionAwaitUncaught) \ + V(AsyncFunctionResolveOrReject) \ + V(ThrowUndefinedIfHole) \ + V(CopyDataProperties) \ + V(StArraySpread) \ + V(GetIteratorNext) \ + V(SetObjectWithProto) \ + V(LoadICByValue) \ + V(StoreICByValue) \ + V(StoreOwnICByValue) \ + V(StOwnByValue) \ + V(LdSuperByValue) \ + V(StSuperByValue) \ + V(StObjByValue) \ + V(LdObjByIndex) \ + V(StObjByIndex) \ + V(StOwnByIndex) \ + V(CreateClassWithBuffer) \ + V(CreateSharedClass) \ + V(LdSendableClass) \ + V(SetClassConstructorLength) \ + V(LoadICByName) \ + V(StoreICByName) \ + V(StoreOwnICByName) \ + V(UpdateHotnessCounter) \ + V(CheckSafePoint) \ + V(PGODump) \ + V(PGOPreDump) \ + V(JitCompile) \ + V(CountInterpExecFuncs) \ + V(BaselineJitCompile) \ + V(UpdateHotnessCounterWithProf) \ + V(GetModuleNamespaceByIndex) \ + V(GetModuleNamespaceByIndexOnJSFunc) \ + V(GetModuleNamespace) \ + V(StModuleVarByIndex) \ + V(StModuleVarByIndexOnJSFunc) \ + V(StModuleVar) \ + V(LdLocalModuleVarByIndex) \ + V(LdLocalModuleVarByIndexWithModule) \ + V(LdExternalModuleVarByIndex) \ + V(LdExternalModuleVarByIndexWithModule) \ + V(LdSendableExternalModuleVarByIndex) \ + V(LdSendableLocalModuleVarByIndex) \ + V(LdLazyExternalModuleVarByIndex) \ + V(LdLazySendableExternalModuleVarByIndex) \ + V(LdLocalModuleVarByIndexOnJSFunc) \ + V(LdExternalModuleVarByIndexOnJSFunc) \ + V(LdModuleVar) \ + V(GetModuleValueOuterInternal) \ + V(GetModuleName) \ + V(ThrowExportsIsHole) \ + V(NewResolvedIndexBindingRecord) \ + V(HandleResolutionIsNullOrString) \ + V(CheckAndThrowModuleError) \ + V(GetResolvedRecordIndexBindingModule) \ + V(GetResolvedRecordBindingModule) \ + V(Throw) \ + V(GetPropIteratorSlowpath) \ + V(PrimitiveStringCreate) \ + V(AsyncFunctionEnter) \ + V(GetAsyncIterator) \ + V(SetGeneratorState) \ + V(ThrowThrowNotExists) \ + V(ThrowPatternNonCoercible) \ + V(ThrowDeleteSuperProperty) \ + V(Eq) \ + V(TryLdGlobalICByName) \ + V(LoadMiss) \ + V(StoreMiss) \ + V(TryUpdateGlobalRecord) \ + V(ThrowReferenceError) \ + V(StGlobalVar) \ + V(LdGlobalICVar) \ + V(ToIndex) \ + V(NewJSObjectByConstructor) \ + V(CloneHclass) \ + V(AllocateTypedArrayBuffer) \ + V(ToNumber) \ + V(ToBoolean) \ + V(NotEq) \ + V(Less) \ + V(LessEq) \ + V(Greater) \ + V(GreaterEq) \ + V(Add2) \ + V(Sub2) \ + V(Mul2) \ + V(Div2) \ + V(Mod2) \ + V(CreateEmptyObject) \ + V(CreateEmptyArray) \ + V(GetSymbolFunction) \ + V(GetUnmapedArgs) \ + V(CopyRestArgs) \ + V(CreateArrayWithBuffer) \ + V(CreateObjectWithBuffer) \ + V(NewThisObject) \ + V(NewObjRange) \ + V(DefineFunc) \ + V(CreateRegExpWithLiteral) \ + V(ThrowIfSuperNotCorrectCall) \ + V(CreateObjectHavingMethod) \ + V(CreateObjectWithExcludedKeys) \ + V(DefineMethod) \ + V(SetPatchModule) \ + V(ThrowSetterIsUndefinedException) \ + V(ThrowNotCallableException) \ + V(ThrowCallConstructorException) \ + V(ThrowNonConstructorException) \ + V(ThrowStackOverflowException) \ + V(ThrowDerivedMustReturnException) \ + V(CallSpread) \ + V(DefineGetterSetterByValue) \ + V(SuperCall) \ + V(OptSuperCall) \ + V(LdBigInt) \ + V(ToNumeric) \ + V(ToNumericConvertBigInt) \ + V(CallBigIntAsIntN) \ + V(CallBigIntAsUintN) \ + V(DynamicImport) \ + V(CreateAsyncGeneratorObj) \ + V(AsyncGeneratorResolve) \ + V(AsyncGeneratorReject) \ + V(NewLexicalEnvWithName) \ + V(NewSendableEnv) \ + V(OptGetUnmapedArgs) \ + V(OptCopyRestArgs) \ + V(NotifyBytecodePcChanged) \ + V(NotifyDebuggerStatement) \ + V(MethodEntry) \ + V(MethodExit) \ + V(OptNewLexicalEnvWithName) \ + V(OptSuspendGenerator) \ + V(OptAsyncGeneratorResolve) \ + V(OptCreateObjectWithExcludedKeys) \ + V(OptNewObjRange) \ + V(GetTypeArrayPropertyByIndex) \ + V(SetTypeArrayPropertyByIndex) \ + V(FastCopyElementToArray) \ + V(GetPropertyByName) \ + V(JSObjectGetMethod) \ + V(DebugAOTPrint) \ + V(ProfileOptimizedCode) \ + V(ProfileTypedOp) \ + V(VerifyVTableLoading) \ + V(VerifyVTableStoring) \ + V(GetMethodFromCache) \ + V(GetArrayLiteralFromCache) \ + V(GetObjectLiteralFromCache) \ + V(GetStringFromCache) \ + V(OptLdSuperByValue) \ + V(OptStSuperByValue) \ + V(BigIntEqual) \ + V(StringEqual) \ + V(StringIndexOf) \ + V(LdPatchVar) \ + V(StPatchVar) \ + V(DeoptHandler) \ + V(ContainerRBTreeForEach) \ + V(InsertStringToTable) \ + V(GetOrInternStringFromHashTrieTable) \ + V(SlowFlattenString) \ + V(NotifyConcurrentResult) \ + V(DefineField) \ + V(CreatePrivateProperty) \ + V(DefinePrivateProperty) \ + V(LdPrivateProperty) \ + V(StPrivateProperty) \ + V(TestIn) \ + V(UpdateAOTHClass) \ + V(AotInlineTrace) \ + V(AotInlineBuiltinTrace) \ + V(LocaleCompare) \ + V(ArraySort) \ + V(FastStringify) \ + V(ObjectSlowAssign) \ + V(GetLinkedHash) \ + V(LinkedHashMapComputeCapacity) \ + V(LinkedHashSetComputeCapacity) \ + V(JSObjectGrowElementsCapacity) \ + V(HClassCloneWithAddProto) \ + V(LocaleCompareWithGc) \ + V(ParseInt) \ + V(LocaleCompareCacheable) \ + V(ArrayForEachContinue) \ + V(NumberDictionaryPut) \ + V(ThrowRangeError) \ + V(InitializeGeneratorFunction) \ + V(FunctionDefineOwnProperty) \ + V(DefineOwnProperty) \ + V(AOTEnableProtoChangeMarker) \ + V(CheckGetTrapResult) \ + V(CheckSetTrapResult) \ + V(JSProxyGetProperty) \ + V(JSProxySetProperty) \ + V(JSProxyHasProperty) \ + V(JSTypedArrayHasProperty) \ + V(ModuleNamespaceHasProperty) \ + V(JSObjectHasProperty) \ + V(HasProperty) \ + V(DumpObject) \ + V(DumpHeapObjectAddress) \ + V(TryGetInternString) \ + V(FastCopyFromArrayToTypedArray) \ + V(BigIntConstructor) \ + V(ObjectPrototypeHasOwnProperty) \ + V(ReflectHas) \ + V(ReflectConstruct) \ + V(ReflectApply) \ + V(FunctionPrototypeApply) \ + V(FunctionPrototypeBind) \ + V(FunctionPrototypeCall) \ + V(SetPrototypeTransition) \ + V(GetSharedModule) \ + V(SuperCallForwardAllArgs) \ + V(OptSuperCallForwardAllArgs) \ + V(GetCollationValueFromIcuCollator) \ + V(DecodeURIComponent) \ + V(GetAllFlagsInternal) \ + V(SlowSharedObjectStoreBarrier) \ + V(GetNativePcOfstForBaseline) \ + V(AotCallBuiltinTrace) \ + V(NumberBigIntNativePointerToString) // When ASM enters C++ via CallRuntime, if the C++ process requires GetGlobalEnv(), // the current globalenv in ASM must be set to glue before CallRuntime! -// Use CallRuntimeWithGlobalEnv or CallRuntimeWithCurrentEnv. - -#define RUNTIME_STUB_WITH_GC_WITHOUT_GLOBALENV_LIST(V) \ - V(HeapAlloc) \ - V(AllocateInYoung) \ - V(AllocateInOld) \ - V(AllocateInSOld) \ - V(AllocateInSNonMovable) \ - V(GetHash32) \ - V(NewInternalString) \ - V(NewTaggedArray) \ - V(NewCOWTaggedArray) \ - V(NewMutantTaggedArray) \ - V(NewCOWMutantTaggedArray) \ - V(CopyArray) \ - V(IntToString) \ - V(RTSubstitution) \ - V(NameDictionaryGetAllEnumKeys) \ - V(NumberDictionaryGetAllEnumKeys) \ - V(PropertiesSetValue) \ - V(NewEcmaHClass) \ - V(UpdateLayOutAndAddTransition) \ - V(CopyAndUpdateObjLayout) \ - V(RuntimeDump) \ - V(ForceGC) \ - V(NoticeThroughChainAndRefreshUser) \ - V(JumpToCInterpreter) \ - V(UpFrame) \ - V(Neg) \ - V(Not) \ - V(Inc) \ - V(Dec) \ - V(Shl2) \ - V(Shr2) \ - V(Ashr2) \ - V(Or2) \ - V(Xor2) \ - V(And2) \ - V(Exp) \ - V(Eq) \ - V(NotEq) \ - V(Less) \ - V(LessEq) \ - V(Greater) \ - V(GreaterEq) \ - V(Add2) \ - V(Sub2) \ - V(Mul2) \ - V(Div2) \ - V(Mod2) \ - V(SetClassConstructorLength) \ - V(UpdateHotnessCounter) \ - V(CheckSafePoint) \ - V(PGODump) \ - V(PGOPreDump) \ - V(JitCompile) \ - V(CountInterpExecFuncs) \ - V(BaselineJitCompile) \ - V(UpdateHotnessCounterWithProf) \ - V(CreateSharedClass) \ - V(LdSendableClass) \ - V(LdSendableExternalModuleVarByIndex) \ - V(LdSendableLocalModuleVarByIndex) \ - V(LdLazySendableExternalModuleVarByIndex) \ - V(GetModuleName) \ - V(NewResolvedIndexBindingRecord) \ - V(Throw) \ - V(SetGeneratorState) \ - V(CloneHclass) \ - V(ToBoolean) \ - V(SetPatchModule) \ - V(NewLexicalEnvWithName) \ - V(OptNewLexicalEnvWithName) \ - V(NewSendableEnv) \ - V(NotifyBytecodePcChanged) \ - V(NotifyDebuggerStatement) \ - V(MethodEntry) \ - V(MethodExit) \ - V(GetTypeArrayPropertyByIndex) \ - V(DebugAOTPrint) \ - V(ProfileOptimizedCode) \ - V(ProfileTypedOp) \ - V(VerifyVTableLoading) \ - V(VerifyVTableStoring) \ - V(GetMethodFromCache) \ - V(GetArrayLiteralFromCache) \ - V(GetObjectLiteralFromCache) \ - V(GetStringFromCache) \ - V(BigIntEqual) \ - V(StringEqual) \ - V(StringIndexOf) \ - V(DeoptHandler) \ - V(InsertStringToTable) \ - V(GetOrInternStringFromHashTrieTable) \ - V(SlowFlattenString) \ - V(NotifyConcurrentResult) \ - V(UpdateAOTHClass) \ - V(AotInlineTrace) \ - V(AotInlineBuiltinTrace) \ - V(GetLinkedHash) \ - V(LinkedHashMapComputeCapacity) \ - V(LinkedHashSetComputeCapacity) \ - V(JSObjectGrowElementsCapacity) \ - V(HClassCloneWithAddProto) \ - V(DumpObject) \ - V(DumpHeapObjectAddress) \ - V(TryGetInternString) \ - V(SetPrototypeTransition) \ - V(GetSharedModule) \ - V(GetCollationValueFromIcuCollator) \ - V(DecodeURIComponent) \ - V(GetAllFlagsInternal) \ - V(SlowSharedObjectStoreBarrier) \ - V(GetNativePcOfstForBaseline) \ - V(AotCallBuiltinTrace) \ - V(NumberBigIntNativePointerToString) - - -#define RUNTIME_STUB_WITH_GC_LIST(V) \ - RUNTIME_STUB_WITH_GC_WITH_GLOBALENV_LIST(V) \ - RUNTIME_STUB_WITH_GC_WITHOUT_GLOBALENV_LIST(V) #define RUNTIME_STUB_LIST(V) \ RUNTIME_ASM_STUB_LIST(V) \ diff --git a/ecmascript/stubs/runtime_stubs.cpp b/ecmascript/stubs/runtime_stubs.cpp index b990eee6be..c9a930fba1 100644 --- a/ecmascript/stubs/runtime_stubs.cpp +++ b/ecmascript/stubs/runtime_stubs.cpp @@ -2520,6 +2520,23 @@ DEF_RUNTIME_STUBS(CreateEmptyObject) return RuntimeCreateEmptyObject(thread, factory, globalEnv).GetRawData(); } +DEF_RUNTIME_STUBS(CreateEmptyArray) +{ + RUNTIME_STUBS_HEADER(CreateEmptyArray); + EcmaVM *ecmaVm = thread->GetEcmaVM(); + ObjectFactory *factory = ecmaVm->GetFactory(); + JSHandle globalEnv = ecmaVm->GetGlobalEnv(); + return RuntimeCreateEmptyArray(thread, factory, globalEnv).GetRawData(); +} + +DEF_RUNTIME_STUBS(GetSymbolFunction) +{ + RUNTIME_STUBS_HEADER(GetSymbolFunction); + EcmaVM *ecmaVm = thread->GetEcmaVM(); + JSHandle globalEnv = ecmaVm->GetGlobalEnv(); + return globalEnv->GetSymbolFunction().GetTaggedValue().GetRawData(); +} + DEF_RUNTIME_STUBS(GetUnmapedArgs) { RUNTIME_STUBS_HEADER(GetUnmapedArgs); -- Gitee