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

Side by Side Diff: src/api.cc

Issue 1710573002: Revert of Add Scoped Context Info (Isolate) to V8 Traces (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 | « include/v8-platform.h ('k') | src/d8.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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "src/property.h" 51 #include "src/property.h"
52 #include "src/property-descriptor.h" 52 #include "src/property-descriptor.h"
53 #include "src/property-details.h" 53 #include "src/property-details.h"
54 #include "src/prototype.h" 54 #include "src/prototype.h"
55 #include "src/runtime/runtime.h" 55 #include "src/runtime/runtime.h"
56 #include "src/runtime-profiler.h" 56 #include "src/runtime-profiler.h"
57 #include "src/simulator.h" 57 #include "src/simulator.h"
58 #include "src/snapshot/natives.h" 58 #include "src/snapshot/natives.h"
59 #include "src/snapshot/snapshot.h" 59 #include "src/snapshot/snapshot.h"
60 #include "src/startup-data-util.h" 60 #include "src/startup-data-util.h"
61 #include "src/tracing/trace-event.h"
62 #include "src/unicode-inl.h" 61 #include "src/unicode-inl.h"
63 #include "src/v8.h" 62 #include "src/v8.h"
64 #include "src/v8threads.h" 63 #include "src/v8threads.h"
65 #include "src/version.h" 64 #include "src/version.h"
66 #include "src/vm-state-inl.h" 65 #include "src/vm-state-inl.h"
67 66
68 67
69 namespace v8 { 68 namespace v8 {
70 69
71 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) 70 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr))
72 71
73 72
74 #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate)) 73 #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate))
75 74
76 75
77 #define PREPARE_FOR_EXECUTION_GENERIC(isolate, context, function_name, \ 76 #define PREPARE_FOR_EXECUTION_GENERIC(isolate, context, function_name, \
78 bailout_value, HandleScopeClass, \ 77 bailout_value, HandleScopeClass, \
79 do_callback) \ 78 do_callback) \
80 if (IsExecutionTerminatingCheck(isolate)) { \ 79 if (IsExecutionTerminatingCheck(isolate)) { \
81 return bailout_value; \ 80 return bailout_value; \
82 } \ 81 } \
83 TRACE_EVENT_SCOPED_CONTEXT("v8", "Isolate", isolate); \
84 HandleScopeClass handle_scope(isolate); \ 82 HandleScopeClass handle_scope(isolate); \
85 CallDepthScope call_depth_scope(isolate, context, do_callback); \ 83 CallDepthScope call_depth_scope(isolate, context, do_callback); \
86 LOG_API(isolate, function_name); \ 84 LOG_API(isolate, function_name); \
87 ENTER_V8(isolate); \ 85 ENTER_V8(isolate); \
88 bool has_pending_exception = false 86 bool has_pending_exception = false
89 87
90 88
91 #define PREPARE_FOR_EXECUTION_WITH_CONTEXT( \ 89 #define PREPARE_FOR_EXECUTION_WITH_CONTEXT( \
92 context, function_name, bailout_value, HandleScopeClass, do_callback) \ 90 context, function_name, bailout_value, HandleScopeClass, do_callback) \
93 auto isolate = context.IsEmpty() \ 91 auto isolate = context.IsEmpty() \
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 Local<Context> context_; 188 Local<Context> context_;
191 bool escaped_; 189 bool escaped_;
192 bool do_callback_; 190 bool do_callback_;
193 }; 191 };
194 192
195 } // namespace 193 } // namespace
196 194
197 195
198 static ScriptOrigin GetScriptOriginForScript(i::Isolate* isolate, 196 static ScriptOrigin GetScriptOriginForScript(i::Isolate* isolate,
199 i::Handle<i::Script> script) { 197 i::Handle<i::Script> script) {
200 TRACE_EVENT_SCOPED_CONTEXT("v8", "Isolate", isolate);
201 i::Handle<i::Object> scriptName(i::Script::GetNameOrSourceURL(script)); 198 i::Handle<i::Object> scriptName(i::Script::GetNameOrSourceURL(script));
202 i::Handle<i::Object> source_map_url(script->source_mapping_url(), isolate); 199 i::Handle<i::Object> source_map_url(script->source_mapping_url(), isolate);
203 v8::Isolate* v8_isolate = 200 v8::Isolate* v8_isolate =
204 reinterpret_cast<v8::Isolate*>(script->GetIsolate()); 201 reinterpret_cast<v8::Isolate*>(script->GetIsolate());
205 ScriptOriginOptions options(script->origin_options()); 202 ScriptOriginOptions options(script->origin_options());
206 v8::ScriptOrigin origin( 203 v8::ScriptOrigin origin(
207 Utils::ToLocal(scriptName), 204 Utils::ToLocal(scriptName),
208 v8::Integer::New(v8_isolate, script->line_offset()), 205 v8::Integer::New(v8_isolate, script->line_offset()),
209 v8::Integer::New(v8_isolate, script->column_offset()), 206 v8::Integer::New(v8_isolate, script->column_offset()),
210 v8::Boolean::New(v8_isolate, options.IsSharedCrossOrigin()), 207 v8::Boolean::New(v8_isolate, options.IsSharedCrossOrigin()),
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 }; 366 };
370 367
371 } // namespace 368 } // namespace
372 369
373 370
374 StartupData V8::CreateSnapshotDataBlob(const char* custom_source) { 371 StartupData V8::CreateSnapshotDataBlob(const char* custom_source) {
375 i::Isolate* internal_isolate = new i::Isolate(true); 372 i::Isolate* internal_isolate = new i::Isolate(true);
376 ArrayBufferAllocator allocator; 373 ArrayBufferAllocator allocator;
377 internal_isolate->set_array_buffer_allocator(&allocator); 374 internal_isolate->set_array_buffer_allocator(&allocator);
378 Isolate* isolate = reinterpret_cast<Isolate*>(internal_isolate); 375 Isolate* isolate = reinterpret_cast<Isolate*>(internal_isolate);
379 TRACE_EVENT_SCOPED_CONTEXT("v8", "Isolate", isolate);
380 StartupData result = {NULL, 0}; 376 StartupData result = {NULL, 0};
381 { 377 {
382 base::ElapsedTimer timer; 378 base::ElapsedTimer timer;
383 timer.Start(); 379 timer.Start();
384 Isolate::Scope isolate_scope(isolate); 380 Isolate::Scope isolate_scope(isolate);
385 internal_isolate->Init(NULL); 381 internal_isolate->Init(NULL);
386 Persistent<Context> context; 382 Persistent<Context> context;
387 i::Snapshot::Metadata metadata; 383 i::Snapshot::Metadata metadata;
388 { 384 {
389 HandleScope handle_scope(isolate); 385 HandleScope handle_scope(isolate);
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 auto context = v8_isolate->GetCurrentContext(); 1843 auto context = v8_isolate->GetCurrentContext();
1848 RETURN_TO_LOCAL_UNCHECKED(Compile(context, source, options), Script); 1844 RETURN_TO_LOCAL_UNCHECKED(Compile(context, source, options), Script);
1849 } 1845 }
1850 1846
1851 1847
1852 MaybeLocal<Script> ScriptCompiler::CompileModule(Local<Context> context, 1848 MaybeLocal<Script> ScriptCompiler::CompileModule(Local<Context> context,
1853 Source* source, 1849 Source* source,
1854 CompileOptions options) { 1850 CompileOptions options) {
1855 CHECK(i::FLAG_harmony_modules); 1851 CHECK(i::FLAG_harmony_modules);
1856 auto isolate = context->GetIsolate(); 1852 auto isolate = context->GetIsolate();
1857 TRACE_EVENT_SCOPED_CONTEXT("V8", "Isolate", isolate);
1858 auto maybe = CompileUnboundInternal(isolate, source, options, true); 1853 auto maybe = CompileUnboundInternal(isolate, source, options, true);
1859 Local<UnboundScript> generic; 1854 Local<UnboundScript> generic;
1860 if (!maybe.ToLocal(&generic)) return MaybeLocal<Script>(); 1855 if (!maybe.ToLocal(&generic)) return MaybeLocal<Script>();
1861 v8::Context::Scope scope(context); 1856 v8::Context::Scope scope(context);
1862 return generic->BindToCurrentContext(); 1857 return generic->BindToCurrentContext();
1863 } 1858 }
1864 1859
1865 1860
1866 class IsIdentifierHelper { 1861 class IsIdentifierHelper {
1867 public: 1862 public:
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
2274 void v8::TryCatch::SetCaptureMessage(bool value) { 2269 void v8::TryCatch::SetCaptureMessage(bool value) {
2275 capture_message_ = value; 2270 capture_message_ = value;
2276 } 2271 }
2277 2272
2278 2273
2279 // --- M e s s a g e --- 2274 // --- M e s s a g e ---
2280 2275
2281 2276
2282 Local<String> Message::Get() const { 2277 Local<String> Message::Get() const {
2283 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2278 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2284 TRACE_EVENT_SCOPED_CONTEXT("v8", "Isolate", isolate);
2285 ENTER_V8(isolate); 2279 ENTER_V8(isolate);
2286 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); 2280 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
2287 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2281 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2288 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(isolate, obj); 2282 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(isolate, obj);
2289 Local<String> result = Utils::ToLocal(raw_result); 2283 Local<String> result = Utils::ToLocal(raw_result);
2290 return scope.Escape(result); 2284 return scope.Escape(result);
2291 } 2285 }
2292 2286
2293 2287
2294 ScriptOrigin Message::GetScriptOrigin() const { 2288 ScriptOrigin Message::GetScriptOrigin() const {
2295 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2289 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2296 auto message = i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 2290 auto message = i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
2297 auto script_wraper = i::Handle<i::Object>(message->script(), isolate); 2291 auto script_wraper = i::Handle<i::Object>(message->script(), isolate);
2298 auto script_value = i::Handle<i::JSValue>::cast(script_wraper); 2292 auto script_value = i::Handle<i::JSValue>::cast(script_wraper);
2299 i::Handle<i::Script> script(i::Script::cast(script_value->value())); 2293 i::Handle<i::Script> script(i::Script::cast(script_value->value()));
2300 return GetScriptOriginForScript(isolate, script); 2294 return GetScriptOriginForScript(isolate, script);
2301 } 2295 }
2302 2296
2303 2297
2304 v8::Local<Value> Message::GetScriptResourceName() const { 2298 v8::Local<Value> Message::GetScriptResourceName() const {
2305 return GetScriptOrigin().ResourceName(); 2299 return GetScriptOrigin().ResourceName();
2306 } 2300 }
2307 2301
2308 2302
2309 v8::Local<v8::StackTrace> Message::GetStackTrace() const { 2303 v8::Local<v8::StackTrace> Message::GetStackTrace() const {
2310 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2304 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2311 TRACE_EVENT_SCOPED_CONTEXT("v8", "Isolate", isolate);
2312 ENTER_V8(isolate); 2305 ENTER_V8(isolate);
2313 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); 2306 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
2314 auto message = i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 2307 auto message = i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
2315 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); 2308 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate);
2316 if (!stackFramesObj->IsJSArray()) return v8::Local<v8::StackTrace>(); 2309 if (!stackFramesObj->IsJSArray()) return v8::Local<v8::StackTrace>();
2317 auto stackTrace = i::Handle<i::JSArray>::cast(stackFramesObj); 2310 auto stackTrace = i::Handle<i::JSArray>::cast(stackFramesObj);
2318 return scope.Escape(Utils::StackTraceToLocal(stackTrace)); 2311 return scope.Escape(Utils::StackTraceToLocal(stackTrace));
2319 } 2312 }
2320 2313
2321 2314
(...skipping 3188 matching lines...) Expand 10 before | Expand all | Expand 10 after
5510 // Leave V8. 5503 // Leave V8.
5511 5504
5512 return env; 5505 return env;
5513 } 5506 }
5514 5507
5515 Local<Context> v8::Context::New(v8::Isolate* external_isolate, 5508 Local<Context> v8::Context::New(v8::Isolate* external_isolate,
5516 v8::ExtensionConfiguration* extensions, 5509 v8::ExtensionConfiguration* extensions,
5517 v8::Local<ObjectTemplate> global_template, 5510 v8::Local<ObjectTemplate> global_template,
5518 v8::Local<Value> global_object) { 5511 v8::Local<Value> global_object) {
5519 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); 5512 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate);
5520 TRACE_EVENT_SCOPED_CONTEXT("v8", "Isolate", isolate);
5521 LOG_API(isolate, "Context::New"); 5513 LOG_API(isolate, "Context::New");
5522 i::HandleScope scope(isolate); 5514 i::HandleScope scope(isolate);
5523 ExtensionConfiguration no_extensions; 5515 ExtensionConfiguration no_extensions;
5524 if (extensions == NULL) extensions = &no_extensions; 5516 if (extensions == NULL) extensions = &no_extensions;
5525 i::Handle<i::Context> env = 5517 i::Handle<i::Context> env =
5526 CreateEnvironment(isolate, extensions, global_template, global_object); 5518 CreateEnvironment(isolate, extensions, global_template, global_object);
5527 if (env.is_null()) { 5519 if (env.is_null()) {
5528 if (isolate->has_pending_exception()) { 5520 if (isolate->has_pending_exception()) {
5529 isolate->OptionalRescheduleException(true); 5521 isolate->OptionalRescheduleException(true);
5530 } 5522 }
(...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after
7149 7141
7150 Isolate* Isolate::GetCurrent() { 7142 Isolate* Isolate::GetCurrent() {
7151 i::Isolate* isolate = i::Isolate::Current(); 7143 i::Isolate* isolate = i::Isolate::Current();
7152 return reinterpret_cast<Isolate*>(isolate); 7144 return reinterpret_cast<Isolate*>(isolate);
7153 } 7145 }
7154 7146
7155 7147
7156 Isolate* Isolate::New(const Isolate::CreateParams& params) { 7148 Isolate* Isolate::New(const Isolate::CreateParams& params) {
7157 i::Isolate* isolate = new i::Isolate(false); 7149 i::Isolate* isolate = new i::Isolate(false);
7158 Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate); 7150 Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate);
7159 TRACE_EVENT_SCOPED_CONTEXT("v8", "Isolate", isolate);
7160 CHECK(params.array_buffer_allocator != NULL); 7151 CHECK(params.array_buffer_allocator != NULL);
7161 isolate->set_array_buffer_allocator(params.array_buffer_allocator); 7152 isolate->set_array_buffer_allocator(params.array_buffer_allocator);
7162 if (params.snapshot_blob != NULL) { 7153 if (params.snapshot_blob != NULL) {
7163 isolate->set_snapshot_blob(params.snapshot_blob); 7154 isolate->set_snapshot_blob(params.snapshot_blob);
7164 } else { 7155 } else {
7165 isolate->set_snapshot_blob(i::Snapshot::DefaultSnapshotBlob()); 7156 isolate->set_snapshot_blob(i::Snapshot::DefaultSnapshotBlob());
7166 } 7157 }
7167 if (params.entry_hook) { 7158 if (params.entry_hook) {
7168 isolate->set_function_entry_hook(params.entry_hook); 7159 isolate->set_function_entry_hook(params.entry_hook);
7169 } 7160 }
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
8563 Address callback_address = 8554 Address callback_address =
8564 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8555 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8565 VMState<EXTERNAL> state(isolate); 8556 VMState<EXTERNAL> state(isolate);
8566 ExternalCallbackScope call_scope(isolate, callback_address); 8557 ExternalCallbackScope call_scope(isolate, callback_address);
8567 callback(info); 8558 callback(info);
8568 } 8559 }
8569 8560
8570 8561
8571 } // namespace internal 8562 } // namespace internal
8572 } // namespace v8 8563 } // namespace v8
OLDNEW
« no previous file with comments | « include/v8-platform.h ('k') | src/d8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698