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(), true); |
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 2576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4372 bool v8::Object::IsConstructor() { | 4373 bool v8::Object::IsConstructor() { |
4373 auto self = Utils::OpenHandle(this); | 4374 auto self = Utils::OpenHandle(this); |
4374 return self->IsConstructor(); | 4375 return self->IsConstructor(); |
4375 } | 4376 } |
4376 | 4377 |
4377 MaybeLocal<Value> Object::CallAsFunction(Local<Context> context, | 4378 MaybeLocal<Value> Object::CallAsFunction(Local<Context> context, |
4378 Local<Value> recv, int argc, | 4379 Local<Value> recv, int argc, |
4379 Local<Value> argv[]) { | 4380 Local<Value> argv[]) { |
4380 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Object::CallAsFunction()", | 4381 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Object::CallAsFunction()", |
4381 Value); | 4382 Value); |
| 4383 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); |
4382 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4384 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
4383 TRACE_EVENT0("v8", "V8.Execute"); | 4385 TRACE_EVENT0("v8", "V8.Execute"); |
4384 auto self = Utils::OpenHandle(this); | 4386 auto self = Utils::OpenHandle(this); |
4385 auto recv_obj = Utils::OpenHandle(*recv); | 4387 auto recv_obj = Utils::OpenHandle(*recv); |
4386 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4388 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
4387 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4389 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
4388 Local<Value> result; | 4390 Local<Value> result; |
4389 has_pending_exception = !ToLocal<Value>( | 4391 has_pending_exception = !ToLocal<Value>( |
4390 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); | 4392 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); |
4391 RETURN_ON_FAILED_EXECUTION(Value); | 4393 RETURN_ON_FAILED_EXECUTION(Value); |
4392 RETURN_ESCAPED(result); | 4394 RETURN_ESCAPED(result); |
4393 } | 4395 } |
4394 | 4396 |
4395 | 4397 |
4396 Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc, | 4398 Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc, |
4397 v8::Local<v8::Value> argv[]) { | 4399 v8::Local<v8::Value> argv[]) { |
4398 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4400 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4399 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); | 4401 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); |
4400 RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast), | 4402 RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast), |
4401 Value); | 4403 Value); |
4402 } | 4404 } |
4403 | 4405 |
4404 | 4406 |
4405 MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc, | 4407 MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc, |
4406 Local<Value> argv[]) { | 4408 Local<Value> argv[]) { |
4407 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, | 4409 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, |
4408 "v8::Object::CallAsConstructor()", Value); | 4410 "v8::Object::CallAsConstructor()", Value); |
| 4411 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); |
4409 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4412 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
4410 TRACE_EVENT0("v8", "V8.Execute"); | 4413 TRACE_EVENT0("v8", "V8.Execute"); |
4411 auto self = Utils::OpenHandle(this); | 4414 auto self = Utils::OpenHandle(this); |
4412 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4415 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
4413 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4416 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
4414 Local<Value> result; | 4417 Local<Value> result; |
4415 has_pending_exception = !ToLocal<Value>( | 4418 has_pending_exception = !ToLocal<Value>( |
4416 i::Execution::New(isolate, self, self, argc, args), &result); | 4419 i::Execution::New(isolate, self, self, argc, args), &result); |
4417 RETURN_ON_FAILED_EXECUTION(Value); | 4420 RETURN_ON_FAILED_EXECUTION(Value); |
4418 RETURN_ESCAPED(result); | 4421 RETURN_ESCAPED(result); |
(...skipping 30 matching lines...) Expand all Loading... |
4449 Local<v8::Object> Function::NewInstance() const { | 4452 Local<v8::Object> Function::NewInstance() const { |
4450 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL) | 4453 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL) |
4451 .FromMaybe(Local<Object>()); | 4454 .FromMaybe(Local<Object>()); |
4452 } | 4455 } |
4453 | 4456 |
4454 | 4457 |
4455 MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc, | 4458 MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc, |
4456 v8::Local<v8::Value> argv[]) const { | 4459 v8::Local<v8::Value> argv[]) const { |
4457 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Function::NewInstance()", | 4460 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Function::NewInstance()", |
4458 Object); | 4461 Object); |
| 4462 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); |
4459 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4463 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
4460 TRACE_EVENT0("v8", "V8.Execute"); | 4464 TRACE_EVENT0("v8", "V8.Execute"); |
4461 auto self = Utils::OpenHandle(this); | 4465 auto self = Utils::OpenHandle(this); |
4462 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4466 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
4463 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4467 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
4464 Local<Object> result; | 4468 Local<Object> result; |
4465 has_pending_exception = !ToLocal<Object>( | 4469 has_pending_exception = !ToLocal<Object>( |
4466 i::Execution::New(isolate, self, self, argc, args), &result); | 4470 i::Execution::New(isolate, self, self, argc, args), &result); |
4467 RETURN_ON_FAILED_EXECUTION(Object); | 4471 RETURN_ON_FAILED_EXECUTION(Object); |
4468 RETURN_ESCAPED(result); | 4472 RETURN_ESCAPED(result); |
4469 } | 4473 } |
4470 | 4474 |
4471 | 4475 |
4472 Local<v8::Object> Function::NewInstance(int argc, | 4476 Local<v8::Object> Function::NewInstance(int argc, |
4473 v8::Local<v8::Value> argv[]) const { | 4477 v8::Local<v8::Value> argv[]) const { |
4474 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4478 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4475 RETURN_TO_LOCAL_UNCHECKED(NewInstance(context, argc, argv), Object); | 4479 RETURN_TO_LOCAL_UNCHECKED(NewInstance(context, argc, argv), Object); |
4476 } | 4480 } |
4477 | 4481 |
4478 | 4482 |
4479 MaybeLocal<v8::Value> Function::Call(Local<Context> context, | 4483 MaybeLocal<v8::Value> Function::Call(Local<Context> context, |
4480 v8::Local<v8::Value> recv, int argc, | 4484 v8::Local<v8::Value> recv, int argc, |
4481 v8::Local<v8::Value> argv[]) { | 4485 v8::Local<v8::Value> argv[]) { |
4482 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Function::Call()", Value); | 4486 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Function::Call()", Value); |
| 4487 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); |
4483 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4488 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
4484 TRACE_EVENT0("v8", "V8.Execute"); | 4489 TRACE_EVENT0("v8", "V8.Execute"); |
4485 auto self = Utils::OpenHandle(this); | 4490 auto self = Utils::OpenHandle(this); |
4486 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); | 4491 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); |
4487 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4492 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
4488 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4493 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
4489 Local<Value> result; | 4494 Local<Value> result; |
4490 has_pending_exception = !ToLocal<Value>( | 4495 has_pending_exception = !ToLocal<Value>( |
4491 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); | 4496 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); |
4492 RETURN_ON_FAILED_EXECUTION(Value); | 4497 RETURN_ON_FAILED_EXECUTION(Value); |
(...skipping 4335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8828 Address callback_address = | 8833 Address callback_address = |
8829 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8834 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8830 VMState<EXTERNAL> state(isolate); | 8835 VMState<EXTERNAL> state(isolate); |
8831 ExternalCallbackScope call_scope(isolate, callback_address); | 8836 ExternalCallbackScope call_scope(isolate, callback_address); |
8832 callback(info); | 8837 callback(info); |
8833 } | 8838 } |
8834 | 8839 |
8835 | 8840 |
8836 } // namespace internal | 8841 } // namespace internal |
8837 } // namespace v8 | 8842 } // namespace v8 |
OLD | NEW |