Comment #1 on issue 2338 by alysson...@gmail.com: V8 engine embedded in a
DLL doesn't work when using the V8/javascript debug system
http://code.google.com/p/v8/issues/detail?id=2338
I am testing/debugging more this issue and I discovered what exactly is the
problem and I bring a suggestion.
The FPU control word has a bit parameter that allows or disallows division
by zero (please, look the documentation of FPU control word). If this
parameter is true, the result of a division by is +Infinity or -Infinity...
If false, an exception is thrown.
In C++, the default behavior is Allow Division by Zero.
The V8 library believes (no treatment) that a division of a finite number
by zero will return +Infinity or -Infinity instead of raising an exception.
In Delphi, the default behavior is to NOT allow division by zero. I loaded
the DLL that contains the V8 engine in an "exe" file compiled by Delphi.
Therefore, the library was running over a behavior that is not the expected
one.
Activating debugger agent triggered the load of the Debugger context, wich
compiles a default javascript code. The javascript code contains the
following function:
------------------------
function NumberToJSON_(value) {
if (isNaN(value)) {
return 'NaN';
}
if (!NUMBER_IS_FINITE(value)) { division
if (value > 0) {
return 'Infinity';
} else {
return '-Infinity';
}
}
return value;
--------------------
NUMBER_IS_FINITE does an 1.0/0.0 division to check if the number is
Infinity.
Because 1.0/0.0 is a full literal expression, the V8 resolves its value on
compile-time instead of runtime.
In compile time of the javascript, a division by zero exception was thrown
in unit "parser.cc", function Parser::ParseBinaryExpression..
---------------------
case Token::DIV:
x = factory()->NewNumberLiteral(x_val / y_val);
continue;
--------------
Suggestion:
Because the ECMA Script specification tells that a division by zero must
return +Infinity or -Infinity (11.5.2 Applying the / Operator), I suggest
that the V8 should do some treatment/validation/assertion about the
actual "zero divide bit parameter" value on FPU control word,
This treatment must works both on compile-time and runtime of a javascript
code.
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev