|Summary:||Add jsCast to replace static_cast|
|Product:||WebKit||Reporter:||Mark Hahnenberg <mhahnenberg>|
|Severity:||Normal||CC:||abarth, barraclough, ggaren, japhet, oliver, webkit.review.bot|
|Version:||528+ (Nightly build)|
Description Mark Hahnenberg 2011-11-10 16:00:59 PST
We do a lot of downcasts in JSC, especially now that we've done away with virtual methods in favor of static ones that take a generic first argument (e.g. JSCell) and then downcast to type the function expects. We currently don't do any checking to make sure that the object is indeed of the type expected. In order to remedy this, we should add a new custom cast that ASSERTs we have the correct object, then performs the cast and returns the result. jsCast will behave like a static_cast when performance matters and a dynamic_cast using our own custom RTTI in our debug builds.
Comment 2 Geoffrey Garen 2011-11-10 22:15:57 PST
Comment 3 Gavin Barraclough 2011-11-11 09:14:15 PST
(In reply to comment #0) > jsCast will behave like a static_cast when performance matters and a dynamic_cast using our own custom RTTI in our debug builds. Presumably you mean we'll ASSERT in debug builds? - I wouldn't make sense to change behavior in debug/ndebug - that would just mask bugs.
Comment 4 Mark Hahnenberg 2011-11-11 09:40:46 PST
> Presumably you mean we'll ASSERT in debug builds? - I wouldn't make sense to change behavior in debug/ndebug - that would just mask bugs. Right. Since we're using an ASSERT, it will actually perform the check at runtime that the object is of the correct type in debug builds. Sorry about comparing to dynamic_cast, I just meant that we check dynamically. It won't return null or any of that stuff.