New issue
Advanced search Search tips

Issue 662542 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Feature



Sign in to add a comment

Add v8.ASSERT() for v8 extras

Project Member Reported by ricea@chromium.org, Nov 4 2016

Issue description

It would be nice if V8 Extras could use a v8.ASSERT() function which would work in debug builds but be compiled out of optimised builds. Or it could just be a no-op in optimised builds, which would still be useful for many cheap checks.

I am thinking of a syntax like

v8.ASSERT(condition, message)

which would do nothing if |condition| was true. If |condition| was false, it would print
`Assertion failed: ${message}`, then a stack trace, and abort hard enough to cause a layout test to fail (crashing the process would fulfill this requirement).

Example:

v8.ASSERT(new Date() > 0, 'Javascript has been invented');
 
I am now thinking a preprocessor step in the build process might be the right way to do this. For example, lines prefixed with /* DEBUG-ONLY */ get removed in Release mode. It should be a pretty simple Python script, assuming we can run Python scripts during build.

Comment 2 by ricea@chromium.org, Aug 2 2017

I've actually been considering running the files through the C preprocessor. Javascript syntax is close enough to C that it can remove whole function calls.

Sign in to add a comment