mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-12-02 16:07:20 +00:00
!5393 Create Object With BC Info
Merge pull request !5393 from ChunyangWang/create_obj_with_bc_info
This commit is contained in:
commit
8d1283a06c
@ -524,7 +524,7 @@ public:
|
||||
GateRef CheckNullAndConvertToBool(GateRef gate);
|
||||
GateRef CheckUndefinedAndConvertToInt32(GateRef gate);
|
||||
GateRef StartAllocate();
|
||||
GateRef FinishAllocate();
|
||||
GateRef FinishAllocate(GateRef value);
|
||||
|
||||
inline GateRef PrimitiveToNumber(GateRef x, VariableType type);
|
||||
inline GateRef GetValueFromTaggedArray(GateRef array, GateRef index);
|
||||
|
@ -102,7 +102,8 @@ enum class CallExceptionKind : bool {
|
||||
V(MulWithOverflow, (GateRef gate, GateRef e1, GateRef e2)) \
|
||||
V(ExtractValue, (GateRef gate, GateRef e1, GateRef e2)) \
|
||||
V(Sqrt, (GateRef gate, GateRef e1)) \
|
||||
V(ReadSp, (GateRef gate))
|
||||
V(ReadSp, (GateRef gate)) \
|
||||
V(FinishAllocate, (GateRef gate, GateRef e1))
|
||||
|
||||
bool IsAddIntergerType(MachineType machineType);
|
||||
bool IsMulIntergerType(MachineType machineType);
|
||||
|
@ -204,6 +204,7 @@ void LLVMIRBuilder::InitializeHandlers()
|
||||
{OpCode::EXTRACT_VALUE, &LLVMIRBuilder::HandleExtractValue},
|
||||
{OpCode::SQRT, &LLVMIRBuilder::HandleSqrt},
|
||||
{OpCode::READSP, &LLVMIRBuilder::HandleReadSp},
|
||||
{OpCode::FINISH_ALLOCATE, &LLVMIRBuilder::HandleFinishAllocate},
|
||||
};
|
||||
illegalOpHandlers_ = {
|
||||
OpCode::NOP, OpCode::CIRCUIT_ROOT, OpCode::DEPEND_ENTRY,
|
||||
@ -212,7 +213,7 @@ void LLVMIRBuilder::InitializeHandlers()
|
||||
OpCode::DEPEND_SELECTOR, OpCode::DEPEND_RELAY,
|
||||
OpCode::FRAME_STATE, OpCode::STATE_SPLIT, OpCode::FRAME_ARGS,
|
||||
OpCode::LOOP_EXIT_DEPEND, OpCode::LOOP_EXIT,
|
||||
OpCode::START_ALLOCATE, OpCode::FINISH_ALLOCATE, OpCode::FRAME_VALUES
|
||||
OpCode::START_ALLOCATE, OpCode::FRAME_VALUES
|
||||
};
|
||||
}
|
||||
|
||||
@ -1349,6 +1350,21 @@ void LLVMIRBuilder::VisitMod(GateRef gate, GateRef e1, GateRef e2)
|
||||
}
|
||||
}
|
||||
|
||||
void LLVMIRBuilder::HandleFinishAllocate(GateRef gate)
|
||||
{
|
||||
auto g0 = acc_.GetValueIn(gate, 0);
|
||||
VisitFinishAllocate(gate, g0);
|
||||
}
|
||||
|
||||
void LLVMIRBuilder::VisitFinishAllocate(GateRef gate, GateRef e1)
|
||||
{
|
||||
LLVMValueRef result = GetLValue(e1);
|
||||
Bind(gate, result);
|
||||
if (IsLogEnabled()) {
|
||||
SetDebugInfo(gate, result);
|
||||
}
|
||||
}
|
||||
|
||||
void LLVMIRBuilder::VisitBranch(GateRef gate, GateRef cmp, int btrue, int bfalse)
|
||||
{
|
||||
if (gate2LValue_.count(cmp) == 0) {
|
||||
|
@ -854,12 +854,12 @@ GateRef CircuitBuilder::StartAllocate()
|
||||
return newGate;
|
||||
}
|
||||
|
||||
GateRef CircuitBuilder::FinishAllocate()
|
||||
GateRef CircuitBuilder::FinishAllocate(GateRef value)
|
||||
{
|
||||
auto currentLabel = env_->GetCurrentLabel();
|
||||
auto currentDepend = currentLabel->GetDepend();
|
||||
GateRef newGate = GetCircuit()->NewGate(circuit_->FinishAllocate(), MachineType::I64,
|
||||
{ currentDepend }, GateType::NJSValue());
|
||||
{ currentDepend, value }, acc_.GetGateType(value));
|
||||
currentLabel->SetDepend(newGate);
|
||||
return newGate;
|
||||
}
|
||||
@ -869,7 +869,7 @@ GateRef CircuitBuilder::HeapAlloc(GateRef size, GateType type, RegionSpaceFlag f
|
||||
auto currentLabel = env_->GetCurrentLabel();
|
||||
auto currentControl = currentLabel->GetControl();
|
||||
auto currentDepend = currentLabel->GetDepend();
|
||||
auto ret = GetCircuit()->NewGate(circuit_->HeapAlloc(flag), MachineType::ANYVALUE,
|
||||
auto ret = GetCircuit()->NewGate(circuit_->HeapAlloc(flag), MachineType::I64,
|
||||
{ currentControl, currentDepend, size }, type);
|
||||
currentLabel->SetControl(ret);
|
||||
currentLabel->SetDepend(ret);
|
||||
|
@ -36,7 +36,7 @@ namespace panda::ecmascript::kungfu {
|
||||
V(COWArrayCheck, COW_ARRAY_CHECK, GateFlags::CHECKABLE, 1, 1, 1) \
|
||||
V(ConvertHoleAsUndefined, CONVERT_HOLE_AS_UNDEFINED, GateFlags::NO_WRITE, 1, 1, 1) \
|
||||
V(EcmaStringCheck, ECMA_STRING_CHECK, GateFlags::CHECKABLE, 1, 1, 1) \
|
||||
V(FinishAllocate, FINISH_ALLOCATE, GateFlags::NONE_FLAG, 0, 1, 0) \
|
||||
V(FinishAllocate, FINISH_ALLOCATE, GateFlags::NONE_FLAG, 0, 1, 1) \
|
||||
V(FlattenTreeStringCheck, FLATTEN_TREE_STRING_CHECK, GateFlags::CHECKABLE, 1, 1, 1) \
|
||||
V(HeapObjectCheck, HEAP_OBJECT_CHECK, GateFlags::CHECKABLE, 1, 1, 1) \
|
||||
V(ProtoChangeMarkerCheck, PROTO_CHANGE_MARKER_CHECK, GateFlags::CHECKABLE, 1, 1, 1) \
|
||||
|
@ -175,8 +175,7 @@ GateRef NTypeHCRLowering::NewJSArrayLiteral(GateRef gate, GateRef elements, Gate
|
||||
builder_.StoreConstOffset(VariableType::INT64(), array, JSArray::TRACK_INFO_OFFSET, builder_.Undefined());
|
||||
}
|
||||
builder_.StoreConstOffset(VariableType::JS_POINTER(), array, lengthAccessorOffset, accessor);
|
||||
builder_.FinishAllocate();
|
||||
return array;
|
||||
return builder_.FinishAllocate(array);
|
||||
}
|
||||
|
||||
GateRef NTypeHCRLowering::NewTaggedArray(size_t length)
|
||||
@ -194,9 +193,7 @@ GateRef NTypeHCRLowering::NewTaggedArray(size_t length)
|
||||
for (size_t offset = TaggedArray::DATA_OFFSET; offset < endOffset; offset += JSTaggedValue::TaggedTypeSize()) {
|
||||
builder_.StoreConstOffset(VariableType::INT64(), elements, offset, builder_.Hole());
|
||||
}
|
||||
builder_.FinishAllocate();
|
||||
|
||||
return elements;
|
||||
return builder_.FinishAllocate(elements);
|
||||
}
|
||||
|
||||
GateRef NTypeHCRLowering::LowerCallRuntime(GateRef glue, GateRef hirGate, int index, const std::vector<GateRef> &args,
|
||||
@ -289,8 +286,7 @@ GateRef NTypeHCRLowering::NewTaggedArray(GateRef length)
|
||||
builder_.Bind(&loopEnd);
|
||||
builder_.LoopEnd(&loopHead);
|
||||
builder_.Bind(&exit);
|
||||
builder_.FinishAllocate();
|
||||
auto ret = *array;
|
||||
auto ret = builder_.FinishAllocate(*array);
|
||||
builder_.SubCfgExit();
|
||||
return ret;
|
||||
}
|
||||
|
@ -2253,9 +2253,6 @@ void TypeBytecodeLowering::LowerCreateObjectWithBuffer(GateRef gate)
|
||||
|
||||
PGOTypeManager *ptManager = thread_->GetCurrentEcmaContext()->GetPTManager();
|
||||
int hclassIndex = static_cast<int>(ptManager->GetHClassIndexByProfileType(type));
|
||||
if (hclassIndex == -1) {
|
||||
return;
|
||||
}
|
||||
ASSERT(acc_.GetNumValueIn(gate) == 2); // 2: number of value ins
|
||||
GateRef index = acc_.GetValueIn(gate, 0);
|
||||
auto imm = acc_.GetConstantValue(index);
|
||||
@ -2271,8 +2268,9 @@ void TypeBytecodeLowering::LowerCreateObjectWithBuffer(GateRef gate)
|
||||
return;
|
||||
}
|
||||
std::vector<uint64_t> inlinedProps;
|
||||
JSHandle<JSHClass> newClass = JSHandle<JSHClass>(thread_, ptManager->QueryHClass(type.first, type.second));
|
||||
JSHandle<JSHClass> oldClass = JSHandle<JSHClass>(thread_, objhandle->GetClass());
|
||||
JSHandle<JSHClass> newClass = hclassIndex == -1 ? oldClass :
|
||||
JSHandle<JSHClass>(thread_, ptManager->QueryHClass(type.first, type.second));
|
||||
if (oldClass->GetInlinedProperties() != newClass->GetInlinedProperties()) {
|
||||
return;
|
||||
}
|
||||
@ -2292,6 +2290,7 @@ void TypeBytecodeLowering::LowerCreateObjectWithBuffer(GateRef gate)
|
||||
}
|
||||
}
|
||||
|
||||
AddProfiling(gate);
|
||||
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
|
||||
GateRef oldObj = builder_.GetObjectFromConstPool(glue_, gate, jsFunc,
|
||||
builder_.TruncInt64ToInt32(index), ConstPoolType::OBJECT_LITERAL);
|
||||
@ -2310,7 +2309,7 @@ void TypeBytecodeLowering::LowerCreateObjectWithBuffer(GateRef gate)
|
||||
builder_.StoreConstOffset(VariableType::INT64(), newObj, newClass->GetInlinedPropertiesOffset(i),
|
||||
builder_.Int64(inlinedProps.at(i)));
|
||||
}
|
||||
builder_.FinishAllocate();
|
||||
acc_.ReplaceHirAndDeleteIfException(gate, builder_.GetStateDepend(), newObj);
|
||||
GateRef ret = builder_.FinishAllocate(newObj);
|
||||
acc_.ReplaceHirAndDeleteIfException(gate, builder_.GetStateDepend(), ret);
|
||||
}
|
||||
} // namespace panda::ecmascript
|
||||
|
@ -123,6 +123,7 @@ group("ark_aot_ts_test") {
|
||||
"forin_non_empty_prototype",
|
||||
"forin_special_object",
|
||||
"forloop",
|
||||
"framestatesalloc",
|
||||
"framestatesasync",
|
||||
"framestatesphi",
|
||||
"generatormerge",
|
||||
|
18
test/aottest/framestatesalloc/BUILD.gn
Normal file
18
test/aottest/framestatesalloc/BUILD.gn
Normal file
@ -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.
|
||||
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
|
||||
host_aot_test_action("framestatesalloc") {
|
||||
deps = []
|
||||
}
|
13
test/aottest/framestatesalloc/expect_output.txt
Normal file
13
test/aottest/framestatesalloc/expect_output.txt
Normal file
@ -0,0 +1,13 @@
|
||||
# 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.
|
||||
|
27
test/aottest/framestatesalloc/framestatesalloc.ts
Normal file
27
test/aottest/framestatesalloc/framestatesalloc.ts
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
function foo() {
|
||||
// framevalues should't handle object of unfinished allocation
|
||||
return {
|
||||
value: -0,
|
||||
writable: false,
|
||||
configurable: false
|
||||
}
|
||||
}
|
||||
|
||||
let obj = {}
|
||||
|
||||
Object.defineProperty(obj, "foo", foo());
|
@ -1,3 +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.
|
||||
*/
|
||||
|
||||
declare function print(arg:any):string;
|
||||
class A {
|
||||
constructor() {
|
||||
|
Loading…
Reference in New Issue
Block a user