diff --git a/runtime/base/json_stringifier.cpp b/runtime/base/json_stringifier.cpp index b883a433c6fed45f8a768056170e9f36bc407bc3..49cceb45c96ffffeb91acb0774a9278357190f17 100644 --- a/runtime/base/json_stringifier.cpp +++ b/runtime/base/json_stringifier.cpp @@ -354,6 +354,9 @@ JSTaggedValue JsonStringifier::SerializeJSONProperty(const JSHandle Builtins::CreateSetter(const JSHandle &env, E void Builtins::SetConstant(const JSHandle &obj, const char *key, JSTaggedValue value) const { + JSHandle valueHandle(thread_, value); JSHandle keyString(factory_->NewFromString(key)); - PropertyDescriptor descriptor(thread_, JSHandle(thread_, value), false, false, false); + PropertyDescriptor descriptor(thread_, valueHandle, false, false, false); JSObject::DefineOwnProperty(thread_, obj, keyString, descriptor); } diff --git a/runtime/builtins/builtins_array.cpp b/runtime/builtins/builtins_array.cpp index cbd3dc352840aecb5a9780dbc8a1ffd1b22e954e..0d226be5c8b418a04d739ec200be784c9a36877f 100644 --- a/runtime/builtins/builtins_array.cpp +++ b/runtime/builtins/builtins_array.cpp @@ -782,6 +782,9 @@ static JSTaggedValue FlattenIntoArray(JSThread *thread, const JSHandle THROW_TYPE_ERROR_AND_RETURN(thread, "out of range", JSTaggedValue::Exception()); } JSTaggedValue str = + // TODO(audovichenko): Remove this suppression when CSA gets recognize primitive TaggedValue + // (issue #I5QOJX) + // SUPPRESS_CSA_NEXTLINE(alpha.core.WasteObjHeader) JSTaggedValue::ToString(thread, JSHandle(thread, targetIdx)).GetTaggedValue(); JSHandle strHandle(thread, str); JSObject::CreateDataPropertyOrThrow(thread, target, strHandle, element); @@ -790,6 +793,8 @@ static JSTaggedValue FlattenIntoArray(JSThread *thread, const JSHandle } } // 4. Return targetIndex. + // TODO(audovichenko): Remove this suppression when CSA gets recognize primitive TaggedValue (issue #I5QOJX) + // SUPPRESS_CSA_NEXTLINE(alpha.core.WasteObjHeader) return targetIdx; } diff --git a/runtime/builtins/builtins_function.cpp b/runtime/builtins/builtins_function.cpp index 16e053ed5008ad31a7ed8c5cb99e4658f622304b..2d59ba02a10f20e5759aa1a41592b5d7c0b0a6d3 100644 --- a/runtime/builtins/builtins_function.cpp +++ b/runtime/builtins/builtins_function.cpp @@ -74,6 +74,8 @@ static JSHandle WrapEvalHack(JSThread *thread, JSMethod *target, JST JSHandle func = factory->NewJSFunctionByDynClass(target, dynclass, FunctionKind::NORMAL_FUNCTION); func->SetStrict(thread, false); func->SetLexicalEnv(thread, vm->GetGlobalEnv()); + // TODO(audovichenko): Remove this suppression when CSA gets recognize primitive TaggedValue (issue #I5QOJX) + // SUPPRESS_CSA_NEXTLINE(alpha.core.WasteObjHeader) JSFunction::SetFunctionLength(thread, func, funcLen); JSHandle emptyString = globalConst->GetHandledEmptyString(); JSHandle nameKey = globalConst->GetHandledNameString(); diff --git a/runtime/builtins/builtins_typedarray.cpp b/runtime/builtins/builtins_typedarray.cpp index fcbab7c481e3640b93cc6e23913a74fcd2a91437..5b112b1fdcc551cae5c71e4439b79edd468713e6 100644 --- a/runtime/builtins/builtins_typedarray.cpp +++ b/runtime/builtins/builtins_typedarray.cpp @@ -1094,6 +1094,9 @@ JSTaggedValue BuiltinsTypedArray::Set(EcmaRuntimeCallInfo *argv) // iv. Set targetByteIndex to targetByteIndex + 1. while (targetByteIndex < limit) { JSTaggedValue taggedData = + // TODO(audovichenko): Remove this suppression when CSA gets recognize primitive TaggedValue + // (issue #I5QOJX) + // SUPPRESS_CSA_NEXTLINE(alpha.core.WasteObjHeader) BuiltinsArrayBuffer::GetValueFromBuffer(srcBuffer, srcByteIndex, DataViewType::UINT8, true); value.Update(taggedData); JSTaggedNumber kNumber = JSTaggedValue::ToNumber(thread, value); diff --git a/runtime/ecma_entrypoints.cpp b/runtime/ecma_entrypoints.cpp index bc7d384763c9c0ac99480958b4230f6a210ef25d..c41b4facc20058c66fbfb19f4ecf21aa5a2c6390 100644 --- a/runtime/ecma_entrypoints.cpp +++ b/runtime/ecma_entrypoints.cpp @@ -29,8 +29,10 @@ extern "C" uintptr_t JSGetGlobalVarAddress(uint32_t id) auto res = op.GetValue(); if (res.IsUndefined() || !res.IsPropertyBox()) { PropertyAttributes attributes = PropertyAttributes::Default(true, true, false); + [[maybe_unused]] EcmaHandleScope scope(thread); JSHandle global_handle(thread, global_obj); - JSHandle key_handle(thread, key); + // Reread key because GC can move it in ctor of ObjectOperator + JSHandle key_handle(thread, GetConstantPool(thread)->GetObjectFromCache(id)); op.AddProperty(global_handle, key_handle, attributes); res = op.GetValue(); } diff --git a/runtime/interpreter/slow_runtime_stub.cpp b/runtime/interpreter/slow_runtime_stub.cpp index d2b09630c3d2b27ebf9c0692ff1d08cdd08412be..4218e6a8d9ce76c5964ec6c8e3eeb9d1cab220d0 100644 --- a/runtime/interpreter/slow_runtime_stub.cpp +++ b/runtime/interpreter/slow_runtime_stub.cpp @@ -1585,6 +1585,7 @@ JSTaggedValue SlowRuntimeStub::StArraySpread(JSThread *thread, JSTaggedValue dst JSHandle dstHandle(thread, dst); JSHandle srcHandle(thread, src); + JSMutableHandle indexHandle(thread, index); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); if (srcHandle->IsUndefined()) { THROW_TYPE_ERROR_AND_RETURN(thread, "undefined is not iterable", JSTaggedValue::Exception()); @@ -1596,7 +1597,7 @@ JSTaggedValue SlowRuntimeStub::StArraySpread(JSThread *thread, JSTaggedValue dst if (srcHandle->IsString()) { JSHandle srcString = JSTaggedValue::ToString(thread, srcHandle); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - uint32_t dstLen = index.GetInt(); + uint32_t dstLen = indexHandle.GetTaggedValue().GetInt(); uint32_t strLen = srcString->GetLength(); for (uint32_t i = 0; i < strLen; i++) { uint16_t res = srcString->At(i); @@ -1622,7 +1623,6 @@ JSTaggedValue SlowRuntimeStub::StArraySpread(JSThread *thread, JSTaggedValue dst RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); } - JSMutableHandle indexHandle(thread, index); JSHandle valueStr = globalConst->GetHandledValueString(); PropertyDescriptor desc(thread); JSHandle iterResult; diff --git a/runtime/js_function.cpp b/runtime/js_function.cpp index d3dd0733020b3ffcf16c5861033b7d09f8fca8ed..7d659ae37cf93bfb1b12a166087eaf7863223b60 100644 --- a/runtime/js_function.cpp +++ b/runtime/js_function.cpp @@ -459,10 +459,10 @@ bool JSFunction::SetFunctionLength(JSThread *thread, const JSHandle ASSERT_PRINT(func->IsExtensible(), "Function must be extensible"); ASSERT_PRINT(length.IsInteger(), "length must be integer"); JSHandle lengthKeyHandle = thread->GlobalConstants()->GetHandledLengthString(); - ASSERT_PRINT(!JSTaggedValue::Less(thread, JSHandle(thread, length), - JSHandle(thread, JSTaggedValue(0))), + JSHandle lengthHandle(thread, length); + ASSERT_PRINT(!JSTaggedValue::Less(thread, lengthHandle, JSHandle(thread, JSTaggedValue(0))), "length must be non negtive integer"); - PropertyDescriptor lengthDesc(thread, JSHandle(thread, length), false, false, cfg); + PropertyDescriptor lengthDesc(thread, lengthHandle, false, false, cfg); JSHandle funcHandle(func); return JSTaggedValue::DefinePropertyOrThrow(thread, funcHandle, lengthKeyHandle, lengthDesc); } diff --git a/runtime/js_number_format.cpp b/runtime/js_number_format.cpp index 7da773c73c887ca8cf6a35555e0e7de63d424910..0321a72a5d653afd9b7e4a228fa6fa87ca56da5e 100644 --- a/runtime/js_number_format.cpp +++ b/runtime/js_number_format.cpp @@ -757,6 +757,9 @@ void GroupToParts(JSThread *thread, const icu::number::FormattedNumber &formatte RETURN_IF_ABRUPT_COMPLETION(thread); index++; { + // TODO(audovichenko): Remove this suppression when CSA gets recognize primitive TaggedValue + // (issue #I5QOJX) + // SUPPRESS_CSA_NEXTLINE(alpha.core.WasteObjHeader) typeString.Update(JSLocale::GetNumberFieldType(thread, x, fieldId).GetTaggedValue()); substring = JSLocale::IcuToString(thread, formattedText, start, limit); JSLocale::PutElement(thread, index, receiver, typeString, JSHandle::Cast(substring)); @@ -782,6 +785,8 @@ void GroupToParts(JSThread *thread, const icu::number::FormattedNumber &formatte if (styleOption == StyleOption::UNIT && static_cast(fieldId) == UNUM_PERCENT_FIELD) { typeString.Update(globalConst->GetUnitString()); } else { + // TODO(audovichenko): Remove this suppression when CSA gets recognize primitive TaggedValue (issue #I5QOJX) + // SUPPRESS_CSA_NEXTLINE(alpha.core.WasteObjHeader) typeString.Update(JSLocale::GetNumberFieldType(thread, x, fieldId).GetTaggedValue()); } JSHandle substring = JSLocale::IcuToString(thread, formattedText, start, limit); @@ -819,6 +824,8 @@ JSHandle JSNumberFormat::FormatNumericToParts(JSThread *thread, const J JSHandle arr = JSArray::ArrayCreate(thread, JSTaggedNumber(0)); JSHandle result = JSHandle::Cast(arr); + // TODO(audovichenko): Remove this suppression when CSA gets recognize primitive TaggedValue (issue #I5QOJX) + // SUPPRESS_CSA_NEXTLINE(alpha.core.WasteObjHeader) GroupToParts(thread, formattedNumber, result, numberFormat, x); RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSArray, thread); return result; diff --git a/runtime/js_typed_array.cpp b/runtime/js_typed_array.cpp index 88497b63a77f66c6a4c635a4af8b2c3322b33709..762c7ef948e64f9e8dbe038783017120ce8ee324 100644 --- a/runtime/js_typed_array.cpp +++ b/runtime/js_typed_array.cpp @@ -188,6 +188,9 @@ bool JSTypedArray::DefineOwnProperty(JSThread *thread, const JSHandle value = desc.GetValue(); + // TODO(audovichenko): Remove this suppression when CSA gets recognize primitive TaggedValue + // (issue #I5QOJX) + // SUPPRESS_CSA_NEXTLINE(alpha.core.WasteObjHeader) return (JSTypedArray::IntegerIndexedElementSet(thread, typedarray, numericIndex, value)); } return true; @@ -449,6 +452,7 @@ OperationResult JSTypedArray::FastElementGet(JSThread *thread, const JSHandle &typedarray, JSTaggedValue index, const JSHandle &value) { + JSHandle indexHandle(thread, index); // 1. Assert: Type(index) is Number. ASSERT(index.IsNumber()); // 2. Assert: O is an Object that has [[ViewedArrayBuffer]], [[ArrayLength]], [[ByteOffset]], and @@ -478,7 +482,6 @@ bool JSTypedArray::IntegerIndexedElementSet(JSThread *thread, const JSHandle indexHandle(thread, index); JSTaggedNumber indexNumber = JSTaggedValue::ToNumber(thread, indexHandle); double tNegZero = -0.0; auto eZero = JSTaggedNumber(tNegZero); diff --git a/runtime/object_factory.cpp b/runtime/object_factory.cpp index 88353d282cd656a19e19e9bd17f087b3461a2282..45f1fb16f44cde7871d64186d831e7f10c8bf662 100644 --- a/runtime/object_factory.cpp +++ b/runtime/object_factory.cpp @@ -1599,6 +1599,8 @@ JSHandle ObjectFactory::NewTaggedArray(uint32_t length, JSTaggedVal } JSHandle array(thread_, header); + // TODO(audovichenko): Remove this suppression when CSA gets recognize primitive TaggedValue (issue #I5QOJX) + // SUPPRESS_CSA_NEXTLINE(alpha.core.WasteObjHeader) array->InitializeWithSpecialValue(initVal, length); return array; } @@ -1624,6 +1626,8 @@ JSHandle ObjectFactory::NewTaggedArrayImpl(uint32_t length, JSTagge size_t size = TaggedArray::ComputeSize(JSTaggedValue::TaggedTypeSize(), length); auto header = heapHelper_.AllocateYoungGenerationOrHugeObject(weak ? weakArrayClass_ : arrayClass_, size); JSHandle array(thread_, header); + // TODO(audovichenko): Remove this suppression when CSA gets recognize primitive TaggedValue (issue #I5QOJX) + // SUPPRESS_CSA_NEXTLINE(alpha.core.WasteObjHeader) array->InitializeWithSpecialValue(initVal, length); return array; }