Closed
Bug 327896
Opened 20 years ago
Closed 20 years ago
JS_STATIC_ASSERT to assert during compilation
Categories
(Core :: JavaScript Engine, enhancement)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
People
(Reporter: igor, Assigned: igor)
References
Details
Attachments
(1 file, 3 obsolete files)
In few places SpiderMonkey's code use JS_ASSERT(compiler_time_constant_condition). It would be nice to replace them by truly compiler time asserts that are always on and trigger compilation errors when violated.
| Assignee | ||
Comment 1•20 years ago
|
||
The patch adds JS_COMPILER_ASSERT to jsutil.h and uses it in jsbit.h/jsgc.c. Does it compiles with Visual C without any warnings about unused typedefs?
Comment 2•20 years ago
|
||
Ah, good, your ASSERT -> ASSERT_IMPL -> ASSERT_IMPL2 trick here makes __LINE__ actually become the number. For the macro args, perhaps _condition and _line would be a bit safer?
| Assignee | ||
Comment 3•20 years ago
|
||
Extending the patch to asserts about ATOM_INDEX_LIMIT_LOG2 and JSTYPE_LIMIT
Attachment #212453 -
Attachment is obsolete: true
Attachment #212476 -
Flags: review?(brendan)
Attachment #212453 -
Flags: review?(brendan)
| Assignee | ||
Comment 4•20 years ago
|
||
This version removes changes to jsbit.h: I will add them to the patch from bug 327129.
Attachment #212476 -
Attachment is obsolete: true
Attachment #212478 -
Flags: review?(brendan)
Attachment #212476 -
Flags: review?(brendan)
| Assignee | ||
Comment 5•20 years ago
|
||
(In reply to comment #2)
> Ah, good, your ASSERT -> ASSERT_IMPL -> ASSERT_IMPL2 trick here makes __LINE__
> actually become the number. For the macro args, perhaps _condition and _line
> would be a bit safer?
I am curious why _line would be safer?
Comment 6•20 years ago
|
||
Comment on attachment 212478 [details] [diff] [review]
Implementation v3
Cool. One thought: JS_STATIC_ASSERT might be slightly clearer (JS_COMPILER could mean something to-do with the SpiderMonkey bytecode compiler).
/be
Attachment #212478 -
Flags: review?(brendan) → review+
| Assignee | ||
Comment 7•20 years ago
|
||
Attachment #212478 -
Attachment is obsolete: true
| Assignee | ||
Comment 8•20 years ago
|
||
I committed the last patch
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Summary: Compiler-time asserts → JS_STATIC_ASSERT to assert during compilation
Updated•20 years ago
|
Flags: testcase-
Comment 9•19 years ago
|
||
A static assertion macro based on this one is being added to NSPR in bug 375985 :)
Comment 10•19 years ago
|
||
This caused bug 381236.
You need to log in
before you can comment on or make changes to this bug.
Description
•