• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_CHECKS_H_
6 #define V8_CHECKS_H_
7 
8 #include "src/base/logging.h"
9 
10 #ifdef DEBUG
11 #ifndef OPTIMIZED_DEBUG
12 #define ENABLE_SLOW_DCHECKS    1
13 #endif
14 #endif
15 
16 namespace v8 {
17 
18 class Value;
19 template <class T> class Handle;
20 
21 namespace internal {
22 
23 intptr_t HeapObjectTagMask();
24 
25 #ifdef ENABLE_SLOW_DCHECKS
26 #define SLOW_DCHECK(condition) \
27   CHECK(!v8::internal::FLAG_enable_slow_asserts || (condition))
28 extern bool FLAG_enable_slow_asserts;
29 #else
30 #define SLOW_DCHECK(condition) ((void) 0)
31 const bool FLAG_enable_slow_asserts = false;
32 #endif
33 
34 } }  // namespace v8::internal
35 
36 
37 void CheckNonEqualsHelper(const char* file, int line,
38                           const char* expected_source, double expected,
39                           const char* value_source, double value);
40 
41 void CheckEqualsHelper(const char* file, int line, const char* expected_source,
42                        double expected, const char* value_source, double value);
43 
44 void CheckNonEqualsHelper(const char* file, int line,
45                           const char* unexpected_source,
46                           v8::Handle<v8::Value> unexpected,
47                           const char* value_source,
48                           v8::Handle<v8::Value> value);
49 
50 void CheckEqualsHelper(const char* file,
51                        int line,
52                        const char* expected_source,
53                        v8::Handle<v8::Value> expected,
54                        const char* value_source,
55                        v8::Handle<v8::Value> value);
56 
57 #define DCHECK_TAG_ALIGNED(address) \
58   DCHECK((reinterpret_cast<intptr_t>(address) & HeapObjectTagMask()) == 0)
59 
60 #define DCHECK_SIZE_TAG_ALIGNED(size) DCHECK((size & HeapObjectTagMask()) == 0)
61 
62 #endif  // V8_CHECKS_H_
63