diff options
author | dglazkov@google.com <dglazkov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-12 23:46:31 +0000 |
---|---|---|
committer | dglazkov@google.com <dglazkov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-12 23:46:31 +0000 |
commit | 6892170a2019fee4d7379327da4e4ca3810352db (patch) | |
tree | 2489887817f3f6109eea470f16fb8871acdd9918 /webkit/port/bindings | |
parent | 6abfeeb39355769268e42ab2d41eab2d11208091 (diff) | |
download | chromium_src-6892170a2019fee4d7379327da4e4ca3810352db.zip chromium_src-6892170a2019fee4d7379327da4e4ca3810352db.tar.gz chromium_src-6892170a2019fee4d7379327da4e4ca3810352db.tar.bz2 |
Merge 39141:39143: The ScriptCallStack (2/2)
Review URL: http://codereview.chromium.org/14092
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6956 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port/bindings')
-rw-r--r-- | webkit/port/bindings/scripts/CodeGeneratorV8.pm | 15 | ||||
-rw-r--r-- | webkit/port/bindings/v8/ScriptCallFrame.cpp | 65 | ||||
-rw-r--r-- | webkit/port/bindings/v8/ScriptCallFrame.h | 75 | ||||
-rw-r--r-- | webkit/port/bindings/v8/ScriptCallStack.cpp | 60 | ||||
-rw-r--r-- | webkit/port/bindings/v8/ScriptCallStack.h | 59 | ||||
-rw-r--r-- | webkit/port/bindings/v8/ScriptString.h | 1 | ||||
-rw-r--r-- | webkit/port/bindings/v8/ScriptValue.h | 10 | ||||
-rw-r--r-- | webkit/port/bindings/v8/v8_custom.cpp | 103 | ||||
-rw-r--r-- | webkit/port/bindings/v8/v8_custom.h | 16 |
9 files changed, 285 insertions, 119 deletions
diff --git a/webkit/port/bindings/scripts/CodeGeneratorV8.pm b/webkit/port/bindings/scripts/CodeGeneratorV8.pm index 72d5a80..b128c8a 100644 --- a/webkit/port/bindings/scripts/CodeGeneratorV8.pm +++ b/webkit/port/bindings/scripts/CodeGeneratorV8.pm @@ -793,6 +793,11 @@ END push(@implContentDecls, " ExceptionCode ec = 0;\n"); } + if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { + push(@implContentDecls, " ScriptCallStack callStack(args, $numParameters);\n"); + $implIncludes{"ScriptCallStack.h"} = 1; + } + my $paramIndex = 0; foreach my $parameter (@{$function->parameters}) { my $parameterName = $parameter->name; @@ -1340,6 +1345,10 @@ sub GenerateFunctionCallString() if ($function->signature->extendedAttributes->{"v8implname"}) { $name = $function->signature->extendedAttributes->{"v8implname"}; } + + if ($function->signature->extendedAttributes->{"ImplementationFunction"}) { + $name = $function->signature->extendedAttributes->{"ImplementationFunction"}; + } my $functionString = "imp->${name}("; @@ -1385,6 +1394,12 @@ sub GenerateFunctionCallString() } $index++; } + + if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { + $functionString .= ", " if not $first; + $functionString .= "&callStack"; + if ($first) { $first = 0; } + } if (@{$function->raisesExceptions}) { $functionString .= ", " if not $first; diff --git a/webkit/port/bindings/v8/ScriptCallFrame.cpp b/webkit/port/bindings/v8/ScriptCallFrame.cpp new file mode 100644 index 0000000..bfcdd37 --- /dev/null +++ b/webkit/port/bindings/v8/ScriptCallFrame.cpp @@ -0,0 +1,65 @@ +// 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 "PlatformString.h" +#include "v8.h" +#include "v8_binding.h" +#include "v8_proxy.h" +#include "ScriptValue.h" + +namespace WebCore { + + ScriptCallFrame::ScriptCallFrame(const String& functionName, + const String& urlString, + int lineNumber, + const v8::Arguments& arguments, + unsigned int skipArgumentCount) + : m_functionName(functionName) + , m_sourceURL(urlString) + , m_lineNumber(lineNumber) + { + for (int i = 0; i < arguments.Length(); ++i) { + m_arguments.append(ScriptValue(arguments[i])); + } + } + + ScriptCallFrame::~ScriptCallFrame() + { + } + + const ScriptValue& ScriptCallFrame::argumentAt(unsigned index) const + { + ASSERT(m_arguments.size() > index); + return m_arguments[index]; + } + +} // namespace WebCore diff --git a/webkit/port/bindings/v8/ScriptCallFrame.h b/webkit/port/bindings/v8/ScriptCallFrame.h new file mode 100644 index 0000000..bf6f1a7 --- /dev/null +++ b/webkit/port/bindings/v8/ScriptCallFrame.h @@ -0,0 +1,75 @@ +// 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 "KURL.h" +#include <wtf/Vector.h> +#include "ScriptString.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 ScriptString& functionName() const { return m_functionName; } + const KURL& 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: + ScriptString m_functionName; + KURL m_sourceURL; + unsigned m_lineNumber; + + Vector<ScriptValue> m_arguments; + }; + +} // namespace WebCore + +#endif // ScriptCallFrame_h diff --git a/webkit/port/bindings/v8/ScriptCallStack.cpp b/webkit/port/bindings/v8/ScriptCallStack.cpp new file mode 100644 index 0000000..0ebb912 --- /dev/null +++ b/webkit/port/bindings/v8/ScriptCallStack.cpp @@ -0,0 +1,60 @@ +// 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 "v8.h" +#include "v8_binding.h" +#include "v8_proxy.h" + +namespace WebCore { + +ScriptCallStack::ScriptCallStack(const v8::Arguments& arguments, + unsigned skipArgumentCount) + : m_lastCaller(String(), V8Proxy::GetSourceName(), + V8Proxy::GetSourceLineNumber() + 1, arguments, + skipArgumentCount) +{ +} + +ScriptCallStack::~ScriptCallStack() +{ +} + +const ScriptCallFrame& ScriptCallStack::at(unsigned index) const +{ + // Currently, only one ScriptCallFrame is supported. When we can get + // a full stack trace from V8, we can do this right. + ASSERT(index == 0); + + return m_lastCaller; +} + +} // namespace WebCore diff --git a/webkit/port/bindings/v8/ScriptCallStack.h b/webkit/port/bindings/v8/ScriptCallStack.h new file mode 100644 index 0000000..d3cfe04 --- /dev/null +++ b/webkit/port/bindings/v8/ScriptCallStack.h @@ -0,0 +1,59 @@ +// 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 "ScriptValue.h" +#include <wtf/Noncopyable.h> + +namespace v8 { + class Arguments; +} + +namespace WebCore { + + class ScriptCallStack : public Noncopyable { + public: + ScriptCallStack(const v8::Arguments&, unsigned skipArgumentCount = 0); + ~ScriptCallStack(); + + // frame retrieval methods + const ScriptCallFrame &at(unsigned) const; + // TODO(dglazkov): implement retrieving and storing call stack trace + unsigned size() const { return 1; } + + private: + ScriptCallFrame m_lastCaller; + }; + +} // namespace WebCore + +#endif // ScriptCallStack_h diff --git a/webkit/port/bindings/v8/ScriptString.h b/webkit/port/bindings/v8/ScriptString.h index fd379e3..e6eb036 100644 --- a/webkit/port/bindings/v8/ScriptString.h +++ b/webkit/port/bindings/v8/ScriptString.h @@ -37,6 +37,7 @@ namespace WebCore { class ScriptString { public: + ScriptString(const String& s) : m_str(s) {} ScriptString(const char* s) : m_str(s) {} operator String() const { return m_str; } diff --git a/webkit/port/bindings/v8/ScriptValue.h b/webkit/port/bindings/v8/ScriptValue.h index 5106cb4..ff3556f 100644 --- a/webkit/port/bindings/v8/ScriptValue.h +++ b/webkit/port/bindings/v8/ScriptValue.h @@ -92,6 +92,16 @@ public: return !operator==(value); } + bool isNull() const + { + return m_value->IsNull(); + } + + bool isUndefined() const + { + return m_value->IsUndefined(); + } + void clear() { if (!m_value.IsEmpty()) { #ifndef NDEBUG diff --git a/webkit/port/bindings/v8/v8_custom.cpp b/webkit/port/bindings/v8/v8_custom.cpp index da488ba..e4ae777 100644 --- a/webkit/port/bindings/v8/v8_custom.cpp +++ b/webkit/port/bindings/v8/v8_custom.cpp @@ -100,7 +100,6 @@ #include "RenderPartObject.h" #include "RenderWidget.h" #include "ScheduledAction.h" -#include "ScriptCallContext.h" #include "ScriptState.h" #include "ScriptController.h" #include "SecurityOrigin.h" @@ -2296,108 +2295,6 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DPutImageData) { } -// Console --------------------------------------------------------------------- - -CALLBACK_FUNC_DECL(ConsoleAssert) { - INC_STATS("DOM.Console.assert()"); - V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); - return v8::Undefined(); -} - -CALLBACK_FUNC_DECL(ConsoleCount) { - INC_STATS("DOM.Console.count()"); - V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); - return v8::Undefined(); -} - -CALLBACK_FUNC_DECL(ConsoleDebug) { - INC_STATS("DOM.Console.debug()"); - V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); - return v8::Undefined(); -} - -CALLBACK_FUNC_DECL(ConsoleDir) { - INC_STATS("DOM.Console.dir()"); - V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); - return v8::Undefined(); -} - -CALLBACK_FUNC_DECL(ConsoleError) { - INC_STATS("DOM.Console.error()"); - v8::Handle<v8::Value> holder = args.Holder(); - Console* imp = V8Proxy::ToNativeObject<Console>(V8ClassIndex::CONSOLE, holder); - ScriptCallContext context(args); - imp->error(&context); - return v8::Undefined(); -} - -CALLBACK_FUNC_DECL(ConsoleGroup) { - INC_STATS("DOM.Console.group()"); - v8::Handle<v8::Value> holder = args.Holder(); - Console* imp = V8Proxy::ToNativeObject<Console>(V8ClassIndex::CONSOLE, holder); - ScriptCallContext context(args); - imp->group(&context); - return v8::Undefined(); -} - -CALLBACK_FUNC_DECL(ConsoleInfo) { - INC_STATS("DOM.Console.info()"); - v8::Handle<v8::Value> holder = args.Holder(); - Console* imp = V8Proxy::ToNativeObject<Console>(V8ClassIndex::CONSOLE, holder); - ScriptCallContext context(args); - imp->info(&context); - return v8::Undefined(); -} - -CALLBACK_FUNC_DECL(ConsoleLog) { - INC_STATS("DOM.Console.log()"); - v8::Handle<v8::Value> holder = args.Holder(); - Console* imp = V8Proxy::ToNativeObject<Console>(V8ClassIndex::CONSOLE, holder); - ScriptCallContext context(args); - imp->log(&context); - return v8::Undefined(); -} - -CALLBACK_FUNC_DECL(ConsoleProfile) { - INC_STATS("DOM.Console.profile()"); - V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); - return v8::Undefined(); -} - -CALLBACK_FUNC_DECL(ConsoleProfileEnd) { - INC_STATS("DOM.Console.profileEnd()"); - V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); - return v8::Undefined(); -} - -CALLBACK_FUNC_DECL(ConsoleTimeEnd) { - INC_STATS("DOM.Console.timeEnd()"); - V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); - return v8::Undefined(); -} - -CALLBACK_FUNC_DECL(ConsoleWarn) { - INC_STATS("DOM.Console.warn()"); - v8::Handle<v8::Value> holder = args.Holder(); - Console* imp = V8Proxy::ToNativeObject<Console>(V8ClassIndex::CONSOLE, holder); - ScriptCallContext context(args); - imp->warn(&context); - return v8::Undefined(); -} - -CALLBACK_FUNC_DECL(ConsoleDirxml) { - INC_STATS("DOM.Console.dirxml()"); - V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); - return v8::Undefined(); -} - -CALLBACK_FUNC_DECL(ConsoleTrace) { - INC_STATS("DOM.Console.trace()"); - V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); - return v8::Undefined(); -} - - // Clipboard ------------------------------------------------------------------- diff --git a/webkit/port/bindings/v8/v8_custom.h b/webkit/port/bindings/v8/v8_custom.h index 08ea4bc..ce7bd03 100644 --- a/webkit/port/bindings/v8/v8_custom.h +++ b/webkit/port/bindings/v8/v8_custom.h @@ -267,22 +267,6 @@ DECLARE_CALLBACK(CanvasRenderingContext2DFillText) DECLARE_CALLBACK(CanvasRenderingContext2DStrokeText) DECLARE_CALLBACK(CanvasRenderingContext2DPutImageData) -// Console customized functions -DECLARE_CALLBACK(ConsoleAssert) -DECLARE_CALLBACK(ConsoleCount) -DECLARE_CALLBACK(ConsoleDebug) -DECLARE_CALLBACK(ConsoleDir) -DECLARE_CALLBACK(ConsoleError) -DECLARE_CALLBACK(ConsoleGroup) -DECLARE_CALLBACK(ConsoleInfo) -DECLARE_CALLBACK(ConsoleLog) -DECLARE_CALLBACK(ConsoleProfile) -DECLARE_CALLBACK(ConsoleProfileEnd) -DECLARE_CALLBACK(ConsoleTimeEnd) -DECLARE_CALLBACK(ConsoleWarn) -DECLARE_CALLBACK(ConsoleDirxml) -DECLARE_CALLBACK(ConsoleTrace) - // Implementation of Clipboard attributes and methods. DECLARE_PROPERTY_ACCESSOR_GETTER(ClipboardTypes) DECLARE_CALLBACK(ClipboardClearData) |