Closed Bug 362910 Opened 18 years ago Closed 15 years ago

xml[elem]() does not call XML method

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: igor, Assigned: igor)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file, 1 obsolete file)

Consider the following js shell session:

js> xml=<a><b/><c/></a>
<a>
  <b/>
  <c/>
</a>
js> xml['children']()
xml['children']()
<b/>
<c/>
js> xml[tmp = 'children']()
xml[tmp = 'children']()
typein:18: TypeError: xml[tmp = "children"] is not a function
js> 

Here xml[tmp = 'children']() instead of the expected call to XML method generates an error since SpiderMonkey does not call GetMethod for [] operator in the call context. xml['children']() works because that is optimized as xml.children().
Attached patch v1 (obsolete) — Splinter Review
The patch adds js_GetMethod to consolidate various queries for a XML/!XML method property spread throughout the code. JSOP_CALLELEM uses the new method.

The patch also removes JSXMLObjectOps - they are useless as in all cases the code use OBJECT_IS_XML guards before casting JSObjectOps to them. As such the code can always call the function in question directly.
Assignee: general → igor
Attachment #367062 - Flags: review?(brendan)
Attached patch v2Splinter Review
In the previous patch I have added a bogus assert to GetXMLFunction.
Attachment #367062 - Attachment is obsolete: true
Attachment #367067 - Flags: review?(brendan)
Attachment #367062 - Flags: review?(brendan)
Attachment #367067 - Flags: review?(brendan) → review+
Comment on attachment 367067 [details] [diff] [review]
v2

Looks good, we can always evolve JSObjectOps directly in bug 408416.

/be
This is a good cleanup that reduces code size; with baking time it can go into 1.9.1 for b4.

/be
Flags: wanted1.9.1?
Well, OK, but let's try to focus on blockers. Code cleanup is not a late in the cycle activity.
Flags: wanted1.9.1? → wanted1.9.1+
True, not sure if this is on the radar for another bug. It doesn't block anything. Igor?

/be
Igor mentioned another bug relating to this in IRC, I don't remember which it was.
(In reply to comment #7)
> Igor mentioned another bug relating to this in IRC, I don't remember which it
> was.

Most of the cleanup (js_GetMethod) comes from an initial prototype for bug 369696 to implement "the proper" solution there. That does not work (I will comment in the bug), but at least instead of throwing it away completely that part ended up in this bug.
Whiteboard: fixed-in-tracemonkey
http://hg.mozilla.org/mozilla-central/rev/4650f81f1853
Status: NEW → RESOLVED
Closed: 15 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: