Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Unified Diff: src/code-stub-assembler.h

Issue 2489743002: [stubs] Ensure CSA_ASSERT and CSA_SLOW_ASSERT do not produce unused instructions in release mode. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/builtins/builtins-string.cc ('k') | src/code-stub-assembler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stub-assembler.h
diff --git a/src/code-stub-assembler.h b/src/code-stub-assembler.h
index 36e7801bdd188c082a16e0a29e594835e56a8741..0ec3ce41ce9b06f461ebbf4fc7e181d650d632b4 100644
--- a/src/code-stub-assembler.h
+++ b/src/code-stub-assembler.h
@@ -161,8 +161,13 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
compiler::Node* offset);
compiler::Node* IsRegularHeapObjectSize(compiler::Node* size);
- void Assert(compiler::Node* condition, const char* string = nullptr,
+ typedef std::function<compiler::Node*()> ConditionBody;
+ void Assert(ConditionBody condition_body, const char* string = nullptr,
const char* file = nullptr, int line = 0);
+ void SlowAssert(ConditionBody condition_body, const char* string = nullptr,
+ const char* file = nullptr, int line = 0);
+ // No-op. Used by CSA_ASSERT macro.
+ inline void Nop() {}
// Check a value for smi-ness
compiler::Node* TaggedIsSmi(compiler::Node* a);
@@ -1257,14 +1262,17 @@ class CodeStubArguments {
compiler::Node* fp_;
};
-#define CSA_ASSERT(x) Assert((x), #x, __FILE__, __LINE__)
+#ifdef DEBUG
+#define CSA_ASSERT(x) Assert([&] { return (x); }, #x, __FILE__, __LINE__)
Benedikt Meurer 2016/11/09 04:52:09 Can we please, please find a less awkward syntax f
Igor Sheludko 2016/11/09 12:10:34 Ok, I can remove this lambda code.
+#else
+#define CSA_ASSERT(x) Nop()
+#endif
+
#ifdef ENABLE_SLOW_DCHECKS
-#define CSA_SLOW_ASSERT(x) \
- if (FLAG_enable_slow_asserts) { \
- Assert((x), #x, __FILE__, __LINE__); \
- }
+#define CSA_SLOW_ASSERT(x) \
+ SlowAssert([&] { return (x); }, #x, __FILE__, __LINE__)
#else
-#define CSA_SLOW_ASSERT(x)
+#define CSA_SLOW_ASSERT(x) Nop()
#endif
DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags);
« no previous file with comments | « src/builtins/builtins-string.cc ('k') | src/code-stub-assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698