[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

yurys at chromium.org yurys at chromium.org
Wed Dec 22 14:49:40 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 59d720a3e5180bedafa25b57c3e2d665e811dcd1
Author: yurys at chromium.org <yurys at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Oct 21 12:31:37 2010 +0000

    2010-10-21  Yury Semikhatsky  <yurys at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            Web Inspector: decouple ScriptArguments from ScriptCallStack
            https://bugs.webkit.org/show_bug.cgi?id=48058
    
            ScriptCallFrame and ScriptCallStack are now the same for both JSC and V8.
            The factory functions that allow to create ScriptCallStack from VM-specific
            objects are defined in ScriptCallStackFactory.cpp.
    
            ScriptArguments class is used for passing arguments from JS code to the native
            part.
    
            No new tests. This refactoring is covered with existing Console tests.
    
            * WebCore.gypi:
            * WebCore.xcodeproj/project.pbxproj:
            * bindings/js/ScriptCallFrame.cpp: Removed.
            * bindings/js/ScriptCallFrame.h: Removed.
            * bindings/js/ScriptCallStack.cpp: Removed.
            * bindings/js/ScriptCallStack.h: Removed.
            * bindings/js/ScriptCallStackFactory.cpp: Added.
            (WebCore::createScriptCallStack):
            (WebCore::createScriptArguments):
            (WebCore::ScriptCallStack::stackTrace):
            * bindings/js/ScriptCallStackFactory.h: Added.
            * bindings/js/ScriptState.h:
            (WebCore::ScriptStateProtectedPtr::get):
            * bindings/scripts/CodeGeneratorJS.pm:
            * bindings/scripts/CodeGeneratorV8.pm:
            * bindings/v8/ScriptCallFrame.cpp: Removed.
            * bindings/v8/ScriptCallFrame.h: Removed.
            * bindings/v8/ScriptCallStack.cpp: Removed.
            * bindings/v8/ScriptCallStack.h: Removed.
            * bindings/v8/ScriptCallStackFactory.cpp: Added.
            (WebCore::toScriptCallFrame):
            (WebCore::toScriptCallFramesVector):
            (WebCore::createScriptCallStack):
            (WebCore::createScriptArguments):
            (WebCore::ScriptCallStack::stackTrace):
            * bindings/v8/ScriptCallStackFactory.h: Added.
            * bindings/v8/ScriptController.cpp:
            (WebCore::ScriptController::setCaptureCallStackForUncaughtExceptions):
            * bindings/v8/ScriptState.h:
            (WebCore::ScriptStateProtectedPtr::get):
            * bindings/v8/V8ConsoleMessage.cpp:
            (WebCore::V8ConsoleMessage::handler):
            (WebCore::V8ConsoleMessage::dispatchNow):
            * bindings/v8/V8ConsoleMessage.h:
            * bindings/v8/custom/V8ConsoleCustom.cpp:
            (WebCore::V8Console::traceCallback):
            (WebCore::V8Console::assertCallback):
            * inspector/ConsoleMessage.cpp:
            (WebCore::ConsoleMessage::ConsoleMessage):
            (WebCore::ConsoleMessage::addToFrontend):
            (WebCore::ConsoleMessage::updateRepeatCountInConsole):
            (WebCore::ConsoleMessage::isEqual):
            * inspector/ConsoleMessage.h:
            * inspector/InspectorController.cpp:
            (WebCore::InspectorController::addMessageToConsole):
            (WebCore::InspectorController::startGroup):
            * inspector/InspectorController.h:
            * inspector/ScriptArguments.cpp: Added.
            (WebCore::ScriptArguments::ScriptArguments):
            (WebCore::ScriptArguments::~ScriptArguments):
            (WebCore::ScriptArguments::argumentAt):
            (WebCore::ScriptArguments::globalState):
            (WebCore::ScriptArguments::getFirstArgumentAsString):
            (WebCore::ScriptArguments::isEqual):
            * inspector/ScriptArguments.h: Added.
            (WebCore::ScriptArguments::argumentCount):
            * inspector/ScriptCallFrame.cpp: Added.
            (WebCore::ScriptCallFrame::ScriptCallFrame):
            (WebCore::ScriptCallFrame::~ScriptCallFrame):
            (WebCore::ScriptCallFrame::isEqual):
            (WebCore::ScriptCallFrame::buildInspectorObject):
            * inspector/ScriptCallFrame.h: Added.
            (WebCore::ScriptCallFrame::functionName):
            (WebCore::ScriptCallFrame::sourceURL):
            (WebCore::ScriptCallFrame::lineNumber):
            * inspector/ScriptCallStack.cpp: Added.
            (WebCore::ScriptCallStack::ScriptCallStack):
            (WebCore::ScriptCallStack::~ScriptCallStack):
            (WebCore::ScriptCallStack::at):
            (WebCore::ScriptCallStack::size):
            (WebCore::ScriptCallStack::isEqual):
            (WebCore::ScriptCallStack::buildInspectorObject):
            * inspector/ScriptCallStack.h: Added.
            * page/Console.cpp:
            (WebCore::Console::addMessage):
            (WebCore::Console::debug):
            (WebCore::Console::error):
            (WebCore::Console::info):
            (WebCore::Console::log):
            (WebCore::Console::dir):
            (WebCore::Console::dirxml):
            (WebCore::Console::trace):
            (WebCore::Console::assertCondition):
            (WebCore::Console::count):
            (WebCore::Console::markTimeline):
            (WebCore::Console::profile):
            (WebCore::Console::profileEnd):
            (WebCore::Console::timeEnd):
            (WebCore::Console::group):
            (WebCore::Console::groupCollapsed):
            (WebCore::Console::shouldCaptureFullStackTrace):
            (WebCore::Console::warn):
            * page/Console.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70232 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/Android.jscbindings.mk b/WebCore/Android.jscbindings.mk
index 3288059..eea3537 100644
--- a/WebCore/Android.jscbindings.mk
+++ b/WebCore/Android.jscbindings.mk
@@ -166,8 +166,7 @@ LOCAL_SRC_FILES += \
 	bindings/js/ScheduledAction.cpp \
 	bindings/js/ScriptArray.cpp \
 	bindings/js/ScriptCachedFrameData.cpp \
-	bindings/js/ScriptCallFrame.cpp \
-	bindings/js/ScriptCallStack.cpp \
+	bindings/js/ScriptCallStackFactory.cpp \
 	bindings/js/ScriptController.cpp \
 	bindings/js/ScriptEventListener.cpp \
 	bindings/js/ScriptFunctionCall.cpp \
diff --git a/WebCore/Android.v8bindings.mk b/WebCore/Android.v8bindings.mk
index fdee6fb..692b453 100644
--- a/WebCore/Android.v8bindings.mk
+++ b/WebCore/Android.v8bindings.mk
@@ -49,8 +49,7 @@ LOCAL_SRC_FILES += \
 	bindings/v8/ScheduledAction.cpp \
 	bindings/v8/ScopedDOMDataStore.cpp \
 	bindings/v8/ScriptArray.cpp \
-	bindings/v8/ScriptCallFrame.cpp \
-	bindings/v8/ScriptCallStack.cpp \
+	bindings/v8/ScriptCallStackFactory.cpp \
 	bindings/v8/ScriptController.cpp \
 	bindings/v8/ScriptEventListener.cpp \
 	bindings/v8/ScriptFunctionCall.cpp \
diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt
index 42e344a..8f5d621 100644
--- a/WebCore/CMakeLists.txt
+++ b/WebCore/CMakeLists.txt
@@ -686,8 +686,7 @@ SET(WebCore_SOURCES
     bindings/js/JSXSLTProcessorCustom.cpp
     bindings/js/ScheduledAction.cpp
     bindings/js/ScriptCachedFrameData.cpp
-    bindings/js/ScriptCallFrame.cpp
-    bindings/js/ScriptCallStack.cpp
+    bindings/js/ScriptCallStackFactory.cpp
     bindings/js/ScriptController.cpp
     bindings/js/ScriptDebugServer.cpp
     bindings/js/ScriptEventListener.cpp
@@ -1123,7 +1122,10 @@ SET(WebCore_SOURCES
     inspector/InspectorState.cpp
     inspector/InspectorStorageAgent.cpp
     inspector/InspectorTimelineAgent.cpp
+    inspector/ScriptArguments.cpp
     inspector/ScriptBreakpoint.cpp
+    inspector/ScriptCallFrame.cpp
+    inspector/ScriptCallStack.cpp
     inspector/TimelineRecordFactory.cpp
 
     loader/Cache.cpp
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ae89ee2..1370ec1 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,113 @@
+2010-10-21  Yury Semikhatsky  <yurys at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: decouple ScriptArguments from ScriptCallStack
+        https://bugs.webkit.org/show_bug.cgi?id=48058
+
+        ScriptCallFrame and ScriptCallStack are now the same for both JSC and V8.
+        The factory functions that allow to create ScriptCallStack from VM-specific
+        objects are defined in ScriptCallStackFactory.cpp.
+
+        ScriptArguments class is used for passing arguments from JS code to the native
+        part.
+
+        No new tests. This refactoring is covered with existing Console tests.
+
+        * WebCore.gypi:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/ScriptCallFrame.cpp: Removed.
+        * bindings/js/ScriptCallFrame.h: Removed.
+        * bindings/js/ScriptCallStack.cpp: Removed.
+        * bindings/js/ScriptCallStack.h: Removed.
+        * bindings/js/ScriptCallStackFactory.cpp: Added.
+        (WebCore::createScriptCallStack):
+        (WebCore::createScriptArguments):
+        (WebCore::ScriptCallStack::stackTrace):
+        * bindings/js/ScriptCallStackFactory.h: Added.
+        * bindings/js/ScriptState.h:
+        (WebCore::ScriptStateProtectedPtr::get):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        * bindings/scripts/CodeGeneratorV8.pm:
+        * bindings/v8/ScriptCallFrame.cpp: Removed.
+        * bindings/v8/ScriptCallFrame.h: Removed.
+        * bindings/v8/ScriptCallStack.cpp: Removed.
+        * bindings/v8/ScriptCallStack.h: Removed.
+        * bindings/v8/ScriptCallStackFactory.cpp: Added.
+        (WebCore::toScriptCallFrame):
+        (WebCore::toScriptCallFramesVector):
+        (WebCore::createScriptCallStack):
+        (WebCore::createScriptArguments):
+        (WebCore::ScriptCallStack::stackTrace):
+        * bindings/v8/ScriptCallStackFactory.h: Added.
+        * bindings/v8/ScriptController.cpp:
+        (WebCore::ScriptController::setCaptureCallStackForUncaughtExceptions):
+        * bindings/v8/ScriptState.h:
+        (WebCore::ScriptStateProtectedPtr::get):
+        * bindings/v8/V8ConsoleMessage.cpp:
+        (WebCore::V8ConsoleMessage::handler):
+        (WebCore::V8ConsoleMessage::dispatchNow):
+        * bindings/v8/V8ConsoleMessage.h:
+        * bindings/v8/custom/V8ConsoleCustom.cpp:
+        (WebCore::V8Console::traceCallback):
+        (WebCore::V8Console::assertCallback):
+        * inspector/ConsoleMessage.cpp:
+        (WebCore::ConsoleMessage::ConsoleMessage):
+        (WebCore::ConsoleMessage::addToFrontend):
+        (WebCore::ConsoleMessage::updateRepeatCountInConsole):
+        (WebCore::ConsoleMessage::isEqual):
+        * inspector/ConsoleMessage.h:
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::addMessageToConsole):
+        (WebCore::InspectorController::startGroup):
+        * inspector/InspectorController.h:
+        * inspector/ScriptArguments.cpp: Added.
+        (WebCore::ScriptArguments::ScriptArguments):
+        (WebCore::ScriptArguments::~ScriptArguments):
+        (WebCore::ScriptArguments::argumentAt):
+        (WebCore::ScriptArguments::globalState):
+        (WebCore::ScriptArguments::getFirstArgumentAsString):
+        (WebCore::ScriptArguments::isEqual):
+        * inspector/ScriptArguments.h: Added.
+        (WebCore::ScriptArguments::argumentCount):
+        * inspector/ScriptCallFrame.cpp: Added.
+        (WebCore::ScriptCallFrame::ScriptCallFrame):
+        (WebCore::ScriptCallFrame::~ScriptCallFrame):
+        (WebCore::ScriptCallFrame::isEqual):
+        (WebCore::ScriptCallFrame::buildInspectorObject):
+        * inspector/ScriptCallFrame.h: Added.
+        (WebCore::ScriptCallFrame::functionName):
+        (WebCore::ScriptCallFrame::sourceURL):
+        (WebCore::ScriptCallFrame::lineNumber):
+        * inspector/ScriptCallStack.cpp: Added.
+        (WebCore::ScriptCallStack::ScriptCallStack):
+        (WebCore::ScriptCallStack::~ScriptCallStack):
+        (WebCore::ScriptCallStack::at):
+        (WebCore::ScriptCallStack::size):
+        (WebCore::ScriptCallStack::isEqual):
+        (WebCore::ScriptCallStack::buildInspectorObject):
+        * inspector/ScriptCallStack.h: Added.
+        * page/Console.cpp:
+        (WebCore::Console::addMessage):
+        (WebCore::Console::debug):
+        (WebCore::Console::error):
+        (WebCore::Console::info):
+        (WebCore::Console::log):
+        (WebCore::Console::dir):
+        (WebCore::Console::dirxml):
+        (WebCore::Console::trace):
+        (WebCore::Console::assertCondition):
+        (WebCore::Console::count):
+        (WebCore::Console::markTimeline):
+        (WebCore::Console::profile):
+        (WebCore::Console::profileEnd):
+        (WebCore::Console::timeEnd):
+        (WebCore::Console::group):
+        (WebCore::Console::groupCollapsed):
+        (WebCore::Console::shouldCaptureFullStackTrace):
+        (WebCore::Console::warn):
+        * page/Console.h:
+
 2010-10-21  Pavel Feldman  <pfeldman at chromium.org>
 
         Reviewed by Yury Semikhatsky.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 1f25500..be11b79 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -816,10 +816,8 @@ webcore_sources += \
 	WebCore/bindings/js/ScheduledAction.h \
 	WebCore/bindings/js/ScriptCachedFrameData.cpp \
 	WebCore/bindings/js/ScriptCachedFrameData.h \
-	WebCore/bindings/js/ScriptCallFrame.cpp \
-	WebCore/bindings/js/ScriptCallFrame.h \
-	WebCore/bindings/js/ScriptCallStack.cpp \
-	WebCore/bindings/js/ScriptCallStack.h \
+	WebCore/bindings/js/ScriptCallStackFactory.cpp \
+	WebCore/bindings/js/ScriptCallStackFactory.h \
 	WebCore/bindings/js/ScriptController.cpp \
 	WebCore/bindings/js/ScriptController.h \
 	WebCore/bindings/js/ScriptDebugServer.cpp \
@@ -1851,8 +1849,14 @@ webcore_sources += \
 	WebCore/inspector/InspectorValues.cpp \
 	WebCore/inspector/InspectorValues.h \
 	WebCore/inspector/InspectorWorkerResource.h \
+	WebCore/inspector/ScriptArguments.cpp \
+	WebCore/inspector/ScriptArguments.h \
 	WebCore/inspector/ScriptBreakpoint.cpp \
 	WebCore/inspector/ScriptBreakpoint.h \
+	WebCore/inspector/ScriptCallFrame.cpp \
+	WebCore/inspector/ScriptCallFrame.h \
+	WebCore/inspector/ScriptCallStack.cpp \
+	WebCore/inspector/ScriptCallStack.h \
 	WebCore/inspector/ScriptDebugListener.h \
 	WebCore/inspector/ScriptGCEventListener.h \
 	WebCore/inspector/TimelineRecordFactory.cpp \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 705a430..0a78d9e 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -699,10 +699,6 @@
             'bindings/js/ScheduledAction.h',
             'bindings/js/ScriptCachedFrameData.cpp',
             'bindings/js/ScriptCachedFrameData.h',
-            'bindings/js/ScriptCallFrame.cpp',
-            'bindings/js/ScriptCallFrame.h',
-            'bindings/js/ScriptCallStack.cpp',
-            'bindings/js/ScriptCallStack.h',
             'bindings/js/ScriptController.cpp',
             'bindings/js/ScriptController.h',
             'bindings/js/ScriptControllerGtk.cpp',
@@ -869,10 +865,8 @@
             'bindings/v8/ScopedDOMDataStore.cpp',
             'bindings/v8/ScopedDOMDataStore.h',
             'bindings/v8/ScriptCachedFrameData.h',
-            'bindings/v8/ScriptCallFrame.cpp',
-            'bindings/v8/ScriptCallFrame.h',
-            'bindings/v8/ScriptCallStack.cpp',
-            'bindings/v8/ScriptCallStack.h',
+            'bindings/v8/ScriptCallStackFactory.cpp',
+            'bindings/v8/ScriptCallStackFactory.h',
             'bindings/v8/ScriptController.cpp',
             'bindings/v8/ScriptController.h',
             'bindings/v8/ScriptDebugServer.cpp',
@@ -1953,6 +1947,12 @@
             'inspector/InspectorWorkerResource.h',
             'inspector/ScriptBreakpoint.cpp',
             'inspector/ScriptBreakpoint.h',
+            'inspector/ScriptArguments.cpp',
+            'inspector/ScriptArguments.h',
+            'inspector/ScriptCallFrame.cpp',
+            'inspector/ScriptCallFrame.h',
+            'inspector/ScriptCallStack.cpp',
+            'inspector/ScriptCallStack.h',
             'inspector/ScriptDebugListener.h',
             'inspector/ScriptGCEventListener.h',
             'inspector/TimelineRecordFactory.cpp',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index b6ac4ae..9c09188 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -351,8 +351,7 @@ v8 {
         bindings/v8/ScopedDOMDataStore.cpp \
 #        bindings/v8/ScriptArray.cpp \
         bindings/v8/ScriptCachedFrameData.cpp \
-        bindings/v8/ScriptCallFrame.cpp \
-        bindings/v8/ScriptCallStack.cpp \
+        bindings/v8/ScriptCallStackFactory.cpp \
         bindings/ScriptControllerBase.cpp \
         bindings/v8/ScriptController.cpp \
         bindings/v8/ScriptEventListener.cpp \
@@ -574,8 +573,7 @@ v8 {
         bindings/js/JSPopStateEventCustom.cpp \
         bindings/js/JSWorkerContextErrorHandler.cpp \
         bindings/js/ScriptCachedFrameData.cpp \
-        bindings/js/ScriptCallFrame.cpp \
-        bindings/js/ScriptCallStack.cpp \
+        bindings/js/ScriptCallStackFactory.cpp \
         bindings/js/ScriptController.cpp \
         bindings/js/ScriptDebugServer.cpp \
         bindings/js/ScriptEventListener.cpp \
@@ -1012,7 +1010,10 @@ SOURCES += \
     inspector/InspectorStyleSheet.cpp \
     inspector/InspectorTimelineAgent.cpp \
     inspector/InspectorValues.cpp \
+    inspector/ScriptArguments.cpp \
     inspector/ScriptBreakpoint.cpp \
+    inspector/ScriptCallFrame.cpp \
+    inspector/ScriptCallStack.cpp \
     inspector/TimelineRecordFactory.cpp \
     loader/archive/ArchiveFactory.cpp \
     loader/archive/ArchiveResource.cpp \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index fd9421c..6d863c2 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -60394,7 +60394,7 @@
 					>
 				</File>
 				<File
-					RelativePath="..\bindings\js\ScriptCallFrame.cpp"
+					RelativePath="..\bindings\js\ScriptCallStackFactory.cpp"
 					>
 					<FileConfiguration
 						Name="Debug|Win32"
@@ -60446,63 +60446,7 @@
 					</FileConfiguration>
 				</File>
 				<File
-					RelativePath="..\bindings\js\ScriptCallFrame.h"
-					>
-				</File>
-				<File
-					RelativePath="..\bindings\js\ScriptCallStack.cpp"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						ExcludedFromBuild="true"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						ExcludedFromBuild="true"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Debug_Internal|Win32"
-						ExcludedFromBuild="true"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Debug_Cairo|Win32"
-						ExcludedFromBuild="true"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release_Cairo|Win32"
-						ExcludedFromBuild="true"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Debug_All|Win32"
-						ExcludedFromBuild="true"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath="..\bindings\js\ScriptCallStack.h"
+					RelativePath="..\bindings\js\ScriptCallStackFactory.h"
 					>
 				</File>
 				<File
@@ -63395,6 +63339,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\inspector\ScriptArguments.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\inspector\ScriptArguments.h"
+				>
+			</File>
+			<File
 				RelativePath="..\inspector\ScriptBreakpoint.cpp"
 				>
 			</File>
@@ -63403,6 +63355,22 @@
 				>
 			</File>
 			<File
+				RelativePath="..\inspector\ScriptCallFrame.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\inspector\ScriptCallFrame.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inspector\ScriptCallStack.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\inspector\ScriptCallStack.h"
+				>
+			</File>
+			<File
 				RelativePath="..\inspector\ScriptDebugListener.h"
 				>
 			</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 5bc440b..87d8928 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -5459,6 +5459,10 @@
 		F3644AFF1119805900E0D537 /* InjectedScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3644AFD1119805900E0D537 /* InjectedScript.cpp */; };
 		F3644B001119805900E0D537 /* InjectedScript.h in Headers */ = {isa = PBXBuildFile; fileRef = F3644AFE1119805900E0D537 /* InjectedScript.h */; };
 		F375CC071150D300008DDB81 /* InspectorWorkerResource.h in Headers */ = {isa = PBXBuildFile; fileRef = F375CC061150D300008DDB81 /* InspectorWorkerResource.h */; };
+		F392249C126F11AE00A926D9 /* ScriptCallStackFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F392249A126F11AE00A926D9 /* ScriptCallStackFactory.cpp */; };
+		F392249D126F11AE00A926D9 /* ScriptCallStackFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */; };
+		F39BE95B12673BF400E0A674 /* ScriptArguments.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F39BE95912673BF400E0A674 /* ScriptArguments.cpp */; };
+		F39BE95C12673BF400E0A674 /* ScriptArguments.h in Headers */ = {isa = PBXBuildFile; fileRef = F39BE95A12673BF400E0A674 /* ScriptArguments.h */; };
 		F3D461481161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */; };
 		F3D461491161D53200CA0D09 /* JSWorkerContextErrorHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */; };
 		F4EAF4AE10C742B1009100D3 /* OpenTypeSanitizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4EAF4AC10C742B1009100D3 /* OpenTypeSanitizer.cpp */; };
@@ -11485,6 +11489,10 @@
 		F3644AFD1119805900E0D537 /* InjectedScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedScript.cpp; sourceTree = "<group>"; };
 		F3644AFE1119805900E0D537 /* InjectedScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedScript.h; sourceTree = "<group>"; };
 		F375CC061150D300008DDB81 /* InspectorWorkerResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorWorkerResource.h; sourceTree = "<group>"; };
+		F392249A126F11AE00A926D9 /* ScriptCallStackFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptCallStackFactory.cpp; sourceTree = "<group>"; };
+		F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptCallStackFactory.h; sourceTree = "<group>"; };
+		F39BE95912673BF400E0A674 /* ScriptArguments.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptArguments.cpp; sourceTree = "<group>"; };
+		F39BE95A12673BF400E0A674 /* ScriptArguments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptArguments.h; sourceTree = "<group>"; };
 		F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerContextErrorHandler.cpp; sourceTree = "<group>"; };
 		F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWorkerContextErrorHandler.h; sourceTree = "<group>"; };
 		F4EAF4AC10C742B1009100D3 /* OpenTypeSanitizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OpenTypeSanitizer.cpp; path = opentype/OpenTypeSanitizer.cpp; sourceTree = "<group>"; };
@@ -12256,8 +12264,14 @@
 				F375CC061150D300008DDB81 /* InspectorWorkerResource.h */,
 				1C81BA050E97348300266E07 /* JavaScriptCallFrame.idl */,
 				BCC64F5F0DCFB84E0081EF3B /* localizedStrings.js */,
+				F39BE95912673BF400E0A674 /* ScriptArguments.cpp */,
+				F39BE95A12673BF400E0A674 /* ScriptArguments.h */,
 				200B190811C277D900DCCD3A /* ScriptBreakpoint.cpp */,
 				7AFD4A8A1131C2760035B883 /* ScriptBreakpoint.h */,
+				416E75CA0EDF90C700360E1D /* ScriptCallFrame.cpp */,
+				416E75C90EDF90C700360E1D /* ScriptCallFrame.h */,
+				416E75BD0EDF8FD700360E1D /* ScriptCallStack.cpp */,
+				416E75BC0EDF8FD700360E1D /* ScriptCallStack.h */,
 				7AFD4FF3113277B60035B883 /* ScriptDebugListener.h */,
 				9FA37EEF1172FD4100C4CD55 /* ScriptProfile.idl */,
 				9FA37EF01172FD4100C4CD55 /* ScriptProfileNode.idl */,
@@ -16773,10 +16787,8 @@
 				BCA378BB0D15F64200B793D6 /* ScheduledAction.h */,
 				41F1D21E0EF35C2A00DA8753 /* ScriptCachedFrameData.cpp */,
 				41F1D21D0EF35C2A00DA8753 /* ScriptCachedFrameData.h */,
-				416E75CA0EDF90C700360E1D /* ScriptCallFrame.cpp */,
-				416E75C90EDF90C700360E1D /* ScriptCallFrame.h */,
-				416E75BD0EDF8FD700360E1D /* ScriptCallStack.cpp */,
-				416E75BC0EDF8FD700360E1D /* ScriptCallStack.h */,
+				F392249A126F11AE00A926D9 /* ScriptCallStackFactory.cpp */,
+				F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */,
 				93B70D5309EB0C7C009D8468 /* ScriptController.cpp */,
 				93B70D5409EB0C7C009D8468 /* ScriptController.h */,
 				A83E1C720E49042B00140B9C /* ScriptControllerMac.mm */,
@@ -20552,6 +20564,7 @@
 				1CEFC9B90D78DC8C007D2579 /* SchedulePair.h in Headers */,
 				5162C7F511F77EFB00612EFE /* SchemeRegistry.h in Headers */,
 				BCEC01BE0C274DAC009F4EC9 /* Screen.h in Headers */,
+				F39BE95C12673BF400E0A674 /* ScriptArguments.h in Headers */,
 				A84D82C111D3474800972990 /* ScriptableDocumentParser.h in Headers */,
 				7AFD4A8B1131C2760035B883 /* ScriptBreakpoint.h in Headers */,
 				41F1D21F0EF35C2A00DA8753 /* ScriptCachedFrameData.h in Headers */,
@@ -21126,6 +21139,7 @@
 				081CDFB9126ECFDB00D215CA /* DeprecatedSVGAnimatedPropertyTraits.h in Headers */,
 				081CDFBA126ECFDB00D215CA /* DeprecatedSVGAnimatedTemplate.h in Headers */,
 				081CDFBF126ECFE800D215CA /* SVGAnimatedPropertySynchronizer.h in Headers */,
+				F392249D126F11AE00A926D9 /* ScriptCallStackFactory.h in Headers */,
 				088A0E04126EF1DB00978F7A /* SVGAnimatedListPropertyTearOff.h in Headers */,
 				088A0E05126EF1DB00978F7A /* SVGAnimatedProperty.h in Headers */,
 				088A0E06126EF1DB00978F7A /* SVGAnimatedPropertyDescription.h in Headers */,
@@ -23179,6 +23193,7 @@
 				5162C7F411F77EFB00612EFE /* SchemeRegistry.cpp in Sources */,
 				BCEC01BD0C274DAC009F4EC9 /* Screen.cpp in Sources */,
 				A84D82C211D3474800972990 /* ScriptableDocumentParser.cpp in Sources */,
+				F39BE95B12673BF400E0A674 /* ScriptArguments.cpp in Sources */,
 				200B190911C277D900DCCD3A /* ScriptBreakpoint.cpp in Sources */,
 				41F1D2200EF35C2A00DA8753 /* ScriptCachedFrameData.cpp in Sources */,
 				416E75CC0EDF90C700360E1D /* ScriptCallFrame.cpp in Sources */,
@@ -23687,6 +23702,7 @@
 				9728C3131268E4390041E89B /* MarkupAccumulator.cpp in Sources */,
 				E18772F1126E2629003DD586 /* Language.cpp in Sources */,
 				7A1F2B52126C61B20006A7E6 /* InspectorClient.cpp in Sources */,
+				F392249C126F11AE00A926D9 /* ScriptCallStackFactory.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebCore/bindings/js/JSBindingsAllInOne.cpp b/WebCore/bindings/js/JSBindingsAllInOne.cpp
index cf08ca9..e2012ce 100644
--- a/WebCore/bindings/js/JSBindingsAllInOne.cpp
+++ b/WebCore/bindings/js/JSBindingsAllInOne.cpp
@@ -141,8 +141,7 @@
 #include "MemoryInfo.cpp"
 #include "ScheduledAction.cpp"
 #include "ScriptCachedFrameData.cpp"
-#include "ScriptCallFrame.cpp"
-#include "ScriptCallStack.cpp"
+#include "ScriptCallStackFactory.cpp"
 #include "ScriptController.cpp"
 #include "ScriptControllerWin.cpp"
 #include "ScriptDebugServer.cpp"
diff --git a/WebCore/bindings/js/ScriptCallFrame.cpp b/WebCore/bindings/js/ScriptCallFrame.cpp
deleted file mode 100644
index 2f74b96..0000000
--- a/WebCore/bindings/js/ScriptCallFrame.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * 
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScriptCallFrame.h"
-
-#include <runtime/ArgList.h>
-#include <runtime/UString.h>
-
-using namespace JSC;
-
-namespace WebCore {
-
-ScriptCallFrame::ScriptCallFrame(const UString& functionName, const UString& urlString, int lineNumber, ExecState* exec, unsigned skipArgumentCount)
-    : m_functionName(ustringToString(functionName))
-    , m_sourceURL(ustringToString(urlString))
-    , m_lineNumber(lineNumber)
-{
-    if (!exec)
-        return;
-    size_t argumentCount = exec->argumentCount();
-    for (size_t i = skipArgumentCount; i < argumentCount; ++i)
-        m_arguments.append(ScriptValue(exec->argument(i)));
-}
-
-ScriptCallFrame::~ScriptCallFrame()
-{
-}
-
-const ScriptValue &ScriptCallFrame::argumentAt(unsigned index) const
-{
-    ASSERT(m_arguments.size() > index);
-    return m_arguments[index];
-}
-
-} // namespace WebCore
diff --git a/WebCore/bindings/js/ScriptCallFrame.h b/WebCore/bindings/js/ScriptCallFrame.h
deleted file mode 100644
index 31aec7e..0000000
--- a/WebCore/bindings/js/ScriptCallFrame.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * 
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScriptCallFrame_h
-#define ScriptCallFrame_h
-
-#include "PlatformString.h"
-#include "ScriptValue.h"
-#include <wtf/Vector.h>
-
-namespace JSC {
-class ExecState;
-class UString;
-}
-
-namespace WebCore {
-
-class ScriptCallFrame  {
-public:
-    ScriptCallFrame(const JSC::UString& functionName, const JSC::UString& urlString, int lineNumber, JSC::ExecState*, unsigned skipArgumentCount);
-    ~ScriptCallFrame();
-
-    const String& functionName() const { return m_functionName; }
-    const String& sourceURL() const { return m_sourceURL; }
-    unsigned lineNumber() const { return m_lineNumber; }
-
-    // argument retrieval methods
-    const ScriptValue& argumentAt(unsigned) const;
-    unsigned argumentCount() const { return m_arguments.size(); }
-
-private:
-    String m_functionName;
-    String m_sourceURL;
-    unsigned m_lineNumber;
-
-    Vector<ScriptValue> m_arguments;
-};
-
-} // namespace WebCore
-
-#endif // ScriptCallFrame_h
diff --git a/WebCore/bindings/js/ScriptCallStack.cpp b/WebCore/bindings/js/ScriptCallStack.cpp
deleted file mode 100644
index de61b07..0000000
--- a/WebCore/bindings/js/ScriptCallStack.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * 
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScriptCallStack.h"
-
-#include <interpreter/CallFrame.h>
-#include <interpreter/Interpreter.h>
-#include <runtime/JSFunction.h>
-#include <runtime/JSValue.h>
-#include <runtime/UString.h>
-#include <runtime/JSGlobalData.h>
-
-using namespace JSC;
-
-namespace WebCore {
-
-ScriptCallStack::ScriptCallStack(ExecState* exec, unsigned skipArgumentCount)
-    : m_initialized(false)
-    , m_exec(exec)
-    , m_caller(0)
-{
-    int signedLineNumber;
-    intptr_t sourceID;
-    UString urlString;
-    JSValue function;
-
-    exec->interpreter()->retrieveLastCaller(exec, signedLineNumber, sourceID, urlString, function);
-
-    unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0;
-
-    if (function) {
-        m_caller = asFunction(function);
-        m_frames.append(ScriptCallFrame(m_caller->name(m_exec), urlString, lineNumber, m_exec, skipArgumentCount));
-    } else {
-        // Caller is unknown, but we should still add the frame, because
-        // something called us, and gave us arguments.
-        m_frames.append(ScriptCallFrame(UString(), urlString, lineNumber, m_exec, skipArgumentCount));
-    }
-}
-
-ScriptCallStack::~ScriptCallStack()
-{
-}
-
-const ScriptCallFrame &ScriptCallStack::at(unsigned index)
-{
-    // First frame is pre-populated in constructor, so don't trigger
-    // initialization unless looking beyond the first frame.
-    if (index > 0)
-        initialize();
-    ASSERT(m_frames.size() > index);
-    return m_frames[index];
-}
-
-unsigned ScriptCallStack::size()
-{
-    initialize();
-    return m_frames.size();
-}
-
-void ScriptCallStack::initialize()
-{
-    if (!m_caller || m_initialized)
-        return;
-
-    int signedLineNumber;
-    intptr_t sourceID;
-    UString urlString;
-    JSValue function;
-    // callFrame must exist if m_caller is not null.
-    CallFrame* callFrame = m_exec->callerFrame();
-    while (true) {
-        ASSERT(callFrame);
-        m_exec->interpreter()->retrieveLastCaller(callFrame, signedLineNumber, sourceID, urlString, function);
-        if (!function)
-            break;
-        JSFunction* jsFunction = asFunction(function);
-        unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0;
-        m_frames.append(ScriptCallFrame(jsFunction->name(m_exec), urlString, lineNumber, m_exec, 0));
-        callFrame = callFrame->callerFrame();
-    }
-    m_initialized = true;
-}
-
-bool ScriptCallStack::stackTrace(int, const RefPtr<InspectorArray>&)
-{
-    return false;
-}
-
-} // namespace WebCore
diff --git a/WebCore/bindings/js/ScriptCallStack.h b/WebCore/bindings/js/ScriptCallStack.h
deleted file mode 100644
index 17d1c46..0000000
--- a/WebCore/bindings/js/ScriptCallStack.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * 
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScriptCallStack_h
-#define ScriptCallStack_h
-
-#include "ScriptCallFrame.h"
-#include "ScriptState.h"
-#include <wtf/Noncopyable.h>
-#include <wtf/RefPtr.h>
-
-namespace JSC {
-    class ExecState;
-    class JSValue;
-}
-
-namespace WebCore {
-
-    class InspectorArray;
-
-    class ScriptCallStack : public Noncopyable {
-    public:
-        ScriptCallStack(JSC::ExecState*, unsigned skipArgumentCount = 0);
-        ~ScriptCallStack();
-
-        ScriptState* state() const { return m_exec; }
-        ScriptState* globalState() const { return m_exec->lexicalGlobalObject()->globalExec(); }
-        // frame retrieval methods
-        const ScriptCallFrame &at(unsigned);
-        unsigned size();
-        static bool stackTrace(int, const RefPtr<InspectorArray>&);
-
-    private:
-        void initialize();
-        bool m_initialized;
-
-        JSC::ExecState* m_exec;
-        Vector<ScriptCallFrame> m_frames;
-        JSC::JSFunction* m_caller;
-    };
-
-} // namespace WebCore
-
-#endif // ScriptCallStack_h
diff --git a/WebCore/bindings/js/ScriptCallStackFactory.cpp b/WebCore/bindings/js/ScriptCallStackFactory.cpp
new file mode 100644
index 0000000..25fabdd
--- /dev/null
+++ b/WebCore/bindings/js/ScriptCallStackFactory.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2010 Google Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ScriptCallStackFactory.h"
+
+#include "JSDOMBinding.h"
+#include "ScriptArguments.h"
+#include "ScriptCallFrame.h"
+#include "ScriptCallStack.h"
+#include "ScriptValue.h"
+#include <interpreter/CallFrame.h>
+#include <interpreter/Interpreter.h>
+#include <runtime/ArgList.h>
+#include <runtime/JSFunction.h>
+#include <runtime/JSGlobalData.h>
+#include <runtime/JSValue.h>
+#include <runtime/UString.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+PassOwnPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize)
+{
+    Vector<ScriptCallFrame> frames;
+    CallFrame* callFrame = exec;
+    while (true) {
+        ASSERT(callFrame);
+        int signedLineNumber;
+        intptr_t sourceID;
+        UString urlString;
+        JSValue function;
+
+        exec->interpreter()->retrieveLastCaller(callFrame, signedLineNumber, sourceID, urlString, function);
+        UString functionName;
+        if (function)
+            functionName = asFunction(function)->name(exec);
+        else {
+            // Caller is unknown, but if frames is empty we should still add the frame, because
+            // something called us, and gave us arguments.
+            if (!frames.isEmpty())
+                break;
+        }
+        unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0;
+        frames.append(ScriptCallFrame(ustringToString(functionName), ustringToString(urlString), lineNumber));
+        if (!function || frames.size() == maxStackSize)
+            break;
+        callFrame = callFrame->callerFrame();
+    }
+    return new ScriptCallStack(frames);
+}
+
+PassOwnPtr<ScriptArguments> createScriptArguments(JSC::ExecState* exec, unsigned skipArgumentCount)
+{
+    Vector<ScriptValue> arguments;
+    size_t argumentCount = exec->argumentCount();
+    for (size_t i = skipArgumentCount; i < argumentCount; ++i)
+        arguments.append(ScriptValue(exec->argument(i)));
+    return new ScriptArguments(exec, arguments);
+}
+
+bool ScriptCallStack::stackTrace(int, const RefPtr<InspectorArray>&)
+{
+    return false;
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/js/ScriptCallStackFactory.h b/WebCore/bindings/js/ScriptCallStackFactory.h
new file mode 100644
index 0000000..744d88d
--- /dev/null
+++ b/WebCore/bindings/js/ScriptCallStackFactory.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2010 Google Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ScriptCallStackFactory_h
+#define ScriptCallStackFactory_h
+
+#include <wtf/PassOwnPtr.h>
+
+namespace JSC {
+class ExecState;
+}
+
+namespace WebCore {
+
+class ScriptArguments;
+class ScriptCallStack;
+
+PassOwnPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState*, size_t maxStackSize);
+PassOwnPtr<ScriptArguments> createScriptArguments(JSC::ExecState*, unsigned skipArgumentCount);
+
+} // namespace WebCore
+
+#endif // ScriptCallStackFactory_h
diff --git a/WebCore/bindings/js/ScriptState.h b/WebCore/bindings/js/ScriptState.h
index 6bef4f7..ce43516 100644
--- a/WebCore/bindings/js/ScriptState.h
+++ b/WebCore/bindings/js/ScriptState.h
@@ -52,7 +52,7 @@ class ScriptStateProtectedPtr : public Noncopyable {
 public:
     ScriptStateProtectedPtr() { }
     ScriptStateProtectedPtr(ScriptState* scriptState) : m_globalObject(scriptState->lexicalGlobalObject()) { }
-    ScriptState* get()
+    ScriptState* get() const
     {
         if (m_globalObject)
             return m_globalObject->globalExec();
diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm
index 0b56f13..23db957 100644
--- a/WebCore/bindings/scripts/CodeGeneratorJS.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm
@@ -1966,8 +1966,12 @@ sub GenerateImplementation
                     my $hasOptionalArguments = 0;
 
                     if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) {
-                        push(@implContent, "    ScriptCallStack callStack(exec, $numParameters);\n");
+                        push(@implContent, "    OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, $numParameters));\n");
+                        push(@implContent, "    size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;\n");
+                        push(@implContent, "    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize));\n");
+                        $implIncludes{"ScriptArguments.h"} = 1;
                         $implIncludes{"ScriptCallStack.h"} = 1;
+                        $implIncludes{"ScriptCallStackFactory.h"} = 1;
                     }
 
                     my $callWith = $function->signature->extendedAttributes->{"CallWith"};
@@ -2357,8 +2361,8 @@ sub GenerateImplementationFunctionCall()
 
     if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) {
         $functionString .= ", " if $paramIndex;
-        ++$paramIndex;
-        $functionString .= "&callStack";
+        $paramIndex += 2;
+        $functionString .= "scriptArguments.release(), callStack.release()";
     }
 
     if (@{$function->raisesExceptions}) {
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index 751e350..0c79e64 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -1304,11 +1304,15 @@ END
 
     if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) {
         push(@implContentDecls, <<END);
-    OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, $numParameters));
+    OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, $numParameters));
+    size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;
+    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(maxStackSize));
     if (!callStack)
         return v8::Undefined();
 END
+        $implIncludes{"ScriptArguments.h"} = 1;
         $implIncludes{"ScriptCallStack.h"} = 1;
+        $implIncludes{"ScriptCallStackFactory.h"} = 1;
     }
     if ($function->signature->extendedAttributes->{"SVGCheckSecurityDocument"}) {
         push(@implContentDecls, <<END);
@@ -2719,8 +2723,8 @@ sub GenerateFunctionCallString()
 
     if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) {
         $functionString .= ", " if $index;
-        $functionString .= "callStack.get()";
-        $index++;
+        $functionString .= "scriptArguments.release(), callStack.release()";
+        $index += 2;
     }
 
     if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) {
diff --git a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
index 5236267..7e06068 100644
--- a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
+++ b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
@@ -31,7 +31,9 @@
 #include "JSTestObj.h"
 #include "JSlog.h"
 #include "KURL.h"
+#include "ScriptArguments.h"
 #include "ScriptCallStack.h"
+#include "ScriptCallStackFactory.h"
 #include "SerializedScriptValue.h"
 #include "TestObj.h"
 #include <runtime/Error.h>
@@ -994,12 +996,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomArgsAndException(Ex
     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
     ExceptionCode ec = 0;
-    ScriptCallStack callStack(exec, 1);
+    OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, 1));
+    size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;
+    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize));
     log* intArg = tolog(exec->argument(0));
     if (exec->hadException())
         return JSValue::encode(jsUndefined());
 
-    imp->customArgsAndException(intArg, &callStack, ec);
+    imp->customArgsAndException(intArg, scriptArguments.release(), callStack.release(), ec);
     setDOMException(exec, ec);
     return JSValue::encode(jsUndefined());
 }
diff --git a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
index 44f0d3e..3441b73 100644
--- a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
+++ b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
@@ -26,7 +26,9 @@
 #include "IDBBindingUtilities.h"
 #include "IDBKey.h"
 #include "RuntimeEnabledFeatures.h"
+#include "ScriptArguments.h"
 #include "ScriptCallStack.h"
+#include "ScriptCallStackFactory.h"
 #include "SerializedScriptValue.h"
 #include "V8Binding.h"
 #include "V8BindingMacros.h"
@@ -705,11 +707,13 @@ static v8::Handle<v8::Value> customArgsAndExceptionCallback(const v8::Arguments&
     TestObj* imp = V8TestObj::toNative(args.Holder());
     ExceptionCode ec = 0;
     {
-    OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, 1));
+    OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 1));
+    size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;
+    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(maxStackSize));
     if (!callStack)
         return v8::Undefined();
     EXCEPTION_BLOCK(log*, intArg, V8log::HasInstance(args[0]) ? V8log::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
-    imp->customArgsAndException(intArg, callStack.get(), ec);
+    imp->customArgsAndException(intArg, scriptArguments.release(), callStack.release(), ec);
     if (UNLIKELY(ec))
         goto fail;
     return v8::Handle<v8::Value>();
diff --git a/WebCore/bindings/v8/ScriptCallFrame.cpp b/WebCore/bindings/v8/ScriptCallFrame.cpp
deleted file mode 100644
index f0c7343..0000000
--- a/WebCore/bindings/v8/ScriptCallFrame.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScriptCallFrame.h"
-
-#include <v8.h>
-
-#include "PlatformString.h"
-#include "V8Binding.h"
-#include "V8Proxy.h"
-#include "ScriptValue.h"
-
-namespace WebCore {
-
-ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber, const v8::Arguments& arguments, unsigned skipArgumentCount)
-    : m_functionName(functionName)
-    , m_sourceURL(urlString)
-    , m_lineNumber(lineNumber)
-{
-    for (int i = skipArgumentCount; i < arguments.Length(); ++i)
-        m_arguments.append(ScriptValue(arguments[i]));
-}
-
-ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber)
-    : m_functionName(functionName)
-    , m_sourceURL(urlString)
-    , m_lineNumber(lineNumber)
-{
-}
-
-ScriptCallFrame::~ScriptCallFrame()
-{
-}
-
-const ScriptValue& ScriptCallFrame::argumentAt(unsigned index) const
-{
-    ASSERT(m_arguments.size() > index);
-    return m_arguments[index];
-}
-
-} // namespace WebCore
diff --git a/WebCore/bindings/v8/ScriptCallFrame.h b/WebCore/bindings/v8/ScriptCallFrame.h
deleted file mode 100644
index ff77d4a..0000000
--- a/WebCore/bindings/v8/ScriptCallFrame.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScriptCallFrame_h
-#define ScriptCallFrame_h
-
-#include "KURL.h"
-
-#include <wtf/Vector.h>
-
-namespace v8 {
-    class Arguments;
-}
-
-namespace WebCore {
-    class ScriptValue;
-
-    // FIXME: Implement retrieving line number and source URL and storing here
-    // for all call frames, not just the first one.
-    // See <https://bugs.webkit.org/show_bug.cgi?id=22556> and
-    // <https://bugs.webkit.org/show_bug.cgi?id=21180>
-    class ScriptCallFrame  {
-    public:
-        ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber, const v8::Arguments&, unsigned skipArgumentCount);
-        ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber);
-        ~ScriptCallFrame();
-
-        const String& functionName() const { return m_functionName; }
-        const String& sourceURL() const { return m_sourceURL; }
-        unsigned lineNumber() const { return m_lineNumber; }
-
-        // argument retrieval methods
-        const ScriptValue& argumentAt(unsigned) const;
-        unsigned argumentCount() const { return m_arguments.size(); }
-
-    private:
-        String m_functionName;
-        String m_sourceURL;
-        unsigned m_lineNumber;
-
-        Vector<ScriptValue> m_arguments;
-    };
-
-} // namespace WebCore
-
-#endif // ScriptCallFrame_h
diff --git a/WebCore/bindings/v8/ScriptCallStack.cpp b/WebCore/bindings/v8/ScriptCallStack.cpp
deleted file mode 100644
index 3e29c7a..0000000
--- a/WebCore/bindings/v8/ScriptCallStack.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScriptCallStack.h"
-
-#include "InspectorValues.h"
-#include "ScriptController.h"
-#include "ScriptDebugServer.h"
-#include "ScriptScope.h"
-#include "V8Binding.h"
-
-#include <v8-debug.h>
-
-namespace WebCore {
-
-static void getFrameLocation(v8::Handle<v8::StackFrame> frame, String* sourceName, int* sourceLineNumber, String* functionName)
-{
-    ASSERT(!frame.IsEmpty());
-    v8::Local<v8::String> sourceNameValue(frame->GetScriptNameOrSourceURL());
-    v8::Local<v8::String> functionNameValue(frame->GetFunctionName());
-    *sourceName = sourceNameValue.IsEmpty() ? "" : toWebCoreString(sourceNameValue);
-    *functionName = functionNameValue.IsEmpty() ? "" : toWebCoreString(functionNameValue);
-    *sourceLineNumber = frame->GetLineNumber();
-}
-
-static void getTopFrameLocation(v8::Handle<v8::StackTrace> stackTrace, String* sourceName, int* sourceLineNumber, String* functionName)
-{
-    if (stackTrace->GetFrameCount() <= 0) {
-        // Successfully grabbed stack trace, but there are no frames. It may happen in case of a syntax error for example.
-        // Fallback to setting lineNumber to 0, and source and function name to "undefined".
-        *sourceName = "undefined";
-        *sourceLineNumber = 0;
-        *functionName = "undefined";
-    } else {
-        v8::Handle<v8::StackFrame> frame = stackTrace->GetFrame(0);
-        getFrameLocation(frame, sourceName, sourceLineNumber, functionName);
-    }
-}
-
-static PassOwnPtr<ScriptCallFrame> toScriptCallFrame(v8::Handle<v8::StackFrame> frame)
-{
-    String sourceName;
-    int sourceLineNumber;
-    String functionName;
-    getFrameLocation(frame, &sourceName, &sourceLineNumber, &functionName);
-    return new ScriptCallFrame(functionName, sourceName, sourceLineNumber);
-}
-
-static void toScriptCallFramesVector(v8::Local<v8::Context> context, v8::Handle<v8::StackTrace> stackTrace, Vector<OwnPtr<ScriptCallFrame> >& scriptCallFrames)
-{
-    v8::Context::Scope contextScope(context);
-    int frameCount = stackTrace->GetFrameCount();
-    for (int i = 0; i < frameCount; i++) {
-        v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i);
-        scriptCallFrames.append(toScriptCallFrame(stackFrame));
-    }
-}
-
-const int ScriptCallStack::maxCallStackSizeToCapture = 200;
-const v8::StackTrace::StackTraceOptions ScriptCallStack::stackTraceOptions = static_cast<v8::StackTrace::StackTraceOptions>(
-     v8::StackTrace::kLineNumber
-    | v8::StackTrace::kColumnOffset
-    | v8::StackTrace::kScriptNameOrSourceURL
-    | v8::StackTrace::kFunctionName);
-
-
-PassOwnPtr<ScriptCallStack> ScriptCallStack::create(const v8::Arguments& arguments, unsigned skipArgumentCount, int framCountLimit)
-{
-    v8::HandleScope scope;
-    v8::Local<v8::Context> context = v8::Context::GetCurrent();
-    v8::Context::Scope contextScope(context);
-    v8::Handle<v8::StackTrace> stackTrace(v8::StackTrace::CurrentStackTrace(framCountLimit, ScriptCallStack::stackTraceOptions));
-
-    if (stackTrace.IsEmpty())
-        return 0;
-
-    String sourceName;
-    int sourceLineNumber;
-    String functionName;
-    getTopFrameLocation(stackTrace, &sourceName, &sourceLineNumber, &functionName);
-
-    Vector<OwnPtr<ScriptCallFrame> > scriptCallFrames;
-    if (framCountLimit > 1)
-        toScriptCallFramesVector(context, stackTrace, scriptCallFrames);
-
-    return new ScriptCallStack(ScriptState::forContext(context), new ScriptCallFrame(functionName, sourceName, sourceLineNumber, arguments, skipArgumentCount), scriptCallFrames);
-}
-
-PassOwnPtr<ScriptCallStack> ScriptCallStack::create(ScriptState* state, v8::Handle<v8::StackTrace> stackTrace)
-{
-    v8::HandleScope scope;
-    Vector<OwnPtr<ScriptCallFrame> > scriptCallFrames;
-    toScriptCallFramesVector(state->context(), stackTrace, scriptCallFrames);
-
-    String sourceName;
-    int sourceLineNumber;
-    String functionName;
-    getTopFrameLocation(stackTrace, &sourceName, &sourceLineNumber, &functionName);
-
-    return new ScriptCallStack(state, new ScriptCallFrame(functionName, sourceName, sourceLineNumber), scriptCallFrames);
-}
-
-ScriptCallStack::ScriptCallStack(ScriptState* scriptState, PassOwnPtr<ScriptCallFrame> topFrame, Vector<OwnPtr<ScriptCallFrame> >& scriptCallFrames)
-    : m_topFrame(topFrame)
-    , m_scriptState(scriptState)
-{
-    m_scriptCallFrames.swap(scriptCallFrames);
-}
-
-ScriptCallStack::~ScriptCallStack()
-{
-}
-
-const ScriptCallFrame& ScriptCallStack::at(unsigned index)
-{
-    if (!index && m_topFrame)
-        return *m_topFrame;
-    return *m_scriptCallFrames.at(index);
-}
-
-unsigned ScriptCallStack::size()
-{
-    if (m_scriptCallFrames.isEmpty())
-        return 1;
-    return m_scriptCallFrames.size();
-}
-
-
-bool ScriptCallStack::stackTrace(int frameLimit, const RefPtr<InspectorArray>& stackTrace)
-{
-#if ENABLE(INSPECTOR)
-    if (!v8::Context::InContext())
-        return false;
-    v8::Handle<v8::Context> context = v8::Context::GetCurrent();
-    if (context.IsEmpty())
-        return false;
-    v8::HandleScope scope;
-    v8::Context::Scope contextScope(context);
-    v8::Handle<v8::StackTrace> trace(v8::StackTrace::CurrentStackTrace(frameLimit));
-    int frameCount = trace->GetFrameCount();
-    if (trace.IsEmpty() || !frameCount)
-        return false;
-    for (int i = 0; i < frameCount; ++i) {
-        v8::Handle<v8::StackFrame> frame = trace->GetFrame(i);
-        RefPtr<InspectorObject> frameObject = InspectorObject::create();
-        v8::Local<v8::String> scriptName = frame->GetScriptName();
-        frameObject->setString("scriptName", scriptName.IsEmpty() ? "" : toWebCoreString(scriptName));
-        v8::Local<v8::String> functionName = frame->GetFunctionName();
-        frameObject->setString("functionName", functionName.IsEmpty() ? "" : toWebCoreString(functionName));
-        frameObject->setNumber("lineNumber", frame->GetLineNumber());
-        frameObject->setNumber("column", frame->GetColumn());
-        stackTrace->pushObject(frameObject);
-    }
-    return true;
-#else
-    return false;
-#endif
-}
-
-} // namespace WebCore
diff --git a/WebCore/bindings/v8/ScriptCallStack.h b/WebCore/bindings/v8/ScriptCallStack.h
deleted file mode 100644
index 98e5195..0000000
--- a/WebCore/bindings/v8/ScriptCallStack.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScriptCallStack_h
-#define ScriptCallStack_h
-
-#include "ScriptCallFrame.h"
-#include "ScriptState.h"
-#include "ScriptValue.h"
-#include <wtf/Noncopyable.h>
-#include <wtf/RefPtr.h>
-
-namespace v8 {
-    class Arguments;
-}
-
-namespace WebCore {
-
-class InspectorArray;
-
-class ScriptCallStack : public Noncopyable {
-public:
-    static const int maxCallStackSizeToCapture;
-    static const v8::StackTrace::StackTraceOptions stackTraceOptions;
-
-    static PassOwnPtr<ScriptCallStack> create(const v8::Arguments&, unsigned skipArgumentCount = 0, int framCountLimit = 1);
-    static PassOwnPtr<ScriptCallStack> create(ScriptState*, v8::Handle<v8::StackTrace>);
-    ~ScriptCallStack();
-
-    // Returns false if there is no running JavaScript or if fetching the stack failed.
-    // Sets stackTrace to be an array of stack frame objects.
-    // A stack frame object looks like:
-    // {
-    //   scriptName: <file name for the associated script resource>
-    //   functionName: <name of the JavaScript function>
-    //   lineNumber: <1 based line number>
-    //   column: <1 based column offset on the line>
-    // }
-    static bool stackTrace(int frameLimit, const RefPtr<InspectorArray>& stackTrace);
-
-    const ScriptCallFrame& at(unsigned);
-    unsigned size();
-
-    ScriptState* state() const { return m_scriptState; }
-    ScriptState* globalState() const { return m_scriptState; }
-
-private:
-    ScriptCallStack(ScriptState* scriptState, PassOwnPtr<ScriptCallFrame> topFrame, Vector<OwnPtr<ScriptCallFrame> >& scriptCallFrames);
-    ScriptCallStack(ScriptState* scriptState, v8::Handle<v8::StackTrace> stackTrace);
-
-    OwnPtr<ScriptCallFrame> m_topFrame;
-    ScriptState* m_scriptState;
-    Vector<OwnPtr<ScriptCallFrame> > m_scriptCallFrames;
-};
-
-} // namespace WebCore
-
-#endif // ScriptCallStack_h
diff --git a/WebCore/bindings/v8/ScriptCallStackFactory.cpp b/WebCore/bindings/v8/ScriptCallStackFactory.cpp
new file mode 100644
index 0000000..62fbeef
--- /dev/null
+++ b/WebCore/bindings/v8/ScriptCallStackFactory.cpp
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2010 Google Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ScriptCallStackFactory.h"
+
+#include "InspectorValues.h"
+#include "ScriptArguments.h"
+#include "ScriptCallFrame.h"
+#include "ScriptCallStack.h"
+#include "ScriptScope.h"
+#include "ScriptValue.h"
+#include "V8Binding.h"
+
+#include <v8-debug.h>
+
+namespace WebCore {
+
+static ScriptCallFrame toScriptCallFrame(v8::Handle<v8::StackFrame> frame)
+{
+    String sourceName;
+    v8::Local<v8::String> sourceNameValue(frame->GetScriptNameOrSourceURL());
+    if (!sourceNameValue.IsEmpty())
+        sourceName = toWebCoreString(sourceNameValue);
+
+    String functionName;
+    v8::Local<v8::String> functionNameValue(frame->GetFunctionName());
+    if (!functionNameValue.IsEmpty())
+        functionName = toWebCoreString(functionNameValue);
+
+    int sourceLineNumber = frame->GetLineNumber();
+    return ScriptCallFrame(functionName, sourceName, sourceLineNumber);
+}
+
+static void toScriptCallFramesVector(v8::Local<v8::Context> context, v8::Handle<v8::StackTrace> stackTrace, Vector<ScriptCallFrame>& scriptCallFrames, size_t maxStackSize)
+{
+    // TODO(yurys): remove this???
+    v8::Context::Scope contextScope(context);
+    int frameCount = stackTrace->GetFrameCount();
+    if (frameCount > static_cast<int>(maxStackSize))
+        frameCount = maxStackSize;
+    for (int i = 0; i < frameCount; i++) {
+        v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i);
+        scriptCallFrames.append(toScriptCallFrame(stackFrame));
+    }
+    
+    if (!frameCount) {
+        // Successfully grabbed stack trace, but there are no frames. It may happen in case of a syntax error for example.
+        // Fallback to setting lineNumber to 0, and source and function name to "undefined".
+        scriptCallFrames.append(ScriptCallFrame("undefined", "undefined", 0));
+    }
+}
+
+PassOwnPtr<ScriptCallStack> createScriptCallStack(v8::Local<v8::Context> context, v8::Handle<v8::StackTrace> stackTrace, size_t maxStackSize)
+{
+    v8::HandleScope scope;
+    v8::Context::Scope contextScope(context);
+
+    Vector<ScriptCallFrame> scriptCallFrames;
+    toScriptCallFramesVector(context, stackTrace, scriptCallFrames, maxStackSize);
+    return new ScriptCallStack(scriptCallFrames);
+}
+
+PassOwnPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize)
+{
+    v8::HandleScope scope;
+    v8::Local<v8::Context> context = v8::Context::GetCurrent();
+    // TODO(yurys): remove?
+    v8::Context::Scope contextScope(context);
+    v8::Handle<v8::StackTrace> stackTrace(v8::StackTrace::CurrentStackTrace(maxStackSize, stackTraceOptions));
+    return createScriptCallStack(context, stackTrace, maxStackSize);
+}
+
+PassOwnPtr<ScriptArguments> createScriptArguments(const v8::Arguments& v8arguments, unsigned skipArgumentCount)
+{
+    v8::HandleScope scope;
+    v8::Local<v8::Context> context = v8::Context::GetCurrent();
+    ScriptState* state = ScriptState::forContext(context);
+
+    Vector<ScriptValue> arguments;
+    for (int i = skipArgumentCount; i < v8arguments.Length(); ++i)
+        arguments.append(ScriptValue(v8arguments[i]));
+
+    return new ScriptArguments(state, arguments);
+}
+
+bool ScriptCallStack::stackTrace(int frameLimit, const RefPtr<InspectorArray>& stackTrace)
+{
+#if ENABLE(INSPECTOR)
+    if (!v8::Context::InContext())
+        return false;
+    v8::Handle<v8::Context> context = v8::Context::GetCurrent();
+    if (context.IsEmpty())
+        return false;
+    v8::HandleScope scope;
+    v8::Context::Scope contextScope(context);
+    v8::Handle<v8::StackTrace> trace(v8::StackTrace::CurrentStackTrace(frameLimit));
+    int frameCount = trace->GetFrameCount();
+    if (trace.IsEmpty() || !frameCount)
+        return false;
+    for (int i = 0; i < frameCount; ++i) {
+        v8::Handle<v8::StackFrame> frame = trace->GetFrame(i);
+        RefPtr<InspectorObject> frameObject = InspectorObject::create();
+        v8::Local<v8::String> scriptName = frame->GetScriptName();
+        frameObject->setString("scriptName", scriptName.IsEmpty() ? "" : toWebCoreString(scriptName));
+        v8::Local<v8::String> functionName = frame->GetFunctionName();
+        frameObject->setString("functionName", functionName.IsEmpty() ? "" : toWebCoreString(functionName));
+        frameObject->setNumber("lineNumber", frame->GetLineNumber());
+        frameObject->setNumber("column", frame->GetColumn());
+        stackTrace->pushObject(frameObject);
+    }
+    return true;
+#else
+    return false;
+#endif
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/ScriptCallStackFactory.h b/WebCore/bindings/v8/ScriptCallStackFactory.h
new file mode 100644
index 0000000..613af7b
--- /dev/null
+++ b/WebCore/bindings/v8/ScriptCallStackFactory.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2010 Google Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ScriptCallStackFactory_h
+#define ScriptCallStackFactory_h
+
+#include <v8.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+
+class ScriptState;
+
+const v8::StackTrace::StackTraceOptions stackTraceOptions = static_cast<v8::StackTrace::StackTraceOptions>(
+      v8::StackTrace::kLineNumber
+    | v8::StackTrace::kColumnOffset
+    | v8::StackTrace::kScriptNameOrSourceURL
+    | v8::StackTrace::kFunctionName);
+
+class ScriptArguments;
+class ScriptCallStack;
+
+PassOwnPtr<ScriptCallStack> createScriptCallStack(v8::Local<v8::Context>, v8::Handle<v8::StackTrace>, size_t maxStackSize);
+PassOwnPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize);
+PassOwnPtr<ScriptArguments> createScriptArguments(const v8::Arguments& v8arguments, unsigned skipArgumentCount);
+
+} // namespace WebCore
+
+#endif // ScriptCallStackFactory_h
diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp
index 4904a4e..fa37c38 100644
--- a/WebCore/bindings/v8/ScriptController.cpp
+++ b/WebCore/bindings/v8/ScriptController.cpp
@@ -35,6 +35,7 @@
 #include "PlatformBridge.h"
 #include "Document.h"
 #include "ScriptCallStack.h"
+#include "ScriptCallStackFactory.h"
 #include "ScriptableDocumentParser.h"
 #include "DOMWindow.h"
 #include "Event.h"
@@ -468,7 +469,7 @@ void ScriptController::clearWindowShell(bool)
 #if ENABLE(INSPECTOR)
 void ScriptController::setCaptureCallStackForUncaughtExceptions(bool value)
 {
-    v8::V8::SetCaptureStackTraceForUncaughtExceptions(value, ScriptCallStack::maxCallStackSizeToCapture, ScriptCallStack::stackTraceOptions);
+    v8::V8::SetCaptureStackTraceForUncaughtExceptions(value, ScriptCallStack::maxCallStackSizeToCapture, stackTraceOptions);
 }
 #endif
 
diff --git a/WebCore/bindings/v8/ScriptState.h b/WebCore/bindings/v8/ScriptState.h
index ce350da..11813b0 100644
--- a/WebCore/bindings/v8/ScriptState.h
+++ b/WebCore/bindings/v8/ScriptState.h
@@ -95,7 +95,7 @@ public:
             m_context.Clear();
         }
     }
-    ScriptState* get() { return m_scriptState; }
+    ScriptState* get() const { return m_scriptState; }
 private:
     ScriptState* m_scriptState;
     v8::Persistent<v8::Context> m_context;
diff --git a/WebCore/bindings/v8/V8ConsoleMessage.cpp b/WebCore/bindings/v8/V8ConsoleMessage.cpp
index 8b6bb17..40f9a7a 100644
--- a/WebCore/bindings/v8/V8ConsoleMessage.cpp
+++ b/WebCore/bindings/v8/V8ConsoleMessage.cpp
@@ -37,6 +37,7 @@
 #include "OwnPtr.h"
 #include "Page.h"
 #include "ScriptCallStack.h"
+#include "ScriptCallStackFactory.h"
 #include "V8Binding.h"
 #include "V8Proxy.h"
 
@@ -117,18 +118,17 @@ void V8ConsoleMessage::handler(v8::Handle<v8::Message> message, v8::Handle<v8::V
     // Currently stack trace is only collected when inspector is open.
     if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) {
         v8::Local<v8::Context> context = v8::Context::GetEntered();
-        ScriptState* scriptState = ScriptState::forContext(context);
-        callStack = ScriptCallStack::create(scriptState, stackTrace);
+        callStack = createScriptCallStack(context, stackTrace, ScriptCallStack::maxCallStackSizeToCapture);
     }
 
     v8::Handle<v8::Value> resourceName = message->GetScriptResourceName();
     bool useURL = resourceName.IsEmpty() || !resourceName->IsString();
     String resourceNameString = useURL ? frame->document()->url() : toWebCoreString(resourceName);
     V8ConsoleMessage consoleMessage(errorMessage, resourceNameString, message->GetLineNumber());
-    consoleMessage.dispatchNow(page, callStack.get());
+    consoleMessage.dispatchNow(page, callStack.release());
 }
 
-void V8ConsoleMessage::dispatchNow(Page* page, ScriptCallStack* callStack)
+void V8ConsoleMessage::dispatchNow(Page* page, PassOwnPtr<ScriptCallStack> callStack)
 {
     ASSERT(page);
 
diff --git a/WebCore/bindings/v8/V8ConsoleMessage.h b/WebCore/bindings/v8/V8ConsoleMessage.h
index 387b5ee..6b892dd 100644
--- a/WebCore/bindings/v8/V8ConsoleMessage.h
+++ b/WebCore/bindings/v8/V8ConsoleMessage.h
@@ -33,6 +33,7 @@
 
 #include "PlatformString.h"
 #include <v8.h>
+#include <wtf/PassOwnPtr.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
@@ -81,7 +82,7 @@ namespace WebCore {
         const String m_sourceID;
         const unsigned m_lineNumber;
 
-        void dispatchNow(Page*, ScriptCallStack*);
+        void dispatchNow(Page*, PassOwnPtr<ScriptCallStack>);
 
         // All delayed messages are stored in this vector. If the vector
         // is 0, there are no delayed messages.
diff --git a/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp b/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
index fc83b61..e585cc8 100644
--- a/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
@@ -33,7 +33,9 @@
 #include "V8Console.h"
 
 #include "Console.h"
+#include "ScriptArguments.h"
 #include "ScriptCallStack.h"
+#include "ScriptCallStackFactory.h"
 #include "ScriptProfile.h"
 #include "V8Binding.h"
 #include "V8Proxy.h"
@@ -62,11 +64,9 @@ v8::Handle<v8::Value> V8Console::traceCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.Console.traceCallback");
     Console* imp = V8Console::toNative(args.Holder());
-    v8::HandleScope handleScope;
-    ScriptState* scriptState = ScriptState::current();
-    v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(ScriptCallStack::maxCallStackSizeToCapture, ScriptCallStack::stackTraceOptions);
-    OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(scriptState, stackTrace));
-    imp->trace(callStack.get());
+    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture));
+    OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 0));
+    imp->trace(scriptArguments.release(), callStack.release());
     return v8::Handle<v8::Value>();
 }
 
@@ -74,9 +74,10 @@ v8::Handle<v8::Value> V8Console::assertCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.Console.assertCallback");
     Console* imp = V8Console::toNative(args.Holder());
-    OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, 1, ScriptCallStack::maxCallStackSizeToCapture));
+    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture));
     bool condition = args[0]->BooleanValue();
-    imp->assertCondition(condition, callStack.get());
+    OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 1));
+    imp->assertCondition(condition, scriptArguments.release(), callStack.release());
     return v8::Handle<v8::Value>();
 }
 
diff --git a/WebCore/inspector/ConsoleMessage.cpp b/WebCore/inspector/ConsoleMessage.cpp
index 67930cd..5c0fb38 100644
--- a/WebCore/inspector/ConsoleMessage.cpp
+++ b/WebCore/inspector/ConsoleMessage.cpp
@@ -33,46 +33,14 @@
 
 #include "InjectedScript.h"
 #include "InjectedScriptHost.h"
+#include "InspectorFrontend.h"
 #include "InspectorValues.h"
+#include "ScriptArguments.h"
 #include "ScriptCallStack.h"
 #include "ScriptValue.h"
 
-#if ENABLE(INSPECTOR)
-#include "InspectorFrontend.h"
-#endif
-
 namespace WebCore {
 
-ConsoleMessage::CallFrame::CallFrame(const ScriptCallFrame& frame)
-    : m_functionName(frame.functionName())
-    , m_sourceURL(frame.sourceURL())
-    , m_lineNumber(frame.lineNumber())
-{
-}
-
-ConsoleMessage::CallFrame::CallFrame()
-    : m_lineNumber(0)
-{
-}
-
-bool ConsoleMessage::CallFrame::isEqual(const ConsoleMessage::CallFrame& o) const
-{
-    return m_functionName == o.m_functionName
-        && m_sourceURL == o.m_sourceURL
-        && m_lineNumber == o.m_lineNumber;
-}
-
-#if ENABLE(INSPECTOR)
-PassRefPtr<InspectorObject> ConsoleMessage::CallFrame::buildInspectorObject() const
-{
-    RefPtr<InspectorObject> frame = InspectorObject::create();
-    frame->setString("functionName", m_functionName);
-    frame->setString("sourceURL", m_sourceURL);
-    frame->setNumber("lineNumber", m_lineNumber);
-    return frame;
-}
-#endif
-
 ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, unsigned li, const String& u, unsigned g)
     : m_source(s)
     , m_type(t)
@@ -85,35 +53,26 @@ ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, c
 {
 }
 
-ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, ScriptCallStack* callStack, unsigned g, bool storeTrace)
+ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack, unsigned g)
     : m_source(s)
     , m_type(t)
     , m_level(l)
     , m_message(m)
-#if ENABLE(INSPECTOR)
-    , m_arguments(callStack->at(0).argumentCount())
-    , m_scriptState(callStack->globalState())
-#endif
-    , m_frames(storeTrace ? callStack->size() : 0)
+    , m_arguments(arguments)
+    , m_callStack(callStack)
     , m_groupLevel(g)
     , m_repeatCount(1)
 {
-    const ScriptCallFrame& lastCaller = callStack->at(0);
+    const ScriptCallFrame& lastCaller = m_callStack->at(0);
     m_line = lastCaller.lineNumber();
     m_url = lastCaller.sourceURL();
 
-    if (storeTrace) {
-        for (unsigned i = 0; i < callStack->size(); ++i)
-            m_frames[i] = ConsoleMessage::CallFrame(callStack->at(i));
-    }
 
-#if ENABLE(INSPECTOR)
-    for (unsigned i = 0; i < lastCaller.argumentCount(); ++i)
-        m_arguments[i] = lastCaller.argumentAt(i);
-#endif
+    bool storeTrace = (t == TraceMessageType || t == UncaughtExceptionMessageType || t == AssertMessageType);
+    if (!storeTrace)
+        m_callStack.clear();
 }
 
-#if ENABLE(INSPECTOR)
 void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHost* injectedScriptHost)
 {
     RefPtr<InspectorObject> jsonObj = InspectorObject::create();
@@ -125,12 +84,12 @@ void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHo
     jsonObj->setNumber("groupLevel", static_cast<int>(m_groupLevel));
     jsonObj->setNumber("repeatCount", static_cast<int>(m_repeatCount));
     jsonObj->setString("message", m_message);
-    if (!m_arguments.isEmpty()) {
-        InjectedScript injectedScript = injectedScriptHost->injectedScriptFor(m_scriptState.get());
+    if (m_arguments && m_arguments->argumentCount()) {
+        InjectedScript injectedScript = injectedScriptHost->injectedScriptFor(m_arguments->globalState());
         if (!injectedScript.hasNoValue()) {
             RefPtr<InspectorArray> jsonArgs = InspectorArray::create();
-            for (unsigned i = 0; i < m_arguments.size(); ++i) {
-                RefPtr<InspectorValue> inspectorValue = injectedScript.wrapForConsole(m_arguments[i]);
+            for (unsigned i = 0; i < m_arguments->argumentCount(); ++i) {
+                RefPtr<InspectorValue> inspectorValue = injectedScript.wrapForConsole(m_arguments->argumentAt(i));
                 if (!inspectorValue) {
                     ASSERT_NOT_REACHED();
                     return;
@@ -140,12 +99,8 @@ void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHo
             jsonObj->setArray("parameters", jsonArgs);
         }
     }
-    if (!m_frames.isEmpty()) {
-        RefPtr<InspectorArray> frames = InspectorArray::create();
-        for (unsigned i = 0; i < m_frames.size(); i++)
-            frames->pushObject(m_frames.at(i).buildInspectorObject());
-        jsonObj->setArray("stackTrace", frames);
-    }
+    if (m_callStack)
+        jsonObj->setArray("stackTrace", m_callStack->buildInspectorObject());
     frontend->addConsoleMessage(jsonObj);
 }
 
@@ -153,32 +108,20 @@ void ConsoleMessage::updateRepeatCountInConsole(InspectorFrontend* frontend)
 {
     frontend->updateConsoleMessageRepeatCount(m_repeatCount);
 }
-#endif // ENABLE(INSPECTOR)
 
 bool ConsoleMessage::isEqual(ConsoleMessage* msg) const
 {
-#if ENABLE(INSPECTOR)
-    if (msg->m_arguments.size() != m_arguments.size())
-        return false;
-    if (!msg->m_scriptState.get() && msg->m_arguments.size()) {
-        ASSERT_NOT_REACHED();
-        return false;
-    }
-
-    for (size_t i = 0; i < m_arguments.size(); ++i) {
-        if (!m_arguments[i].isEqual(msg->m_scriptState.get(), msg->m_arguments[i]))
+    if (m_arguments) {
+        if (!m_arguments->isEqual(msg->m_arguments.get()))
             return false;
-    }
-#endif // ENABLE(INSPECTOR)
-
-    size_t frameCount = msg->m_frames.size();
-    if (frameCount != m_frames.size())
+    } else if (msg->m_arguments)
         return false;
 
-    for (size_t i = 0; i < frameCount; ++i) {
-        if (!m_frames[i].isEqual(msg->m_frames[i]))
+    if (m_callStack) {
+        if (!m_callStack->isEqual(msg->m_callStack.get()))
             return false;
-    }
+    } else if (msg->m_callStack)
+        return false;
 
     return msg->m_source == m_source
         && msg->m_type == m_type
diff --git a/WebCore/inspector/ConsoleMessage.h b/WebCore/inspector/ConsoleMessage.h
index 6c3f2c7..23720bf 100644
--- a/WebCore/inspector/ConsoleMessage.h
+++ b/WebCore/inspector/ConsoleMessage.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Matt Lilek <webkit at mattlilek.com>
- * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2009, 2010 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -32,7 +32,6 @@
 #define ConsoleMessage_h
 
 #include "Console.h"
-#include "KURL.h"
 #include "ScriptState.h"
 
 #include <wtf/Vector.h>
@@ -41,6 +40,7 @@ namespace WebCore {
 class InjectedScriptHost;
 class InspectorFrontend;
 class InspectorObject;
+class ScriptArguments;
 class ScriptCallFrame;
 class ScriptCallStack;
 class ScriptValue;
@@ -48,12 +48,10 @@ class ScriptValue;
 class ConsoleMessage : public Noncopyable {
 public:
     ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, unsigned li, const String& u, unsigned g);
-    ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, ScriptCallStack*, unsigned g, bool storeTrace = false);
+    ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>, unsigned g);
 
-#if ENABLE(INSPECTOR)
     void addToFrontend(InspectorFrontend*, InjectedScriptHost*);
     void updateRepeatCountInConsole(InspectorFrontend* frontend);
-#endif
     void incrementCount() { ++m_repeatCount; }
     bool isEqual(ConsoleMessage* msg) const;
 
@@ -61,30 +59,12 @@ public:
     const String& message() const { return m_message; }
 
 private:
-    class CallFrame {
-    public:
-        explicit CallFrame(const ScriptCallFrame& frame);
-        CallFrame();
-        bool isEqual(const CallFrame& o) const;
-#if ENABLE(INSPECTOR)
-        PassRefPtr<InspectorObject> buildInspectorObject() const;
-#endif
-
-    private:
-        String m_functionName;
-        String m_sourceURL;
-        unsigned m_lineNumber;
-    };
-
     MessageSource m_source;
     MessageType m_type;
     MessageLevel m_level;
     String m_message;
-#if ENABLE(INSPECTOR)
-    Vector<ScriptValue> m_arguments;
-    ScriptStateProtectedPtr m_scriptState;
-#endif
-    Vector<CallFrame> m_frames;
+    OwnPtr<ScriptArguments> m_arguments;
+    OwnPtr<ScriptCallStack> m_callStack;
     unsigned m_line;
     String m_url;
     unsigned m_groupLevel;
diff --git a/WebCore/inspector/InspectorController.cpp b/WebCore/inspector/InspectorController.cpp
index f99d487..b195c38 100644
--- a/WebCore/inspector/InspectorController.cpp
+++ b/WebCore/inspector/InspectorController.cpp
@@ -82,6 +82,7 @@
 #include "RenderInline.h"
 #include "ResourceRequest.h"
 #include "ResourceResponse.h"
+#include "ScriptArguments.h"
 #include "ScriptCallStack.h"
 #include "ScriptFunctionCall.h"
 #include "ScriptObject.h"
@@ -339,13 +340,12 @@ void InspectorController::setConsoleMessagesEnabled(bool enabled)
         m_consoleMessages[i]->addToFrontend(m_frontend.get(), m_injectedScriptHost.get());
 }
 
-void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, ScriptCallStack* callStack, const String& message)
+void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
     if (!enabled())
         return;
 
-    bool storeStackTrace = type == TraceMessageType || type == UncaughtExceptionMessageType || type == AssertMessageType;
-    addConsoleMessage(new ConsoleMessage(source, type, level, message, callStack, m_groupLevel, storeStackTrace));
+    addConsoleMessage(new ConsoleMessage(source, type, level, message, arguments, callStack, m_groupLevel));
 }
 
 void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceID)
@@ -391,11 +391,11 @@ void InspectorController::clearConsoleMessages()
         m_frontend->consoleMessagesCleared();
 }
 
-void InspectorController::startGroup(MessageSource source, ScriptCallStack* callStack, bool collapsed)
+void InspectorController::startGroup(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack, bool collapsed)
 {
     ++m_groupLevel;
 
-    addConsoleMessage(new ConsoleMessage(source, collapsed ? StartGroupCollapsedMessageType : StartGroupMessageType, LogMessageLevel, String(), callStack, m_groupLevel));
+    addConsoleMessage(new ConsoleMessage(JSMessageSource, collapsed ? StartGroupCollapsedMessageType : StartGroupMessageType, LogMessageLevel, "", arguments, callStack, m_groupLevel));
 }
 
 void InspectorController::endGroup(MessageSource source, unsigned lineNumber, const String& sourceURL)
diff --git a/WebCore/inspector/InspectorController.h b/WebCore/inspector/InspectorController.h
index 6d4d9e0..68aa147 100644
--- a/WebCore/inspector/InspectorController.h
+++ b/WebCore/inspector/InspectorController.h
@@ -81,6 +81,7 @@ class Page;
 class ResourceRequest;
 class ResourceResponse;
 class ResourceError;
+class ScriptArguments;
 class ScriptCallStack;
 class ScriptProfile;
 class SharedBuffer;
@@ -145,8 +146,8 @@ public:
     void disconnectFrontend();
 
     void setConsoleMessagesEnabled(bool enabled, bool* newState);
-    void addMessageToConsole(MessageSource, MessageType, MessageLevel, ScriptCallStack*, const String& message);
-    void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID);
+    void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>);
+    void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String&);
     void clearConsoleMessages();
     const Vector<OwnPtr<ConsoleMessage> >& consoleMessages() const { return m_consoleMessages; }
 
@@ -232,7 +233,7 @@ public:
     void startTiming(const String& title);
     bool stopTiming(const String& title, double& elapsed);
 
-    void startGroup(MessageSource source, ScriptCallStack* callFrame, bool collapsed = false);
+    void startGroup(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack> callFrame, bool collapsed = false);
     void endGroup(MessageSource source, unsigned lineNumber, const String& sourceURL);
 
     void markTimeline(const String& message);
diff --git a/WebCore/inspector/ScriptArguments.cpp b/WebCore/inspector/ScriptArguments.cpp
new file mode 100644
index 0000000..e30e135
--- /dev/null
+++ b/WebCore/inspector/ScriptArguments.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2010 Google Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ScriptArguments.h"
+
+#include "ScriptValue.h"
+
+namespace WebCore {
+
+ScriptArguments::ScriptArguments(ScriptState* scriptState, Vector<ScriptValue>& arguments)
+    : m_scriptState(scriptState)
+{
+    m_arguments.swap(arguments);
+}
+
+ScriptArguments::~ScriptArguments()
+{
+}
+
+const ScriptValue &ScriptArguments::argumentAt(size_t index) const
+{
+    ASSERT(m_arguments.size() > index);
+    return m_arguments[index];
+}
+
+ScriptState* ScriptArguments::globalState() const
+{
+    return m_scriptState.get();
+}
+
+bool ScriptArguments::getFirstArgumentAsString(String& result, bool checkForNullOrUndefined)
+{
+    if (!argumentCount())
+        return false;
+
+    const ScriptValue& value = argumentAt(0);
+    if (checkForNullOrUndefined && (value.isNull() || value.isUndefined()))
+        return false;
+
+    if (!globalState()) {
+        ASSERT_NOT_REACHED();
+        return false;
+    }
+
+    result = value.toString(globalState());
+    return true;
+}
+
+bool ScriptArguments::isEqual(ScriptArguments* other) const
+{
+    if (!other)
+        return false;
+
+    if (m_arguments.size() != other->m_arguments.size())
+        return false;
+    if (!globalState() && m_arguments.size())
+        return false;
+
+    for (size_t i = 0; i < m_arguments.size(); ++i) {
+        if (!m_arguments[i].isEqual(other->globalState(), other->m_arguments[i]))
+            return false;
+    }
+    return true;
+}
+
+} // namespace WebCore
diff --git a/WebCore/inspector/ScriptArguments.h b/WebCore/inspector/ScriptArguments.h
new file mode 100644
index 0000000..fdf05ab
--- /dev/null
+++ b/WebCore/inspector/ScriptArguments.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2010 Google Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ScriptArguments_h
+#define ScriptArguments_h
+
+#include "PlatformString.h"
+#include "ScriptState.h"
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class ScriptValue;
+
+class ScriptArguments {
+public:
+    ScriptArguments(ScriptState*, Vector<ScriptValue>& arguments);
+    ~ScriptArguments();
+
+    const ScriptValue& argumentAt(size_t) const;
+    size_t argumentCount() const { return m_arguments.size(); }
+
+    ScriptState* globalState() const;
+
+    bool getFirstArgumentAsString(WTF::String& result, bool checkForNullOrUndefined = false);
+    bool isEqual(ScriptArguments*) const;
+
+private:
+    ScriptStateProtectedPtr m_scriptState;
+    Vector<ScriptValue> m_arguments;
+};
+
+} // namespace WebCore
+
+#endif // ScriptArguments_h
diff --git a/WebCore/inspector/ScriptCallFrame.cpp b/WebCore/inspector/ScriptCallFrame.cpp
new file mode 100644
index 0000000..5455d25
--- /dev/null
+++ b/WebCore/inspector/ScriptCallFrame.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2010 Google Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ScriptCallFrame.h"
+
+#include "InspectorValues.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, unsigned lineNumber)
+    : m_functionName(functionName)
+    , m_sourceURL(urlString)
+    , m_lineNumber(lineNumber)
+{
+}
+
+ScriptCallFrame::~ScriptCallFrame()
+{
+}
+
+bool ScriptCallFrame::isEqual(const ScriptCallFrame& o) const
+{
+    return m_functionName == o.m_functionName
+        && m_sourceURL == o.m_sourceURL
+        && m_lineNumber == o.m_lineNumber;
+}
+
+PassRefPtr<InspectorObject> ScriptCallFrame::buildInspectorObject() const
+{
+    RefPtr<InspectorObject> frame = InspectorObject::create();
+    frame->setString("functionName", m_functionName);
+    frame->setString("sourceURL", m_sourceURL);
+    frame->setNumber("lineNumber", m_lineNumber);
+    return frame;
+}
+
+} // namespace WebCore
diff --git a/WebCore/inspector/ScriptCallFrame.h b/WebCore/inspector/ScriptCallFrame.h
new file mode 100644
index 0000000..60d77e1
--- /dev/null
+++ b/WebCore/inspector/ScriptCallFrame.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2010 Google Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ScriptCallFrame_h
+#define ScriptCallFrame_h
+
+#include "PlatformString.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+class InspectorObject;
+
+class ScriptCallFrame  {
+public:
+    ScriptCallFrame(const String& functionName, const String& urlString, unsigned lineNumber);
+    ~ScriptCallFrame();
+
+    const String& functionName() const { return m_functionName; }
+    const String& sourceURL() const { return m_sourceURL; }
+    unsigned lineNumber() const { return m_lineNumber; }
+
+    bool isEqual(const ScriptCallFrame&) const;
+    PassRefPtr<InspectorObject> buildInspectorObject() const;
+
+private:
+    String m_functionName;
+    String m_sourceURL;
+    unsigned m_lineNumber;
+};
+
+} // namespace WebCore
+
+#endif // ScriptCallFrame_h
diff --git a/WebCore/inspector/ScriptCallStack.cpp b/WebCore/inspector/ScriptCallStack.cpp
new file mode 100644
index 0000000..8d010bb
--- /dev/null
+++ b/WebCore/inspector/ScriptCallStack.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2008, Google Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ScriptCallStack.h"
+
+#include "InspectorValues.h"
+
+namespace WebCore {
+
+ScriptCallStack::ScriptCallStack(Vector<ScriptCallFrame>& frames)
+{
+    m_frames.swap(frames);
+}
+
+ScriptCallStack::~ScriptCallStack()
+{
+}
+
+const ScriptCallFrame &ScriptCallStack::at(size_t index)
+{
+    ASSERT(m_frames.size() > index);
+    return m_frames[index];
+}
+
+size_t ScriptCallStack::size()
+{
+    return m_frames.size();
+}
+
+bool ScriptCallStack::isEqual(ScriptCallStack* o) const
+{
+    if (!o)
+        return false;
+
+    size_t frameCount = o->m_frames.size();
+    if (frameCount != m_frames.size())
+        return false;
+
+    for (size_t i = 0; i < frameCount; ++i) {
+        if (!m_frames[i].isEqual(o->m_frames[i]))
+            return false;
+    }
+
+    return true;
+}
+
+PassRefPtr<InspectorArray> ScriptCallStack::buildInspectorObject() const
+{
+    RefPtr<InspectorArray> frames = InspectorArray::create();
+    for (size_t i = 0; i < m_frames.size(); i++)
+        frames->pushObject(m_frames.at(i).buildInspectorObject());
+    return frames;
+}
+
+} // namespace WebCore
diff --git a/WebCore/inspector/ScriptCallStack.h b/WebCore/inspector/ScriptCallStack.h
new file mode 100644
index 0000000..54c6bba
--- /dev/null
+++ b/WebCore/inspector/ScriptCallStack.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2008, 2010 Google Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ScriptCallStack_h
+#define ScriptCallStack_h
+
+#include "ScriptCallFrame.h"
+#include <wtf/Noncopyable.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class InspectorArray;
+
+class ScriptCallStack : public Noncopyable {
+public:
+    static const size_t maxCallStackSizeToCapture = 200;
+
+    ScriptCallStack(Vector<ScriptCallFrame>&);
+    ~ScriptCallStack();
+
+    const ScriptCallFrame &at(size_t);
+    size_t size();
+    static bool stackTrace(int, const RefPtr<InspectorArray>&);
+
+    bool isEqual(ScriptCallStack*) const;
+    PassRefPtr<InspectorArray> buildInspectorObject() const;
+
+private:
+    Vector<ScriptCallFrame> m_frames;
+};
+
+} // namespace WebCore
+
+#endif // ScriptCallStack_h
diff --git a/WebCore/page/Console.cpp b/WebCore/page/Console.cpp
index 2d4cc98..7dd85a6 100644
--- a/WebCore/page/Console.cpp
+++ b/WebCore/page/Console.cpp
@@ -41,6 +41,7 @@
 #include "PageGroup.h"
 #include "PlatformString.h"
 
+#include "ScriptArguments.h"
 #include "ScriptCallStack.h"
 #include "ScriptProfile.h"
 #include "ScriptProfiler.h"
@@ -77,19 +78,6 @@ static void printSourceURLAndLine(const String& sourceURL, unsigned lineNumber)
     }
 }
 
-static bool getFirstArgumentAsString(ScriptState* scriptState, const ScriptCallFrame& callFrame, String& result, bool checkForNullOrUndefined = false)
-{
-    if (!callFrame.argumentCount())
-        return false;
-
-    const ScriptValue& value = callFrame.argumentAt(0);
-    if (checkForNullOrUndefined && (value.isNull() || value.isUndefined()))
-        return false;
-
-    result = value.toString(scriptState);
-    return true;
-}
-
 static void printMessageSourceAndLevelPrefix(MessageSource source, MessageLevel level)
 {
     const char* sourceString;
@@ -144,7 +132,12 @@ static void printMessageSourceAndLevelPrefix(MessageSource source, MessageLevel
     printf("%s %s:", sourceString, levelString);
 }
 
-void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, ScriptCallStack* callStack)
+void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL)
+{
+    addMessage(source, type, level, message, lineNumber, sourceURL, 0);
+}
+
+void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, PassOwnPtr<ScriptCallStack> callStack)
 {
     Page* page = this->page();
     if (!page)
@@ -155,7 +148,7 @@ void Console::addMessage(MessageSource source, MessageType type, MessageLevel le
 
 #if ENABLE(INSPECTOR)
     if (callStack)
-        page->inspectorController()->addMessageToConsole(source, type, level, callStack, message);
+        page->inspectorController()->addMessageToConsole(source, type, level, message, 0, callStack);
     else
         page->inspectorController()->addMessageToConsole(source, type, level, message, lineNumber, sourceURL);
 #endif
@@ -169,7 +162,7 @@ void Console::addMessage(MessageSource source, MessageType type, MessageLevel le
     printf(" %s\n", message.utf8().data());
 }
 
-void Console::addMessage(MessageType type, MessageLevel level, ScriptCallStack* callStack, bool acceptNoArguments)
+void Console::addMessage(MessageType type, MessageLevel level, PassOwnPtr<ScriptArguments> arguments,  PassOwnPtr<ScriptCallStack> callStack, bool acceptNoArguments)
 {
     Page* page = this->page();
     if (!page)
@@ -177,15 +170,15 @@ void Console::addMessage(MessageType type, MessageLevel level, ScriptCallStack*
 
     const ScriptCallFrame& lastCaller = callStack->at(0);
 
-    if (!acceptNoArguments && !lastCaller.argumentCount())
+    if (!acceptNoArguments && !arguments->argumentCount())
         return;
 
     String message;
-    if (getFirstArgumentAsString(callStack->state(), lastCaller, message))
+    if (arguments->getFirstArgumentAsString(message))
         page->chrome()->client()->addMessageToConsole(JSMessageSource, type, level, message, lastCaller.lineNumber(), lastCaller.sourceURL());
 
 #if ENABLE(INSPECTOR)
-    page->inspectorController()->addMessageToConsole(JSMessageSource, type, level, callStack, message);
+    page->inspectorController()->addMessageToConsole(JSMessageSource, type, level, "", arguments, callStack);
 #endif
 
     if (!Console::shouldPrintExceptions())
@@ -194,49 +187,49 @@ void Console::addMessage(MessageType type, MessageLevel level, ScriptCallStack*
     printSourceURLAndLine(lastCaller.sourceURL(), 0);
     printMessageSourceAndLevelPrefix(JSMessageSource, level);
 
-    for (unsigned i = 0; i < lastCaller.argumentCount(); ++i) {
+    for (unsigned i = 0; i < arguments->argumentCount(); ++i) {
         String argAsString;
-        if (lastCaller.argumentAt(i).getString(callStack->state(), argAsString))
+        if (arguments->argumentAt(i).getString(arguments->globalState(), argAsString))
             printf(" %s", argAsString.utf8().data());
     }
     printf("\n");
 }
 
-void Console::debug(ScriptCallStack* callStack)
+void Console::debug(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
     // In Firebug, console.debug has the same behavior as console.log. So we'll do the same.
-    log(callStack);
+    log(arguments, callStack);
 }
 
-void Console::error(ScriptCallStack* callStack)
+void Console::error(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
-    addMessage(LogMessageType, ErrorMessageLevel, callStack);
+    addMessage(LogMessageType, ErrorMessageLevel, arguments, callStack);
 }
 
-void Console::info(ScriptCallStack* callStack)
+void Console::info(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
-    log(callStack);
+    log(arguments, callStack);
 }
 
-void Console::log(ScriptCallStack* callStack)
+void Console::log(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
-    addMessage(LogMessageType, LogMessageLevel, callStack);
+    addMessage(LogMessageType, LogMessageLevel, arguments, callStack);
 }
 
-void Console::dir(ScriptCallStack* callStack)
+void Console::dir(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
-    addMessage(ObjectMessageType, LogMessageLevel, callStack);
+    addMessage(ObjectMessageType, LogMessageLevel, arguments, callStack);
 }
 
-void Console::dirxml(ScriptCallStack* callStack)
+void Console::dirxml(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
     // The standard behavior of our console.log will print the DOM tree for nodes.
-    log(callStack);
+    log(arguments, callStack);
 }
 
-void Console::trace(ScriptCallStack* callStack)
+void Console::trace(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
-    addMessage(TraceMessageType, LogMessageLevel, callStack, true);
+    addMessage(TraceMessageType, LogMessageLevel, arguments, callStack, true);
 
     if (!shouldPrintExceptions())
         return;
@@ -248,15 +241,15 @@ void Console::trace(ScriptCallStack* callStack)
     }
 }
 
-void Console::assertCondition(bool condition, ScriptCallStack* callStack)
+void Console::assertCondition(bool condition, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
     if (condition)
         return;
 
-    addMessage(AssertMessageType, ErrorMessageLevel, callStack, true);
+    addMessage(AssertMessageType, ErrorMessageLevel, arguments, callStack, true);
 }
 
-void Console::count(ScriptCallStack* callStack)
+void Console::count(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
 #if ENABLE(INSPECTOR)
     Page* page = this->page();
@@ -267,7 +260,7 @@ void Console::count(ScriptCallStack* callStack)
     // Follow Firebug's behavior of counting with null and undefined title in
     // the same bucket as no argument
     String title;
-    getFirstArgumentAsString(callStack->state(), lastCaller, title);
+    arguments->getFirstArgumentAsString(title);
 
     page->inspectorController()->count(title, lastCaller.lineNumber(), lastCaller.sourceURL());
 #else
@@ -275,20 +268,19 @@ void Console::count(ScriptCallStack* callStack)
 #endif
 }
 
-void Console::markTimeline(ScriptCallStack* callStack)
+void Console::markTimeline(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>)
 {
 #if ENABLE(INSPECTOR)
     Page* page = this->page();
     if (!page)
         return;
 
-    const ScriptCallFrame& lastCaller = callStack->at(0);
     String message;
-    getFirstArgumentAsString(callStack->state(), lastCaller, message);
+    arguments->getFirstArgumentAsString(message);
 
     page->inspectorController()->markTimeline(message);
 #else
-    UNUSED_PARAM(callStack);
+    UNUSED_PARAM(arguments);
 #endif
 }
 
@@ -321,7 +313,7 @@ String Console::lastWMLErrorMessage() const
 
 #if ENABLE(JAVASCRIPT_DEBUGGER)
 
-void Console::profile(const String& title, ScriptCallStack* callStack)
+void Console::profile(const String& title, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
     Page* page = this->page();
     if (!page)
@@ -342,7 +334,7 @@ void Console::profile(const String& title, ScriptCallStack* callStack)
         resolvedTitle = "";
 #endif
 
-    ScriptProfiler::start(callStack->state(), resolvedTitle);
+    ScriptProfiler::start(arguments->globalState(), resolvedTitle);
 
 #if ENABLE(INSPECTOR)
     const ScriptCallFrame& lastCaller = callStack->at(0);
@@ -350,7 +342,7 @@ void Console::profile(const String& title, ScriptCallStack* callStack)
 #endif
 }
 
-void Console::profileEnd(const String& title, ScriptCallStack* callStack)
+void Console::profileEnd(const String& title, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
     Page* page = this->page();
     if (!page)
@@ -362,7 +354,7 @@ void Console::profileEnd(const String& title, ScriptCallStack* callStack)
         return;
 #endif
 
-    RefPtr<ScriptProfile> profile = ScriptProfiler::stop(callStack->state(), title);
+    RefPtr<ScriptProfile> profile = ScriptProfiler::stop(arguments->globalState(), title);
     if (!profile)
         return;
 
@@ -394,7 +386,7 @@ void Console::time(const String& title)
 #endif
 }
 
-void Console::timeEnd(const String& title, ScriptCallStack* callStack)
+void Console::timeEnd(const String& title, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack> callStack)
 {
 #if ENABLE(INSPECTOR)
     Page* page = this->page();
@@ -420,28 +412,30 @@ void Console::timeEnd(const String& title, ScriptCallStack* callStack)
 #endif
 }
 
-void Console::group(ScriptCallStack* callStack)
+void Console::group(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
 #if ENABLE(INSPECTOR)
     Page* page = this->page();
     if (!page)
         return;
 
-    page->inspectorController()->startGroup(JSMessageSource, callStack);
+    page->inspectorController()->startGroup(arguments, callStack);
 #else
+    UNUSED_PARAM(arguments);
     UNUSED_PARAM(callStack);
 #endif
 }
 
-void Console::groupCollapsed(ScriptCallStack* callStack)
+void Console::groupCollapsed(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
 #if ENABLE(INSPECTOR)
     Page* page = this->page();
     if (!page)
         return;
 
-    page->inspectorController()->startGroup(JSMessageSource, callStack, true);
+    page->inspectorController()->startGroup(arguments, callStack, true);
 #else
+    UNUSED_PARAM(arguments);
     UNUSED_PARAM(callStack);
 #endif
 }
@@ -457,9 +451,22 @@ void Console::groupEnd()
 #endif
 }
 
-void Console::warn(ScriptCallStack* callStack)
+bool Console::shouldCaptureFullStackTrace() const
+{
+#if ENABLE(INSPECTOR)
+    Page* page = this->page();
+    if (!page)
+        return false;
+
+    return page->inspectorController()->hasFrontend();
+#else
+    return false;
+#endif
+}
+
+void Console::warn(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
-    addMessage(LogMessageType, WarningMessageLevel, callStack);
+    addMessage(LogMessageType, WarningMessageLevel, arguments, callStack);
 }
 
 MemoryInfo* Console::memory() const
diff --git a/WebCore/page/Console.h b/WebCore/page/Console.h
index ab62525..9a48fb6 100644
--- a/WebCore/page/Console.h
+++ b/WebCore/page/Console.h
@@ -39,6 +39,8 @@
 
 namespace WebCore {
 
+class ScriptArguments;
+
 #if ENABLE(JAVASCRIPT_DEBUGGER)
 typedef Vector<RefPtr<ScriptProfile> > ProfilesArray;
 #endif
@@ -83,32 +85,35 @@ public:
     Frame* frame() const;
     void disconnectFrame();
 
-    void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, ScriptCallStack* callStack = 0);
-
-    void debug(ScriptCallStack*);
-    void error(ScriptCallStack*);
-    void info(ScriptCallStack*);
-    void log(ScriptCallStack*);
-    void warn(ScriptCallStack*);
-    void dir(ScriptCallStack*);
-    void dirxml(ScriptCallStack*);
-    void trace(ScriptCallStack*);
-    void assertCondition(bool condition, ScriptCallStack*);
-    void count(ScriptCallStack*);
-    void markTimeline(ScriptCallStack*);
+    void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL);
+    void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, PassOwnPtr<ScriptCallStack> callStack);
+
+    void debug(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void error(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void info(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void log(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void warn(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void dir(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void dirxml(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void trace(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void assertCondition(bool condition, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void count(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void markTimeline(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
 #if ENABLE(WML)
     String lastWMLErrorMessage() const;
 #endif
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-    void profile(const String&, ScriptCallStack*);
-    void profileEnd(const String&, ScriptCallStack*);
+    void profile(const String&, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void profileEnd(const String&, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
 #endif
     void time(const String&);
-    void timeEnd(const String&, ScriptCallStack*);
-    void group(ScriptCallStack*);
-    void groupCollapsed(ScriptCallStack*);
+    void timeEnd(const String&, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void group(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void groupCollapsed(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
     void groupEnd();
 
+    bool shouldCaptureFullStackTrace() const;
+
     static bool shouldPrintExceptions();
     static void setShouldPrintExceptions(bool);
 
@@ -120,7 +125,7 @@ public:
 
 private:
     inline Page* page() const;
-    void addMessage(MessageType, MessageLevel, ScriptCallStack*, bool acceptNoArguments = false);
+    void addMessage(MessageType, MessageLevel, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>, bool acceptNoArguments = false);
 
     Console(Frame*);
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list