[JSC] Correct values and members of JSBigInt appropriately
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Jun 2018 18:47:26 +0000 (18:47 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Jun 2018 18:47:26 +0000 (18:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186196

Reviewed by Darin Adler.

This patch cleans up a bit to select more appropriate values and members of JSBigInt.

1. JSBigInt's structure should be StructureIsImmortal.
2. JSBigInt::allocationSize should be annotated with `inline`.
3. Remove JSBigInt::visitChildren since it is completely the same to JSCell::visitChildren.
4. Remove JSBigInt::finishCreation since it is completely the same to JSCell::finishCreation.

* runtime/JSBigInt.cpp:
(JSC::JSBigInt::allocationSize):
(JSC::JSBigInt::allocateFor):
(JSC::JSBigInt::compareToDouble):
(JSC::JSBigInt::visitChildren): Deleted.
(JSC::JSBigInt::finishCreation): Deleted.
* runtime/JSBigInt.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232401 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSBigInt.cpp
Source/JavaScriptCore/runtime/JSBigInt.h

index 3d25986..5539718 100644 (file)
@@ -1,3 +1,25 @@
+2018-06-01  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [JSC] Correct values and members of JSBigInt appropriately
+        https://bugs.webkit.org/show_bug.cgi?id=186196
+
+        Reviewed by Darin Adler.
+
+        This patch cleans up a bit to select more appropriate values and members of JSBigInt.
+
+        1. JSBigInt's structure should be StructureIsImmortal.
+        2. JSBigInt::allocationSize should be annotated with `inline`.
+        3. Remove JSBigInt::visitChildren since it is completely the same to JSCell::visitChildren.
+        4. Remove JSBigInt::finishCreation since it is completely the same to JSCell::finishCreation.
+
+        * runtime/JSBigInt.cpp:
+        (JSC::JSBigInt::allocationSize):
+        (JSC::JSBigInt::allocateFor):
+        (JSC::JSBigInt::compareToDouble):
+        (JSC::JSBigInt::visitChildren): Deleted.
+        (JSC::JSBigInt::finishCreation): Deleted.
+        * runtime/JSBigInt.h:
+
 2018-05-30  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         [DFG] InById should be converted to MatchStructure
index 8545233..6742d9b 100644 (file)
@@ -61,13 +61,6 @@ namespace JSC {
 const ClassInfo JSBigInt::s_info =
     { "JSBigInt", nullptr, nullptr, nullptr, CREATE_METHOD_TABLE(JSBigInt) };
 
-void JSBigInt::visitChildren(JSCell* cell, SlotVisitor& visitor)
-{
-    JSBigInt* thisObject = jsCast<JSBigInt*>(cell);
-    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-    Base::visitChildren(thisObject, visitor);
-}
-
 JSBigInt::JSBigInt(VM& vm, Structure* structure, unsigned length)
     : Base(vm, structure)
     , m_length(length)
@@ -92,7 +85,7 @@ JSBigInt* JSBigInt::createZero(VM& vm)
     return zeroBigInt;
 }
 
-size_t JSBigInt::allocationSize(unsigned length)
+inline size_t JSBigInt::allocationSize(unsigned length)
 {
     size_t sizeWithPadding = WTF::roundUpToMultipleOf<sizeof(size_t)>(sizeof(JSBigInt));
     return sizeWithPadding + length * sizeof(Digit);
@@ -105,12 +98,6 @@ JSBigInt* JSBigInt::createWithLength(VM& vm, unsigned length)
     return bigInt;
 }
 
-void JSBigInt::finishCreation(VM& vm)
-{
-    Base::finishCreation(vm);
-}
-
-
 JSBigInt* JSBigInt::createFrom(VM& vm, int32_t value)
 {
     if (!value)
@@ -1058,7 +1045,6 @@ JSBigInt* JSBigInt::rightTrim(VM& vm)
 JSBigInt* JSBigInt::allocateFor(ExecState* state, VM& vm, unsigned radix, unsigned charcount)
 {
     ASSERT(2 <= radix && radix <= 36);
-    ASSERT(charcount >= 0);
 
     size_t bitsPerChar = maxBitsPerCharTable[radix];
     size_t chars = charcount;
@@ -1320,7 +1306,7 @@ JSBigInt::ComparisonResult JSBigInt::compareToDouble(JSBigInt* x, double y)
 
     // 0-indexed position of {x}'s most significant bit within the {msd}.
     int msdTopBit = digitBits - 1 - msdLeadingZeros;
-    ASSERT(msdTopBit == (xBitLength - 1) % digitBits);
+    ASSERT(msdTopBit == static_cast<int>((xBitLength - 1) % digitBits));
     
     // Shifted chunk of {mantissa} for comparing with {digit}.
     Digit compareMantissa;
index 28e4da6..fba5a6d 100644 (file)
@@ -37,7 +37,7 @@ namespace JSC {
 
 class JSBigInt final : public JSCell {
     using Base = JSCell;
-    static const unsigned StructureFlags = Base::StructureFlags | OverridesToThis;
+    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal | OverridesToThis;
 
 public:
 
@@ -46,10 +46,7 @@ public:
     enum class InitializationType { None, WithZero };
     void initialize(InitializationType);
 
-    static void visitChildren(JSCell*, SlotVisitor&);
-
     static size_t estimatedSize(JSCell*);
-    static size_t allocationSize(unsigned length);
 
     static Structure* createStructure(VM&, JSGlobalObject*, JSValue prototype);
     static JSBigInt* createZero(VM&);
@@ -62,8 +59,6 @@ public:
 
     DECLARE_EXPORT_INFO;
 
-    void finishCreation(VM&);
-
     JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
 
     void setSign(bool sign) { m_sign = sign; }
@@ -175,6 +170,7 @@ private:
 
     void inplaceMultiplyAdd(Digit multiplier, Digit part);
     
+    static size_t allocationSize(unsigned length);
     static size_t offsetOfData();
     Digit* dataStorage();