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