OLD | NEW |
---|---|
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 23 matching lines...) Expand all Loading... | |
34 #include "bindings/v8/DOMWrapperWorld.h" | 34 #include "bindings/v8/DOMWrapperWorld.h" |
35 #include "bindings/v8/ScriptCallStackFactory.h" | 35 #include "bindings/v8/ScriptCallStackFactory.h" |
36 #include "bindings/v8/ScriptController.h" | 36 #include "bindings/v8/ScriptController.h" |
37 #include "bindings/v8/ScriptProfiler.h" | 37 #include "bindings/v8/ScriptProfiler.h" |
38 #include "bindings/v8/V8Binding.h" | 38 #include "bindings/v8/V8Binding.h" |
39 #include "bindings/v8/V8ErrorHandler.h" | 39 #include "bindings/v8/V8ErrorHandler.h" |
40 #include "bindings/v8/V8GCController.h" | 40 #include "bindings/v8/V8GCController.h" |
41 #include "bindings/v8/V8PerContextData.h" | 41 #include "bindings/v8/V8PerContextData.h" |
42 #include "core/dom/Document.h" | 42 #include "core/dom/Document.h" |
43 #include "core/dom/ExceptionCode.h" | 43 #include "core/dom/ExceptionCode.h" |
44 #include "core/inspector/ScriptCallStack.h" | |
45 #include "core/frame/ConsoleTypes.h" | 44 #include "core/frame/ConsoleTypes.h" |
46 #include "core/frame/ContentSecurityPolicy.h" | 45 #include "core/frame/ContentSecurityPolicy.h" |
47 #include "core/frame/DOMWindow.h" | 46 #include "core/frame/DOMWindow.h" |
48 #include "core/frame/Frame.h" | 47 #include "core/frame/Frame.h" |
48 #include "core/inspector/ScriptCallStack.h" | |
49 #include "public/platform/Platform.h" | 49 #include "public/platform/Platform.h" |
50 #include "wtf/RefPtr.h" | 50 #include "wtf/RefPtr.h" |
51 #include "wtf/text/WTFString.h" | 51 #include "wtf/text/WTFString.h" |
52 #include <v8-debug.h> | 52 #include <v8-debug.h> |
53 | 53 |
54 namespace WebCore { | 54 namespace WebCore { |
55 | 55 |
56 static Frame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> data, v 8::Isolate* isolate) | 56 static Frame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> data, v 8::Isolate* isolate) |
57 { | 57 { |
58 const WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data); | 58 const WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data); |
(...skipping 18 matching lines...) Expand all Loading... | |
77 | 77 |
78 static void reportFatalErrorInMainThread(const char* location, const char* messa ge) | 78 static void reportFatalErrorInMainThread(const char* location, const char* messa ge) |
79 { | 79 { |
80 int memoryUsageMB = blink::Platform::current()->actualMemoryUsageMB(); | 80 int memoryUsageMB = blink::Platform::current()->actualMemoryUsageMB(); |
81 printf("V8 error: %s (%s). Current memory usage: %d MB\n", message, locatio n, memoryUsageMB); | 81 printf("V8 error: %s (%s). Current memory usage: %d MB\n", message, locatio n, memoryUsageMB); |
82 CRASH(); | 82 CRASH(); |
83 } | 83 } |
84 | 84 |
85 static void messageHandlerInMainThread(v8::Handle<v8::Message> message, v8::Hand le<v8::Value> data) | 85 static void messageHandlerInMainThread(v8::Handle<v8::Message> message, v8::Hand le<v8::Value> data) |
86 { | 86 { |
87 // See v8/src/isolate.c | |
88 static const char stackOverFlowMessageString[] = "Uncaught RangeError: Maxim um call stack size exceeded"; | |
haraken
2014/02/21 04:19:21
Can we share code with handleMaxRecursionDepthExec
yhirano
2014/02/21 07:32:51
Done.
| |
87 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 89 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
88 // If called during context initialization, there will be no entered context . | 90 // If called during context initialization, there will be no entered context . |
89 v8::Handle<v8::Context> enteredContext = isolate->GetEnteredContext(); | 91 v8::Handle<v8::Context> enteredContext = isolate->GetEnteredContext(); |
90 if (enteredContext.IsEmpty()) | 92 if (enteredContext.IsEmpty()) |
91 return; | 93 return; |
92 | 94 |
93 DOMWindow* enteredWindow = toDOMWindow(enteredContext); | 95 DOMWindow* enteredWindow = toDOMWindow(enteredContext); |
94 if (!enteredWindow->isCurrentlyDisplayedInFrame()) | 96 if (!enteredWindow->isCurrentlyDisplayedInFrame()) |
95 return; | 97 return; |
96 | 98 |
97 String errorMessage = toCoreString(message->Get()); | 99 String errorMessage = toCoreString(message->Get()); |
100 const bool isStackOverFlowException = errorMessage == stackOverFlowMessageSt ring; | |
98 | 101 |
99 v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace(); | 102 v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace(); |
100 RefPtr<ScriptCallStack> callStack; | 103 RefPtr<ScriptCallStack> callStack; |
104 // When the message consists of a stack over flow exception its stack trace is invalid. | |
101 // Currently stack trace is only collected when inspector is open. | 105 // Currently stack trace is only collected when inspector is open. |
102 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) | 106 if (!isStackOverFlowException && !stackTrace.IsEmpty() && stackTrace->GetFra meCount() > 0) |
103 callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallSt ackSizeToCapture, isolate); | 107 callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallSt ackSizeToCapture, isolate); |
104 | 108 |
105 v8::Handle<v8::Value> resourceName = message->GetScriptResourceName(); | 109 v8::Handle<v8::Value> resourceName = message->GetScriptResourceName(); |
106 bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsStrin g(); | 110 bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsStrin g(); |
107 String resource = shouldUseDocumentURL ? enteredWindow->document()->url() : toCoreString(resourceName.As<v8::String>()); | 111 String resource = shouldUseDocumentURL ? enteredWindow->document()->url() : toCoreString(resourceName.As<v8::String>()); |
108 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCr ossOrigin : NotSharableCrossOrigin; | 112 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCr ossOrigin : NotSharableCrossOrigin; |
109 | 113 |
110 DOMWrapperWorld* world = DOMWrapperWorld::current(isolate); | 114 DOMWrapperWorld* world = DOMWrapperWorld::current(isolate); |
111 RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, resource, messag e->GetLineNumber(), message->GetStartColumn() + 1, world); | 115 RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, resource, messag e->GetLineNumber(), message->GetStartColumn() + 1, world); |
112 if (V8DOMWrapper::isDOMWrapper(data)) { | 116 if (V8DOMWrapper::isDOMWrapper(data)) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 v8::V8::AddMessageListener(messageHandlerInWorker); | 226 v8::V8::AddMessageListener(messageHandlerInWorker); |
223 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); | 227 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); |
224 | 228 |
225 v8::ResourceConstraints resourceConstraints; | 229 v8::ResourceConstraints resourceConstraints; |
226 uint32_t here; | 230 uint32_t here; |
227 resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uin t32_t*)); | 231 resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uin t32_t*)); |
228 v8::SetResourceConstraints(isolate, &resourceConstraints); | 232 v8::SetResourceConstraints(isolate, &resourceConstraints); |
229 } | 233 } |
230 | 234 |
231 } // namespace WebCore | 235 } // namespace WebCore |
OLD | NEW |