mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 08:03:29 +00:00
Add missing call target check for Set and Map
Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IANXIB Signed-off-by: daizihan <daizihan@huawei.com> Change-Id: Ib9e0bda1a11579d7422bbb760cc26ac4dae38bbb
This commit is contained in:
parent
8faea49627
commit
856872a884
@ -253,9 +253,13 @@ GateRef BuiltinLowering::LowerCallTargetCheck(Environment *env, GateRef gate)
|
||||
return LowerCallTargetCheckWithDetector(gate, id);
|
||||
}
|
||||
case BuiltinsStubCSigns::ID::DateGetTime:
|
||||
case BuiltinsStubCSigns::ID::MapClear:
|
||||
case BuiltinsStubCSigns::ID::MapDelete:
|
||||
case BuiltinsStubCSigns::ID::MapGet:
|
||||
case BuiltinsStubCSigns::ID::MapHas:
|
||||
case BuiltinsStubCSigns::ID::SetAdd:
|
||||
case BuiltinsStubCSigns::ID::SetClear:
|
||||
case BuiltinsStubCSigns::ID::SetDelete:
|
||||
case BuiltinsStubCSigns::ID::SetHas: {
|
||||
return LowerCallTargetCheckWithObjectType(gate, id);
|
||||
}
|
||||
@ -333,12 +337,16 @@ GateRef BuiltinLowering::LowerCallTargetCheckWithObjectType(GateRef gate, Builti
|
||||
{
|
||||
JSType expectType = JSType::INVALID;
|
||||
switch (id) {
|
||||
case BuiltinsStubCSigns::ID::MapClear:
|
||||
case BuiltinsStubCSigns::ID::MapDelete:
|
||||
case BuiltinsStubCSigns::ID::MapGet:
|
||||
case BuiltinsStubCSigns::ID::MapHas: {
|
||||
expectType = JSType::JS_MAP;
|
||||
break;
|
||||
}
|
||||
case BuiltinsStubCSigns::ID::SetAdd:
|
||||
case BuiltinsStubCSigns::ID::SetClear:
|
||||
case BuiltinsStubCSigns::ID::SetDelete:
|
||||
case BuiltinsStubCSigns::ID::SetHas: {
|
||||
expectType = JSType::JS_SET;
|
||||
break;
|
||||
|
@ -270,6 +270,22 @@ printClear1(mm) //aot: [trace] Check Type: BuiltinInstanceHClassMismatch
|
||||
//: undefined
|
||||
|
||||
print("case 3") //: case 3
|
||||
|
||||
function checkObjWithMapProto() {
|
||||
let o = {};
|
||||
Object.setPrototypeOf(o, Map.prototype);
|
||||
try {
|
||||
print((o as Map<number, number>).clear(1));
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
//aot: [trace] Check Type: NotCallTarget1
|
||||
//: TypeError: obj is not JSMap
|
||||
checkObjWithMapProto();
|
||||
|
||||
|
||||
if (ArkTools.isAOTCompiled(printClear1)) {
|
||||
Map.prototype.clear = function() {
|
||||
return "prototype";
|
||||
|
@ -257,6 +257,21 @@ printDelete2(mm, 1); //aot: [trace] Check Type: BuiltinInstanceHClassMismatch
|
||||
//: false
|
||||
|
||||
print("case 3") //: case 3
|
||||
|
||||
function checkObjWithMapProto() {
|
||||
let o = {};
|
||||
Object.setPrototypeOf(o, Map.prototype);
|
||||
try {
|
||||
print((o as Map<number, number>).delete(1));
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
//aot: [trace] Check Type: NotCallTarget1
|
||||
//: TypeError: obj is not JSMap
|
||||
checkObjWithMapProto();
|
||||
|
||||
if (ArkTools.isAOTCompiled(printDelete2)) {
|
||||
Map.prototype.delete = function(x: any) {
|
||||
return -x * 10;
|
||||
|
@ -286,6 +286,20 @@ print(mm.size); //: 1
|
||||
printClear2(mm) //: undefined
|
||||
print(m.size); //: 0
|
||||
|
||||
function checkObjWithSetProto() {
|
||||
let o = {};
|
||||
Object.setPrototypeOf(o, Set.prototype);
|
||||
try {
|
||||
o.clear(1);
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
//aot: [trace] Check Type: NotCallTarget1
|
||||
//: TypeError: obj is not JSSet
|
||||
checkObjWithSetProto();
|
||||
|
||||
if (ArkTools.isAOTCompiled(printClear2)) {
|
||||
Object.setPrototypeOf(mm, mimicSet)
|
||||
}
|
||||
|
@ -272,6 +272,22 @@ printDelete2(mm, 1); //aot: [trace] Check Type: BuiltinInstanceHClassMismatch
|
||||
//: false
|
||||
|
||||
print("case 3"); //: case 3
|
||||
|
||||
function checkObjWithSetProto() {
|
||||
let o = {};
|
||||
Object.setPrototypeOf(o, Set.prototype);
|
||||
try {
|
||||
o.delete(1);
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
//aot: [trace] Check Type: NotCallTarget1
|
||||
//: TypeError: obj is not JSSet
|
||||
checkObjWithSetProto();
|
||||
|
||||
|
||||
if (ArkTools.isAOTCompiled(printDelete2)) {
|
||||
Set.prototype.delete = function(x: any) {
|
||||
return -x * 10;
|
||||
|
Loading…
Reference in New Issue
Block a user