mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-06 23:54:03 +00:00
!6558 挑单5752 5802 5784 5775 5797 5795到4.0release
Merge pull request !6558 from 韩靖/OpenHarmony-4.0-Release
This commit is contained in:
commit
bd9398543b
@ -63,6 +63,7 @@ JSTaggedValue BuiltinsDate::DateConstructor(EcmaRuntimeCallInfo *argv)
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
if (objValue->IsString()) { // The value is a string object.
|
||||
timeValue = JSDate::Parse(argv);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
} else { // The value is a number.
|
||||
JSTaggedNumber val = JSTaggedValue::ToNumber(thread, objValue);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
@ -72,25 +73,8 @@ JSTaggedValue BuiltinsDate::DateConstructor(EcmaRuntimeCallInfo *argv)
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
}
|
||||
} else { // two or more values
|
||||
std::array<int64_t, DATE_LENGTH> fields = {0, 0, 1, 0, 0, 0, 0, 0, 0};
|
||||
if (length > CONSTRUCTOR_MAX_LENGTH) { // The max length is 7.
|
||||
length = CONSTRUCTOR_MAX_LENGTH;
|
||||
}
|
||||
uint32_t i = 0;
|
||||
for (; i < length; ++i) {
|
||||
JSHandle<JSTaggedValue> value = GetCallArg(argv, i);
|
||||
JSTaggedNumber res = JSTaggedValue::ToNumber(thread, value);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
double temp = res.GetNumber();
|
||||
if (std::isnan(temp) || !std::isfinite(temp)) { // Check the double value is finite.
|
||||
break;
|
||||
}
|
||||
fields[i] = static_cast<int64_t>(temp);
|
||||
if (i == 0 && fields[0] >= 0 && fields[0] < JSDate::HUNDRED) {
|
||||
fields[0] += JSDate::NINETEEN_HUNDRED_YEAR;
|
||||
}
|
||||
}
|
||||
timeValue = JSTaggedValue((i == length) ? JSDate::SetDateValues(&fields, true) : base::NAN_VALUE);
|
||||
timeValue = ExtractDateFields(thread, length, argv, timeValue);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
}
|
||||
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
@ -482,4 +466,29 @@ JSTaggedValue BuiltinsDate::ToLocaleTimeString(EcmaRuntimeCallInfo *argv)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
JSTaggedValue BuiltinsDate::ExtractDateFields(JSThread *thread, uint32_t &length, EcmaRuntimeCallInfo *argv,
|
||||
JSTaggedValue &timeValue)
|
||||
{
|
||||
std::array<int64_t, DATE_LENGTH> fields = {0, 0, 1, 0, 0, 0, 0, 0, 0};
|
||||
if (length > CONSTRUCTOR_MAX_LENGTH) { // The max length is 7.
|
||||
length = CONSTRUCTOR_MAX_LENGTH;
|
||||
}
|
||||
uint32_t i = 0;
|
||||
for (; i < length; ++i) {
|
||||
JSHandle<JSTaggedValue> value = GetCallArg(argv, i);
|
||||
JSTaggedNumber res = JSTaggedValue::ToNumber(thread, value);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
double temp = JSDate::TimeClip(res.GetNumber());
|
||||
if (std::isnan(temp) || !std::isfinite(temp)) { // Check the double value is finite.
|
||||
break;
|
||||
}
|
||||
fields[i] = static_cast<int64_t>(temp);
|
||||
if (i == 0 && fields[0] >= 0 && fields[0] < JSDate::HUNDRED) {
|
||||
fields[0] += JSDate::NINETEEN_HUNDRED_YEAR;
|
||||
}
|
||||
}
|
||||
timeValue = JSTaggedValue((i == length) ? JSDate::SetDateValues(&fields, true) : base::NAN_VALUE);
|
||||
return timeValue;
|
||||
}
|
||||
} // namespace panda::ecmascript::builtins
|
||||
|
@ -166,6 +166,8 @@ public:
|
||||
static JSTaggedValue ToPrimitive(EcmaRuntimeCallInfo *argv);
|
||||
|
||||
private:
|
||||
static JSTaggedValue ExtractDateFields(JSThread *thread, uint32_t &length, EcmaRuntimeCallInfo *argv,
|
||||
JSTaggedValue &timeValue);
|
||||
// definition for set data code.
|
||||
static constexpr uint32_t CODE_SET_DATE = 0x32;
|
||||
static constexpr uint32_t CODE_SET_MILLISECONDS = 0x76;
|
||||
|
@ -303,13 +303,13 @@ JSTaggedValue BuiltinsMap::AddEntriesFromIterable(JSThread *thread, const JSHand
|
||||
return ret;
|
||||
}
|
||||
// Let k be Get(nextItem, "0").
|
||||
JSHandle<JSTaggedValue> key = JSObject::GetProperty(thread, nextValue, keyIndex).GetValue();
|
||||
JSHandle<JSTaggedValue> key = JSTaggedValue::GetProperty(thread, nextValue, keyIndex).GetValue();
|
||||
// If k is an abrupt completion, return IteratorClose(iter, k).
|
||||
if (thread->HasPendingException()) {
|
||||
return JSIterator::IteratorCloseAndReturn(thread, iter);
|
||||
}
|
||||
// Let v be Get(nextItem, "1").
|
||||
JSHandle<JSTaggedValue> value = JSObject::GetProperty(thread, nextValue, valueIndex).GetValue();
|
||||
JSHandle<JSTaggedValue> value = JSTaggedValue::GetProperty(thread, nextValue, valueIndex).GetValue();
|
||||
// If v is an abrupt completion, return IteratorClose(iter, v).
|
||||
if (thread->HasPendingException()) {
|
||||
return JSIterator::IteratorCloseAndReturn(thread, iter);
|
||||
|
@ -105,6 +105,7 @@ JSTaggedValue BuiltinsNumber::IsInteger(EcmaRuntimeCallInfo *argv)
|
||||
double value = JSTaggedNumber(msg.GetTaggedValue()).GetNumber();
|
||||
// 3. Let integer be ToInteger(number).
|
||||
JSTaggedNumber number = JSTaggedValue::ToInteger(thread, msg);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
// 4. If integer is not equal to number, return false.
|
||||
// 5. Otherwise, return true.
|
||||
result = (value == number.GetNumber());
|
||||
@ -142,6 +143,7 @@ JSTaggedValue BuiltinsNumber::IsSafeInteger(EcmaRuntimeCallInfo *argv)
|
||||
double value = JSTaggedNumber(msg.GetTaggedValue()).GetNumber();
|
||||
// 3. Let integer be ToInteger(number).
|
||||
JSTaggedNumber number = JSTaggedValue::ToInteger(thread, msg);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
// 4. If integer is not equal to number, return false.
|
||||
// 5. If abs(integer) ≤ 253−1, return true.
|
||||
result = (value == number.GetNumber()) && std::abs(value) <= base::MAX_SAFE_INTEGER;
|
||||
@ -266,6 +268,7 @@ JSTaggedValue BuiltinsNumber::ToFixed(EcmaRuntimeCallInfo *argv)
|
||||
// 3. Let f be ToInteger(fractionDigits). (If fractionDigits is undefined, this step produces the value 0).
|
||||
JSHandle<JSTaggedValue> digitArgv = GetCallArg(argv, 0);
|
||||
JSTaggedNumber digitInt = JSTaggedValue::ToInteger(thread, digitArgv);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
if (digitArgv->IsUndefined()) {
|
||||
digitInt = JSTaggedNumber(0);
|
||||
}
|
||||
|
@ -1067,6 +1067,7 @@ JSTaggedValue BuiltinsPromise::Finally(EcmaRuntimeCallInfo *argv)
|
||||
JSHandle<JSObject> ctor = JSHandle<JSObject>::Cast(promise);
|
||||
JSHandle<JSTaggedValue> promiseFunc = JSHandle<JSTaggedValue>::Cast(env->GetPromiseFunction());
|
||||
JSHandle<JSTaggedValue> constructor = JSObject::SpeciesConstructor(thread, ctor, promiseFunc);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
ASSERT_PRINT(constructor->IsConstructor(), "constructor is not constructor");
|
||||
JSHandle<JSTaggedValue> thenFinally;
|
||||
JSHandle<JSTaggedValue> catchFinally;
|
||||
|
@ -807,6 +807,10 @@ JSTaggedValue BuiltinsTypedArray::Join(EcmaRuntimeCallInfo *argv)
|
||||
}
|
||||
}
|
||||
allocateLength += sepLength * (length - 1);
|
||||
if (allocateLength <= 1) {
|
||||
// sep unused, set isOneByte to default(true)
|
||||
isOneByte = true;
|
||||
}
|
||||
auto newString = EcmaStringAccessor::CreateLineString(thread->GetEcmaVM(), allocateLength, isOneByte);
|
||||
int current = 0;
|
||||
DISALLOW_GARBAGE_COLLECTION;
|
||||
|
@ -115,7 +115,7 @@ JSTaggedValue JSArray::ArraySpeciesCreate(JSThread *thread, const JSHandle<JSObj
|
||||
// Let C be Get(originalArray, "constructor").
|
||||
auto *hclass = originalArray->GetJSHClass();
|
||||
if (hclass->IsJSArray() && !hclass->HasConstructor()) {
|
||||
return JSArray::ArrayCreate(thread, length, ArrayMode::LITERAL).GetTaggedValue();
|
||||
return JSArray::ArrayCreate(thread, length).GetTaggedValue();
|
||||
}
|
||||
JSHandle<JSTaggedValue> constructorKey = globalConst->GetHandledConstructorString();
|
||||
constructor = JSTaggedValue::GetProperty(thread, originalValue, constructorKey).GetValue();
|
||||
@ -133,7 +133,7 @@ JSTaggedValue JSArray::ArraySpeciesCreate(JSThread *thread, const JSHandle<JSObj
|
||||
JSTaggedValue realmArrayConstructor = realmC->GetArrayFunction().GetTaggedValue();
|
||||
// If SameValue(C, realmC.[[intrinsics]].[[%Array%]]) is true, let C be undefined.
|
||||
if (JSTaggedValue::SameValue(constructor.GetTaggedValue(), realmArrayConstructor)) {
|
||||
return JSArray::ArrayCreate(thread, length, ArrayMode::LITERAL).GetTaggedValue();
|
||||
return JSArray::ArrayCreate(thread, length).GetTaggedValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -147,14 +147,14 @@ JSTaggedValue JSArray::ArraySpeciesCreate(JSThread *thread, const JSHandle<JSObj
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
// If C is null, let C be undefined.
|
||||
if (constructor->IsNull()) {
|
||||
return JSArray::ArrayCreate(thread, length, ArrayMode::LITERAL).GetTaggedValue();
|
||||
return JSArray::ArrayCreate(thread, length).GetTaggedValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If C is undefined, return ArrayCreate(length).
|
||||
if (constructor->IsUndefined()) {
|
||||
return JSArray::ArrayCreate(thread, length, ArrayMode::LITERAL).GetTaggedValue();
|
||||
return JSArray::ArrayCreate(thread, length).GetTaggedValue();
|
||||
}
|
||||
// If IsConstructor(C) is false, throw a TypeError exception.
|
||||
if (!constructor->IsConstructor()) {
|
||||
|
@ -1479,15 +1479,21 @@ JSHandle<BigInt> BigInt::FloorMod(JSThread *thread, JSHandle<BigInt> leftVal, JS
|
||||
|
||||
JSTaggedValue BigInt::AsUintN(JSThread *thread, JSTaggedNumber &bits, JSHandle<BigInt> bigint)
|
||||
{
|
||||
uint32_t bit = bits.ToUint32();
|
||||
JSHandle<JSTaggedValue> bitsHandle = JSHandle<JSTaggedValue>(thread, bits);
|
||||
JSTaggedNumber number = JSTaggedValue::ToNumber(thread, bitsHandle);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
int64_t bit = base::NumberHelper::DoubleToInt64(number.GetNumber());
|
||||
if (bit == 0) {
|
||||
return Int32ToBigInt(thread, 0).GetTaggedValue();
|
||||
}
|
||||
if (bigint->IsZero()) {
|
||||
return bigint.GetTaggedValue();
|
||||
}
|
||||
JSHandle<BigInt> exponent = Uint32ToBigInt(thread, bit);
|
||||
JSHandle<BigInt> base = Int32ToBigInt(thread, 2); // 2 : base value
|
||||
JSHandle<BigInt> exponent = Uint64ToBigInt(thread, bit);
|
||||
JSHandle<BigInt> base = Int64ToBigInt(thread, 2); // 2 : base value
|
||||
if (bit >= kMaxLengthBits && !bigint->GetSign()) {
|
||||
return bigint.GetTaggedValue();
|
||||
}
|
||||
JSHandle<BigInt> tValue = Exponentiate(thread, base, exponent);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
return FloorMod(thread, bigint, tValue).GetTaggedValue();
|
||||
@ -1495,16 +1501,22 @@ JSTaggedValue BigInt::AsUintN(JSThread *thread, JSTaggedNumber &bits, JSHandle<B
|
||||
|
||||
JSTaggedValue BigInt::AsintN(JSThread *thread, JSTaggedNumber &bits, JSHandle<BigInt> bigint)
|
||||
{
|
||||
uint32_t bit = bits.ToUint32();
|
||||
JSHandle<JSTaggedValue> bitsHandle = JSHandle<JSTaggedValue>(thread, bits);
|
||||
JSTaggedNumber number = JSTaggedValue::ToNumber(thread, bitsHandle);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
int64_t bit = base::NumberHelper::DoubleToInt64(number.GetNumber());
|
||||
if (bit == 0) {
|
||||
return Int32ToBigInt(thread, 0).GetTaggedValue();
|
||||
}
|
||||
if (bigint->IsZero()) {
|
||||
return bigint.GetTaggedValue();
|
||||
}
|
||||
JSHandle<BigInt> exp = Int32ToBigInt(thread, bit);
|
||||
JSHandle<BigInt> exponent = Int32ToBigInt(thread, bit - 1);
|
||||
JSHandle<BigInt> base = Int32ToBigInt(thread, 2); // 2 : base value
|
||||
JSHandle<BigInt> exp = Int64ToBigInt(thread, bit);
|
||||
JSHandle<BigInt> exponent = Int64ToBigInt(thread, bit - 1);
|
||||
JSHandle<BigInt> base = Int64ToBigInt(thread, 2); // 2 : base value
|
||||
if (bit >= kMaxLengthBits && !bigint->GetSign()) {
|
||||
return bigint.GetTaggedValue();
|
||||
}
|
||||
JSHandle<BigInt> tValue = Exponentiate(thread, base, exp);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
JSHandle<BigInt> modValue = FloorMod(thread, bigint, tValue);
|
||||
@ -1605,7 +1617,7 @@ JSTaggedNumber BigInt::BigIntToNumber(JSHandle<BigInt> bigint)
|
||||
return Rounding(sign, mantissa, exponent, true);
|
||||
}
|
||||
while (index > 0) {
|
||||
if (bigint->GetDigit(index--) != 0) {
|
||||
if (bigint->GetDigit(--index) != 0) {
|
||||
return Rounding(sign, mantissa, exponent, true);
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ class BigInt : public TaggedObject {
|
||||
public:
|
||||
static constexpr uint32_t DATEBITS = sizeof(uint32_t) * 8; // 8 : one-bit number of bytes
|
||||
static constexpr uint32_t MAXBITS = 1_MB; // 1 MB : Maximum space that can be opened up
|
||||
static constexpr uint32_t kMaxLengthBits = 1 << 30; // ~1 billion.
|
||||
static constexpr uint32_t MAXSIZE = MAXBITS / DATEBITS; // the maximum value of size
|
||||
static constexpr uint32_t MAXOCTALVALUE = 7; // 7 : max octal value
|
||||
static constexpr uint32_t BINARY = 2; // 2 : binary
|
||||
|
@ -408,7 +408,7 @@ void ObjectOperator::TransitionForAttributeChanged(const JSHandle<JSObject> &rec
|
||||
uint32_t index = GetIndex();
|
||||
JSHandle<GlobalDictionary> dictHandle(thread_, receiver->GetProperties());
|
||||
dictHandle->SetAttributes(thread_, index, attr);
|
||||
GlobalDictionary::InvalidatePropertyBox(thread_, dictHandle, index, attr);
|
||||
GlobalDictionary::InvalidatePropertyBox(thread_, dictHandle, GetIndex(), attr);
|
||||
} else {
|
||||
uint32_t index = GetIndex();
|
||||
if (!receiver->GetJSHClass()->IsDictionaryMode()) {
|
||||
|
@ -20,6 +20,9 @@
|
||||
* @tc.require: issueI7DG0J
|
||||
*/
|
||||
|
||||
var number = Number(0x01000000000000080000000000000000000000n)
|
||||
print(number)
|
||||
|
||||
try {
|
||||
BigInt.asUintN(2147483649, -1873965464n);
|
||||
} catch (e) {
|
||||
@ -69,4 +72,7 @@ let v49 = -12n;
|
||||
v49--;
|
||||
const v52 = (v49 >> v49).constructor;
|
||||
const t48 = v52.__defineSetter__;
|
||||
print(v52(v35));
|
||||
print(v52(v35));
|
||||
|
||||
print(BigInt.asUintN(2**32, 42n));
|
||||
print(BigInt.asIntN(2**32, 42n));
|
@ -11,6 +11,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
2.2300745198530623e+43
|
||||
test successful
|
||||
9007130451115262
|
||||
1
|
||||
@ -21,3 +22,5 @@ RangeError
|
||||
RangeError
|
||||
SyntaxError
|
||||
0
|
||||
42
|
||||
42
|
||||
|
@ -37,3 +37,4 @@ not-equal
|
||||
RangeError: The sum of srcLength and targetOffset is greater than targetLength.
|
||||
RangeError: The sum of srcLength and targetOffset is greater than targetLength.
|
||||
RangeError: The newByteLength is out of range.
|
||||
0
|
||||
|
@ -253,3 +253,7 @@ try {
|
||||
} catch (error) {
|
||||
print(error)
|
||||
}
|
||||
|
||||
const v3 = String.fromCharCode(564654156456456465465)
|
||||
const v5 = new Int16Array(true);
|
||||
print(v5["join"](v3));
|
||||
|
Loading…
Reference in New Issue
Block a user