| 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 4245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4256 Value); | 4256 Value); |
| 4257 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4257 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
| 4258 auto self = Utils::OpenHandle(this); | 4258 auto self = Utils::OpenHandle(this); |
| 4259 auto recv_obj = Utils::OpenHandle(*recv); | 4259 auto recv_obj = Utils::OpenHandle(*recv); |
| 4260 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4260 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
| 4261 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4261 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
| 4262 i::Handle<i::JSFunction> fun; | 4262 i::Handle<i::JSFunction> fun; |
| 4263 if (self->IsJSFunction()) { | 4263 if (self->IsJSFunction()) { |
| 4264 fun = i::Handle<i::JSFunction>::cast(self); | 4264 fun = i::Handle<i::JSFunction>::cast(self); |
| 4265 } else { | 4265 } else { |
| 4266 i::Handle<i::Object> delegate; | 4266 has_pending_exception = |
| 4267 has_pending_exception = !i::Execution::TryGetFunctionDelegate(isolate, self) | 4267 !i::Execution::GetFunctionDelegate(isolate, self).ToHandle(&fun); |
| 4268 .ToHandle(&delegate); | |
| 4269 RETURN_ON_FAILED_EXECUTION(Value); | 4268 RETURN_ON_FAILED_EXECUTION(Value); |
| 4270 fun = i::Handle<i::JSFunction>::cast(delegate); | |
| 4271 recv_obj = self; | 4269 recv_obj = self; |
| 4272 } | 4270 } |
| 4273 Local<Value> result; | 4271 Local<Value> result; |
| 4274 has_pending_exception = | 4272 has_pending_exception = |
| 4275 !ToLocal<Value>( | 4273 !ToLocal<Value>( |
| 4276 i::Execution::Call(isolate, fun, recv_obj, argc, args, true), | 4274 i::Execution::Call(isolate, fun, recv_obj, argc, args, true), |
| 4277 &result); | 4275 &result); |
| 4278 RETURN_ON_FAILED_EXECUTION(Value); | 4276 RETURN_ON_FAILED_EXECUTION(Value); |
| 4279 RETURN_ESCAPED(result); | 4277 RETURN_ESCAPED(result); |
| 4280 } | 4278 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 4298 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4296 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
| 4299 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4297 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
| 4300 if (self->IsJSFunction()) { | 4298 if (self->IsJSFunction()) { |
| 4301 auto fun = i::Handle<i::JSFunction>::cast(self); | 4299 auto fun = i::Handle<i::JSFunction>::cast(self); |
| 4302 Local<Value> result; | 4300 Local<Value> result; |
| 4303 has_pending_exception = | 4301 has_pending_exception = |
| 4304 !ToLocal<Value>(i::Execution::New(fun, argc, args), &result); | 4302 !ToLocal<Value>(i::Execution::New(fun, argc, args), &result); |
| 4305 RETURN_ON_FAILED_EXECUTION(Value); | 4303 RETURN_ON_FAILED_EXECUTION(Value); |
| 4306 RETURN_ESCAPED(result); | 4304 RETURN_ESCAPED(result); |
| 4307 } | 4305 } |
| 4308 i::Handle<i::Object> delegate; | 4306 i::Handle<i::JSFunction> fun; |
| 4309 has_pending_exception = !i::Execution::TryGetConstructorDelegate( | 4307 has_pending_exception = |
| 4310 isolate, self).ToHandle(&delegate); | 4308 !i::Execution::GetConstructorDelegate(isolate, self).ToHandle(&fun); |
| 4311 RETURN_ON_FAILED_EXECUTION(Value); | 4309 RETURN_ON_FAILED_EXECUTION(Value); |
| 4312 if (!delegate->IsUndefined()) { | 4310 Local<Value> result; |
| 4313 auto fun = i::Handle<i::JSFunction>::cast(delegate); | 4311 has_pending_exception = !ToLocal<Value>( |
| 4314 Local<Value> result; | 4312 i::Execution::Call(isolate, fun, self, argc, args), &result); |
| 4315 has_pending_exception = | 4313 RETURN_ON_FAILED_EXECUTION(Value); |
| 4316 !ToLocal<Value>(i::Execution::Call(isolate, fun, self, argc, args), | 4314 RETURN_ESCAPED(result); |
| 4317 &result); | |
| 4318 RETURN_ON_FAILED_EXECUTION(Value); | |
| 4319 DCHECK(!delegate->IsUndefined()); | |
| 4320 RETURN_ESCAPED(result); | |
| 4321 } | |
| 4322 return MaybeLocal<Value>(); | |
| 4323 } | 4315 } |
| 4324 | 4316 |
| 4325 | 4317 |
| 4326 Local<v8::Value> Object::CallAsConstructor(int argc, | 4318 Local<v8::Value> Object::CallAsConstructor(int argc, |
| 4327 v8::Local<v8::Value> argv[]) { | 4319 v8::Local<v8::Value> argv[]) { |
| 4328 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4320 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4329 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); | 4321 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); |
| 4330 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value); | 4322 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value); |
| 4331 } | 4323 } |
| 4332 | 4324 |
| (...skipping 4075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8408 Address callback_address = | 8400 Address callback_address = |
| 8409 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8401 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8410 VMState<EXTERNAL> state(isolate); | 8402 VMState<EXTERNAL> state(isolate); |
| 8411 ExternalCallbackScope call_scope(isolate, callback_address); | 8403 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8412 callback(info); | 8404 callback(info); |
| 8413 } | 8405 } |
| 8414 | 8406 |
| 8415 | 8407 |
| 8416 } // namespace internal | 8408 } // namespace internal |
| 8417 } // namespace v8 | 8409 } // namespace v8 |
| OLD | NEW |