Title: [182938] trunk
Revision
182938
Author
commit-qu...@webkit.org
Date
2015-04-16 18:36:10 -0700 (Thu, 16 Apr 2015)

Log Message

Number.parseInt is not === global parseInt in nightly r182673
https://bugs.webkit.org/show_bug.cgi?id=143799

Patch by Jordan Harband <ljh...@gmail.com> on 2015-04-16
Reviewed by Darin Adler.

Source/_javascript_Core:

Ensuring parseInt === Number.parseInt, per spec
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.parseint

* runtime/CommonIdentifiers.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::parseIntFunction):
* runtime/NumberConstructor.cpp:
(JSC::NumberConstructor::finishCreation):

LayoutTests:

* js/number-constructor-expected.txt:
* js/parseInt-expected.txt:
* js/script-tests/number-constructor.js:
* js/script-tests/parseInt.js:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (182937 => 182938)


--- trunk/LayoutTests/ChangeLog	2015-04-17 01:28:45 UTC (rev 182937)
+++ trunk/LayoutTests/ChangeLog	2015-04-17 01:36:10 UTC (rev 182938)
@@ -1,3 +1,15 @@
+2015-04-16  Jordan Harband  <ljh...@gmail.com>
+
+        Number.parseInt is not === global parseInt in nightly r182673
+        https://bugs.webkit.org/show_bug.cgi?id=143799
+
+        Reviewed by Darin Adler.
+
+        * js/number-constructor-expected.txt:
+        * js/parseInt-expected.txt:
+        * js/script-tests/number-constructor.js:
+        * js/script-tests/parseInt.js:
+
 2015-04-16  Tim Horton  <timothy_hor...@apple.com>
 
         Rebaseline mouse-cursor-image-set results after r182869

Modified: trunk/LayoutTests/js/number-constructor-expected.txt (182937 => 182938)


--- trunk/LayoutTests/js/number-constructor-expected.txt	2015-04-17 01:28:45 UTC (rev 182937)
+++ trunk/LayoutTests/js/number-constructor-expected.txt	2015-04-17 01:36:10 UTC (rev 182938)
@@ -122,6 +122,8 @@
 PASS Number.parseFloat("20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") is 2e+307
 PASS Number.parseFloat("200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") is Infinity
 PASS Number.parseFloat(foo) threw exception ReferenceError: Can't find variable: foo.
+PASS Number.parseInt is parseInt
+PASS var numberParseInt = Number.parseInt; parseInt = function () {}; numberParseInt is Number.parseInt
 PASS Number.parseInt.length is 2
 PASS Number.parseInt("0") is 0
 PASS Number.parseInt("-0") is -0

Modified: trunk/LayoutTests/js/parseInt-expected.txt (182937 => 182938)


--- trunk/LayoutTests/js/parseInt-expected.txt	2015-04-17 01:28:45 UTC (rev 182937)
+++ trunk/LayoutTests/js/parseInt-expected.txt	2015-04-17 01:36:10 UTC (rev 182938)
@@ -3,6 +3,8 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
+PASS parseInt.length is 2
+PASS var origParseInt = parseInt; Number.parseInt = function () {}; origParseInt is parseInt
 PASS parseInt('123') is 123
 PASS parseInt('123x4') is 123
 PASS parseInt('-123') is -123

Modified: trunk/LayoutTests/js/script-tests/number-constructor.js (182937 => 182938)


--- trunk/LayoutTests/js/script-tests/number-constructor.js	2015-04-17 01:28:45 UTC (rev 182937)
+++ trunk/LayoutTests/js/script-tests/number-constructor.js	2015-04-17 01:36:10 UTC (rev 182938)
@@ -130,6 +130,8 @@
 shouldThrow('Number.parseFloat(foo)');
 
 // parseInt
+shouldBe('Number.parseInt', 'parseInt');
+shouldBe('var numberParseInt = Number.parseInt; parseInt = function () {}; numberParseInt', 'Number.parseInt');
 shouldBe('Number.parseInt.length', '2');
 shouldBe('Number.parseInt("0")', '0');
 shouldBe('Number.parseInt("-0")', '-0');

Modified: trunk/LayoutTests/js/script-tests/parseInt.js (182937 => 182938)


--- trunk/LayoutTests/js/script-tests/parseInt.js	2015-04-17 01:28:45 UTC (rev 182937)
+++ trunk/LayoutTests/js/script-tests/parseInt.js	2015-04-17 01:36:10 UTC (rev 182938)
@@ -1,5 +1,8 @@
 description('Tests for the parseInt function.');
 
+shouldBe("parseInt.length", "2");
+shouldBe('var origParseInt = parseInt; Number.parseInt = function () {}; origParseInt', 'parseInt');
+
 // Simple hex & dec integer values.
 shouldBe("parseInt('123')", '123');
 shouldBe("parseInt('123x4')", '123');

Modified: trunk/Source/_javascript_Core/ChangeLog (182937 => 182938)


--- trunk/Source/_javascript_Core/ChangeLog	2015-04-17 01:28:45 UTC (rev 182937)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-04-17 01:36:10 UTC (rev 182938)
@@ -1,3 +1,21 @@
+2015-04-16  Jordan Harband  <ljh...@gmail.com>
+
+        Number.parseInt is not === global parseInt in nightly r182673
+        https://bugs.webkit.org/show_bug.cgi?id=143799
+
+        Reviewed by Darin Adler.
+
+        Ensuring parseInt === Number.parseInt, per spec
+        https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.parseint
+
+        * runtime/CommonIdentifiers.h:
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::init):
+        * runtime/JSGlobalObject.h:
+        (JSC::JSGlobalObject::parseIntFunction):
+        * runtime/NumberConstructor.cpp:
+        (JSC::NumberConstructor::finishCreation):
+
 2015-04-16  Mark Lam  <mark....@apple.com>
 
         Gardening: fix CLOOP build after r182927.

Modified: trunk/Source/_javascript_Core/runtime/CommonIdentifiers.h (182937 => 182938)


--- trunk/Source/_javascript_Core/runtime/CommonIdentifiers.h	2015-04-17 01:28:45 UTC (rev 182937)
+++ trunk/Source/_javascript_Core/runtime/CommonIdentifiers.h	2015-04-17 01:36:10 UTC (rev 182938)
@@ -142,6 +142,7 @@
     macro(osrExitSites) \
     macro(osrExits) \
     macro(parse) \
+    macro(parseInt) \
     macro(postMessage) \
     macro(profiledBytecodes) \
     macro(propertyIsEnumerable) \

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp (182937 => 182938)


--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp	2015-04-17 01:28:45 UTC (rev 182937)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp	2015-04-17 01:36:10 UTC (rev 182938)
@@ -154,7 +154,6 @@
 
 /* Source for JSGlobalObject.lut.h
 @begin globalObjectTable
-  parseInt              globalFuncParseInt              DontEnum|Function 2
   parseFloat            globalFuncParseFloat            DontEnum|Function 1
   isNaN                 globalFuncIsNaN                 DontEnum|Function 1
   isFinite              globalFuncIsFinite              DontEnum|Function 1
@@ -314,7 +313,10 @@
     m_promisePrototype.set(vm, this, JSPromisePrototype::create(exec, this, JSPromisePrototype::createStructure(vm, this, m_objectPrototype.get())));
     m_promiseStructure.set(vm, this, JSPromise::createStructure(vm, this, m_promisePrototype.get()));
 #endif // ENABLE(PROMISES)
-    
+
+    m_parseIntFunction.set(vm, this, JSFunction::create(vm, this, 2, vm.propertyNames->parseInt.string(), globalFuncParseInt, NoIntrinsic));
+    putDirectWithoutTransition(vm, vm.propertyNames->parseInt, m_parseIntFunction.get(), DontEnum | Function);
+
 #define CREATE_PROTOTYPE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
 m_ ## lowerName ## Prototype.set(vm, this, capitalName##Prototype::create(vm, this, capitalName##Prototype::createStructure(vm, this, m_objectPrototype.get()))); \
 m_ ## properName ## Structure.set(vm, this, instanceType::createStructure(vm, this, m_ ## lowerName ## Prototype.get()));
@@ -693,6 +695,7 @@
     visitor.append(&thisObject->m_nullGetterFunction);
     visitor.append(&thisObject->m_nullSetterFunction);
 
+    visitor.append(&thisObject->m_parseIntFunction);
     visitor.append(&thisObject->m_evalFunction);
     visitor.append(&thisObject->m_callFunction);
     visitor.append(&thisObject->m_applyFunction);

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.h (182937 => 182938)


--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.h	2015-04-17 01:28:45 UTC (rev 182937)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.h	2015-04-17 01:36:10 UTC (rev 182938)
@@ -185,6 +185,8 @@
     WriteBarrier<NullGetterFunction> m_nullGetterFunction;
     WriteBarrier<NullSetterFunction> m_nullSetterFunction;
 
+    WriteBarrier<JSFunction> m_parseIntFunction;
+
     WriteBarrier<JSFunction> m_evalFunction;
     WriteBarrier<JSFunction> m_callFunction;
     WriteBarrier<JSFunction> m_applyFunction;
@@ -392,6 +394,8 @@
     NullGetterFunction* nullGetterFunction() const { return m_nullGetterFunction.get(); }
     NullSetterFunction* nullSetterFunction() const { return m_nullSetterFunction.get(); }
 
+    JSFunction* parseIntFunction() const { return m_parseIntFunction.get(); }
+
     JSFunction* evalFunction() const { return m_evalFunction.get(); }
     JSFunction* callFunction() const { return m_callFunction.get(); }
     JSFunction* applyFunction() const { return m_applyFunction.get(); }

Modified: trunk/Source/_javascript_Core/runtime/NumberConstructor.cpp (182937 => 182938)


--- trunk/Source/_javascript_Core/runtime/NumberConstructor.cpp	2015-04-17 01:28:45 UTC (rev 182937)
+++ trunk/Source/_javascript_Core/runtime/NumberConstructor.cpp	2015-04-17 01:36:10 UTC (rev 182938)
@@ -73,7 +73,7 @@
     putDirectNativeFunctionWithoutTransition(vm, numberPrototype->globalObject(), Identifier::fromString(&vm, "isNaN"), 1, numberConstructorFuncIsNaN, NoIntrinsic, DontEnum | Function);
     putDirectNativeFunctionWithoutTransition(vm, numberPrototype->globalObject(), Identifier::fromString(&vm, "isSafeInteger"), 1, numberConstructorFuncIsSafeInteger, NoIntrinsic, DontEnum | Function);
     putDirectNativeFunctionWithoutTransition(vm, numberPrototype->globalObject(), Identifier::fromString(&vm, "parseFloat"), 1, globalFuncParseFloat, NoIntrinsic, DontEnum | Function);
-    putDirectNativeFunctionWithoutTransition(vm, numberPrototype->globalObject(), Identifier::fromString(&vm, "parseInt"), 2, globalFuncParseInt, NoIntrinsic, DontEnum | Function);
+    putDirectWithoutTransition(vm, Identifier::fromString(&vm, "parseInt"), numberPrototype->globalObject()->parseIntFunction(), DontEnum | Function);
 }
 
 // ECMA 15.7.1
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to