[Development] QML, v8 and freezing the global object

Thomas McGuire thomas.mcguire at kdab.com
Fri Oct 12 13:35:47 CEST 2012


Hi,

On Friday 12 October 2012 12:16:26 aaron.kennedy at nokia.com wrote:
> On 11/10/2012, at 3:04 PM, ext Thomas McGuire wrote:
> > the QML engine "freezes" the global JS object. This is apparently(?) to
> > prevent accidental writes to the global object. For those who don't know,
> > the global object in JS provides objects and properties available in
> > global scope, such as "console" (for console.log) or "qsTr".
> 
> In addition preventing the common errors that a mutable global object
> causes (try running common JS libraries and see how many of them
> accidentally modify the global object because they forgot to put a "var"
> somewhere), 

Ah, I see, I didn't know enough about JS to know that this would create a 
global variable/property.

> a mutable global object would prevent QML from optimising any
> bindings as it cannot be sure of the names in any given scope.

You mean v4 optimizations? Isn't the global object last in the scope lookup, 
so this doesn't matter?

Anyway, I can see why the global objects is frozen, I just wish there'd be 
some way to get rid of the 100ms penalty of this.

Regards,
Thomas
-- 
** Qt Developer Conference: http://qtconference.kdab.com/ **

Thomas McGuire | thomas.mcguire at kdab.com | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel. Germany +49-30-521325470, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3637 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20121012/5db85b59/attachment.bin>


More information about the Development mailing list