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

Side by Side Diff: Source/bindings/core/v8/V8Initializer.cpp

Issue 743153002: [DevTools] Show stack trace for exceptions in dedicated workers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@worker-capture-stack
Patch Set: Rebased Created 6 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 // WorkerGlobalScope::reportException will send the exception to the worker object. 476 // WorkerGlobalScope::reportException will send the exception to the worker object.
477 if (perIsolateData->isReportingException()) 477 if (perIsolateData->isReportingException())
478 return; 478 return;
479 perIsolateData->setReportingException(true); 479 perIsolateData->setReportingException(true);
480 480
481 ScriptState* scriptState = ScriptState::current(isolate); 481 ScriptState* scriptState = ScriptState::current(isolate);
482 // During the frame teardown, there may not be a valid context. 482 // During the frame teardown, there may not be a valid context.
483 if (ExecutionContext* context = scriptState->executionContext()) { 483 if (ExecutionContext* context = scriptState->executionContext()) {
484 String errorMessage = toCoreString(message->Get()); 484 String errorMessage = toCoreString(message->Get());
485 TOSTRING_VOID(V8StringResource<>, sourceURL, message->GetScriptOrigin(). ResourceName()); 485 TOSTRING_VOID(V8StringResource<>, sourceURL, message->GetScriptOrigin(). ResourceName());
486 int scriptId = message->GetScriptOrigin().ScriptID()->Value(); 486 int scriptId = 0;
487 RefPtrWillBeRawPtr<ScriptCallStack> callStack = extractCallStack(isolate , message, &scriptId);
487 488
488 RefPtrWillBeRawPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sourceURL, message->GetLineNumber(), message->GetStartColumn() + 1, &DOMWrapperW orld::current(isolate)); 489 RefPtrWillBeRawPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sourceURL, message->GetLineNumber(), message->GetStartColumn() + 1, &DOMWrapperW orld::current(isolate));
489 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? Sharab leCrossOrigin : NotSharableCrossOrigin; 490 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? Sharab leCrossOrigin : NotSharableCrossOrigin;
490 491
491 // If execution termination has been triggered as part of constructing 492 // If execution termination has been triggered as part of constructing
492 // the error event from the v8::Message, quietly leave. 493 // the error event from the v8::Message, quietly leave.
493 if (!v8::V8::IsExecutionTerminating(isolate)) { 494 if (!v8::V8::IsExecutionTerminating(isolate)) {
494 V8ErrorHandler::storeExceptionOnErrorEventWrapper(isolate, event.get (), data, scriptState->context()->Global()); 495 V8ErrorHandler::storeExceptionOnErrorEventWrapper(isolate, event.get (), data, scriptState->context()->Global());
495 context->reportException(event.release(), scriptId, nullptr, corsSta tus); 496 context->reportException(event.release(), scriptId, callStack, corsS tatus);
496 } 497 }
497 } 498 }
498 499
499 perIsolateData->setReportingException(false); 500 perIsolateData->setReportingException(false);
500 } 501 }
501 502
502 static const int kWorkerMaxStackSize = 500 * 1024; 503 static const int kWorkerMaxStackSize = 500 * 1024;
503 504
504 // This function uses a local stack variable to determine the isolate's stack li mit. AddressSanitizer may 505 // This function uses a local stack variable to determine the isolate's stack li mit. AddressSanitizer may
505 // relocate that local variable to a fake stack, which may lead to problems duri ng JavaScript execution. 506 // relocate that local variable to a fake stack, which may lead to problems duri ng JavaScript execution.
506 // Therefore we disable AddressSanitizer for V8Initializer::initializeWorker(). 507 // Therefore we disable AddressSanitizer for V8Initializer::initializeWorker().
507 NO_SANITIZE_ADDRESS 508 NO_SANITIZE_ADDRESS
508 void V8Initializer::initializeWorker(v8::Isolate* isolate) 509 void V8Initializer::initializeWorker(v8::Isolate* isolate)
509 { 510 {
510 initializeV8Common(isolate); 511 initializeV8Common(isolate);
511 512
512 v8::V8::AddMessageListener(messageHandlerInWorker); 513 v8::V8::AddMessageListener(messageHandlerInWorker);
513 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); 514 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker);
514 515
515 uint32_t here; 516 uint32_t here;
516 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*))); 517 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*)));
517 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); 518 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker);
518 } 519 }
519 520
520 } // namespace blink 521 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698