OLD | NEW |
---|---|
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 type var; \ | 63 type var; \ |
64 { \ | 64 { \ |
65 v8::TryCatch block; \ | 65 v8::TryCatch block; \ |
66 var = (value); \ | 66 var = (value); \ |
67 if (UNLIKELY(block.HasCaught())) { \ | 67 if (UNLIKELY(block.HasCaught())) { \ |
68 block.ReThrow(); \ | 68 block.ReThrow(); \ |
69 return retVal; \ | 69 return retVal; \ |
70 } \ | 70 } \ |
71 } | 71 } |
72 | 72 |
73 #define TONATIVE_VOID_ASYNC_INTERNAL(var, value, info) \ | |
74 var = (value); \ | |
75 if (UNLIKELY(block.HasCaught())) { \ | |
76 v8SetReturnValue(info, ScriptPromise::rejectRaw(info.GetIsolate(), block .Exception())); \ | |
77 rethrow.cancel(); \ | |
Jens Widell
2014/07/30 10:29:10
Would it work to do block.Reset() here instead? I
yhirano
2014/07/31 03:03:25
Sadly, No.
When an exception is thrown and is caug
Jens Widell
2014/07/31 08:29:09
That is unfortunate, and sounds like a bug in TryC
yhirano
2014/08/06 05:48:47
I've just created a V8 patch. https://codereview.c
yhirano
2014/08/11 06:29:35
Done.
| |
78 return; \ | |
79 } | |
80 | |
81 #define TONATIVE_VOID_ASYNC(type, var, value, info) \ | |
82 type var; \ | |
83 { \ | |
84 v8::TryCatch block; \ | |
85 V8RethrowTryCatchScope rethrow(block); \ | |
Jens Widell
2014/07/30 10:29:10
Additionally, if we skip rethrow.cancel(), we coul
yhirano
2014/07/31 03:03:25
I think we can't skip rethrow.cancel() at present.
yhirano
2014/08/11 06:29:35
Done.
| |
86 TONATIVE_VOID_ASYNC_INTERNAL(var, value, info); \ | |
87 } | |
88 | |
89 | |
73 #define TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState) \ | 90 #define TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState) \ |
74 var = (value); \ | 91 var = (value); \ |
75 if (UNLIKELY(block.HasCaught() || exceptionState.throwIfNeeded())) \ | 92 if (UNLIKELY(block.HasCaught() || exceptionState.throwIfNeeded())) \ |
76 return; \ | 93 return; \ |
77 | 94 |
78 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \ | 95 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \ |
79 type var; \ | 96 type var; \ |
80 { \ | 97 { \ |
81 v8::TryCatch block; \ | 98 v8::TryCatch block; \ |
82 V8RethrowTryCatchScope rethrow(block); \ | 99 V8RethrowTryCatchScope rethrow(block); \ |
83 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState); \ | 100 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState); \ |
84 } | 101 } |
85 | 102 |
86 #define TONATIVE_DEFAULT_EXCEPTIONSTATE(type, var, value, exceptionState, retVal ) \ | 103 #define TONATIVE_DEFAULT_EXCEPTIONSTATE(type, var, value, exceptionState, retVal ) \ |
87 type var; \ | 104 type var; \ |
88 { \ | 105 { \ |
89 v8::TryCatch block; \ | 106 v8::TryCatch block; \ |
90 V8RethrowTryCatchScope rethrow(block); \ | 107 V8RethrowTryCatchScope rethrow(block); \ |
91 var = (value); \ | 108 var = (value); \ |
92 if (UNLIKELY(block.HasCaught() || exceptionState.throwIfNeeded())) \ | 109 if (UNLIKELY(block.HasCaught() || exceptionState.throwIfNeeded())) \ |
93 return retVal; \ | 110 return retVal; \ |
94 } | 111 } |
95 | 112 |
113 #define TONATIVE_VOID_EXCEPTIONSTATE_ASYNC_INTERNAL(scriptState, var, value, exc eptionState, info) \ | |
114 var = (value); \ | |
115 if (UNLIKELY(block.HasCaught())) { \ | |
116 v8SetReturnValue(info, ScriptPromise::rejectRaw(info.GetIsolate(), block .Exception())); \ | |
117 rethrow.cancel(); \ | |
118 return; \ | |
119 } \ | |
120 if (UNLIKELY(exceptionState.hadException())) { \ | |
121 v8SetReturnValue(info, exceptionState.reject(scriptState).v8Value()); \ | |
122 return; \ | |
123 } | |
124 | |
125 #define TONATIVE_VOID_EXCEPTIONSTATE_ASYNC(scriptState, type, var, value, except ionState, info) \ | |
126 type var; \ | |
127 { \ | |
128 v8::TryCatch block; \ | |
129 V8RethrowTryCatchScope rethrow(block); \ | |
130 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(scriptState, var, value, exception State, info); \ | |
131 } | |
132 | |
96 // type is an instance of class template V8StringResource<>, | 133 // type is an instance of class template V8StringResource<>, |
97 // but Mode argument varies; using type (not Mode) for consistency | 134 // but Mode argument varies; using type (not Mode) for consistency |
98 // with other macros and ease of code generation | 135 // with other macros and ease of code generation |
99 #define TOSTRING_VOID(type, var, value) \ | 136 #define TOSTRING_VOID(type, var, value) \ |
100 type var(value); \ | 137 type var(value); \ |
101 if (UNLIKELY(!var.prepare())) \ | 138 if (UNLIKELY(!var.prepare())) \ |
102 return; | 139 return; |
103 | 140 |
104 #define TOSTRING_VOID_INTERNAL(var, value) \ | 141 #define TOSTRING_VOID_INTERNAL(var, value) \ |
105 var = (value); \ | 142 var = (value); \ |
106 if (UNLIKELY(!var.prepare())) \ | 143 if (UNLIKELY(!var.prepare())) \ |
107 return; | 144 return; |
108 | 145 |
109 #define TOSTRING_DEFAULT(type, var, value, retVal) \ | 146 #define TOSTRING_DEFAULT(type, var, value, retVal) \ |
110 type var(value); \ | 147 type var(value); \ |
111 if (UNLIKELY(!var.prepare())) \ | 148 if (UNLIKELY(!var.prepare())) \ |
112 return retVal; | 149 return retVal; |
113 | 150 |
151 #define TOSTRING_VOID_ASYNC_INTERNAL(var, value, info) \ | |
152 var = (value); \ | |
153 if (UNLIKELY(!var.prepare())) { \ | |
154 rethrow.cancel(); \ | |
155 info.GetReturnValue().Set(ScriptPromise::rejectRaw(info.GetIsolate(), bl ock.Exception())); \ | |
156 return; \ | |
157 } | |
158 | |
159 #define TOSTRING_VOID_ASYNC(type, var, value, info) \ | |
160 type var; \ | |
161 { \ | |
162 v8::TryCatch block; \ | |
163 V8RethrowTryCatchScope rethrow(block); \ | |
164 TOSTRING_VOID_ASYNC_INTERNAL(type, var, value, info); \ | |
165 } | |
166 | |
114 } // namespace blink | 167 } // namespace blink |
115 | 168 |
116 #endif // V8BindingMacros_h | 169 #endif // V8BindingMacros_h |
OLD | NEW |