1/* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/* 17 * @tc.name:builtinsgc 18 * @tc.desc:gc builtins sanity check 19 * @tc.type: FUNC 20 */ 21let freesize = ArkTools.GC.getFreeHeapSize(); 22if (freesize <= 0) { 23 print("not positive free heap size"); 24} 25 26let maxsize = ArkTools.GC.getReservedHeapSize(); 27if (maxsize <= 0) { 28 print("not positive max heap size"); 29} 30 31let usedsize = ArkTools.GC.getUsedHeapSize(); 32if (usedsize <= 0) { 33 print("not positive used heap size"); 34} 35 36let myobj = new Object(); 37let addr = ArkTools.GC.getObjectAddress(myobj); 38if (addr <= 0) { 39 print("not positive object address"); 40} 41 42let spacetype = ArkTools.GC.getObjectSpaceType(myobj); 43if (spacetype != 9 && spacetype != 12) { 44 print("unexpected object space type"); 45} 46 47try { 48 ArkTools.GC.registerNativeAllocation(-1); 49 print("negative value exception is expected") 50} catch (e) { 51} 52 53try { 54 ArkTools.GC.registerNativeFree(-1); 55 print("negative value exception is expected") 56} catch (e) { 57} 58 59ArkTools.GC.registerNativeFree(100); 60ArkTools.GC.registerNativeAllocation(20000); 61 62let gcId = ArkTools.GC.startGC("old", function () { 63 print("start concurrent mark"); 64}, false); 65ArkTools.GC.waitForFinishGC(gcId); 66 67ArkTools.GC.allocateArrayObject(10); 68