<div dir="ltr">On Fri, Aug 15, 2008 at 7:54 AM, Maksim Orlovich <span dir="ltr"><<a href="mailto:mo85@cornell.edu">mo85@cornell.edu</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
It's actually a lot worse in this case, since the ECMAScript runtime must<br>
be able to enforce the sandbox properly even in face of incorrectly<br>
threaded programs.<br>
In particular, if two threads are accessing properties of the same object<br>
at the same time w/o proper locking, the invariants of the property map<br>
data structure should not be violated, which means perhaps the most basic<br>
and hottest data structure in the language runtime has to be thread-safe<br>
(or, at the very least guarantee that whatever happens won't result in a<br>
crash). This is a heavy burden both on the performance and complexity of<br>
the implementation. And, actually, all of the above would apply to<br>
concurrent DOM calls, too.<br>
</blockquote><div><br>That is a very good point in general; defining and enforcing language semantics in the presence of data races is very hard. Just check out the "Java memory model" work.<br><br>For JS in particular, though, it's possible to be fast and thread-safe --- Spidermonkey is. I'm not saying it's a good idea :-).<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">In contrast, a worker implementation, as far I can see, just requires<br>
thread safety of the message passing implementation --- hardly a<br>
challenge; and somewhat trickier but more localized safety of the GC heap.<br>
</blockquote><div> </div></div>AFAIK the workers use logically separate heaps, so the implementation can physically separate the heaps if necessary.<br><br clear="all">Rob<br>-- <br>"He was pierced for our transgressions, he was crushed for our iniquities; the punishment that brought us peace was upon him, and by his wounds we are healed. We all, like sheep, have gone astray, each of us has turned to his own way; and the LORD has laid on him the iniquity of us all." [Isaiah 53:5-6]<br>
</div>