Comment #3 on issue 2148 by [email protected]: Null(Isolate* isolate) crashes if we pass 0 for isolate
http://code.google.com/p/v8/issues/detail?id=2148

- I agree that V8 wants to avoid the NULL check.

- On the other hand, V8 bindings cannot avoid using an optional Isolate* argument, since the method implementation is exactly the same except for Null(Isolate*) or Null(), like this:

    Handle<Value> foo(..., Isolate* isolate = 0) {
        ...; // method implementation
        return isolate ? Null(isolate) : Null();
    }

- Since it is too dirty to write a ternary operator here and there, V8 bindings should use a macro, like this:

    #define V8_NULL(isolate) (isolate) ? (Null(isolate)) : (Null())

    Handle<Value> foo(..., Isolate* isolate = 0) {
        ...;
        return V8_NULL(isolate);
    }

- Ideally we should use the macro only for the optional Isolate*, and should use v8::Null(isolate) for the non-optional Isolate*. But It is really buggy to mix them. If someone misused v8::Null(isolate) for a NULL isolate in the future (Note: custom bindings are written by non-V8-professional folks), it causes a crash bug. Thus I think V8 bindings need to use V8_NULL(isolate) _almost_ always. "_almost_" means that V8 bindings can use v8::Null(isolate) directly for a few cases in which the performance is really critical.

- Consequently, if V8 does not implement the NULL check, V8 bindings would instead implement the macro that always does the NULL check.


So my feeling is that...

- If V8 could implement the NULL check without decreasing the performance, that would be best. (BTW, what happens if you use cmov for the NULL check? Does it still decrease performance?) - Otherwise, V8 bindings would implement the macro for the NULL check and use the macro in almost all places in V8 bindings, which would definitely decrease performance.

Any good idea?


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to