Commit e7f10a33 authored by oliver's avatar oliver

Fix regression caused by earlier bitwise and optimisation. 1 & undefined != 1.

Reviewed by Maciej.

The implementation of JSImmediate::areBothImmediateNumbers relies on
(JSImmediate::getTag(immediate1) & JSImmediate::getTag(immediate2)) having
a unique result when both immediate values are numbers.

The regression was due to UndefinedType & NumberType returning NumberType (3 & 1).
By swapping the value of NumberType and UndefinedType this ceases to be a problem.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@27630 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 67a6dcd2
2007-11-08 Oliver Hunt <oliver@apple.com>
Reviewed by Maciej.
Fix regression caused by earlier bitwise and optimisation. 1 & undefined != 1.
The implementation of JSImmediate::areBothImmediateNumbers relies on
(JSImmediate::getTag(immediate1) & JSImmediate::getTag(immediate2)) having
a unique result when both immediate values are numbers.
The regression was due to UndefinedType & NumberType returning NumberType (3 & 1).
By swapping the value of NumberType and UndefinedType this ceases to be a problem.
* kjs/JSType.h:
(KJS::):
2007-11-08 Darin Adler <darin@apple.com>
- fix build
......
......@@ -29,9 +29,9 @@ namespace KJS {
*/
enum JSType {
UnspecifiedType = 0,
NumberType = 1,
UndefinedType = 1,
BooleanType = 2,
UndefinedType = 3,
NumberType = 3,
NullType = 4,
StringType = 5,
ObjectType = 6,
......
2007-11-08 Oliver Hunt <oliver@apple.com>
Reviewed by Maciej.
Layout test to guard against bit operation regressions.
* fast/js/bitwise-and-on-undefined-expected.txt: Added.
* fast/js/bitwise-and-on-undefined.html: Added.
2007-11-08 Dan Bernstein <mitz@apple.com>
Reviewed by Beth Dakin.
......
This tests the bitwise operators work correctly in conjunction with undefined and null.
SUCCESS: 0 & null = 0
SUCCESS: 0 & undefined = 0
SUCCESS: 1 & null = 0
SUCCESS: 1 & undefined = 0
SUCCESS: 0 | null = 0
SUCCESS: 0 | undefined = 0
SUCCESS: 1 | null = 1
SUCCESS: 1 | undefined = 1
SUCCESS: 0 ^ null = 0
SUCCESS: 0 ^ undefined = 0
SUCCESS: 1 ^ null = 1
SUCCESS: 1 ^ undefined = 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>test of bitwise operators mixing integers, null, and undefined</title>
<style>
.failure { color: red; }
.success { color: green; }
</style>
<script type="text/javascript">
if (window.layoutTestController) layoutTestController.dumpAsText();
function log(msg) {
document.getElementById("log").innerHTML += msg;
}
function logTest(expression, expected) {
var result;
try {
result = eval(expression);
} catch (e) {
result = e;
}
if (result != expected)
log("<li class='failure'>FAILED: " + expression + " = " + result + " -- expected: " + expected + "</li>");
else
log("<li class='success'>SUCCESS: " + expression + " = " + result + "</li>");
}
function runTest() {
logTest("0 & null", 0);
logTest("0 & undefined", 0);
logTest("1 & null", 0);
logTest("1 & undefined", 0);
logTest("0 | null", 0);
logTest("0 | undefined", 0);
logTest("1 | null", 1);
logTest("1 | undefined", 1);
logTest("0 ^ null", 0);
logTest("0 ^ undefined", 0);
logTest("1 ^ null", 1);
logTest("1 ^ undefined", 1);
}
</script>
</head>
This tests the bitwise operators work correctly in conjunction with undefined and null.<br />
<body onload="runTest()">
<ul id="log"></ul>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment