| 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 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1776 i::Object* url = i::Script::cast(obj->script())->source_mapping_url(); | 1776 i::Object* url = i::Script::cast(obj->script())->source_mapping_url(); |
| 1777 return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); | 1777 return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); |
| 1778 } else { | 1778 } else { |
| 1779 return Local<String>(); | 1779 return Local<String>(); |
| 1780 } | 1780 } |
| 1781 } | 1781 } |
| 1782 | 1782 |
| 1783 | 1783 |
| 1784 MaybeLocal<Value> Script::Run(Local<Context> context) { | 1784 MaybeLocal<Value> Script::Run(Local<Context> context) { |
| 1785 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Script::Run()", Value) | 1785 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Script::Run()", Value) |
| 1786 i::HistogramTimerScope execute_timer(isolate->counters()->execute()); |
| 1786 i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy()); | 1787 i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy()); |
| 1787 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 1788 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
| 1788 TRACE_EVENT0("v8", "V8.Execute"); | 1789 TRACE_EVENT0("v8", "V8.Execute"); |
| 1789 auto fun = i::Handle<i::JSFunction>::cast(Utils::OpenHandle(this)); | 1790 auto fun = i::Handle<i::JSFunction>::cast(Utils::OpenHandle(this)); |
| 1790 i::Handle<i::Object> receiver = isolate->global_proxy(); | 1791 i::Handle<i::Object> receiver = isolate->global_proxy(); |
| 1791 Local<Value> result; | 1792 Local<Value> result; |
| 1792 has_pending_exception = | 1793 has_pending_exception = |
| 1793 !ToLocal<Value>(i::Execution::Call(isolate, fun, receiver, 0, NULL), | 1794 !ToLocal<Value>(i::Execution::Call(isolate, fun, receiver, 0, NULL), |
| 1794 &result); | 1795 &result); |
| 1795 RETURN_ON_FAILED_EXECUTION(Value); | 1796 RETURN_ON_FAILED_EXECUTION(Value); |
| (...skipping 2570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4366 bool v8::Object::IsConstructor() { | 4367 bool v8::Object::IsConstructor() { |
| 4367 auto self = Utils::OpenHandle(this); | 4368 auto self = Utils::OpenHandle(this); |
| 4368 return self->IsConstructor(); | 4369 return self->IsConstructor(); |
| 4369 } | 4370 } |
| 4370 | 4371 |
| 4371 MaybeLocal<Value> Object::CallAsFunction(Local<Context> context, | 4372 MaybeLocal<Value> Object::CallAsFunction(Local<Context> context, |
| 4372 Local<Value> recv, int argc, | 4373 Local<Value> recv, int argc, |
| 4373 Local<Value> argv[]) { | 4374 Local<Value> argv[]) { |
| 4374 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Object::CallAsFunction()", | 4375 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Object::CallAsFunction()", |
| 4375 Value); | 4376 Value); |
| 4377 i::HistogramTimerScope execute_timer(isolate->counters()->execute()); |
| 4376 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4378 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
| 4377 TRACE_EVENT0("v8", "V8.Execute"); | 4379 TRACE_EVENT0("v8", "V8.Execute"); |
| 4378 auto self = Utils::OpenHandle(this); | 4380 auto self = Utils::OpenHandle(this); |
| 4379 auto recv_obj = Utils::OpenHandle(*recv); | 4381 auto recv_obj = Utils::OpenHandle(*recv); |
| 4380 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4382 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
| 4381 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4383 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
| 4382 Local<Value> result; | 4384 Local<Value> result; |
| 4383 has_pending_exception = !ToLocal<Value>( | 4385 has_pending_exception = !ToLocal<Value>( |
| 4384 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); | 4386 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); |
| 4385 RETURN_ON_FAILED_EXECUTION(Value); | 4387 RETURN_ON_FAILED_EXECUTION(Value); |
| 4386 RETURN_ESCAPED(result); | 4388 RETURN_ESCAPED(result); |
| 4387 } | 4389 } |
| 4388 | 4390 |
| 4389 | 4391 |
| 4390 Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc, | 4392 Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc, |
| 4391 v8::Local<v8::Value> argv[]) { | 4393 v8::Local<v8::Value> argv[]) { |
| 4392 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4394 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4393 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); | 4395 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); |
| 4394 RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast), | 4396 RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast), |
| 4395 Value); | 4397 Value); |
| 4396 } | 4398 } |
| 4397 | 4399 |
| 4398 | 4400 |
| 4399 MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc, | 4401 MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc, |
| 4400 Local<Value> argv[]) { | 4402 Local<Value> argv[]) { |
| 4401 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, | 4403 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, |
| 4402 "v8::Object::CallAsConstructor()", Value); | 4404 "v8::Object::CallAsConstructor()", Value); |
| 4405 i::HistogramTimerScope execute_timer(isolate->counters()->execute()); |
| 4403 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4406 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
| 4404 TRACE_EVENT0("v8", "V8.Execute"); | 4407 TRACE_EVENT0("v8", "V8.Execute"); |
| 4405 auto self = Utils::OpenHandle(this); | 4408 auto self = Utils::OpenHandle(this); |
| 4406 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4409 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
| 4407 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4410 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
| 4408 Local<Value> result; | 4411 Local<Value> result; |
| 4409 has_pending_exception = !ToLocal<Value>( | 4412 has_pending_exception = !ToLocal<Value>( |
| 4410 i::Execution::New(isolate, self, self, argc, args), &result); | 4413 i::Execution::New(isolate, self, self, argc, args), &result); |
| 4411 RETURN_ON_FAILED_EXECUTION(Value); | 4414 RETURN_ON_FAILED_EXECUTION(Value); |
| 4412 RETURN_ESCAPED(result); | 4415 RETURN_ESCAPED(result); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 4443 Local<v8::Object> Function::NewInstance() const { | 4446 Local<v8::Object> Function::NewInstance() const { |
| 4444 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL) | 4447 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL) |
| 4445 .FromMaybe(Local<Object>()); | 4448 .FromMaybe(Local<Object>()); |
| 4446 } | 4449 } |
| 4447 | 4450 |
| 4448 | 4451 |
| 4449 MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc, | 4452 MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc, |
| 4450 v8::Local<v8::Value> argv[]) const { | 4453 v8::Local<v8::Value> argv[]) const { |
| 4451 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Function::NewInstance()", | 4454 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Function::NewInstance()", |
| 4452 Object); | 4455 Object); |
| 4456 i::HistogramTimerScope execute_timer(isolate->counters()->execute()); |
| 4453 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4457 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
| 4454 TRACE_EVENT0("v8", "V8.Execute"); | 4458 TRACE_EVENT0("v8", "V8.Execute"); |
| 4455 auto self = Utils::OpenHandle(this); | 4459 auto self = Utils::OpenHandle(this); |
| 4456 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4460 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
| 4457 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4461 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
| 4458 Local<Object> result; | 4462 Local<Object> result; |
| 4459 has_pending_exception = !ToLocal<Object>( | 4463 has_pending_exception = !ToLocal<Object>( |
| 4460 i::Execution::New(isolate, self, self, argc, args), &result); | 4464 i::Execution::New(isolate, self, self, argc, args), &result); |
| 4461 RETURN_ON_FAILED_EXECUTION(Object); | 4465 RETURN_ON_FAILED_EXECUTION(Object); |
| 4462 RETURN_ESCAPED(result); | 4466 RETURN_ESCAPED(result); |
| 4463 } | 4467 } |
| 4464 | 4468 |
| 4465 | 4469 |
| 4466 Local<v8::Object> Function::NewInstance(int argc, | 4470 Local<v8::Object> Function::NewInstance(int argc, |
| 4467 v8::Local<v8::Value> argv[]) const { | 4471 v8::Local<v8::Value> argv[]) const { |
| 4468 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4472 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4469 RETURN_TO_LOCAL_UNCHECKED(NewInstance(context, argc, argv), Object); | 4473 RETURN_TO_LOCAL_UNCHECKED(NewInstance(context, argc, argv), Object); |
| 4470 } | 4474 } |
| 4471 | 4475 |
| 4472 | 4476 |
| 4473 MaybeLocal<v8::Value> Function::Call(Local<Context> context, | 4477 MaybeLocal<v8::Value> Function::Call(Local<Context> context, |
| 4474 v8::Local<v8::Value> recv, int argc, | 4478 v8::Local<v8::Value> recv, int argc, |
| 4475 v8::Local<v8::Value> argv[]) { | 4479 v8::Local<v8::Value> argv[]) { |
| 4476 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Function::Call()", Value); | 4480 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Function::Call()", Value); |
| 4481 i::HistogramTimerScope execute_timer(isolate->counters()->execute()); |
| 4477 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4482 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
| 4478 TRACE_EVENT0("v8", "V8.Execute"); | 4483 TRACE_EVENT0("v8", "V8.Execute"); |
| 4479 auto self = Utils::OpenHandle(this); | 4484 auto self = Utils::OpenHandle(this); |
| 4480 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); | 4485 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); |
| 4481 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4486 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
| 4482 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4487 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
| 4483 Local<Value> result; | 4488 Local<Value> result; |
| 4484 has_pending_exception = !ToLocal<Value>( | 4489 has_pending_exception = !ToLocal<Value>( |
| 4485 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); | 4490 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); |
| 4486 RETURN_ON_FAILED_EXECUTION(Value); | 4491 RETURN_ON_FAILED_EXECUTION(Value); |
| (...skipping 4324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8811 Address callback_address = | 8816 Address callback_address = |
| 8812 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8817 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8813 VMState<EXTERNAL> state(isolate); | 8818 VMState<EXTERNAL> state(isolate); |
| 8814 ExternalCallbackScope call_scope(isolate, callback_address); | 8819 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8815 callback(info); | 8820 callback(info); |
| 8816 } | 8821 } |
| 8817 | 8822 |
| 8818 | 8823 |
| 8819 } // namespace internal | 8824 } // namespace internal |
| 8820 } // namespace v8 | 8825 } // namespace v8 |
| OLD | NEW |