Reviewers: Mads Ager,
Message:
Hi Mads,
The WebKit change to cache ScriptData landed earlier today (r48975) and
showed a
~7% win on the morejs page cycler:
http://build.chromium.org/buildbot/perf/xp-release-dual-core/morejs/report.html?history=500&rev=-1
Unfortunately, I introduced a bug and it had to be rolled back (r48995).
The bug
turned out to be due to my conversion of the source code to UTF8 in webkit.
It
crashed on scripts with non-ascii characters.
One fix is for me to pass the same Handle<String> that is passed to
Compile() to
PreCompile(). It should also be more efficient. What do you think about this
solution?
If this looks good to you, I'll add unittests.
Thanks,
Tony
Description:
Add an overloaded PreCompile method that takes a Handle<String>.x
Please review this at http://codereview.chromium.org/2633004/show
SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/
Affected files:
M include/v8.h
M src/api.cc
Index: include/v8.h
===================================================================
--- include/v8.h (revision 4802)
+++ include/v8.h (working copy)
@@ -513,6 +513,7 @@
class V8EXPORT ScriptData { // NOLINT
public:
virtual ~ScriptData() { }
+
/**
* Pre-compiles the specified script (context-independent).
*
@@ -522,6 +523,13 @@
static ScriptData* PreCompile(const char* input, int length);
/**
+ * Pre-compiles the specified script (context-independent).
+ *
+ * \param source Script source code.
+ */
+ static ScriptData* PreCompile(Handle<String> source);
+
+ /**
* Load previous pre-compilation data.
*
* \param data Pointer to data returned by a call to Data() of a previous
Index: src/api.cc
===================================================================
--- src/api.cc (revision 4802)
+++ src/api.cc (working copy)
@@ -1120,6 +1120,12 @@
}
+ScriptData* ScriptData::PreCompile(v8::Handle<String> source) {
+ i::Handle<i::String> str = Utils::OpenHandle(*source);
+ return i::PreParse(str, NULL, NULL);
+}
+
+
ScriptData* ScriptData::New(const char* data, int length) {
// Return an empty ScriptData if the length is obviously invalid.
if (length % sizeof(unsigned) != 0) {
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev