Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Side by Side Diff: src/api.cc

Issue 2344723004: Introduce PREPARE_FOR_EXECUTION_WITH_CONTEXT_IN_RUNTIME_CALL_STATS_SCOPE (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 #define PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \ 98 #define PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \
99 bailout_value, HandleScopeClass, \ 99 bailout_value, HandleScopeClass, \
100 do_callback) \ 100 do_callback) \
101 auto isolate = context.IsEmpty() \ 101 auto isolate = context.IsEmpty() \
102 ? i::Isolate::Current() \ 102 ? i::Isolate::Current() \
103 : reinterpret_cast<i::Isolate*>(context->GetIsolate()); \ 103 : reinterpret_cast<i::Isolate*>(context->GetIsolate()); \
104 PREPARE_FOR_EXECUTION_GENERIC(isolate, context, class_name, function_name, \ 104 PREPARE_FOR_EXECUTION_GENERIC(isolate, context, class_name, function_name, \
105 bailout_value, HandleScopeClass, do_callback); 105 bailout_value, HandleScopeClass, do_callback);
106 106
107 #define PREPARE_FOR_EXECUTION_WITH_CONTEXT_IN_RUNTIME_CALL_STATS_SCOPE( \
108 category, name, context, class_name, function_name, bailout_value, \
109 HandleScopeClass, do_callback) \
110 auto isolate = context.IsEmpty() \
111 ? i::Isolate::Current() \
112 : reinterpret_cast<i::Isolate*>(context->GetIsolate()); \
113 TRACE_EVENT_CALL_STATS_SCOPED(isolate, category, name); \
114 PREPARE_FOR_EXECUTION_GENERIC(isolate, context, class_name, function_name, \
115 bailout_value, HandleScopeClass, do_callback);
116
107 #define PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, class_name, function_name, \ 117 #define PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, class_name, function_name, \
108 T) \ 118 T) \
109 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), class_name, \ 119 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), class_name, \
110 function_name, MaybeLocal<T>(), \ 120 function_name, MaybeLocal<T>(), \
111 InternalEscapableScope, false); 121 InternalEscapableScope, false);
112 122
113 #define PREPARE_FOR_EXECUTION(context, class_name, function_name, T) \ 123 #define PREPARE_FOR_EXECUTION(context, class_name, function_name, T) \
114 PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \ 124 PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \
115 MaybeLocal<T>(), InternalEscapableScope, \ 125 MaybeLocal<T>(), InternalEscapableScope, \
116 false) 126 false)
(...skipping 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1833 if (obj->script()->IsScript()) { 1843 if (obj->script()->IsScript()) {
1834 i::Object* url = i::Script::cast(obj->script())->source_mapping_url(); 1844 i::Object* url = i::Script::cast(obj->script())->source_mapping_url();
1835 return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); 1845 return Utils::ToLocal(i::Handle<i::Object>(url, isolate));
1836 } else { 1846 } else {
1837 return Local<String>(); 1847 return Local<String>();
1838 } 1848 }
1839 } 1849 }
1840 1850
1841 1851
1842 MaybeLocal<Value> Script::Run(Local<Context> context) { 1852 MaybeLocal<Value> Script::Run(Local<Context> context) {
1843 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Script, Run, Value) 1853 PREPARE_FOR_EXECUTION_WITH_CONTEXT_IN_RUNTIME_CALL_STATS_SCOPE(
1854 "v8", "V8.Execute", context, Script, Run, MaybeLocal<Value>(),
1855 InternalEscapableScope, true);
1844 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); 1856 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true);
1845 i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy()); 1857 i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy());
1846 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); 1858 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
1847 TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute");
1848 auto fun = i::Handle<i::JSFunction>::cast(Utils::OpenHandle(this)); 1859 auto fun = i::Handle<i::JSFunction>::cast(Utils::OpenHandle(this));
1849 1860
1850 i::Handle<i::Object> receiver; 1861 i::Handle<i::Object> receiver;
1851 Local<Value> result; 1862 Local<Value> result;
1852 1863
1853 if (fun->shared()->scope_info()->scope_type() == i::MODULE_SCOPE) { 1864 if (fun->shared()->scope_info()->scope_type() == i::MODULE_SCOPE) {
1854 receiver = isolate->factory()->undefined_value(); 1865 receiver = isolate->factory()->undefined_value();
1855 i::Handle<i::Object> argv[] = { 1866 i::Handle<i::Object> argv[] = {
1856 handle(isolate->native_context()->current_module())}; 1867 handle(isolate->native_context()->current_module())};
1857 has_pending_exception = !ToLocal<Value>( 1868 has_pending_exception = !ToLocal<Value>(
(...skipping 2885 matching lines...) Expand 10 before | Expand all | Expand 10 after
4743 } 4754 }
4744 4755
4745 bool v8::Object::IsConstructor() { 4756 bool v8::Object::IsConstructor() {
4746 auto self = Utils::OpenHandle(this); 4757 auto self = Utils::OpenHandle(this);
4747 return self->IsConstructor(); 4758 return self->IsConstructor();
4748 } 4759 }
4749 4760
4750 MaybeLocal<Value> Object::CallAsFunction(Local<Context> context, 4761 MaybeLocal<Value> Object::CallAsFunction(Local<Context> context,
4751 Local<Value> recv, int argc, 4762 Local<Value> recv, int argc,
4752 Local<Value> argv[]) { 4763 Local<Value> argv[]) {
4753 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Object, CallAsFunction, Value); 4764 PREPARE_FOR_EXECUTION_WITH_CONTEXT_IN_RUNTIME_CALL_STATS_SCOPE(
4765 "v8", "V8.Execute", context, Object, CallAsFunction, MaybeLocal<Value>(),
4766 InternalEscapableScope, true);
4754 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); 4767 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
4755 TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute");
4756 auto self = Utils::OpenHandle(this); 4768 auto self = Utils::OpenHandle(this);
4757 auto recv_obj = Utils::OpenHandle(*recv); 4769 auto recv_obj = Utils::OpenHandle(*recv);
4758 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); 4770 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**));
4759 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); 4771 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
4760 Local<Value> result; 4772 Local<Value> result;
4761 has_pending_exception = !ToLocal<Value>( 4773 has_pending_exception = !ToLocal<Value>(
4762 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); 4774 i::Execution::Call(isolate, self, recv_obj, argc, args), &result);
4763 RETURN_ON_FAILED_EXECUTION(Value); 4775 RETURN_ON_FAILED_EXECUTION(Value);
4764 RETURN_ESCAPED(result); 4776 RETURN_ESCAPED(result);
4765 } 4777 }
4766 4778
4767 4779
4768 Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc, 4780 Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc,
4769 v8::Local<v8::Value> argv[]) { 4781 v8::Local<v8::Value> argv[]) {
4770 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4782 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4771 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); 4783 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv);
4772 RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast), 4784 RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast),
4773 Value); 4785 Value);
4774 } 4786 }
4775 4787
4776 4788
4777 MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc, 4789 MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc,
4778 Local<Value> argv[]) { 4790 Local<Value> argv[]) {
4779 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Object, CallAsConstructor, 4791 PREPARE_FOR_EXECUTION_WITH_CONTEXT_IN_RUNTIME_CALL_STATS_SCOPE(
4780 Value); 4792 "v8", "V8.Execute", context, Object, CallAsConstructor,
4793 MaybeLocal<Value>(), InternalEscapableScope, true);
4781 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); 4794 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
4782 TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute");
4783 auto self = Utils::OpenHandle(this); 4795 auto self = Utils::OpenHandle(this);
4784 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); 4796 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**));
4785 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); 4797 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
4786 Local<Value> result; 4798 Local<Value> result;
4787 has_pending_exception = !ToLocal<Value>( 4799 has_pending_exception = !ToLocal<Value>(
4788 i::Execution::New(isolate, self, self, argc, args), &result); 4800 i::Execution::New(isolate, self, self, argc, args), &result);
4789 RETURN_ON_FAILED_EXECUTION(Value); 4801 RETURN_ON_FAILED_EXECUTION(Value);
4790 RETURN_ESCAPED(result); 4802 RETURN_ESCAPED(result);
4791 } 4803 }
4792 4804
(...skipping 27 matching lines...) Expand all
4820 4832
4821 4833
4822 Local<v8::Object> Function::NewInstance() const { 4834 Local<v8::Object> Function::NewInstance() const {
4823 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL) 4835 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL)
4824 .FromMaybe(Local<Object>()); 4836 .FromMaybe(Local<Object>());
4825 } 4837 }
4826 4838
4827 4839
4828 MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc, 4840 MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc,
4829 v8::Local<v8::Value> argv[]) const { 4841 v8::Local<v8::Value> argv[]) const {
4830 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Function, NewInstance, Object); 4842 PREPARE_FOR_EXECUTION_WITH_CONTEXT_IN_RUNTIME_CALL_STATS_SCOPE(
4843 "v8", "V8.Execute", context, Function, NewInstance, MaybeLocal<Object>(),
4844 InternalEscapableScope, true);
4831 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); 4845 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
4832 TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute");
4833 auto self = Utils::OpenHandle(this); 4846 auto self = Utils::OpenHandle(this);
4834 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); 4847 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**));
4835 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); 4848 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
4836 Local<Object> result; 4849 Local<Object> result;
4837 has_pending_exception = !ToLocal<Object>( 4850 has_pending_exception = !ToLocal<Object>(
4838 i::Execution::New(isolate, self, self, argc, args), &result); 4851 i::Execution::New(isolate, self, self, argc, args), &result);
4839 RETURN_ON_FAILED_EXECUTION(Object); 4852 RETURN_ON_FAILED_EXECUTION(Object);
4840 RETURN_ESCAPED(result); 4853 RETURN_ESCAPED(result);
4841 } 4854 }
4842 4855
4843 4856
4844 Local<v8::Object> Function::NewInstance(int argc, 4857 Local<v8::Object> Function::NewInstance(int argc,
4845 v8::Local<v8::Value> argv[]) const { 4858 v8::Local<v8::Value> argv[]) const {
4846 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4859 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4847 RETURN_TO_LOCAL_UNCHECKED(NewInstance(context, argc, argv), Object); 4860 RETURN_TO_LOCAL_UNCHECKED(NewInstance(context, argc, argv), Object);
4848 } 4861 }
4849 4862
4850 4863
4851 MaybeLocal<v8::Value> Function::Call(Local<Context> context, 4864 MaybeLocal<v8::Value> Function::Call(Local<Context> context,
4852 v8::Local<v8::Value> recv, int argc, 4865 v8::Local<v8::Value> recv, int argc,
4853 v8::Local<v8::Value> argv[]) { 4866 v8::Local<v8::Value> argv[]) {
4854 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Function, Call, Value); 4867 PREPARE_FOR_EXECUTION_WITH_CONTEXT_IN_RUNTIME_CALL_STATS_SCOPE(
4868 "v8", "V8.Execute", context, Function, Call, MaybeLocal<Value>(),
4869 InternalEscapableScope, true);
4855 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); 4870 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
4856 TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute");
4857 auto self = Utils::OpenHandle(this); 4871 auto self = Utils::OpenHandle(this);
4858 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); 4872 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
4859 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); 4873 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**));
4860 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); 4874 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
4861 Local<Value> result; 4875 Local<Value> result;
4862 has_pending_exception = !ToLocal<Value>( 4876 has_pending_exception = !ToLocal<Value>(
4863 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); 4877 i::Execution::Call(isolate, self, recv_obj, argc, args), &result);
4864 RETURN_ON_FAILED_EXECUTION(Value); 4878 RETURN_ON_FAILED_EXECUTION(Value);
4865 RETURN_ESCAPED(result); 4879 RETURN_ESCAPED(result);
4866 } 4880 }
(...skipping 4462 matching lines...) Expand 10 before | Expand all | Expand 10 after
9329 Address callback_address = 9343 Address callback_address =
9330 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 9344 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
9331 VMState<EXTERNAL> state(isolate); 9345 VMState<EXTERNAL> state(isolate);
9332 ExternalCallbackScope call_scope(isolate, callback_address); 9346 ExternalCallbackScope call_scope(isolate, callback_address);
9333 callback(info); 9347 callback(info);
9334 } 9348 }
9335 9349
9336 9350
9337 } // namespace internal 9351 } // namespace internal
9338 } // namespace v8 9352 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698