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

Side by Side Diff: src/api.cc

Issue 2221853002: Revert of [Tracing] Embed V8 runtime call stats into tracing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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 | src/api-arguments.cc » ('j') | 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 #include "src/v8.h" 68 #include "src/v8.h"
69 #include "src/v8threads.h" 69 #include "src/v8threads.h"
70 #include "src/version.h" 70 #include "src/version.h"
71 #include "src/vm-state-inl.h" 71 #include "src/vm-state-inl.h"
72 72
73 namespace v8 { 73 namespace v8 {
74 74
75 #define LOG_API(isolate, class_name, function_name) \ 75 #define LOG_API(isolate, class_name, function_name) \
76 i::RuntimeCallTimerScope _runtime_timer( \ 76 i::RuntimeCallTimerScope _runtime_timer( \
77 isolate, &i::RuntimeCallStats::API_##class_name##_##function_name); \ 77 isolate, &i::RuntimeCallStats::API_##class_name##_##function_name); \
78 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( \
79 isolate, &internal::tracing::TraceEventStatsTable:: \
80 API_##class_name##_##function_name); \
81 LOG(isolate, ApiEntryCall("v8::" #class_name "::" #function_name)) 78 LOG(isolate, ApiEntryCall("v8::" #class_name "::" #function_name))
82 79
83 #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate)) 80 #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate))
84 81
85 #define PREPARE_FOR_EXECUTION_GENERIC(isolate, context, class_name, \ 82 #define PREPARE_FOR_EXECUTION_GENERIC(isolate, context, class_name, \
86 function_name, bailout_value, \ 83 function_name, bailout_value, \
87 HandleScopeClass, do_callback) \ 84 HandleScopeClass, do_callback) \
88 if (IsExecutionTerminatingCheck(isolate)) { \ 85 if (IsExecutionTerminatingCheck(isolate)) { \
89 return bailout_value; \ 86 return bailout_value; \
90 } \ 87 } \
(...skipping 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after
1833 return Local<String>(); 1830 return Local<String>();
1834 } 1831 }
1835 } 1832 }
1836 1833
1837 1834
1838 MaybeLocal<Value> Script::Run(Local<Context> context) { 1835 MaybeLocal<Value> Script::Run(Local<Context> context) {
1839 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Script, Run, Value) 1836 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Script, Run, Value)
1840 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); 1837 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true);
1841 i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy()); 1838 i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy());
1842 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); 1839 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
1843 TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute"); 1840 TRACE_EVENT0("v8", "V8.Execute");
1844 auto fun = i::Handle<i::JSFunction>::cast(Utils::OpenHandle(this)); 1841 auto fun = i::Handle<i::JSFunction>::cast(Utils::OpenHandle(this));
1845 i::Handle<i::Object> receiver = isolate->global_proxy(); 1842 i::Handle<i::Object> receiver = isolate->global_proxy();
1846 Local<Value> result; 1843 Local<Value> result;
1847 has_pending_exception = 1844 has_pending_exception =
1848 !ToLocal<Value>(i::Execution::Call(isolate, fun, receiver, 0, NULL), 1845 !ToLocal<Value>(i::Execution::Call(isolate, fun, receiver, 0, NULL),
1849 &result); 1846 &result);
1850 RETURN_ON_FAILED_EXECUTION(Value); 1847 RETURN_ON_FAILED_EXECUTION(Value);
1851 RETURN_ESCAPED(result); 1848 RETURN_ESCAPED(result);
1852 } 1849 }
1853 1850
(...skipping 14 matching lines...) Expand all
1868 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared())); 1865 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared()));
1869 } 1866 }
1870 1867
1871 1868
1872 MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal( 1869 MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal(
1873 Isolate* v8_isolate, Source* source, CompileOptions options, 1870 Isolate* v8_isolate, Source* source, CompileOptions options,
1874 bool is_module) { 1871 bool is_module) {
1875 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 1872 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
1876 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, ScriptCompiler, CompileUnbound, 1873 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, ScriptCompiler, CompileUnbound,
1877 UnboundScript); 1874 UnboundScript);
1878 TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.ScriptCompiler"); 1875 TRACE_EVENT0("v8", "V8.ScriptCompiler");
1879 1876
1880 // Don't try to produce any kind of cache when the debugger is loaded. 1877 // Don't try to produce any kind of cache when the debugger is loaded.
1881 if (isolate->debug()->is_loaded() && 1878 if (isolate->debug()->is_loaded() &&
1882 (options == kProduceParserCache || options == kProduceCodeCache)) { 1879 (options == kProduceParserCache || options == kProduceCodeCache)) {
1883 options = kNoCompileOptions; 1880 options = kNoCompileOptions;
1884 } 1881 }
1885 1882
1886 i::ScriptData* script_data = NULL; 1883 i::ScriptData* script_data = NULL;
1887 if (options == kConsumeParserCache || options == kConsumeCodeCache) { 1884 if (options == kConsumeParserCache || options == kConsumeCodeCache) {
1888 DCHECK(source->cached_data); 1885 DCHECK(source->cached_data);
(...skipping 2523 matching lines...) Expand 10 before | Expand all | Expand 10 after
4412 bool v8::Object::IsConstructor() { 4409 bool v8::Object::IsConstructor() {
4413 auto self = Utils::OpenHandle(this); 4410 auto self = Utils::OpenHandle(this);
4414 return self->IsConstructor(); 4411 return self->IsConstructor();
4415 } 4412 }
4416 4413
4417 MaybeLocal<Value> Object::CallAsFunction(Local<Context> context, 4414 MaybeLocal<Value> Object::CallAsFunction(Local<Context> context,
4418 Local<Value> recv, int argc, 4415 Local<Value> recv, int argc,
4419 Local<Value> argv[]) { 4416 Local<Value> argv[]) {
4420 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Object, CallAsFunction, Value); 4417 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Object, CallAsFunction, Value);
4421 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); 4418 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
4422 TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute"); 4419 TRACE_EVENT0("v8", "V8.Execute");
4423 auto self = Utils::OpenHandle(this); 4420 auto self = Utils::OpenHandle(this);
4424 auto recv_obj = Utils::OpenHandle(*recv); 4421 auto recv_obj = Utils::OpenHandle(*recv);
4425 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); 4422 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**));
4426 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); 4423 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
4427 Local<Value> result; 4424 Local<Value> result;
4428 has_pending_exception = !ToLocal<Value>( 4425 has_pending_exception = !ToLocal<Value>(
4429 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); 4426 i::Execution::Call(isolate, self, recv_obj, argc, args), &result);
4430 RETURN_ON_FAILED_EXECUTION(Value); 4427 RETURN_ON_FAILED_EXECUTION(Value);
4431 RETURN_ESCAPED(result); 4428 RETURN_ESCAPED(result);
4432 } 4429 }
4433 4430
4434 4431
4435 Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc, 4432 Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc,
4436 v8::Local<v8::Value> argv[]) { 4433 v8::Local<v8::Value> argv[]) {
4437 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4434 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4438 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); 4435 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv);
4439 RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast), 4436 RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast),
4440 Value); 4437 Value);
4441 } 4438 }
4442 4439
4443 4440
4444 MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc, 4441 MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc,
4445 Local<Value> argv[]) { 4442 Local<Value> argv[]) {
4446 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Object, CallAsConstructor, 4443 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Object, CallAsConstructor,
4447 Value); 4444 Value);
4448 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); 4445 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
4449 TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute"); 4446 TRACE_EVENT0("v8", "V8.Execute");
4450 auto self = Utils::OpenHandle(this); 4447 auto self = Utils::OpenHandle(this);
4451 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); 4448 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**));
4452 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); 4449 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
4453 Local<Value> result; 4450 Local<Value> result;
4454 has_pending_exception = !ToLocal<Value>( 4451 has_pending_exception = !ToLocal<Value>(
4455 i::Execution::New(isolate, self, self, argc, args), &result); 4452 i::Execution::New(isolate, self, self, argc, args), &result);
4456 RETURN_ON_FAILED_EXECUTION(Value); 4453 RETURN_ON_FAILED_EXECUTION(Value);
4457 RETURN_ESCAPED(result); 4454 RETURN_ESCAPED(result);
4458 } 4455 }
4459 4456
(...skipping 29 matching lines...) Expand all
4489 Local<v8::Object> Function::NewInstance() const { 4486 Local<v8::Object> Function::NewInstance() const {
4490 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL) 4487 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL)
4491 .FromMaybe(Local<Object>()); 4488 .FromMaybe(Local<Object>());
4492 } 4489 }
4493 4490
4494 4491
4495 MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc, 4492 MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc,
4496 v8::Local<v8::Value> argv[]) const { 4493 v8::Local<v8::Value> argv[]) const {
4497 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Function, NewInstance, Object); 4494 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Function, NewInstance, Object);
4498 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); 4495 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
4499 TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute"); 4496 TRACE_EVENT0("v8", "V8.Execute");
4500 auto self = Utils::OpenHandle(this); 4497 auto self = Utils::OpenHandle(this);
4501 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); 4498 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**));
4502 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); 4499 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
4503 Local<Object> result; 4500 Local<Object> result;
4504 has_pending_exception = !ToLocal<Object>( 4501 has_pending_exception = !ToLocal<Object>(
4505 i::Execution::New(isolate, self, self, argc, args), &result); 4502 i::Execution::New(isolate, self, self, argc, args), &result);
4506 RETURN_ON_FAILED_EXECUTION(Object); 4503 RETURN_ON_FAILED_EXECUTION(Object);
4507 RETURN_ESCAPED(result); 4504 RETURN_ESCAPED(result);
4508 } 4505 }
4509 4506
4510 4507
4511 Local<v8::Object> Function::NewInstance(int argc, 4508 Local<v8::Object> Function::NewInstance(int argc,
4512 v8::Local<v8::Value> argv[]) const { 4509 v8::Local<v8::Value> argv[]) const {
4513 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4510 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4514 RETURN_TO_LOCAL_UNCHECKED(NewInstance(context, argc, argv), Object); 4511 RETURN_TO_LOCAL_UNCHECKED(NewInstance(context, argc, argv), Object);
4515 } 4512 }
4516 4513
4517 4514
4518 MaybeLocal<v8::Value> Function::Call(Local<Context> context, 4515 MaybeLocal<v8::Value> Function::Call(Local<Context> context,
4519 v8::Local<v8::Value> recv, int argc, 4516 v8::Local<v8::Value> recv, int argc,
4520 v8::Local<v8::Value> argv[]) { 4517 v8::Local<v8::Value> argv[]) {
4521 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Function, Call, Value); 4518 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Function, Call, Value);
4522 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); 4519 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
4523 TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute"); 4520 TRACE_EVENT0("v8", "V8.Execute");
4524 auto self = Utils::OpenHandle(this); 4521 auto self = Utils::OpenHandle(this);
4525 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); 4522 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
4526 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); 4523 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**));
4527 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); 4524 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
4528 Local<Value> result; 4525 Local<Value> result;
4529 has_pending_exception = !ToLocal<Value>( 4526 has_pending_exception = !ToLocal<Value>(
4530 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); 4527 i::Execution::Call(isolate, self, recv_obj, argc, args), &result);
4531 RETURN_ON_FAILED_EXECUTION(Value); 4528 RETURN_ON_FAILED_EXECUTION(Value);
4532 RETURN_ESCAPED(result); 4529 RETURN_ESCAPED(result);
4533 } 4530 }
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after
5694 return result; 5691 return result;
5695 } 5692 }
5696 5693
5697 Local<Context> NewContext(v8::Isolate* external_isolate, 5694 Local<Context> NewContext(v8::Isolate* external_isolate,
5698 v8::ExtensionConfiguration* extensions, 5695 v8::ExtensionConfiguration* extensions,
5699 v8::MaybeLocal<ObjectTemplate> global_template, 5696 v8::MaybeLocal<ObjectTemplate> global_template,
5700 v8::MaybeLocal<Value> global_object, 5697 v8::MaybeLocal<Value> global_object,
5701 size_t context_snapshot_index) { 5698 size_t context_snapshot_index) {
5702 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); 5699 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate);
5703 LOG_API(isolate, Context, New); 5700 LOG_API(isolate, Context, New);
5704 TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.NewContext");
5705 i::HandleScope scope(isolate); 5701 i::HandleScope scope(isolate);
5706 ExtensionConfiguration no_extensions; 5702 ExtensionConfiguration no_extensions;
5707 if (extensions == NULL) extensions = &no_extensions; 5703 if (extensions == NULL) extensions = &no_extensions;
5708 i::Handle<i::Context> env = 5704 i::Handle<i::Context> env =
5709 CreateEnvironment<i::Context>(isolate, extensions, global_template, 5705 CreateEnvironment<i::Context>(isolate, extensions, global_template,
5710 global_object, context_snapshot_index); 5706 global_object, context_snapshot_index);
5711 if (env.is_null()) { 5707 if (env.is_null()) {
5712 if (isolate->has_pending_exception()) { 5708 if (isolate->has_pending_exception()) {
5713 isolate->OptionalRescheduleException(true); 5709 isolate->OptionalRescheduleException(true);
5714 } 5710 }
(...skipping 3243 matching lines...) Expand 10 before | Expand all | Expand 10 after
8958 8954
8959 8955
8960 void InvokeAccessorGetterCallback( 8956 void InvokeAccessorGetterCallback(
8961 v8::Local<v8::Name> property, 8957 v8::Local<v8::Name> property,
8962 const v8::PropertyCallbackInfo<v8::Value>& info, 8958 const v8::PropertyCallbackInfo<v8::Value>& info,
8963 v8::AccessorNameGetterCallback getter) { 8959 v8::AccessorNameGetterCallback getter) {
8964 // Leaving JavaScript. 8960 // Leaving JavaScript.
8965 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8961 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
8966 RuntimeCallTimerScope timer(isolate, 8962 RuntimeCallTimerScope timer(isolate,
8967 &RuntimeCallStats::AccessorGetterCallback); 8963 &RuntimeCallStats::AccessorGetterCallback);
8968 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED(
8969 isolate,
8970 &internal::tracing::TraceEventStatsTable::AccessorGetterCallback);
8971 Address getter_address = reinterpret_cast<Address>(reinterpret_cast<intptr_t>( 8964 Address getter_address = reinterpret_cast<Address>(reinterpret_cast<intptr_t>(
8972 getter)); 8965 getter));
8973 VMState<EXTERNAL> state(isolate); 8966 VMState<EXTERNAL> state(isolate);
8974 ExternalCallbackScope call_scope(isolate, getter_address); 8967 ExternalCallbackScope call_scope(isolate, getter_address);
8975 getter(property, info); 8968 getter(property, info);
8976 } 8969 }
8977 8970
8978 8971
8979 void InvokeFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info, 8972 void InvokeFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info,
8980 v8::FunctionCallback callback) { 8973 v8::FunctionCallback callback) {
8981 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8974 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
8982 RuntimeCallTimerScope timer(isolate, 8975 RuntimeCallTimerScope timer(isolate,
8983 &RuntimeCallStats::InvokeFunctionCallback); 8976 &RuntimeCallStats::InvokeFunctionCallback);
8984 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED(
8985 isolate,
8986 &internal::tracing::TraceEventStatsTable::InvokeFunctionCallback);
8987 Address callback_address = 8977 Address callback_address =
8988 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8978 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8989 VMState<EXTERNAL> state(isolate); 8979 VMState<EXTERNAL> state(isolate);
8990 ExternalCallbackScope call_scope(isolate, callback_address); 8980 ExternalCallbackScope call_scope(isolate, callback_address);
8991 callback(info); 8981 callback(info);
8992 } 8982 }
8993 8983
8994 8984
8995 } // namespace internal 8985 } // namespace internal
8996 } // namespace v8 8986 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/api-arguments.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698