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

Side by Side Diff: src/arguments.cc

Issue 17059005: Make sure ExternalCallbackScope is always created when VM state changes to EXTERNAL (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/builtins.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 #include "arguments.h" 29 #include "arguments.h"
30 30
31 #include "vm-state-inl.h"
32
31 namespace v8 { 33 namespace v8 {
32 namespace internal { 34 namespace internal {
33 35
34 36
35 static bool Match(void* a, void* b) { 37 static bool Match(void* a, void* b) {
36 return a == b; 38 return a == b;
37 } 39 }
38 40
39 41
40 static uint32_t Hash(void* function) { 42 static uint32_t Hash(void* function) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // Nothing was set, return empty handle as per previous behaviour. 85 // Nothing was set, return empty handle as per previous behaviour.
84 if ((*handle)->IsTheHole()) return v8::Handle<V>(); 86 if ((*handle)->IsTheHole()) return v8::Handle<V>();
85 return Utils::Convert<Object, V>(Handle<Object>(handle)); 87 return Utils::Convert<Object, V>(Handle<Object>(handle));
86 } 88 }
87 89
88 90
89 v8::Handle<v8::Value> FunctionCallbackArguments::Call(InvocationCallback f) { 91 v8::Handle<v8::Value> FunctionCallbackArguments::Call(InvocationCallback f) {
90 Isolate* isolate = this->isolate(); 92 Isolate* isolate = this->isolate();
91 void* f_as_void = CallbackTable::FunctionToVoidPtr(f); 93 void* f_as_void = CallbackTable::FunctionToVoidPtr(f);
92 bool new_style = CallbackTable::ReturnsVoid(isolate, f_as_void); 94 bool new_style = CallbackTable::ReturnsVoid(isolate, f_as_void);
95 VMState<EXTERNAL> state(isolate);
96 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
93 if (new_style) { 97 if (new_style) {
94 FunctionCallback c = reinterpret_cast<FunctionCallback>(f); 98 FunctionCallback c = reinterpret_cast<FunctionCallback>(f);
95 FunctionCallbackInfo<v8::Value> info(end(), 99 FunctionCallbackInfo<v8::Value> info(end(),
96 argv_, 100 argv_,
97 argc_, 101 argc_,
98 is_construct_call_); 102 is_construct_call_);
99 c(info); 103 c(info);
100 } else { 104 } else {
101 v8::Arguments args(end(), 105 v8::Arguments args(end(),
102 argv_, 106 argv_,
103 argc_, 107 argc_,
104 is_construct_call_); 108 is_construct_call_);
105 v8::Handle<v8::Value> return_value = f(args); 109 v8::Handle<v8::Value> return_value = f(args);
106 if (!return_value.IsEmpty()) return return_value; 110 if (!return_value.IsEmpty()) return return_value;
107 } 111 }
108 return GetReturnValue<v8::Value>(isolate); 112 return GetReturnValue<v8::Value>(isolate);
109 } 113 }
110 114
111 115
112 #define WRITE_CALL_0(OldFunction, NewFunction, ReturnValue) \ 116 #define WRITE_CALL_0(OldFunction, NewFunction, ReturnValue) \
113 v8::Handle<ReturnValue> PropertyCallbackArguments::Call(OldFunction f) { \ 117 v8::Handle<ReturnValue> PropertyCallbackArguments::Call(OldFunction f) { \
114 Isolate* isolate = this->isolate(); \ 118 Isolate* isolate = this->isolate(); \
115 void* f_as_void = CallbackTable::FunctionToVoidPtr(f); \ 119 void* f_as_void = CallbackTable::FunctionToVoidPtr(f); \
116 bool new_style = CallbackTable::ReturnsVoid(isolate, f_as_void); \ 120 bool new_style = CallbackTable::ReturnsVoid(isolate, f_as_void); \
121 VMState<EXTERNAL> state(isolate); \
122 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
117 if (new_style) { \ 123 if (new_style) { \
118 NewFunction c = reinterpret_cast<NewFunction>(f); \ 124 NewFunction c = reinterpret_cast<NewFunction>(f); \
119 PropertyCallbackInfo<ReturnValue> info(end()); \ 125 PropertyCallbackInfo<ReturnValue> info(end()); \
120 c(info); \ 126 c(info); \
121 } else { \ 127 } else { \
122 v8::AccessorInfo info(end()); \ 128 v8::AccessorInfo info(end()); \
123 v8::Handle<ReturnValue> return_value = f(info); \ 129 v8::Handle<ReturnValue> return_value = f(info); \
124 if (!return_value.IsEmpty()) return return_value; \ 130 if (!return_value.IsEmpty()) return return_value; \
125 } \ 131 } \
126 return GetReturnValue<ReturnValue>(isolate); \ 132 return GetReturnValue<ReturnValue>(isolate); \
127 } 133 }
128 134
129 #define WRITE_CALL_1(OldFunction, NewFunction, ReturnValue, Arg1) \ 135 #define WRITE_CALL_1(OldFunction, NewFunction, ReturnValue, Arg1) \
130 v8::Handle<ReturnValue> PropertyCallbackArguments::Call(OldFunction f, \ 136 v8::Handle<ReturnValue> PropertyCallbackArguments::Call(OldFunction f, \
131 Arg1 arg1) { \ 137 Arg1 arg1) { \
132 Isolate* isolate = this->isolate(); \ 138 Isolate* isolate = this->isolate(); \
133 void* f_as_void = CallbackTable::FunctionToVoidPtr(f); \ 139 void* f_as_void = CallbackTable::FunctionToVoidPtr(f); \
134 bool new_style = CallbackTable::ReturnsVoid(isolate, f_as_void); \ 140 bool new_style = CallbackTable::ReturnsVoid(isolate, f_as_void); \
141 VMState<EXTERNAL> state(isolate); \
142 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
135 if (new_style) { \ 143 if (new_style) { \
136 NewFunction c = reinterpret_cast<NewFunction>(f); \ 144 NewFunction c = reinterpret_cast<NewFunction>(f); \
137 PropertyCallbackInfo<ReturnValue> info(end()); \ 145 PropertyCallbackInfo<ReturnValue> info(end()); \
138 c(arg1, info); \ 146 c(arg1, info); \
139 } else { \ 147 } else { \
140 v8::AccessorInfo info(end()); \ 148 v8::AccessorInfo info(end()); \
141 v8::Handle<ReturnValue> return_value = f(arg1, info); \ 149 v8::Handle<ReturnValue> return_value = f(arg1, info); \
142 if (!return_value.IsEmpty()) return return_value; \ 150 if (!return_value.IsEmpty()) return return_value; \
143 } \ 151 } \
144 return GetReturnValue<ReturnValue>(isolate); \ 152 return GetReturnValue<ReturnValue>(isolate); \
145 } 153 }
146 154
147 #define WRITE_CALL_2(OldFunction, NewFunction, ReturnValue, Arg1, Arg2) \ 155 #define WRITE_CALL_2(OldFunction, NewFunction, ReturnValue, Arg1, Arg2) \
148 v8::Handle<ReturnValue> PropertyCallbackArguments::Call(OldFunction f, \ 156 v8::Handle<ReturnValue> PropertyCallbackArguments::Call(OldFunction f, \
149 Arg1 arg1, \ 157 Arg1 arg1, \
150 Arg2 arg2) { \ 158 Arg2 arg2) { \
151 Isolate* isolate = this->isolate(); \ 159 Isolate* isolate = this->isolate(); \
152 void* f_as_void = CallbackTable::FunctionToVoidPtr(f); \ 160 void* f_as_void = CallbackTable::FunctionToVoidPtr(f); \
153 bool new_style = CallbackTable::ReturnsVoid(isolate, f_as_void); \ 161 bool new_style = CallbackTable::ReturnsVoid(isolate, f_as_void); \
162 VMState<EXTERNAL> state(isolate); \
163 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
154 if (new_style) { \ 164 if (new_style) { \
155 NewFunction c = reinterpret_cast<NewFunction>(f); \ 165 NewFunction c = reinterpret_cast<NewFunction>(f); \
156 PropertyCallbackInfo<ReturnValue> info(end()); \ 166 PropertyCallbackInfo<ReturnValue> info(end()); \
157 c(arg1, arg2, info); \ 167 c(arg1, arg2, info); \
158 } else { \ 168 } else { \
159 v8::AccessorInfo info(end()); \ 169 v8::AccessorInfo info(end()); \
160 v8::Handle<ReturnValue> return_value = f(arg1, arg2, info); \ 170 v8::Handle<ReturnValue> return_value = f(arg1, arg2, info); \
161 if (!return_value.IsEmpty()) return return_value; \ 171 if (!return_value.IsEmpty()) return return_value; \
162 } \ 172 } \
163 return GetReturnValue<ReturnValue>(isolate); \ 173 return GetReturnValue<ReturnValue>(isolate); \
164 } 174 }
165 175
166 #define WRITE_CALL_2_VOID(OldFunction, NewFunction, ReturnValue, Arg1, Arg2) \ 176 #define WRITE_CALL_2_VOID(OldFunction, NewFunction, ReturnValue, Arg1, Arg2) \
167 void PropertyCallbackArguments::Call(OldFunction f, \ 177 void PropertyCallbackArguments::Call(OldFunction f, \
168 Arg1 arg1, \ 178 Arg1 arg1, \
169 Arg2 arg2) { \ 179 Arg2 arg2) { \
170 Isolate* isolate = this->isolate(); \ 180 Isolate* isolate = this->isolate(); \
171 void* f_as_void = CallbackTable::FunctionToVoidPtr(f); \ 181 void* f_as_void = CallbackTable::FunctionToVoidPtr(f); \
172 bool new_style = CallbackTable::ReturnsVoid(isolate, f_as_void); \ 182 bool new_style = CallbackTable::ReturnsVoid(isolate, f_as_void); \
183 VMState<EXTERNAL> state(isolate); \
184 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
173 if (new_style) { \ 185 if (new_style) { \
174 NewFunction c = reinterpret_cast<NewFunction>(f); \ 186 NewFunction c = reinterpret_cast<NewFunction>(f); \
175 PropertyCallbackInfo<ReturnValue> info(end()); \ 187 PropertyCallbackInfo<ReturnValue> info(end()); \
176 c(arg1, arg2, info); \ 188 c(arg1, arg2, info); \
177 } else { \ 189 } else { \
178 v8::AccessorInfo info(end()); \ 190 v8::AccessorInfo info(end()); \
179 f(arg1, arg2, info); \ 191 f(arg1, arg2, info); \
180 } \ 192 } \
181 } 193 }
182 194
183 FOR_EACH_CALLBACK_TABLE_MAPPING_0(WRITE_CALL_0) 195 FOR_EACH_CALLBACK_TABLE_MAPPING_0(WRITE_CALL_0)
184 FOR_EACH_CALLBACK_TABLE_MAPPING_1(WRITE_CALL_1) 196 FOR_EACH_CALLBACK_TABLE_MAPPING_1(WRITE_CALL_1)
185 FOR_EACH_CALLBACK_TABLE_MAPPING_2(WRITE_CALL_2) 197 FOR_EACH_CALLBACK_TABLE_MAPPING_2(WRITE_CALL_2)
186 FOR_EACH_CALLBACK_TABLE_MAPPING_2_VOID_RETURN(WRITE_CALL_2_VOID) 198 FOR_EACH_CALLBACK_TABLE_MAPPING_2_VOID_RETURN(WRITE_CALL_2_VOID)
187 199
188 #undef WRITE_CALL_0 200 #undef WRITE_CALL_0
189 #undef WRITE_CALL_1 201 #undef WRITE_CALL_1
190 #undef WRITE_CALL_2 202 #undef WRITE_CALL_2
191 #undef WRITE_CALL_2_VOID 203 #undef WRITE_CALL_2_VOID
192 204
193 205
194 } } // namespace v8::internal 206 } } // namespace v8::internal
195 207
OLDNEW
« no previous file with comments | « no previous file | src/builtins.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698