Changeset 262342 in webkit for trunk/Source/JavaScriptCore/runtime/JSBigInt.h
- Timestamp:
- May 30, 2020, 12:46:53 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSBigInt.h
r262012 r262342 66 66 67 67 static Structure* createStructure(VM&, JSGlobalObject*, JSValue prototype); 68 JS_EXPORT_PRIVATE static JSBigInt* createZero(VM&); 69 JS_EXPORT_PRIVATE static JSBigInt* tryCreateWithLength(JSGlobalObject*, unsigned length); 70 static JSBigInt* createWithLengthUnchecked(VM&, unsigned length); 71 72 JS_EXPORT_PRIVATE static JSBigInt* createFrom(VM&, int32_t value); 73 static JSBigInt* createFrom(VM&, uint32_t value); 74 static JSBigInt* createFrom(VM&, int64_t value); 75 static JSBigInt* createFrom(VM&, uint64_t value); 76 static JSBigInt* createFrom(VM&, bool value); 77 static JSBigInt* createFrom(VM&, double value); 68 JS_EXPORT_PRIVATE static JSBigInt* createZero(JSGlobalObject*); 69 JS_EXPORT_PRIVATE static JSBigInt* tryCreateZero(VM&); 70 JS_EXPORT_PRIVATE static JSBigInt* tryCreateWithLength(VM&, unsigned length); 71 JS_EXPORT_PRIVATE static JSBigInt* createWithLength(JSGlobalObject*, unsigned length); 72 73 JS_EXPORT_PRIVATE static JSBigInt* createFrom(JSGlobalObject*, int32_t value); 74 static JSBigInt* tryCreateFrom(VM&, int32_t value); 75 static JSBigInt* createFrom(JSGlobalObject*, uint32_t value); 76 static JSBigInt* createFrom(JSGlobalObject*, int64_t value); 77 static JSBigInt* createFrom(JSGlobalObject*, uint64_t value); 78 static JSBigInt* createFrom(JSGlobalObject*, bool value); 79 static JSBigInt* createFrom(JSGlobalObject*, double value); 80 81 static JSBigInt* createFrom(JSGlobalObject*, VM&, int32_t value); 78 82 79 83 static size_t offsetOfLength() … … 91 95 unsigned length() const { return m_length; } 92 96 93 static JSValue makeHeapBigIntOrBigInt32( VM& vm, int64_t value)97 static JSValue makeHeapBigIntOrBigInt32(JSGlobalObject* globalObject, int64_t value) 94 98 { 95 99 #if USE(BIGINT32) … … 97 101 return jsBigInt32(static_cast<int32_t>(value)); 98 102 #endif 99 return JSBigInt::createFrom( vm, value);100 } 101 102 static JSValue makeHeapBigIntOrBigInt32( VM& vm, double value)103 return JSBigInt::createFrom(globalObject, value); 104 } 105 106 static JSValue makeHeapBigIntOrBigInt32(JSGlobalObject* globalObject, double value) 103 107 { 104 108 ASSERT(isInteger(value)); 105 109 if (std::abs(value) <= maxSafeInteger()) 106 return makeHeapBigIntOrBigInt32( vm, static_cast<int64_t>(value));107 return JSBigInt::createFrom( vm, value);110 return makeHeapBigIntOrBigInt32(globalObject, static_cast<int64_t>(value)); 111 return JSBigInt::createFrom(globalObject, value); 108 112 } 109 113 … … 159 163 ComparisonResult static compareToDouble(JSBigInt* x, double y); 160 164 161 ALWAYS_INLINE static JSValue asInt32OrHeapCell( VM& vm, int64_t value)165 ALWAYS_INLINE static JSValue asInt32OrHeapCell(JSGlobalObject* globalObject, int64_t value) 162 166 { 163 167 #if USE(BIGINT32) … … 165 169 return jsBigInt32(static_cast<int32_t>(value)); 166 170 #endif 167 return createFrom(vm, value); 168 } 169 ALWAYS_INLINE static JSValue asInt32OrHeapCell(JSGlobalObject* globalObject, int64_t value) 170 { 171 return asInt32OrHeapCell(globalObject->vm(), value); 171 return createFrom(globalObject, value); 172 172 } 173 173 … … 185 185 }; 186 186 private: 187 static JSBigInt* createWithLength(JSGlobalObject*, VM&, unsigned length); 188 static JSBigInt* createZero(JSGlobalObject*, VM&); 187 189 188 190 template <typename BigIntImpl1, typename BigIntImpl2> … … 211 213 212 214 template <typename BigIntImpl> 213 static ImplResult unaryMinusImpl( VM&, BigIntImpl x);215 static ImplResult unaryMinusImpl(JSGlobalObject*, BigIntImpl x); 214 216 215 217 template <typename BigIntImpl1, typename BigIntImpl2> … … 296 298 { 297 299 if (!y) { 298 auto scope = DECLARE_THROW_SCOPE(g lobalObject->vm());300 auto scope = DECLARE_THROW_SCOPE(getVM(globalObject)); 299 301 throwRangeError(globalObject, scope, "0 is an invalid divisor value."_s); 300 302 return JSValue(); … … 311 313 { 312 314 if (!y) { 313 auto scope = DECLARE_THROW_SCOPE(g lobalObject->vm());315 auto scope = DECLARE_THROW_SCOPE(getVM(globalObject)); 314 316 throwRangeError(globalObject, scope, "0 is an invalid divisor value."_s); 315 317 return JSValue(); … … 319 321 #endif 320 322 321 static JSValue unaryMinus( VM&, JSBigInt* x);322 #if USE(BIGINT32) 323 static JSValue unaryMinus( VM& vm, int32_t x)324 { 325 return asInt32OrHeapCell( vm, -static_cast<int64_t>(x));323 static JSValue unaryMinus(JSGlobalObject*, JSBigInt* x); 324 #if USE(BIGINT32) 325 static JSValue unaryMinus(JSGlobalObject* globalObject, int32_t x) 326 { 327 return asInt32OrHeapCell(globalObject, -static_cast<int64_t>(x)); 326 328 } 327 329 #endif … … 424 426 Digit digit(unsigned); 425 427 void setDigit(unsigned, Digit); // Use only when initializing. 426 JS_EXPORT_PRIVATE JSBigInt* rightTrim(VM&); 428 JS_EXPORT_PRIVATE JSBigInt* rightTrim(JSGlobalObject*); 429 JS_EXPORT_PRIVATE JSBigInt* tryRightTrim(VM&); 427 430 428 431 private: 429 432 JSBigInt(VM&, Structure*, Digit*, unsigned length); 430 433 431 static JSBigInt* createFromImpl(VM&, uint64_t value, bool sign); 434 JSBigInt* rightTrim(JSGlobalObject*, VM&); 435 436 static JSBigInt* createFromImpl(JSGlobalObject*, uint64_t value, bool sign); 432 437 433 438 static constexpr unsigned bitsPerByte = 8; … … 455 460 static ComparisonResult absoluteCompare(BigIntImpl1 x, BigIntImpl2 y); 456 461 template <typename BigIntImpl> 457 static void absoluteDivWithDigitDivisor(VM&, BigIntImpl x, Digit divisor, JSBigInt** quotient, Digit& remainder);462 static bool absoluteDivWithDigitDivisor(JSGlobalObject*, VM&, BigIntImpl x, Digit divisor, JSBigInt** quotient, Digit& remainder); 458 463 template <typename BigIntImpl> 459 464 static void internalMultiplyAdd(BigIntImpl source, Digit factor, Digit summand, unsigned, JSBigInt* result); … … 490 495 491 496 template<typename BigIntImpl1, typename BigIntImpl2, typename BitwiseOp> 492 static JSBigInt* absoluteBitwiseOp( VM&, BigIntImpl1 x, BigIntImpl2 y, ExtraDigitsHandling, BitwiseOp&&);493 494 template <typename BigIntImpl1, typename BigIntImpl2> 495 static JSBigInt* absoluteAnd( VM&, BigIntImpl1 x, BigIntImpl2 y);496 template <typename BigIntImpl1, typename BigIntImpl2> 497 static JSBigInt* absoluteOr( VM&, BigIntImpl1 x, BigIntImpl2 y);498 template <typename BigIntImpl1, typename BigIntImpl2> 499 static JSBigInt* absoluteAndNot( VM&, BigIntImpl1 x, BigIntImpl2 y);500 template <typename BigIntImpl1, typename BigIntImpl2> 501 static JSBigInt* absoluteXor( VM&, BigIntImpl1 x, BigIntImpl2 y);497 static JSBigInt* absoluteBitwiseOp(JSGlobalObject*, BigIntImpl1 x, BigIntImpl2 y, ExtraDigitsHandling, BitwiseOp&&); 498 499 template <typename BigIntImpl1, typename BigIntImpl2> 500 static JSBigInt* absoluteAnd(JSGlobalObject*, BigIntImpl1 x, BigIntImpl2 y); 501 template <typename BigIntImpl1, typename BigIntImpl2> 502 static JSBigInt* absoluteOr(JSGlobalObject*, BigIntImpl1 x, BigIntImpl2 y); 503 template <typename BigIntImpl1, typename BigIntImpl2> 504 static JSBigInt* absoluteAndNot(JSGlobalObject*, BigIntImpl1 x, BigIntImpl2 y); 505 template <typename BigIntImpl1, typename BigIntImpl2> 506 static JSBigInt* absoluteXor(JSGlobalObject*, BigIntImpl1 x, BigIntImpl2 y); 502 507 503 508 enum class SignOption { … … 536 541 537 542 template <typename BigIntImpl> 538 static JSBigInt* copy( VM&, BigIntImpl x);543 static JSBigInt* copy(JSGlobalObject*, BigIntImpl x); 539 544 540 545 void inplaceMultiplyAdd(Digit multiplier, Digit part); … … 542 547 static ImplResult absoluteAdd(JSGlobalObject*, BigIntImpl1 x, BigIntImpl2 y, bool resultSign); 543 548 template <typename BigIntImpl1, typename BigIntImpl2> 544 static ImplResult absoluteSub( VM&, BigIntImpl1 x, BigIntImpl2 y, bool resultSign);549 static ImplResult absoluteSub(JSGlobalObject*, BigIntImpl1 x, BigIntImpl2 y, bool resultSign); 545 550 546 551 template <typename BigIntImpl1, typename BigIntImpl2> … … 549 554 static ImplResult rightShiftByAbsolute(JSGlobalObject*, BigIntImpl1 x, BigIntImpl2 y); 550 555 551 static ImplResult rightShiftByMaximum( VM&, bool sign);556 static ImplResult rightShiftByMaximum(JSGlobalObject*, bool sign); 552 557 553 558 template <typename BigIntImpl> … … 559 564 static ImplResult asUintNImpl(JSGlobalObject*, uint64_t, BigIntImpl); 560 565 template <typename BigIntImpl> 561 static ImplResult truncateToNBits( VM&, int32_t, BigIntImpl);562 template <typename BigIntImpl> 563 static ImplResult truncateAndSubFromPowerOfTwo( VM&, int32_t, BigIntImpl, bool resultSign);566 static ImplResult truncateToNBits(JSGlobalObject*, int32_t, BigIntImpl); 567 template <typename BigIntImpl> 568 static ImplResult truncateAndSubFromPowerOfTwo(JSGlobalObject*, int32_t, BigIntImpl, bool resultSign); 564 569 565 570 inline static size_t offsetOfData()
Note:
See TracChangeset
for help on using the changeset viewer.