On Fri, Feb 27, 2015 at 11:43 AM, Michael Hablich <[email protected]> wrote:
> Hey v8-users,
>
> we're making big changes to the api (again).  We've found that our api makes
> it extremely difficult to write exception safe code.
>
> Reference issue
> https://code.google.com/p/v8/issues/detail?id=3929
>
> Further description
> Consider the following:
>
> Local<Value> x = some_value;
> s = x.ToString();
> // in the current context, ToString might throw an exception, run out
> of stack space, whatever...
> // if that happens we just return an empty Local<String>
> s->Anything() // Crash!
>
> There's too much implicit stuff happening here, and it's bad.  It's
> especially bad if you use threads and rely on TerminateExecution(), which
> causes lots of v8 function to return empty handles unexpectedly.
>
> To fix this, we will begin adding functions whose signature makes it
> impossible to make this mistake and we will deprecate and eventually remove
> all old functions.  The new functions will in general come in
> two flavours:
>
> functions like:
> Local<String> ToString(Isolate*);
>
> will become:
> MaybeLocal<String> ToString(Local<Context>);
>
> and functions like:
> double NumberValue();
>
> will become:
> Maybe<bool> NumberValue(Local<Context>);

I think this should read `Maybe<double> NumberValue(Local<Context>)`?

> The Maybe values ensure at compilation time that the value returned is
> checked by the embedder, and the explicit Context makes it clear that a
> context is actually required and that javascript may be executed in that
> context.
>
> Timeline
> We will add the new API parts gradually to the codebase. When this is
> finished there will be approx. 6 weeks of time where the old and the new API
> will exist side-by-side. This is a good time to make the adjustments in your
> embedding code. After this period the old API will get removed.
>
> We apologize in advance for any trouble this may cause, but we're positive
> that this change will reduce crash rates for practically all v8 embedders.
>
> Cheers,
> Michael Hablich

Can you provide guidelines on what context to use in API callbacks?  I
see that src/api.cc uses Isolate::GetCurrentContext() in a number of
places.  When would you use the current context, when
Isolate::GetCallingContext(), etc.?

-- 
-- 
v8-users mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to