On V8, cathing exception from safe cast makes Javascript exec slower

47 views
Skip to first unread message

vroad

unread,
Feb 23, 2015, 8:09:48 PM2/23/15
to haxe...@googlegroups.com
Haxe's document says that catching exception thrown by safe cast is better than checking the type with Std.is, but that's not true on V8 JavaScript engine.

V8 JavaScript engine cannot optimize functions containing try-catch block. If you are sure that the function you wrote will be called frequently, you should not use try-catch in that function.

This seems to be V8-specific, but should this be stated in official document?

https://code.google.com/p/v8/issues/detail?id=1065
http://haxe.org/manual/expression-cast-safe.html

Simon Krajewski

unread,
Feb 24, 2015, 2:10:14 AM2/24/15
to haxe...@googlegroups.com
Am 24.02.2015 um 02:09 schrieb vroad:
> Haxe's document says that catching exception thrown by safe cast is better than checking the type with Std.is

No it doesn't. It only tells you to not use safe casts _and_ check
Std.is because that's outright redundant.

Simon

vroad

unread,
Feb 24, 2015, 9:25:32 AM2/24/15
to haxe...@googlegroups.com
I see, then I could use Std.is + unsafe cast instead of catching exceptions.

2015年2月24日火曜日 16時10分14秒 UTC+9 Simon Krajewski:
Reply all
Reply to author
Forward
0 new messages