From 5c572275382b43bf6fcf69880aa934bcbfcdaa16 Mon Sep 17 00:00:00 2001 From: lifansheng Date: Sat, 11 Sep 2021 17:33:36 +0800 Subject: [PATCH 1/3] resolve ic-262 Signed-off-by: lifansheng --- ecmascript/ic/ic_runtime.cpp | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/ecmascript/ic/ic_runtime.cpp b/ecmascript/ic/ic_runtime.cpp index 55227c0d20..5b511ba274 100644 --- a/ecmascript/ic/ic_runtime.cpp +++ b/ecmascript/ic/ic_runtime.cpp @@ -136,15 +136,20 @@ JSTaggedValue LoadICRuntime::LoadMiss(JSHandle receiver, JSHandle if (receiver->IsTypedArray() || !receiver->IsJSObject()) { return JSTaggedValue::GetProperty(thread_, receiver, key).GetValue().GetTaggedValue(); } - ObjectOperator op(GetThread(), receiver, key); - auto result = JSHandle(thread_, JSObject::GetProperty(GetThread(), &op)); - if (!op.IsFound() && GetICKind() == ICKind::NamedGlobalLoadIC) { + // 1. find from global record + if (GetICKind() == ICKind::NamedGlobalLoadIC) { bool found = false; JSTaggedValue res = SlowRuntimeStub::LdGlobalRecord(thread_, key.GetTaggedValue(), &found); - if (!found) { - return SlowRuntimeStub::ThrowReferenceError(GetThread(), key.GetTaggedValue(), " is not definded"); + if (found) { + icAccessor_.SetAsMega(); + return res; } - return res; + } + // 2. find from global object + ObjectOperator op(GetThread(), receiver, key); + auto result = JSHandle(thread_, JSObject::GetProperty(GetThread(), &op)); + if (!op.IsFound() && GetICKind() == ICKind::NamedGlobalLoadIC) { + return SlowRuntimeStub::ThrowReferenceError(GetThread(), key.GetTaggedValue(), " is not definded"); } RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(GetThread()); // ic-switch @@ -172,7 +177,19 @@ JSTaggedValue StoreICRuntime::StoreMiss(JSHandle receiver, JSHand bool success = JSTaggedValue::SetProperty(GetThread(), receiver, key, value, true); return success ? JSTaggedValue::Undefined() : JSTaggedValue::Exception(); } + // 1. find from global record + if (GetICKind() == ICKind::NamedGlobalStoreIC) { + bool found = false; + SlowRuntimeStub::LdGlobalRecord(thread_, key.GetTaggedValue(), &found); + if (found) { + SlowRuntimeStub::TryUpdateGlobalRecord(thread_, key.GetTaggedValue(), value.GetTaggedValue()); + RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread_); + icAccessor_.SetAsMega(); + return JSTaggedValue::Undefined(); + } + } UpdateReceiverHClass(JSHandle(GetThread(), JSHandle::Cast(receiver)->GetClass())); + // 2. find from global object ObjectOperator op(GetThread(), receiver, key); bool success = JSObject::SetProperty(&op, value, true); if (!success && GetICKind() == ICKind::NamedGlobalStoreIC) { -- Gitee From 45639c4bba0b10763848944da9cd94d51fbfcf5d Mon Sep 17 00:00:00 2001 From: lifansheng Date: Sat, 11 Sep 2021 18:19:47 +0800 Subject: [PATCH 2/3] rename expect_output.txt Signed-off-by: lifansheng --- .../moduletest/globalrecord/{expect_out.txt => expect_output.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/moduletest/globalrecord/{expect_out.txt => expect_output.txt} (100%) diff --git a/test/moduletest/globalrecord/expect_out.txt b/test/moduletest/globalrecord/expect_output.txt similarity index 100% rename from test/moduletest/globalrecord/expect_out.txt rename to test/moduletest/globalrecord/expect_output.txt -- Gitee From 1d77c145d637dad091a081d786f11cb285b614c1 Mon Sep 17 00:00:00 2001 From: lifansheng Date: Sat, 11 Sep 2021 18:21:43 +0800 Subject: [PATCH 3/3] codecheck Signed-off-by: lifansheng --- ecmascript/ic/ic_runtime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecmascript/ic/ic_runtime.cpp b/ecmascript/ic/ic_runtime.cpp index 5b511ba274..e5b0b4c705 100644 --- a/ecmascript/ic/ic_runtime.cpp +++ b/ecmascript/ic/ic_runtime.cpp @@ -178,7 +178,7 @@ JSTaggedValue StoreICRuntime::StoreMiss(JSHandle receiver, JSHand return success ? JSTaggedValue::Undefined() : JSTaggedValue::Exception(); } // 1. find from global record - if (GetICKind() == ICKind::NamedGlobalStoreIC) { + if (GetICKind() == ICKind::NamedGlobalStoreIC) { bool found = false; SlowRuntimeStub::LdGlobalRecord(thread_, key.GetTaggedValue(), &found); if (found) { -- Gitee