Closed Bug 582817 Opened 14 years ago Closed 6 years ago

Asynchronous XML parsing

Categories

(Tamarin Graveyard :: Library, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED WONTFIX
Q3 12 - Dolores

People

(Reporter: siwilkin, Assigned: gchaney)

References

Details

Attachments

(4 files, 2 obsolete files)

This patch tests the notion that exploiting concurrency within the VM can be relatively painless, given the support of:

- A thread-safe GC (bug 582770)
- Thread-safe exceptions (bug 582782)
- Thread-safe interning (bug 582776)
- A thread-pool executor service that supports futures (bug 582772)


ActionScript XML parsing and object-tree construction is currently performed synchronously within the constructor of an XML object (or the top-level XML() function). This patch introduces a new builtin ActionScript class, XMLAsync, which uses the same parsing algorithm, but builds the object-tree asynchronously to the application-thread.

Usage within ActionScript looks like:

var xmlAsync:XMLAsync = XMLAsync.parse(str); // Returns immediately

The returned XMLAsync object now acts like a future which can be claimed anytime via the take() function; this will block the claiming thread until the parse is complete. The progress of the parse can also be checked with peek(), which returns NULL if the parse is not complete rather than blocking:

var xml:XML = xmlAsync.take(); // blocks until the parse is complete
var xml:XML = xmlAsync.peek(); // returns NULL if the parse is not complete

XMLAsync also supports exceptions. If an exception is thrown during parsing, then this will propagate to the application-thread by being thrown from the take() or peek() functions.


Implementation:

The XMLAsyncObject implementation of the above functionality is relatively simple, based on the enhancement bugs listed above.

The AS3 XMLAsync constructor calls the C++ XMLAsyncObject::init() method, which creates a new ExecutorFuture object. This object is passed a function pointer to the VM's XML parsing method, and a pointer to the String to be parsed. The ExecutorFuture is then submitted to the AvmCore's ExecutorService for dispatch to a worker thread.

The XML object tree is build using a GC shared with the application thread, so the resulting structure can be handed-off with no marshaling.

Both the AS3 XMLAsync.take() and peek() methods query the progress of the ExecutorFuture and reflect its blocking semantics. ExecutorFutures record uncaught Exceptions and rethrow these when the future is claimed, hence, no further work is required to implement the AS3 exception semantics of XMLAsync.
Attached patch Initial patch (obsolete) — Splinter Review
Most of this patch is boiler-plate builtin wrangling.

See XMLAsyncGlue.h/.cpp for the actual implementation.
(In reply to comment #0)

Enable the above via AVMFEATURE_XMLASYNC.

Note: If the XMLAsync builtin is built into the VM but AVMFEATURE_XMLASYNC is not enabled, then XMLAsync parsing is performed synchronously.
Depends on: 604694
Assignee: nobody → gchaney
Flags: flashplayer-qrb+
Flags: flashplayer-bug-
Target Milestone: --- → Q1 12 - Brannan
Priority: -- → P3
Depends on: 650028
Depends on: 650035
Attached patch Core patchSplinter Review
Attachment #461098 - Attachment is obsolete: true
Attached patch XMLAsync shell built-in (obsolete) — Splinter Review
The current patches are based on:

TR rev 6090.
Patch queue rev 280.
Blocks: 650108
Attachment #526085 - Attachment is obsolete: true
Target Milestone: Q1 12 - Brannan → Q3 12 - Dolores
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: