Changeset 174049 in webkit
- Timestamp:
- Sep 28, 2014 6:52:42 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r174046 r174049 1 2014-09-28 Diego Pino Garcia <dpino@igalia.com> 2 3 Simple ES6 feature: Number constructor extras 4 https://bugs.webkit.org/show_bug.cgi?id=131707 5 6 Reviewed by Darin Adler. 7 8 * js/Object-getOwnPropertyNames-expected.txt: 9 * js/number-constructor-expected.txt: Added. 10 * js/number-constructor.html: Added. 11 * js/script-tests/Object-getOwnPropertyNames.js: 12 * js/script-tests/number-constructor.js: Added. 13 1 14 2014-09-28 Sungmann Cho <sungmann.cho@navercorp.com> 2 15 -
trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt
r173911 r174049 51 51 PASS getSortedOwnPropertyNames(Boolean) is ['length', 'name', 'prototype'] 52 52 PASS getSortedOwnPropertyNames(Boolean.prototype) is ['constructor', 'toString', 'valueOf'] 53 PASS getSortedOwnPropertyNames(Number) is [' MAX_VALUE', 'MIN_VALUE', 'NEGATIVE_INFINITY', 'NaN', 'POSITIVE_INFINITY', 'length', 'name', 'prototype']53 PASS getSortedOwnPropertyNames(Number) is ['EPSILON', 'MAX_SAFE_INTEGER', 'MAX_VALUE', 'MIN_SAFE_INTEGER', 'MIN_VALUE', 'NEGATIVE_INFINITY', 'NaN', 'POSITIVE_INFINITY', 'isFinite', 'isInteger', 'isNaN', 'isSafeInteger', 'length', 'name', 'parseFloat', 'parseInt', 'prototype'] 54 54 PASS getSortedOwnPropertyNames(Number.prototype) is ['clz', 'constructor', 'toExponential', 'toFixed', 'toLocaleString', 'toPrecision', 'toString', 'valueOf'] 55 55 PASS getSortedOwnPropertyNames(Date) is ['UTC', 'length', 'name', 'now', 'parse', 'prototype'] -
trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js
r173911 r174049 59 59 "Boolean": "['length', 'name', 'prototype']", 60 60 "Boolean.prototype": "['constructor', 'toString', 'valueOf']", 61 "Number": "[' MAX_VALUE', 'MIN_VALUE', 'NEGATIVE_INFINITY', 'NaN', 'POSITIVE_INFINITY', 'length', 'name', 'prototype']",61 "Number": "['EPSILON', 'MAX_SAFE_INTEGER', 'MAX_VALUE', 'MIN_SAFE_INTEGER', 'MIN_VALUE', 'NEGATIVE_INFINITY', 'NaN', 'POSITIVE_INFINITY', 'isFinite', 'isInteger', 'isNaN', 'isSafeInteger', 'length', 'name', 'parseFloat', 'parseInt', 'prototype']", 62 62 "Number.prototype": "['clz', 'constructor', 'toExponential', 'toFixed', 'toLocaleString', 'toPrecision', 'toString', 'valueOf']", 63 63 "Date": "['UTC', 'length', 'name', 'now', 'parse', 'prototype']", -
trunk/Source/JavaScriptCore/ChangeLog
r174036 r174049 1 2014-09-28 Diego Pino Garcia <dpino@igalia.com> 2 3 Simple ES6 feature: Number constructor extras 4 https://bugs.webkit.org/show_bug.cgi?id=131707 5 6 Reviewed by Darin Adler. 7 8 * runtime/CommonIdentifiers.h: 9 * runtime/NumberConstructor.cpp: 10 (JSC::NumberConstructor::finishCreation): Setup constants and 11 functions. 12 (JSC::numberConstructorFuncIsFinite): Added. 13 (JSC::numberConstructorFuncIsInteger): Added. 14 (JSC::numberConstructorFuncIsNaN): Added. 15 (JSC::numberConstructorFuncIsSafeInteger): Added. 16 (JSC::NumberConstructor::getOwnPropertySlot): Deleted. 17 (JSC::numberConstructorNaNValue): Deleted. 18 (JSC::numberConstructorNegInfinity): Deleted. 19 (JSC::numberConstructorPosInfinity): Deleted. 20 (JSC::numberConstructorMaxValue): Deleted. 21 (JSC::numberConstructorMinValue): Deleted. 22 * runtime/NumberConstructor.h: 23 1 24 2014-09-26 Filip Pizlo <fpizlo@apple.com> 2 25 -
trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h
r173911 r174049 119 119 macro(instructionCount) \ 120 120 macro(isArray) \ 121 macro(isFinite) \ 122 macro(isInteger) \ 123 macro(isNaN) \ 121 124 macro(isPrototypeOf) \ 125 macro(isSafeInteger) \ 122 126 macro(isView) \ 123 127 macro(isWatchpoint) \ … … 141 145 macro(osrExits) \ 142 146 macro(parse) \ 147 macro(parseFloat) \ 148 macro(parseInt) \ 143 149 macro(postMessage) \ 144 150 macro(profiledBytecodes) \ -
trunk/Source/JavaScriptCore/runtime/NumberConstructor.cpp
r173911 r174049 27 27 #include "NumberPrototype.h" 28 28 #include "JSCInlines.h" 29 #include "JSGlobalObjectFunctions.h" 29 30 30 31 namespace JSC { 31 32 32 static EncodedJSValue numberConstructorNaNValue(ExecState*, JSObject*, EncodedJSValue, PropertyName); 33 static EncodedJSValue numberConstructorNegInfinity(ExecState*, JSObject*, EncodedJSValue, PropertyName); 34 static EncodedJSValue numberConstructorPosInfinity(ExecState*, JSObject*, EncodedJSValue, PropertyName); 35 static EncodedJSValue numberConstructorMaxValue(ExecState*, JSObject*, EncodedJSValue, PropertyName); 36 static EncodedJSValue numberConstructorMinValue(ExecState*, JSObject*, EncodedJSValue, PropertyName); 33 static EncodedJSValue JSC_HOST_CALL numberConstructorFuncIsFinite(ExecState*); 34 static EncodedJSValue JSC_HOST_CALL numberConstructorFuncIsInteger(ExecState*); 35 static EncodedJSValue JSC_HOST_CALL numberConstructorFuncIsNaN(ExecState*); 36 static EncodedJSValue JSC_HOST_CALL numberConstructorFuncIsSafeInteger(ExecState*); 37 37 38 38 } // namespace JSC 39 40 #include "NumberConstructor.lut.h"41 39 42 40 namespace JSC { … … 44 42 STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(NumberConstructor); 45 43 46 const ClassInfo NumberConstructor::s_info = { "Function", &InternalFunction::s_info, &numberConstructorTable, CREATE_METHOD_TABLE(NumberConstructor) }; 47 48 /* Source for NumberConstructor.lut.h 49 @begin numberConstructorTable 50 NaN numberConstructorNaNValue DontEnum|DontDelete|ReadOnly 51 NEGATIVE_INFINITY numberConstructorNegInfinity DontEnum|DontDelete|ReadOnly 52 POSITIVE_INFINITY numberConstructorPosInfinity DontEnum|DontDelete|ReadOnly 53 MAX_VALUE numberConstructorMaxValue DontEnum|DontDelete|ReadOnly 54 MIN_VALUE numberConstructorMinValue DontEnum|DontDelete|ReadOnly 55 @end 56 */ 44 const ClassInfo NumberConstructor::s_info = { "Function", &InternalFunction::s_info, 0, CREATE_METHOD_TABLE(NumberConstructor) }; 57 45 58 46 NumberConstructor::NumberConstructor(VM& vm, Structure* structure) … … 71 59 // no. of arguments for constructor 72 60 putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete); 73 }74 61 75 bool NumberConstructor::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot) 76 { 77 return getStaticValueSlot<NumberConstructor, InternalFunction>(exec, numberConstructorTable, jsCast<NumberConstructor*>(object), propertyName, slot); 78 } 62 putDirectWithoutTransition(vm, Identifier(&vm, "EPSILON"), jsDoubleNumber(std::numeric_limits<double>::epsilon()), DontDelete | DontEnum | ReadOnly); 63 putDirectWithoutTransition(vm, Identifier(&vm, "MAX_VALUE"), jsDoubleNumber(1.7976931348623157E+308), DontDelete | DontEnum | ReadOnly); 64 putDirectWithoutTransition(vm, Identifier(&vm, "MIN_VALUE"), jsDoubleNumber(5E-324), DontDelete | DontEnum | ReadOnly); 65 putDirectWithoutTransition(vm, Identifier(&vm, "MAX_SAFE_INTEGER"), jsDoubleNumber(9007199254740991.0), DontDelete | DontEnum | ReadOnly); 66 putDirectWithoutTransition(vm, Identifier(&vm, "MIN_SAFE_INTEGER"), jsDoubleNumber(-9007199254740991.0), DontDelete | DontEnum | ReadOnly); 67 putDirectWithoutTransition(vm, Identifier(&vm, "NEGATIVE_INFINITY"), jsDoubleNumber(-std::numeric_limits<double>::infinity()), DontDelete | DontEnum | ReadOnly); 68 putDirectWithoutTransition(vm, Identifier(&vm, "POSITIVE_INFINITY"), jsDoubleNumber(std::numeric_limits<double>::infinity()), DontDelete | DontEnum | ReadOnly); 69 putDirectWithoutTransition(vm, Identifier(&vm, "NaN"), jsNaN(), DontDelete | DontEnum | ReadOnly); 79 70 80 static EncodedJSValue numberConstructorNaNValue(ExecState*, JSObject*, EncodedJSValue, PropertyName) 81 { 82 return JSValue::encode(jsNaN()); 83 } 84 85 static EncodedJSValue numberConstructorNegInfinity(ExecState*, JSObject*, EncodedJSValue, PropertyName) 86 { 87 return JSValue::encode(jsNumber(-std::numeric_limits<double>::infinity())); 88 } 89 90 static EncodedJSValue numberConstructorPosInfinity(ExecState*, JSObject*, EncodedJSValue, PropertyName) 91 { 92 return JSValue::encode(jsNumber(std::numeric_limits<double>::infinity())); 93 } 94 95 static EncodedJSValue numberConstructorMaxValue(ExecState*, JSObject*, EncodedJSValue, PropertyName) 96 { 97 return JSValue::encode(jsNumber(1.7976931348623157E+308)); 98 } 99 100 static EncodedJSValue numberConstructorMinValue(ExecState*, JSObject*, EncodedJSValue, PropertyName) 101 { 102 return JSValue::encode(jsNumber(5E-324)); 71 putDirectNativeFunctionWithoutTransition(vm, numberPrototype->globalObject(), Identifier(&vm, "isFinite"), 1, numberConstructorFuncIsFinite, NoIntrinsic, DontEnum | Function); 72 putDirectNativeFunctionWithoutTransition(vm, numberPrototype->globalObject(), Identifier(&vm, "isInteger"), 1, numberConstructorFuncIsInteger, NoIntrinsic, DontEnum | Function); 73 putDirectNativeFunctionWithoutTransition(vm, numberPrototype->globalObject(), Identifier(&vm, "isNaN"), 1, numberConstructorFuncIsNaN, NoIntrinsic, DontEnum | Function); 74 putDirectNativeFunctionWithoutTransition(vm, numberPrototype->globalObject(), Identifier(&vm, "isSafeInteger"), 1, numberConstructorFuncIsSafeInteger, NoIntrinsic, DontEnum | Function); 75 putDirectNativeFunctionWithoutTransition(vm, numberPrototype->globalObject(), Identifier(&vm, "parseFloat"), 1, globalFuncParseFloat, NoIntrinsic, DontEnum | Function); 76 putDirectNativeFunctionWithoutTransition(vm, numberPrototype->globalObject(), Identifier(&vm, "parseInt"), 1, globalFuncParseInt, NoIntrinsic, DontEnum | Function); 103 77 } 104 78 … … 130 104 } 131 105 106 // ECMA-262 20.1.2.2 107 static EncodedJSValue JSC_HOST_CALL numberConstructorFuncIsFinite(ExecState* exec) 108 { 109 JSValue argument = exec->argument(0); 110 return JSValue::encode(jsBoolean(argument.isNumber() && (argument.isInt32() || std::isfinite(argument.asDouble())))); 111 } 112 113 // ECMA-262 20.1.2.3 114 static EncodedJSValue JSC_HOST_CALL numberConstructorFuncIsInteger(ExecState* exec) 115 { 116 JSValue argument = exec->argument(0); 117 bool isInteger; 118 if (argument.isInt32()) 119 isInteger = true; 120 else if (!argument.isDouble()) 121 isInteger = false; 122 else { 123 double number = argument.asDouble(); 124 isInteger = std::isfinite(number) && trunc(number) == number; 125 } 126 return JSValue::encode(jsBoolean(isInteger)); 127 } 128 129 // ECMA-262 20.1.2.4 130 static EncodedJSValue JSC_HOST_CALL numberConstructorFuncIsNaN(ExecState* exec) 131 { 132 JSValue argument = exec->argument(0); 133 return JSValue::encode(jsBoolean(argument.isDouble() && std::isnan(argument.asDouble()))); 134 } 135 136 // ECMA-262 20.1.2.5 137 static EncodedJSValue JSC_HOST_CALL numberConstructorFuncIsSafeInteger(ExecState* exec) 138 { 139 JSValue argument = exec->argument(0); 140 bool isInteger; 141 if (argument.isInt32()) 142 isInteger = true; 143 else if (!argument.isDouble()) 144 isInteger = false; 145 else { 146 double number = argument.asDouble(); 147 isInteger = trunc(number) == number && std::abs(number) <= 9007199254740991.0; 148 } 149 return JSValue::encode(jsBoolean(isInteger)); 150 } 151 132 152 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/NumberConstructor.h
r173911 r174049 39 39 } 40 40 41 static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);42 JSValue getValueProperty(ExecState*, int token) const;43 44 41 DECLARE_INFO; 45 42 … … 48 45 return Structure::create(vm, globalObject, proto, TypeInfo(ObjectType, StructureFlags), info()); 49 46 } 50 51 enum { NaNValue, NegInfinity, PosInfinity, MaxValue, MinValue };52 47 53 48 protected:
Note: See TracChangeset
for help on using the changeset viewer.