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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8BindingMacros.h

Issue 2121663002: Add IMMEDIATE_CRASH to measure how much V8 APIs return empty MaybeLocal handles Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/V8BindingMacros.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 return retVal; 47 return retVal;
48 48
49 // Checks for a given v8::Value (value) whether it is an ArrayBufferView and 49 // Checks for a given v8::Value (value) whether it is an ArrayBufferView and
50 // below a certain size limit. If below the limit, memory is allocated on the 50 // below a certain size limit. If below the limit, memory is allocated on the
51 // stack to hold the actual payload. Keep the limit in sync with V8's 51 // stack to hold the actual payload. Keep the limit in sync with V8's
52 // typed_array_max_size. 52 // typed_array_max_size.
53 #define allocateFlexibleArrayBufferViewStorage(value) \ 53 #define allocateFlexibleArrayBufferViewStorage(value) \
54 (value->IsArrayBufferView() && (value.As<v8::ArrayBufferView>()->ByteLength( ) <= 64) ? \ 54 (value->IsArrayBufferView() && (value.As<v8::ArrayBufferView>()->ByteLength( ) <= 64) ? \
55 alloca(value.As<v8::ArrayBufferView>()->ByteLength()) : nullptr) 55 alloca(value.As<v8::ArrayBufferView>()->ByteLength()) : nullptr)
56 56
57 void emptyMaybeHandleReturned();
58
57 template <typename T> 59 template <typename T>
58 inline bool v8Call(v8::Maybe<T> maybe, T& outVariable) 60 inline bool v8Call(v8::Maybe<T> maybe, T& outVariable)
59 { 61 {
60 if (maybe.IsNothing()) 62 if (maybe.IsNothing()) {
63 emptyMaybeHandleReturned();
61 return false; 64 return false;
65 }
62 outVariable = maybe.FromJust(); 66 outVariable = maybe.FromJust();
63 return true; 67 return true;
64 } 68 }
65 69
66 inline bool v8CallBoolean(v8::Maybe<bool> maybe) 70 inline bool v8CallBoolean(v8::Maybe<bool> maybe)
67 { 71 {
68 bool result; 72 bool result;
69 return v8Call(maybe, result) && result; 73 return v8Call(maybe, result) && result;
70 } 74 }
71 75
72 template <typename T> 76 template <typename T>
73 inline bool v8Call(v8::Maybe<T> maybe, T& outVariable, v8::TryCatch& tryCatch) 77 inline bool v8Call(v8::Maybe<T> maybe, T& outVariable, v8::TryCatch& tryCatch)
74 { 78 {
75 bool success = v8Call(maybe, outVariable); 79 bool success = v8Call(maybe, outVariable);
76 ASSERT(success || tryCatch.HasCaught()); 80 ASSERT(success || tryCatch.HasCaught());
81 if (!success)
82 emptyMaybeHandleReturned();
77 return success; 83 return success;
78 } 84 }
79 85
80 template <typename T> 86 template <typename T>
81 inline bool v8Call(v8::MaybeLocal<T> maybeLocal, v8::Local<T>& outVariable) 87 inline bool v8Call(v8::MaybeLocal<T> maybeLocal, v8::Local<T>& outVariable)
82 { 88 {
83 return maybeLocal.ToLocal(&outVariable); 89 bool success = maybeLocal.ToLocal(&outVariable);
90 if (!success)
91 emptyMaybeHandleReturned();
92 return success;
84 } 93 }
85 94
86 template <typename T> 95 template <typename T>
87 inline bool v8Call(v8::MaybeLocal<T> maybeLocal, v8::Local<T>& outVariable, v8:: TryCatch& tryCatch) 96 inline bool v8Call(v8::MaybeLocal<T> maybeLocal, v8::Local<T>& outVariable, v8:: TryCatch& tryCatch)
88 { 97 {
89 bool success = maybeLocal.ToLocal(&outVariable); 98 bool success = maybeLocal.ToLocal(&outVariable);
90 ASSERT(success || tryCatch.HasCaught()); 99 ASSERT(success || tryCatch.HasCaught());
100 if (!success)
101 emptyMaybeHandleReturned();
91 return success; 102 return success;
92 } 103 }
93 104
94 template <typename T> 105 template <typename T>
95 inline T v8CallOrCrash(v8::Maybe<T> maybe) 106 inline T v8CallOrCrash(v8::Maybe<T> maybe)
96 { 107 {
97 return maybe.FromJust(); 108 return maybe.FromJust();
98 } 109 }
99 110
100 template <typename T> 111 template <typename T>
101 inline v8::Local<T> v8CallOrCrash(v8::MaybeLocal<T> maybeLocal) 112 inline v8::Local<T> v8CallOrCrash(v8::MaybeLocal<T> maybeLocal)
102 { 113 {
103 return maybeLocal.ToLocalChecked(); 114 return maybeLocal.ToLocalChecked();
104 } 115 }
105 116
106 #define V8_CALL(outVariable, handle, methodCall, failureExpression) \ 117 #define V8_CALL(outVariable, handle, methodCall, failureExpression) \
107 do { \ 118 do { \
108 if (handle.IsEmpty() || !v8Call(handle->methodCall, outVariable)) { \ 119 if (handle.IsEmpty() || !v8Call(handle->methodCall, outVariable)) { \
109 failureExpression; \ 120 failureExpression; \
110 } \ 121 } \
111 } while (0) 122 } while (0)
112 123
113 } // namespace blink 124 } // namespace blink
114 125
115 #endif // V8BindingMacros_h 126 #endif // V8BindingMacros_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/V8BindingMacros.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698