@@ -61,6 +61,8 @@ NumberConstructor::NumberConstructor(JSGlobalObject* globalObject, Structure* st
6161{
6262}
6363
64+ static double MinValueAccountingForDenormals = DBL_MIN;
65+
6466void NumberConstructor::finishCreation (ExecState* exec, NumberPrototype* numberPrototype)
6567{
6668 Base::finishCreation (exec->globalData (), Identifier (exec, numberPrototype->s_info .className ));
@@ -71,6 +73,14 @@ void NumberConstructor::finishCreation(ExecState* exec, NumberPrototype* numberP
7173
7274 // no. of arguments for constructor
7375 putDirectWithoutTransition (exec->globalData (), exec->propertyNames ().length , jsNumber (1 ), ReadOnly | DontEnum | DontDelete);
76+
77+ // Test for denormal support. Use 5E-324 as MIN_VALUE if we have denormals
78+ // Careful: this test gets easily optimized away by the compiler, hence
79+ // the assignment to another var.
80+ double denormalTest = MinValueAccountingForDenormals / 2 ;
81+ if ( denormalTest != 0 ) {
82+ MinValueAccountingForDenormals = 5E-324 ;
83+ }
7484}
7585
7686bool NumberConstructor::getOwnPropertySlot (JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
@@ -110,7 +120,7 @@ static JSValue numberConstructorMaxValue(ExecState*, JSValue, const Identifier&)
110120
111121static JSValue numberConstructorMinValue (ExecState*, JSValue, const Identifier&)
112122{
113- return jsNumber (5E-324 );
123+ return jsNumber (MinValueAccountingForDenormals );
114124}
115125
116126// ECMA 15.7.1
0 commit comments