mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-06 23:54:03 +00:00
clear builtin entry when sttoglobalrecord
Signed-off-by: Like <zhenglike@huawei.com> Change-Id: I315797eee3a49282669015f974c3c28ae09c66b8
This commit is contained in:
parent
31544973e9
commit
c5b1cda20c
@ -16,6 +16,7 @@
|
||||
#ifndef ECMASCRIPT_BUILTIN_ENTRIES_H
|
||||
#define ECMASCRIPT_BUILTIN_ENTRIES_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
@ -86,7 +87,7 @@ enum class BuiltinType : int32_t {
|
||||
|
||||
struct BuiltinEntries {
|
||||
static constexpr size_t COUNT = static_cast<size_t>(BuiltinType::NUMBER_OF_BUILTINS);
|
||||
struct {
|
||||
struct BuiltinEntry {
|
||||
JSTaggedValue box_ {JSTaggedValue::Hole()};
|
||||
JSTaggedValue hClass_ {JSTaggedValue::Hole()};
|
||||
} builtin_[COUNT];
|
||||
@ -101,6 +102,12 @@ struct BuiltinEntries {
|
||||
return reinterpret_cast<uintptr_t>(builtin_ + COUNT);
|
||||
}
|
||||
|
||||
void ClearByIndex(size_t index, JSTaggedValue value)
|
||||
{
|
||||
builtin_[index].box_ = value;
|
||||
builtin_[index].hClass_ = JSTaggedValue::Hole();
|
||||
}
|
||||
|
||||
static constexpr size_t SizeArch32 = sizeof(uint64_t) * 2 * COUNT;
|
||||
static constexpr size_t SizeArch64 = sizeof(uint64_t) * 2 * COUNT;
|
||||
};
|
||||
|
@ -705,7 +705,7 @@ void BytecodeInfoCollector::CollectRecordReferenceREL()
|
||||
auto &recordNames = bytecodeInfo_.GetRecordNames();
|
||||
for (auto &record : recordNames) {
|
||||
JSRecordInfo info = jsPandaFile_->FindRecordInfo(record);
|
||||
if (jsPandaFile_->HasTSTypes(info)|| jsPandaFile_->IsModule(info)) {
|
||||
if (jsPandaFile_->HasTSTypes(info) && jsPandaFile_->IsModule(info)) {
|
||||
CollectRecordImportInfo(record);
|
||||
CollectRecordExportInfo(record);
|
||||
}
|
||||
|
@ -273,9 +273,7 @@ void TypeBytecodeLowering::Lower(GateRef gate)
|
||||
break;
|
||||
case EcmaOpcode::TRYLDGLOBALBYNAME_IMM8_ID16:
|
||||
case EcmaOpcode::TRYLDGLOBALBYNAME_IMM16_ID16:
|
||||
if (enableLoweringBuiltin_) {
|
||||
LowerTypedTryLdGlobalByName(gate);
|
||||
}
|
||||
LowerTypedTryLdGlobalByName(gate);
|
||||
break;
|
||||
case EcmaOpcode::INSTANCEOF_IMM8_V8:
|
||||
LowerInstanceOf(gate);
|
||||
@ -1797,6 +1795,9 @@ void TypeBytecodeLowering::LowerGetIterator(GateRef gate)
|
||||
|
||||
void TypeBytecodeLowering::LowerTypedTryLdGlobalByName(GateRef gate)
|
||||
{
|
||||
if (!enableLoweringBuiltin_) {
|
||||
return;
|
||||
}
|
||||
DISALLOW_GARBAGE_COLLECTION;
|
||||
LoadGlobalObjByNameTypeInfoAccessor tacc(thread_, circuit_, gate);
|
||||
JSTaggedValue key = tacc.GetKeyTaggedValue();
|
||||
|
@ -149,9 +149,7 @@ GateRef TypeHCRLowering::VisitGate(GateRef gate)
|
||||
LowerArrayConstructor(gate, glue);
|
||||
break;
|
||||
case OpCode::LOAD_BUILTIN_OBJECT:
|
||||
if (enableLoweringBuiltin_) {
|
||||
LowerLoadBuiltinObject(gate);
|
||||
}
|
||||
LowerLoadBuiltinObject(gate);
|
||||
break;
|
||||
case OpCode::OBJECT_CONSTRUCTOR_CHECK:
|
||||
LowerObjectConstructorCheck(gate, glue);
|
||||
@ -2181,15 +2179,18 @@ void TypeHCRLowering::ReplaceGateWithPendingException(GateRef glue, GateRef gate
|
||||
|
||||
void TypeHCRLowering::LowerLoadBuiltinObject(GateRef gate)
|
||||
{
|
||||
if (!enableLoweringBuiltin_) {
|
||||
return;
|
||||
}
|
||||
Environment env(gate, circuit_, &builder_);
|
||||
AddProfiling(gate);
|
||||
auto frameState = GetFrameState(gate);
|
||||
GateRef glue = acc_.GetGlueFromArgList();
|
||||
auto builtinEntriesOffset = JSThread::GlueData::GetBuiltinEntriesOffset(false);
|
||||
size_t index = acc_.GetIndex(gate);
|
||||
auto boxOffset = builtinEntriesOffset + BuiltinIndex::GetInstance().GetBuiltinBoxOffset(index);
|
||||
GateRef box = builder_.LoadConstOffset(VariableType::JS_POINTER(), glue, boxOffset);
|
||||
GateRef builtin = builder_.LoadConstOffset(VariableType::JS_POINTER(), box, PropertyBox::VALUE_OFFSET);
|
||||
auto frameState = GetFrameState(gate);
|
||||
auto builtinIsNotHole = builder_.TaggedIsNotHole(builtin);
|
||||
// attributes on globalThis may change, it will cause renew a PropertyBox, the old box will be abandoned
|
||||
// so we need deopt
|
||||
|
@ -217,6 +217,11 @@ public:
|
||||
return glueData_.builtinEntries_;
|
||||
}
|
||||
|
||||
BuiltinEntries* GetBuiltinEntriesPointer()
|
||||
{
|
||||
return &glueData_.builtinEntries_;
|
||||
}
|
||||
|
||||
const CMap<ElementsKind, ConstantIndex> &GetArrayHClassIndexMap() const
|
||||
{
|
||||
return arrayHClassIndexMap_;
|
||||
|
@ -695,6 +695,16 @@ JSTaggedValue RuntimeStubs::RuntimeStOwnByIndex(JSThread *thread, const JSHandle
|
||||
JSTaggedValue RuntimeStubs::RuntimeStGlobalRecord(JSThread *thread, const JSHandle<JSTaggedValue> &prop,
|
||||
const JSHandle<JSTaggedValue> &value, bool isConst)
|
||||
{
|
||||
ObjectFactory* factory = thread->GetEcmaVM()->GetFactory();
|
||||
if (thread->GetEcmaVM()->GetJSOptions().IsEnableLoweringBuiltin()) {
|
||||
BuiltinIndex& builtinIndex = BuiltinIndex::GetInstance();
|
||||
auto index = builtinIndex.GetBuiltinIndex(prop.GetTaggedValue());
|
||||
if (index != BuiltinIndex::NOT_FOUND) {
|
||||
auto box = factory->NewPropertyBox(JSHandle<JSTaggedValue>(thread, JSTaggedValue::Hole()));
|
||||
thread->GetBuiltinEntriesPointer()->ClearByIndex(index, box.GetTaggedValue());
|
||||
}
|
||||
}
|
||||
|
||||
EcmaVM *vm = thread->GetEcmaVM();
|
||||
JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
|
||||
GlobalDictionary *dict = GlobalDictionary::Cast(env->GetGlobalRecord()->GetTaggedObject());
|
||||
@ -710,8 +720,6 @@ JSTaggedValue RuntimeStubs::RuntimeStGlobalRecord(JSThread *thread, const JSHand
|
||||
attributes.SetIsConstProps(true);
|
||||
}
|
||||
JSHandle<GlobalDictionary> dictHandle(thread, dict);
|
||||
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<PropertyBox> box = factory->NewPropertyBox(value);
|
||||
PropertyBoxType boxType = value->IsUndefined() ? PropertyBoxType::UNDEFINED : PropertyBoxType::CONSTANT;
|
||||
attributes.SetBoxType(boxType);
|
||||
|
@ -252,6 +252,8 @@ group("ark_aot_ts_test") {
|
||||
"tonumeric",
|
||||
"try",
|
||||
"try_catch_finally",
|
||||
"tryldglobalbyname_global_object",
|
||||
"tryldglobalbyname_global_record",
|
||||
"trystglobalbynameprefid32",
|
||||
"ts_hclass_generator",
|
||||
"ts_inline",
|
||||
|
@ -13,6 +13,6 @@
|
||||
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
|
||||
host_aot_js_test_action("tryldglobalbyname_global_object") {
|
||||
host_aot_test_action("tryldglobalbyname_global_object") {
|
||||
deps = []
|
||||
}
|
||||
|
@ -175,4 +175,4 @@ GeneratorFunction
|
||||
ReferenceError: GeneratorFunction is not defined
|
||||
[object Intl]
|
||||
Intl
|
||||
ReferenceError: Intl is not defined
|
||||
ReferenceError: Intl is not defined
|
||||
|
19
test/aottest/tryldglobalbyname_global_record/BUILD.gn
Normal file
19
test/aottest/tryldglobalbyname_global_record/BUILD.gn
Normal file
@ -0,0 +1,19 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
|
||||
host_aot_test_action("tryldglobalbyname_global_record") {
|
||||
deps = []
|
||||
without_module = true
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
undefined
|
||||
function Array() { [native code] }
|
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
let Array;
|
||||
print(Array);
|
||||
print(globalThis.Array);
|
@ -938,10 +938,13 @@ template("host_aot_test_action") {
|
||||
extension = "ts"
|
||||
extra_args = [
|
||||
"--merge-abc",
|
||||
"--module",
|
||||
"--type-extractor",
|
||||
]
|
||||
|
||||
if (!(defined(invoker.without_module) && invoker.without_module)) {
|
||||
extra_args += [ "--module" ]
|
||||
}
|
||||
|
||||
if (defined(invoker.is_debug_abc) && invoker.is_debug_abc) {
|
||||
extra_args += [ "--debug" ]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user