Closed Bug 431540 Opened 16 years ago Closed 16 years ago

TT: obj == null should not call obj.valueOf

Categories

(Tamarin Graveyard :: Tracing Virtual Machine, defect, P1)

x86
macOS
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: edwsmith, Assigned: stejohns)

Details

Attachments

(1 file)

but it does.  see vm.fs ==vec, calls obj==nonobj which always calls defaultValue

test case:

var o = { valueOf: function() { print("valueOf"); return 0 } }
print(o != null)

this should not print "valueOf"

please add test case to regression suite when fixing.
Blocks: 431541
Assignee: nobody → stejohns
Priority: -- → P1
Attached patch PatchSplinter Review
I think this has it nailed. Still passes sanities.
Attachment #320308 - Flags: review?(edwsmith)
do the obj==ns and ns==obj cases need to check for a hook?
this fix makes access-binary-trees 2X faster because this function is hot and frequently compares a pointer to null.

TreeNode.prototype.itemCheck = function(){
   if (this.left==null) return this.item;
   else return this.item + this.left.itemCheck() - this.right.itemCheck();
}

(In reply to comment #2)
> do the obj==ns and ns==obj cases need to check for a hook?

AFAIK, no. If ES4 adds the ability to override operator== (to use C++ terminology) then we might need to do so, but nothing in standard builtin objects needs it that I aware of. (Changing it back wouldn't hurt, this is just a performance optimization)
Attachment #320308 - Flags: review?(edwsmith) → review+
pushed as changeset:   361:3b882d257ab0
No longer blocks: 431541
marked fixed; added acceptance test in changeset:   376:c9f90e0fd541
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: