@@ -60,6 +60,8 @@ NumberConstructor::NumberConstructor(VM& vm, Structure* structure)
6060{
6161}
6262
63+ static double MinValueAccountingForDenormals = DBL_MIN;
64+
6365void NumberConstructor::finishCreation (VM& vm, NumberPrototype* numberPrototype)
6466{
6567 Base::finishCreation (vm, NumberPrototype::info ()->className );
@@ -70,6 +72,14 @@ void NumberConstructor::finishCreation(VM& vm, NumberPrototype* numberPrototype)
7072
7173 // no. of arguments for constructor
7274 putDirectWithoutTransition (vm, vm.propertyNames ->length , jsNumber (1 ), ReadOnly | DontEnum | DontDelete);
75+
76+ // Test for denormal support. Use 5E-324 as MIN_VALUE if we have denormals
77+ // Careful: this test gets easily optimized away by the compiler, hence
78+ // the assignment to another var.
79+ double denormalTest = MinValueAccountingForDenormals / 2 ;
80+ if ( denormalTest != 0 ) {
81+ MinValueAccountingForDenormals = 5E-324 ;
82+ }
7383}
7484
7585bool NumberConstructor::getOwnPropertySlot (JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
@@ -104,7 +114,7 @@ static EncodedJSValue numberConstructorMaxValue(ExecState*, EncodedJSValue, Enco
104114
105115static EncodedJSValue numberConstructorMinValue (ExecState*, EncodedJSValue, EncodedJSValue, PropertyName)
106116{
107- return JSValue::encode (jsNumber (5E-324 ));
117+ return JSValue::encode (jsNumber (MinValueAccountingForDenormals ));
108118}
109119
110120// ECMA 15.7.1
0 commit comments