spidermonkey

How to create, handle, and destroy JS::Heap<T> objects in Spidermonkey?

☆樱花仙子☆ 提交于 2019-12-01 21:20:08
问题 Using Spidermonkey 24, 38, 45 Spidermonkey documentation says: "GC thing pointers on the heap must be wrapped in a JS::Heap. The only exception to this is if they are added as roots with the JS_AddRoot() functions or JS::PersistentRooted class, but don't do this unless it's really necessary. JS::Heap pointers must also continue to be traced in the normal way , which is not covered here." What exactly does tracing mean in this case? Is the following code missing something? struct Foo { Foo(JS:

Under the hood, are Javascript objects hash tables?

泄露秘密 提交于 2019-12-01 02:44:18
I was wondering about how Objects are implemented under the hood in Javascript engines (V8, Spidermonkey, etc). Are they really just Hash Tables? If so, how do they handle collisions? Boris Zbarsky First of all, the answer is probably somewhat different for different JS engines. Also, I assume you're specifically asking about the property storage; obviously objects have a bunch of other state too (prototype chain link being an obvious one). In the case of Spidermonkey, objects basically have a linked list of (propname, information about property) pairs, until they have too many properties,

JSON serialization in Spidermonkey

你。 提交于 2019-12-01 00:44:46
I'm using python-spidermonkey to run JavaScript code. In order to pass objects (instead of just strings) to Python, I'm thinking of returning a JSON string. This seems like a common issue, so I wonder whether there are any facilities for this built into either Spidermonkey or python-spidermonkey . (I do know about uneval but that is not meant to be used for JSON serialization - and I'd rather avoid injecting a block of JavaScript to do this.) I would use JSON.stringify. It's part of the ECMAScript 5 standard, and it's implemented in the current version of spidermonkey. I don't know if it's in

Under the hood, are Javascript objects hash tables?

匆匆过客 提交于 2019-11-30 21:35:03
问题 I was wondering about how Objects are implemented under the hood in Javascript engines (V8, Spidermonkey, etc). Are they really just Hash Tables? If so, how do they handle collisions? 回答1: First of all, the answer is probably somewhat different for different JS engines. Also, I assume you're specifically asking about the property storage; obviously objects have a bunch of other state too (prototype chain link being an obvious one). In the case of Spidermonkey, objects basically have a linked

JSON serialization in Spidermonkey

梦想与她 提交于 2019-11-30 18:15:30
问题 I'm using python-spidermonkey to run JavaScript code. In order to pass objects (instead of just strings) to Python, I'm thinking of returning a JSON string. This seems like a common issue, so I wonder whether there are any facilities for this built into either Spidermonkey or python-spidermonkey . (I do know about uneval but that is not meant to be used for JSON serialization - and I'd rather avoid injecting a block of JavaScript to do this.) 回答1: I would use JSON.stringify. It's part of the

Simulating clicking on a javascript link in python

萝らか妹 提交于 2019-11-30 16:59:14
I am trying to collate reviews of restaurants. Urllib2 works fine for the initial page of reviews, but there is then a link to load the next increment of comments which is a javascript link. An example page is here , and the code for the link "Next 25" is: <a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$RestRatings$Next','')" class="red" id="ctl00_ContentPlaceHolder1_RestRatings_Next">NEXT 25>> </a> I have looked at all the previous answers ( e.g. ), and I have to say I'm none the wiser. Looking at the console in Firebug doesn't offer up a handy link. Could you suggest the best

MongoDB SpiderMonkey doesn't understand UTF-8

♀尐吖头ヾ 提交于 2019-11-30 13:42:08
If I add non-ASCII characters to MongoDB database then all db.find() fail telling "non ascii character detected". It's problem of SpiderMonkey, I have to rebuild it with UTF-8 support. I've tried to do it like in http://www.mongodb.org/display/DOCS/Building+Spider+Monkey but it doesn't work (SpiderMonkey is not installed after I've completed all steps). I've got Ubuntu 11.04. Does anybody have instruction how to make it work there ? Working instruction how to make work MongoDB with Google V8 can also help. I'm using MongoDB on Ubuntu Server 11.04, installed it after making fresh OS install

Best way to get spidermonkey js on Ubuntu?

谁说胖子不能爱 提交于 2019-11-30 06:40:43
I need to install the Spidermonkey JS engine on my work machine. The project I'm working on has a jslint script that requires Spidermonkey or a similar js binary. I've tried compiling Spidermonkey from source and gotten stuck in dependency hell. I tried installing the rhino package from the ubuntu repositories, and that turned out to be slow and broken. This morning, I successfully compiled Google's V8 engine and built v8jslint following the instructions here: http://blog.stevenreid.co.uk/2011/06/27/jslint-command-line-tool-powered-by-v8/ v8jslint works, but will only lint one file at a time.

Simulating clicking on a javascript link in python

一世执手 提交于 2019-11-29 23:52:14
问题 I am trying to collate reviews of restaurants. Urllib2 works fine for the initial page of reviews, but there is then a link to load the next increment of comments which is a javascript link. An example page is here, and the code for the link "Next 25" is: <a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$RestRatings$Next','')" class="red" id="ctl00_ContentPlaceHolder1_RestRatings_Next">NEXT 25>> </a> I have looked at all the previous answers (e.g.), and I have to say I'm none the

Does creating functions consume more memory

我的梦境 提交于 2019-11-29 04:25:57
// Case A function Constructor() { this.foo = function() { ... }; ... } // vs // Case B function Constructor() { ... }; Constructor.prototype.foo = function() { ... } One of the main reasons people advise the use of prototypes is that .foo is created once in the case of the prototype where as this.foo is created multiple times when using the other approach. However one would expect interpreters can optimize this. So that there is only one copy of the function foo in case A. Of course you would still have a unique scope context for each object because of closures but that has less overhead then