Re: [v8-users] d8 needs a function similar to JSC's `drainMicrotasks()`

2016-05-19 Thread Adam Klein
The assertOptimized approach seems like a good balance to me of:

1. Avoiding duplicating the assertion helpers and
2. Avoiding broadening d8's runtime environment

Then the only other requirement is that the usage of assertAsync (or
whatever it's called) in tests isn't affected by the concerns about
breaking the operating model assumptions.

On Tue, May 17, 2016 at 10:11 AM, Jakob Kummerow 
wrote:

> I agree that silent nops are bad, and that's not what we have: The
> implementation is
>
>   try {
> OptimizationStatusImpl = new Function(
> "fun", "sync", "return %GetOptimizationStatus(fun, sync);");
>   } catch (e) {
> throw new Error("natives syntax not allowed");
>   }
>
> leading to:
>
> $ out/x64.release/d8 test/mjsunit/mjsunit.js -e "function f(){};
> assertUnoptimized(f);"
> test/mjsunit/mjsunit.js:436: Error: natives syntax not allowed
>
>
> throw new Error("natives syntax not allowed");
>
>
> ^
>
>
> Error: natives syntax not allowed
>
>
> at OptimizationStatus (test/mjsunit/mjsunit.js:436:15)
>
>
> at assertUnoptimized (test/mjsunit/mjsunit.js:444:16)
>
> The point is that mjsunit.js should still load without
> --allow-natives-syntax, so that not every test must specify that flag, only
> those tests that need to call %Natives.
>
> As I said, I don't know whether we need or should have any microtasks
> related helper(s) in mjsunit.js, I just wanted to point out that it's
> technically possible to use %Natives there.
>
> On Tue, May 17, 2016 at 6:29 PM, Michael Starzinger <
> mstarzin...@chromium.org> wrote:
>
>> On Tue, May 17, 2016 at 6:25 PM, Jakob Kummerow 
>> wrote:
>>
>>> On Tue, May 17, 2016 at 1:01 AM, Caitlin Potter 
>>> wrote:
>>>
 As part of the async functions runtime implementation, I had
 implemented a function in d8.cc which would call isolate->RunMicrotasks()
 --- but was talked down from doing this because of a worry that it might
 interfere with certain uses of d8 out in the wild.

 So, I went with using the existing %RunMicrotasks runtime function ---
 but of course this requires a flag to be present, so the mjsunit helpers
 which rely on this can't be present in mjsunit.js (which means either a lot
 of code duplication, or worse).

>>>
>>> Yes they can; grep for "%GetOptimizationStatus" in mjsunit.js.
>>>
>>
>> I would vote for not adding yet another function like assertOptimized to
>> mjsunit.js that tries to catch the "SyntaxError: Unexpected token %" an
>> turns into a nop when the --allow-natives-syntax flag is not passed. This
>> just hides the fact that the request (i.e. draining the microtask queue)
>> can just not be fulfilled without said flag.
>>
>>
>>>
>>> (I can't comment on functionality concerns around %RunMicrotasks -- if
>>> the approach is invalid in general, then the above point is obviously moot.)
>>>
>>>
 What I'd like to do is get a feel for just how dangerous something like
 `runMicrotasks()` in d8.cc, or if we could get away with adding it as a
 method of a `TestUtils` or `Utils` object instead. Something that would
 allow tests which rely on being able to drain the microtask queue (in order
 to execute quickly, predictably, and synchronously, while still verifying
 the correct async behaviours), without requiring a --allow-natives-syntax
 just to parse the script.

 I don't think there's a huge risk in adding these to d8.cc, and they
 aren't exposed in v8 itself (or Chromium) --- if you're a user of d8 and
 you think a global variable named "Utils", "TestUtils", "runMicrotasks", or
 whatever, would interfere with your uses of d8, I'd like to hear why and
 how.

 Hopefully, there's consensus that it's not dangerous to add such a
 method or object to d8's global object.

 --
 --
 v8-users mailing 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-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> --
>>> --
>>> v8-users mailing 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-users+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> --
>> v8-users mailing 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" 

[v8-users] Passive Error Event

2016-05-19 Thread PhistucK
I am not really sure about how to test it, but I guess you know more about
it.

Browsers support the "error" (window.onerror or
window.addEventListener("error", ...)) event, which, if you call
e.preventDefault() and the like, apparently catches the exception (I could
not get it to work for some reason when I tried in the console, though).

I was thinking about the potential performance gains of adding {passive:
true} support for this event - can it simplify some checks and yield (even)
better performance when using the event? Will the V8 engine benefit from
that in some way (for example, fire it not immediately if it knows there is
more code to run at the moment, or something similar, batching and so on)?

Again, I do not know whether there is even any performance implication to
adding an "error" event listener, you probably know more.

Just an idea.



☆*PhistucK*

-- 
-- 
v8-users mailing 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-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] How to create generator function or object from C/C++ code?

2016-05-19 Thread Bogdan Padalko
Hi, 

is it possible to create generator function and/or generator object from v8 
API? If no, are there any plans to do that? I do v8 engine integration and 
at this time I have to wrap raw functions into js generator function.

P.S.: I would also ask the same question about async functions, but it goes 
behind the scope of main question. If there are any info about async 
function creation from v8 API please let me know.

-- 
-- 
v8-users mailing 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-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.