Re: [v8-users] FunctionTemplate::Inherit

2014-06-10 Thread Ben Noordhuis
On Mon, Jun 9, 2014 at 10:54 PM, Jane Chen jxche...@gmail.com wrote: It seems to me that FunctionTemplate::Inherit does not allow multiple inheritance, i.e., there is only one partent template and the last one wins. Is that right? Thanks! That's correct, it's standard JS prototypal

Re: [v8-users] Hidden Classes and Prototype Fields

2014-06-10 Thread Jakob Kummerow
In terms of hidden classes, there shouldn't be a difference. However, since you're setting valueA and valueB in the constructor, setting them on the prototype too seems entirely pointless to me. The prototype's values are never visible from instance objects, right? Unless you want to delete them

[v8-users] Problem with several threads trying to lock an isolate, and the withdrawal of v8::Locker's preemption

2014-06-10 Thread juu
Hello everyone, I'm trying to implement RequireJS on my JS Engine based on v8 (v8 3.21). I have a problem with asynchronous loading and evaluation of scripts. The main thread initialize v8 : create its isolate, context, script etc .. When the main script is ready, the current isolate is

Re: [v8-users] Many functions memory optimization

2014-06-10 Thread Ben Noordhuis
On Tue, Jun 10, 2014 at 9:58 PM, Ilya Kantor ilia...@gmail.com wrote: Hi, When I create many objects new Machine like this ``` function Machine(power) { var enabled = false; this.enable = function() { enabled = true; }; this.disable = function() { enabled = false; };

Re: [v8-users] Many functions memory optimization

2014-06-10 Thread Ilya Kantor
Hi Ben, Is that somehow related with Hidden classes for objects or that's a completely another optimization technique? среда, 11 июня 2014 г., 0:29:07 UTC+4 пользователь Ben Noordhuis написал: On Tue, Jun 10, 2014 at 9:58 PM, Ilya Kantor ili...@gmail.com javascript: wrote: Hi, When

Re: [v8-users] Many functions memory optimization

2014-06-10 Thread Stefan penner
The following drops the need for the closure, and lets v8 optimize nicely. Unfortunately you lose the hidden aspect of the internal state. function Machine(power) { this.enabled = true; } Machine.prototype.enable = function() { this.enabled = true; }; Machine.prototype.disable() {

Re: [v8-users] Many functions memory optimization

2014-06-10 Thread Ilya Kantor
Hi Stefan, I'm asking to deeper understand V8. What's going on in the original code (see first message) which leads to single-function-per-many objects? The following drops the need for the closure, and lets v8 optimize nicely. Unfortunately you lose the hidden aspect of the internal

Re: [v8-users] Many functions memory optimization

2014-06-10 Thread Stefan penner
Understood. This message just caught my attention, as I am often sad that state hidden by closure comes with a relatively high price compared to the state existing on this. Anyways, my tests also indicate the function bodies are correctly shared, leaving only the captured context duplicated. It

Re: [v8-users] Many functions memory optimization

2014-06-10 Thread Ben Noordhuis
On Tue, Jun 10, 2014 at 10:31 PM, Ilya Kantor ilia...@gmail.com wrote: Hi Ben, Is that somehow related with Hidden classes for objects or that's a completely another optimization technique? Hidden classes and closures are somewhat orthogonal, they don't overlap much. See [1] and [2] for good

Re: [v8-users] FunctionTemplate::Inherit

2014-06-10 Thread Jane Chen
Thanks, Ben! I was following the example in test-api.cc and it seemed to have worked for me. I just wanted to make sure that I understand the difference between FunctionTemplate.InstanceTemplate() and FunctionTemplate.PrototypeTemplate(): In order for something to be inherited by the

Re: [v8-users] FunctionTemplate::Inherit

2014-06-10 Thread Jane Chen
Correction: I meant to say that Internal field count needs to be set on _instance_ template for it to take effect on the instances created on instance template. Is that right? On Tuesday, June 10, 2014 5:28:27 PM UTC-7, Jane Chen wrote: Thanks, Ben! I was following the example in