Re: [v8-users] The most efficient way to store private values

2016-05-06 Thread Toon Verwaest
You could also just var symbol = new Private() o[symbol] = {__proto__:null} o[symbol]["your key"] = ... On Fri, May 6, 2016 at 8:58 AM Jochen Eisinger wrote: > You don't have to use ForApi() to create privates, you can create the once > and then keep them around as keys. > > Another alternative

Re: [v8-users] Sunspider benchmark

2016-05-18 Thread Toon Verwaest
>From one of the ionmonkey developers: "We cannot state enough that Sunspider is actually obsolete. It was a good benchmark at the start of the JS performance race. Now it is mostly annoying, since it is testing wrong things. Not the things you want to/should improve." (https://h4writer.com/?p=10

Re: [v8-users] Adding functions to prototype template via SetAccessorProperty

2016-06-05 Thread Toon Verwaest
If you want the value to be an instance of a template, you should just Set the value to the template itself rather than the result of instantiating the template. (So drop GetFunction()) Regards, Toon On Mon, Jun 6, 2016, 02:13 Mark Logan wrote: > This is a very similar (perhaps identical) quest

Re: [v8-users] JavaScript Performance Q's: Dictionary Mode, The Global Object, Objects as Namespaces

2016-08-19 Thread Toon Verwaest
Everything below is based on what V8 currently does, without context of other VMs. Any of this is internal and will likely change at one point or another. But you asked for it ... :) > 1) When exactly do objects go into dictionary mode? Are there general > rules of thumb about this that can be app

Re: [v8-users] Re: named property handler - getter being called for both gets and sets

2016-10-31 Thread Toon Verwaest
It just follows JS property access semantics. And that's complicated. If you're trying to set a property, but it doesn't exist on the receiver, we need check whether the property exists on the prototype chain. If it does and has a setter, we need to call the setter. If it does and is read-only, we

Re: [v8-users] Re: named property handler - getter being called for both gets and sets

2016-10-31 Thread Toon Verwaest
f that out in my test cases. Is anything I > said or maybe something I'm probably doing and didn't say going to cause > the holder != this? > > Thank you so much. > > --Zac > > On Monday, October 31, 2016 at 1:39:29 AM UTC-7, Toon Verwaest wrote: > > It jus

Re: [v8-users] Re: named property handler - getter being called for both gets and sets

2016-10-31 Thread Toon Verwaest
use > the holder != this? > > Thank you so much. > > --Zac > > On Monday, October 31, 2016 at 1:39:29 AM UTC-7, Toon Verwaest wrote: > > It just follows JS property access semantics. And that's complicated. > > If you're trying to set a property, but it doesn&#

Re: [v8-users] Per-isolate FunctionTemplate cache

2016-11-21 Thread Toon Verwaest
I don't know which cache you are talking about. Afaik there's only a "function-template-instantations-cache". That caches JSFunctions per native context resulting from instantiating a function template. On Mon, Nov 21, 2016 at 12:05 PM Ben Noordhuis wrote: > On Sun, Nov 20, 2016 at 11:09 PM, w

Re: [v8-users] Re: Per-isolate FunctionTemplate cache

2016-11-22 Thread Toon Verwaest
If you do FunctionTemplate::New you get a caching template. With caching I mean: every time you instantiate the template in the same native context, you'll get the same function out. This is just how it's supposed to work for Blink. This cache keeps the function strongly since even if objects holdi

Re: [v8-users] How to set the class name of the global object

2016-11-24 Thread Toon Verwaest
Previously we used the class name. On Fri, Nov 25, 2016, 00:53 Theodore Dubois wrote: > Interesting. Out of curiosity, how did this work before Chrome added > support for Symbol.toStringTag? > > ~Theodore > > > On Nov 24, 2016, at 2:36 AM, Ben Noordhuis wrote: > > > > On Thu, Nov 24, 2016 at 4:

Re: [v8-users] Implication of the context parameter in v8::Object::Set().

2017-01-18 Thread Toon Verwaest
list > v8-users@googlegroups.com > http://groups.google.com/group/v8-users > --- > You received this message because you are subscribed to the Google Groups > "v8-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to v8-u

Re: [v8-users] info.This().GetAlignedPointerFromInternalField() crashes in property callbacks when applied to global object?

2017-04-20 Thread Toon Verwaest
0x7fac7e6bfe5e] > [0x7fac7e6bfdb5] > [0x7fac7baea0c0] > [0x7fac7e6bdde1] > [0x7fac7d10f38c] > [0x7fac7d14f12f] > [0x7fac7d11269e] > [0x7fac7d133a8d] > [0x00401f23] > [0x7fac7d9a2304] > [0x7fac7da7095e] > [0x7fac7da6f7c9] > [0x7fac7d989d72] > [0x7fac7d98

Re: [v8-users] info.This().GetAlignedPointerFromInternalField() crashes in property callbacks when applied to global object?

2017-04-20 Thread Toon Verwaest
v8-users < v8-users@googlegroups.com> wrote: > Thanks, but what if I don't control the scripts and can't force them to > prefix global property access with "this."? > > -Kenton > > On Thu, Apr 20, 2017 at 1:39 AM, Toon Verwaest > wrote: > >> The p

Re: [v8-users] Why element kind transition can't cause the cache to miss

2017-09-06 Thread Toon Verwaest
is message because you are subscribed to the Google Groups >> "v8-users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to v8-users+unsubscr...@googlegroups.com. >> For more options, visit https://groups.go

Re: [v8-users] Re: Is "extend" keyword a performance antipattern???

2017-09-24 Thread Toon Verwaest
5 AM UTC+3, Zac Hansen wrote: >>>>> >>>>> Microbenchmarks are infamously difficult to get right as often you're >>>>> not testing what you think you're testing. >>>>> >>>>> Are you sure the optimizer isn't

Re: [v8-users] InstanceTemplate, SetAccessor versus SetNativeDataProperty

2017-10-25 Thread Toon Verwaest
t > plugin.cc: getter called... newText > Default: newText > Default: [ 'native' ] nativeText > > > test2 : (passes --disable-old-api-accessors which makes neither setter > get called ) > npm run test2 > > (sample output) > > node --disable-ol

Re: [v8-users] why can't SetSecurityToken control cross access?

2018-06-01 Thread Toon Verwaest
.FromJust()); > > > > // Create an independent environment > > LocalContext context1(0, templ); > > context1->SetSecurityToken(password2);// set another token > > v8::Local global1 = context1->Global(); > > CHECK(global1->Set(context1.local

Re: [v8-users] why can't SetSecurityToken control cross access?

2018-06-01 Thread Toon Verwaest
reate an environment >> > LocalContext context0(0, templ); >> > context0->SetSecurityToken(password); >> > v8::Local global0 = context0->Global(); >> > CHECK(global0->Set(context0.local(), v8_str("custom"), v8_num(1234)) >> >

Re: [v8-users] Re: Alternate for GetCallingContext

2019-12-03 Thread Toon Verwaest
This API was removed when V8 implemented tail calls: there's no way to guarantee that we get the right calling context. While we could technically reintroduce something like GetCallingContext now that we don't support tail calls anyway, it might make more sense to have explicit support for context

Re: [v8-users] V8_31BIT_SMIS_ON_64BIT_ARCH

2020-04-17 Thread Toon Verwaest
On Wed, Apr 15, 2020 at 5:48 PM Alex Kodat wrote: > Ah yes, of course. So a teensy bit better to set > v8_enable_31bit_smis_on_64bit_arch = false if > v8_enable_pointer_compression == false. This would suggest that the default > for v8_enable_31bit_smis_on_64bit_arch (true) is ever so slightly >

Re: [v8-users] documentation for deopt bailouts

2012-10-11 Thread Toon Verwaest
> > does that mean i should replace the for in with a for loop that iterates > > over Object.keys? > It means you have an object that's either in dictionary mode, or has enumerable properties in its prototype chain. Ideally you avoid both of those cases for objects you want to iterate over. -- v

Re: [v8-users] Best way to protect against external JS affecting internal JS

2013-03-13 Thread Toon Verwaest
Once we have proper symbol (private names) support, you could use that to make your own internal API. On Wed, Mar 13, 2013 at 2:56 PM, Michael Schwartz wrote: > Can Harmony Proxies be used to detect when the prototypes or builtins are > being overridden? > > If so, you could save the original a

Re: [v8-users] snapshot vs nosnapshot

2013-03-18 Thread Toon Verwaest
A snapshot is a startup "image" (in the Smalltalk sense) of the initial heap state of V8. If you compile V8 with snapshot, we already setup the heap at compile time, serialize this heap and include it in the resulting binary. When you start up V8, you don't need to reinitialize the heap by executi

Re: [v8-users] V8 Global Object property dump

2013-04-04 Thread Toon Verwaest
If you run with --allow-natives-syntax, you can %DebugPrint(object); hth On Thu, Apr 4, 2013 at 6:55 PM, Mike Moening wrote: > I'm looking for a simple piece of code that can take a V8 Global Object > and dump out all its properties. > Basically iterate the global and print out a listing of ev

Re: [v8-users] V8 Global Object property dump

2013-04-04 Thread Toon Verwaest
It's a commandline flag to v8. It depends on how you run V8: If you run d8, just pass it directly to d8. If you use chromium, use --js-flags="--allow-natives-syntax". On Thu, Apr 4, 2013 at 9:21 PM, Mike Moening wrote: > I'm using Visual Studio to build V8. > Note sure where/how --allow-natives

Re: [v8-users] Unexpected numbers in the heap

2013-04-20 Thread Toon Verwaest
Hi Andrei, V8 has an optimization that turns arrays into unboxed double arrays. If you build a debug build of V8 you could do %DebugPrint(arr1) for example, and you'll see that the elements kind is set to FAST_DOUBLE_ELEMENTS (or FAST_HOLEY_DOUBLE_ELEMENTS). This means that doubles are stored unb

Re: [v8-users] How to avoid GCs when working with numbers?

2013-04-23 Thread Toon Verwaest
There's work in progress to solve this issue. Stay tuned ;) On Tue, Apr 23, 2013 at 9:54 AM, Ben Noordhuis wrote: > On Mon, Apr 22, 2013 at 11:37 PM, Andrei Kashcha wrote: > > Recently I've been profiling a lot v8's garbage collection. Surprising > truth > > is it's really slow when JS program

Re: [v8-users] Performance of method lookups via prototypes

2013-08-27 Thread Toon Verwaest
Such optimizations are only true for receivers. If you have different prototypes all over the place, your code is going is not going to stay monomorphic. For every distinct prototype there's at least unique hidden class; given that the prototype link is hardwired in the hidden class. regards, Toon

Re: [v8-users] Performance of method lookups via prototypes

2013-08-29 Thread Toon Verwaest
is going, how can you possibly inline it? (Well, >> you can, but you have to inline all possible targets, which makes it a much >> tougher tradeoff.) Maybe it doesn't matter if your bottleneck is elsewhere? >> >> >> On Tue, Aug 27, 2013 at 7:50 PM, Toon Verwaest wrote

Re: [v8-users] How to force GCs on client side ?

2013-09-02 Thread Toon Verwaest
Hi, no, it won't. And it shouldn't. The GC is not a single function that is called internally from time to time to clean up your garbage. The GC is a complex beast that does lots of things for you in the background all the time, to (at least but not limited to) 1) limit overall time spent in the

Re: [v8-users] Property access: dot-notation vs. bracket-notation

2014-03-05 Thread Toon Verwaest
That's a current limitation of keyed access handling in Crankshaft. It's on my TODO list to fix that. As for currently working around it: you'll have to trick the IC to go generic. You could eg pass in a few numbers as "id" to that function. That'll make the IC go generic in fullcodegen, which wil

Re: [v8-users] Re: Many functions memory optimization

2014-06-12 Thread Toon Verwaest
And even if function would be considered immutable, and not be objects, you'd have to get rid of the configurable (and also mutable) function.prototype which is closure-specific (and has a backpointer to the closure as .constructor). On Thu, Jun 12, 2014 at 3:00 PM, 'Andreas Rossberg' via v8-user

Re: [v8-users] Cleaning up the global object between scripts

2014-07-16 Thread Toon Verwaest
V8 has no way to "clean up a global object". The global object is referenced in two ways: either directly (implicit references from contexts), or indirectly via the global proxy (references from JavaScript). ReattachGlobal didn't do what you would have expected, reattached the global object of a

Re: [v8-users] problem about v8 flag

2014-08-27 Thread Toon Verwaest
I'm not exactly sure what you are expecting to happen. That flag is enabled by default and causes V8 to learn more about how objects are used for optimization purposes. It is not a flag enabling user visible tracing. On Wed, Aug 27, 2014 at 3:14 AM, Liu Xiao wrote: > Thank you. > > In fact I t

Re: [v8-users] Re: Array#join - better to special case for Array/etc.?

2014-09-02 Thread Toon Verwaest
> > > I'll recind that statement. It still is easily optimizable to a low > level. An array of numbers can > be compiled eventually to push/pop (pushf/popf for floats). > Even though technically possible, I'm willing to bet it's going to take you a *really* *really* long time to get to exactly one

Re: [v8-users] Property access using non-literal indexer is slow

2014-09-18 Thread Toon Verwaest
Our optimizing compiler does indeed not properly supported keyed named accesses. Only keyed indexed accesses are handled properly and fast. That has as a side effect that we currently don't support fast symbol access. So you won't get the same speed-up for those accesses are you get for regular pro

Re: [v8-users] MIPS V8 performance regression from Chromium M31 to M37?

2014-11-04 Thread Toon Verwaest
Note that --always-opt is an internal debugging flag, not a flag for higher performance. Most often it will result is way lower performance due to missing type feedback necessary for good optimized code. On Tue Nov 04 2014 at 4:10:52 PM Stephen wrote: > Success! > > I ran the Octane benchmarks w

Re: [v8-users] Execution slowdown issue

2015-03-24 Thread Toon Verwaest
If your transactional scripts contain function declarations that you instantiate, even if they are global, you'll inadvertantly cause polymorphism on the second run. That will slow down significantly. You can avoid this by only rerunning scripts that call/instantiate existing functions. Alternative

Re: [v8-users] Chaining global objects in multiple contextes

2015-05-06 Thread Toon Verwaest
I'd say either install the parent global as prototype of the child global, or install a non-masking interceptor. In the first case you probably want to swap Object.prototype in the global's chain with the parent, but that means that the methods will come from the parent context. If you don't want

Re: [v8-users] Hashing Contexts

2015-05-11 Thread Toon Verwaest
You indeed need to be careful. Context->Global() changes semantics after Context->DetachGlobal(). Until navigation it returns the global proxy, afterwards it returns the internal global object for technical reasons... (See https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Split

Re: [v8-users] Object.ForceSet to bypass accessors.

2015-10-07 Thread Toon Verwaest
We don't have such alternative right now (last time I checked). We're still working out the best way to support that use case, which is important to V8/DOM as well. One way would be to always go through the accessor, even after lazy instantiation. I can imagine this to be too slow right now though.

Re: [v8-users] Farewell Callee

2015-12-10 Thread Toon Verwaest
The reasoning behind this change is that in the future we'll have FunctionTemplates that can be called through accessors without even allocating the JSFunction. Registering the last called value isn't possible in that case... Perhaps rather than fully getting rid of the parameter we should change

Re: [v8-users] Farewell Callee

2015-12-10 Thread Toon Verwaest
what it means to call a FunctionTemplate. I > guess for C++ code there really isn't any containing JS scope so the > distinction between Function and FunctionTemplate is kinda (largely?) > meaningless? > > > On Thursday, December 10, 2015 at 1:25:38 PM UTC-8, Toon Verwaest wro

Re: [v8-users] Farewell Callee

2015-12-11 Thread Toon Verwaest
meter which is passed via FunctionCallbackInfo::Data >> >> Data could be an External that points to a data structure holding a weak >> Global pointing back at the function. >> >> Would that work for you? >> >> On Fri, Dec 11, 2015, 8:41 AM Toon Verwaest w

Re: [v8-users] Farewell Callee

2015-12-11 Thread Toon Verwaest
Mmh, it doesn't seem possible to instantiated non-caching function-templates multiple times. Nevermind then ;) On Fri, Dec 11, 2015 at 11:15 AM Toon Verwaest wrote: > If embedders don't want to have multiple Callees instantiated from the > same FunctionTemplate, Jochen'

Re: [v8-users] Farewell Callee

2015-12-12 Thread Toon Verwaest
So it sounds like we can move forward with this change without too much hassle for embedders anyway. Awesome. On Sat, Dec 12, 2015, 07:44 Alex Kodat wrote: > First, I'm really impressed with this group's responsiveness. Awesome! > > Second, I apologize if I gave folks extra work to do -- my inte

Re: [v8-users] inline cache about object property access

2016-01-17 Thread Toon Verwaest
Every time you write obj.x you get a new inline cache. The IC in test is used twice, and so can transition further from 0 through . to 1. The other 2 are used only once and hence only get to . from 0. Iirc for global references within the same straight-line code we reuse the cache, which is why th

Re: [v8-users] Object.ForceSet to bypass accessors.

2016-01-27 Thread Toon Verwaest
undefined after the accessor is set to 0 and > CreateDataProperty is called. Is that expected behavior? > > > On Wednesday, October 7, 2015 at 12:52:08 AM UTC-7, Toon Verwaest wrote: > >> We don't have such alternative right now (last time I checked). We're >> s

Re: [v8-users] Recompute handler

2021-02-08 Thread Toon Verwaest
This is a crutch to ensure we don't go poly/megamorphic in the case some assumptions have changed. We use it when e.g., someone modified the prototype chain of the current receiver. The map of the receiver isn't different from the map that we checked in the inline cache. Something else caused us to

Re: [v8-users] let/const scoping when running JS from C++

2022-04-13 Thread Toon Verwaest
What about just wrapping the code in a block: `"{"+actual_source+"}"` Let and const will stay in the block while var will float out to the global scope. On Tue, Apr 12, 2022 at 1:48 AM Robbie McElrath wrote: > Hello! > > I'm trying to implement a replacement for the eval call >

Re: [v8-users] Question about Error.prepareStackTrace

2022-07-25 Thread Toon Verwaest
As the documentation says: this api is just for rendering the stack, not for trapping all exceptions that are thrown. The closest you can currently get to that is --print-all-exceptions, but that obviously only works locally and just prints the exceptions. On Thu, Jul 21, 2022 at 10:44 AM theratl

Re: [v8-users] Does v8 engine cache returned value from a function?

2022-12-21 Thread Toon Verwaest
I'm not exactly sure what you're running, but I assume it's something like: ``` var global = some_object; for (let i = 0; i < ; i++) { do_something(global) } ``` V8 will learn that "global" never changes, and will optimize the loop in which `do_something` will be inlined; specializing it on

Re: [v8-users] SetPrototype on a FunctionTemplate

2023-11-03 Thread Toon Verwaest
Hi Francis, I don't think there's currently a way to do so. That sounds like a reasonable feature request. Can you file a bug https://bugs.chromium.org/p/v8/issues? cheers, Toon On Thu, Oct 26, 2023 at 5:48 PM Francis Bouvier wrote: > Hi, > > Do you know how can I set the prototype of a Functi