 Chromium Code Reviews
 Chromium Code Reviews Issue 265293004:
  Create fewer local v8::TryCatch objects in generated bindings code  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master
    
  
    Issue 265293004:
  Create fewer local v8::TryCatch objects in generated bindings code  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master| 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 28 matching lines...) Expand all Loading... | |
| 39 | 39 | 
| 40 #define TONATIVE_EXCEPTION(type, var, value) \ | 40 #define TONATIVE_EXCEPTION(type, var, value) \ | 
| 41 type var; \ | 41 type var; \ | 
| 42 { \ | 42 { \ | 
| 43 v8::TryCatch block; \ | 43 v8::TryCatch block; \ | 
| 44 var = (value); \ | 44 var = (value); \ | 
| 45 if (UNLIKELY(block.HasCaught())) \ | 45 if (UNLIKELY(block.HasCaught())) \ | 
| 46 return block.ReThrow(); \ | 46 return block.ReThrow(); \ | 
| 47 } | 47 } | 
| 48 | 48 | 
| 49 #define TONATIVE_VOID_NO_DECL(var, value) \ | |
| 
haraken
2014/05/08 03:45:06
Nit: _NO_DECL => _INTERNAL ?
It's dangerous to al
 
Jens Widell
2014/05/08 16:38:05
Renamed.
 | |
| 50 var = (value); \ | |
| 51 if (UNLIKELY(block.HasCaught())) { \ | |
| 52 block.ReThrow(); \ | |
| 53 return; \ | |
| 54 } | |
| 55 | |
| 49 #define TONATIVE_VOID(type, var, value) \ | 56 #define TONATIVE_VOID(type, var, value) \ | 
| 50 type var; \ | 57 type var; \ | 
| 51 { \ | 58 { \ | 
| 52 v8::TryCatch block; \ | 59 v8::TryCatch block; \ | 
| 53 var = (value); \ | 60 TONATIVE_VOID_NO_DECL(var, value); \ | 
| 54 if (UNLIKELY(block.HasCaught())) { \ | |
| 55 block.ReThrow(); \ | |
| 56 return; \ | |
| 57 } \ | |
| 58 } | 61 } | 
| 59 | 62 | 
| 60 #define TONATIVE_DEFAULT(type, var, value, retVal) \ | 63 #define TONATIVE_DEFAULT(type, var, value, retVal) \ | 
| 61 type var; \ | 64 type var; \ | 
| 62 { \ | 65 { \ | 
| 63 v8::TryCatch block; \ | 66 v8::TryCatch block; \ | 
| 64 var = (value); \ | 67 var = (value); \ | 
| 65 if (UNLIKELY(block.HasCaught())) { \ | 68 if (UNLIKELY(block.HasCaught())) { \ | 
| 66 block.ReThrow(); \ | 69 block.ReThrow(); \ | 
| 67 return retVal; \ | 70 return retVal; \ | 
| 68 } \ | 71 } \ | 
| 69 } | 72 } | 
| 70 | 73 | 
| 71 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \ | 74 #define TONATIVE_VOID_EXCEPTIONSTATE_NO_DECL(var, value, exceptionState) \ | 
| 72 type var; \ | 75 var = (value); \ | 
| 73 { \ | 76 if (UNLIKELY(block.HasCaught())) \ | 
| 74 v8::TryCatch block; \ | 77 exceptionState.rethrowV8Exception(block.Exception()); \ | 
| 75 var = (value); \ | 78 if (UNLIKELY(exceptionState.throwIfNeeded())) \ | 
| 76 if (UNLIKELY(block.HasCaught())) \ | 79 return; | 
| 77 exceptionState.rethrowV8Exception(block.Exception()); \ | 80 | 
| 78 if (UNLIKELY(exceptionState.throwIfNeeded())) \ | 81 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \ | 
| 79 return; \ | 82 type var; \ | 
| 83 { \ | |
| 84 v8::TryCatch block; \ | |
| 85 TONATIVE_VOID_EXCEPTIONSTATE_NO_DECL(var, value, exceptionState); \ | |
| 80 } | 86 } | 
| 81 | 87 | 
| 82 #define TONATIVE_DEFAULT_EXCEPTIONSTATE(type, var, value, exceptionState, retVal ) \ | 88 #define TONATIVE_DEFAULT_EXCEPTIONSTATE(type, var, value, exceptionState, retVal ) \ | 
| 83 type var; \ | 89 type var; \ | 
| 84 { \ | 90 { \ | 
| 85 v8::TryCatch block; \ | 91 v8::TryCatch block; \ | 
| 86 var = (value); \ | 92 var = (value); \ | 
| 87 if (UNLIKELY(block.HasCaught())) \ | 93 if (UNLIKELY(block.HasCaught())) \ | 
| 88 exceptionState.rethrowV8Exception(block.Exception()); \ | 94 exceptionState.rethrowV8Exception(block.Exception()); \ | 
| 89 if (UNLIKELY(exceptionState.throwIfNeeded())) \ | 95 if (UNLIKELY(exceptionState.throwIfNeeded())) \ | 
| 90 return retVal; \ | 96 return retVal; \ | 
| 91 } | 97 } | 
| 92 | 98 | 
| 93 // type is an instance of class template V8StringResource<>, | 99 // type is an instance of class template V8StringResource<>, | 
| 94 // but Mode argument varies; using type (not Mode) for consistency | 100 // but Mode argument varies; using type (not Mode) for consistency | 
| 95 // with other macros and ease of code generation | 101 // with other macros and ease of code generation | 
| 96 #define TOSTRING_VOID(type, var, value) \ | 102 #define TOSTRING_VOID(type, var, value) \ | 
| 97 type var(value); \ | 103 type var(value); \ | 
| 98 if (UNLIKELY(!var.prepare())) \ | 104 if (UNLIKELY(!var.prepare())) \ | 
| 
haraken
2014/05/08 03:45:06
Can we use TOSTRING_VOID_NO_DECL here?
 
Jens Widell
2014/05/08 06:22:06
Make this
  type var;
  TOSTRING_VOID_NO_DECL(var
 | |
| 99 return; | 105 return; | 
| 100 | 106 | 
| 107 #define TOSTRING_VOID_NO_DECL(var, value) \ | |
| 108 var = value; \ | |
| 109 if (UNLIKELY(!var.prepare())) \ | |
| 110 return; | |
| 111 | |
| 101 #define TOSTRING_DEFAULT(type, var, value, retVal) \ | 112 #define TOSTRING_DEFAULT(type, var, value, retVal) \ | 
| 102 type var(value); \ | 113 type var(value); \ | 
| 103 if (UNLIKELY(!var.prepare())) \ | 114 if (UNLIKELY(!var.prepare())) \ | 
| 104 return retVal; | 115 return retVal; | 
| 105 | 116 | 
| 106 } // namespace WebCore | 117 } // namespace WebCore | 
| 107 | 118 | 
| 108 #endif // V8BindingMacros_h | 119 #endif // V8BindingMacros_h | 
| OLD | NEW |