Chromium Code Reviews| Index: include/v8.h |
| diff --git a/include/v8.h b/include/v8.h |
| index c85e71a3a2ed756cae1f39718ce57ac37e49f0db..bbef15ef707a145aad3df5cd37cda50e8365c6d4 100644 |
| --- a/include/v8.h |
| +++ b/include/v8.h |
| @@ -92,6 +92,19 @@ |
| #define V8_DEPRECATED(declarator) declarator |
| #endif |
| +#ifdef __GNUC__ |
|
Sven Panne
2013/04/26 07:09:28
An undefined preprocessor symbol evaluates to 0 by
|
| + #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) |
| + #define V8_UNLIKELY(x) __builtin_expect(!!(x), 0) |
|
Sven Panne
2013/04/26 07:09:28
According to http://gcc.gnu.org/onlinedocs/gcc/Oth
|
| + #define V8_LIKELY(x) __builtin_expect(!!(x), 1) |
| + #else |
| + #define V8_UNLIKELY(x) (x) |
| + #define V8_LIKELY(x) (x) |
| + #endif |
| +#else |
| + #define V8_UNLIKELY(x) (x) |
| + #define V8_LIKELY(x) (x) |
| +#endif |
| + |
| /** |
| * The v8 JavaScript engine. |
| */ |
| @@ -4879,7 +4892,7 @@ void* Object::GetAlignedPointerFromInternalField(int index) { |
| O* obj = *reinterpret_cast<O**>(this); |
| // Fast path: If the object is a plain JSObject, which is the common case, we |
| // know where to find the internal fields and can return the value directly. |
| - if (I::GetInstanceType(obj) == I::kJSObjectType) { |
| + if (V8_LIKELY(I::GetInstanceType(obj) == I::kJSObjectType)) { |
| int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); |
| return I::ReadField<void*>(obj, offset); |
| } |