From 6923d84785569a944ab3cf32daf42a05a2588ca4 Mon Sep 17 00:00:00 2001 From: "marja@chromium.org" Date: Fri, 14 Mar 2014 10:20:33 +0000 Subject: [PATCH] New Compilation API, part 1, try 2 - Distinguish between context bound scripts (Script) and context unbound scripts (UnboundScript). - Add ScriptCompiler (which will later contain functions for async compilation). This is a breaking change, in particular, Script::New no longer exists (it is replaced by ScriptCompiler::CompileUnbound). Script::Compile remains as a backwards-compatible shorthand for ScriptCompiler::Compile. Passing CompilerOptions with produce_data_to_cache = true doesn't do anything yet; the only way to generate the data to cache is the old preparsing API. (To be fixed in the next version.) This is a fixed version of https://codereview.chromium.org/186723005/ BUG= R=dcarney@chromium.org Review URL: https://codereview.chromium.org/199063003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19925 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- include/v8.h | 184 ++++++++++++++-------- samples/lineprocessor.cc | 3 +- samples/shell.cc | 3 +- src/api.cc | 321 ++++++++++++++++++++++----------------- src/api.h | 3 +- src/d8.cc | 14 +- src/heap.cc | 2 +- src/profile-generator-inl.h | 2 +- test/cctest/cctest.h | 49 ++++-- test/cctest/test-api.cc | 46 ++++-- test/cctest/test-cpu-profiler.cc | 16 +- test/cctest/test-debug.cc | 37 +++-- test/cctest/test-log.cc | 4 +- test/cctest/test-parsing.cc | 19 ++- 14 files changed, 427 insertions(+), 276 deletions(-) diff --git a/include/v8.h b/include/v8.h index 9bda3dc..fdaa2a2 100644 --- a/include/v8.h +++ b/include/v8.h @@ -108,6 +108,7 @@ class ObjectTemplate; class Platform; class Primitive; class RawOperationDescriptor; +class Script; class Signature; class StackFrame; class StackTrace; @@ -1146,95 +1147,156 @@ class ScriptOrigin { /** - * A compiled JavaScript script. + * A compiled JavaScript script, not yet tied to a Context. */ -class V8_EXPORT Script { +class V8_EXPORT UnboundScript { public: /** - * Compiles the specified script (context-independent). - * - * \param source Script source code. - * \param origin Script origin, owned by caller, no references are kept - * when New() returns - * \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile() - * using pre_data speeds compilation if it's done multiple times. - * Owned by caller, no references are kept when New() returns. - * \return Compiled script object (context independent; when run it - * will use the currently entered context). + * Binds the script to the currently entered context. */ - static Local