| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/api.h" | 5 #include "src/api.h" |
| 6 | 6 |
| 7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
| 8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
| 9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
| 10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
| (...skipping 4226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4237 MaybeLocal<Value> Object::CallAsFunction(Local<Context> context, | 4237 MaybeLocal<Value> Object::CallAsFunction(Local<Context> context, |
| 4238 Local<Value> recv, int argc, | 4238 Local<Value> recv, int argc, |
| 4239 Local<Value> argv[]) { | 4239 Local<Value> argv[]) { |
| 4240 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Object::CallAsFunction()", | 4240 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Object::CallAsFunction()", |
| 4241 Value); | 4241 Value); |
| 4242 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4242 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
| 4243 auto self = Utils::OpenHandle(this); | 4243 auto self = Utils::OpenHandle(this); |
| 4244 auto recv_obj = Utils::OpenHandle(*recv); | 4244 auto recv_obj = Utils::OpenHandle(*recv); |
| 4245 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4245 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
| 4246 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4246 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
| 4247 i::Handle<i::JSFunction> fun; | |
| 4248 if (self->IsJSFunction()) { | |
| 4249 fun = i::Handle<i::JSFunction>::cast(self); | |
| 4250 } else { | |
| 4251 has_pending_exception = | |
| 4252 !i::Execution::GetFunctionDelegate(isolate, self).ToHandle(&fun); | |
| 4253 RETURN_ON_FAILED_EXECUTION(Value); | |
| 4254 recv_obj = self; | |
| 4255 } | |
| 4256 Local<Value> result; | 4247 Local<Value> result; |
| 4257 has_pending_exception = !ToLocal<Value>( | 4248 has_pending_exception = !ToLocal<Value>( |
| 4258 i::Execution::Call(isolate, fun, recv_obj, argc, args), &result); | 4249 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); |
| 4259 RETURN_ON_FAILED_EXECUTION(Value); | 4250 RETURN_ON_FAILED_EXECUTION(Value); |
| 4260 RETURN_ESCAPED(result); | 4251 RETURN_ESCAPED(result); |
| 4261 } | 4252 } |
| 4262 | 4253 |
| 4263 | 4254 |
| 4264 Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc, | 4255 Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc, |
| 4265 v8::Local<v8::Value> argv[]) { | 4256 v8::Local<v8::Value> argv[]) { |
| 4266 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4257 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4267 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); | 4258 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); |
| 4268 RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast), | 4259 RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast), |
| 4269 Value); | 4260 Value); |
| 4270 } | 4261 } |
| 4271 | 4262 |
| 4272 | 4263 |
| 4273 MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc, | 4264 MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc, |
| 4274 Local<Value> argv[]) { | 4265 Local<Value> argv[]) { |
| 4275 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, | 4266 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, |
| 4276 "v8::Object::CallAsConstructor()", Value); | 4267 "v8::Object::CallAsConstructor()", Value); |
| 4277 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4268 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
| 4278 auto self = Utils::OpenHandle(this); | 4269 auto self = Utils::OpenHandle(this); |
| 4279 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4270 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
| 4280 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4271 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
| 4281 if (self->IsJSFunction()) { | |
| 4282 auto fun = i::Handle<i::JSFunction>::cast(self); | |
| 4283 Local<Value> result; | |
| 4284 has_pending_exception = | |
| 4285 !ToLocal<Value>(i::Execution::New(fun, argc, args), &result); | |
| 4286 RETURN_ON_FAILED_EXECUTION(Value); | |
| 4287 RETURN_ESCAPED(result); | |
| 4288 } | |
| 4289 i::Handle<i::JSFunction> fun; | |
| 4290 has_pending_exception = | |
| 4291 !i::Execution::GetConstructorDelegate(isolate, self).ToHandle(&fun); | |
| 4292 RETURN_ON_FAILED_EXECUTION(Value); | |
| 4293 Local<Value> result; | 4272 Local<Value> result; |
| 4294 has_pending_exception = !ToLocal<Value>( | 4273 has_pending_exception = !ToLocal<Value>( |
| 4295 i::Execution::Call(isolate, fun, self, argc, args), &result); | 4274 i::Execution::New(isolate, self, self, argc, args), &result); |
| 4296 RETURN_ON_FAILED_EXECUTION(Value); | 4275 RETURN_ON_FAILED_EXECUTION(Value); |
| 4297 RETURN_ESCAPED(result); | 4276 RETURN_ESCAPED(result); |
| 4298 } | 4277 } |
| 4299 | 4278 |
| 4300 | 4279 |
| 4301 Local<v8::Value> Object::CallAsConstructor(int argc, | 4280 Local<v8::Value> Object::CallAsConstructor(int argc, |
| 4302 v8::Local<v8::Value> argv[]) { | 4281 v8::Local<v8::Value> argv[]) { |
| 4303 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4282 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4304 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); | 4283 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); |
| 4305 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value); | 4284 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value); |
| (...skipping 4075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8381 Address callback_address = | 8360 Address callback_address = |
| 8382 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8361 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8383 VMState<EXTERNAL> state(isolate); | 8362 VMState<EXTERNAL> state(isolate); |
| 8384 ExternalCallbackScope call_scope(isolate, callback_address); | 8363 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8385 callback(info); | 8364 callback(info); |
| 8386 } | 8365 } |
| 8387 | 8366 |
| 8388 | 8367 |
| 8389 } // namespace internal | 8368 } // namespace internal |
| 8390 } // namespace v8 | 8369 } // namespace v8 |
| OLD | NEW |