Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Side by Side Diff: include/v8.h

Issue 545203003: Revert "Add script streaming API." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « BUILD.gn ('k') | src/api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** \mainpage V8 API Reference Guide 5 /** \mainpage V8 API Reference Guide
6 * 6 *
7 * V8 is Google's open source JavaScript engine. 7 * V8 is Google's open source JavaScript engine.
8 * 8 *
9 * This set of documents provides reference material generated from the 9 * This set of documents provides reference material generated from the
10 * V8 header file, include/v8.h. 10 * V8 header file, include/v8.h.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 class CallHandlerHelper; 123 class CallHandlerHelper;
124 class EscapableHandleScope; 124 class EscapableHandleScope;
125 template<typename T> class ReturnValue; 125 template<typename T> class ReturnValue;
126 126
127 namespace internal { 127 namespace internal {
128 class Arguments; 128 class Arguments;
129 class Heap; 129 class Heap;
130 class HeapObject; 130 class HeapObject;
131 class Isolate; 131 class Isolate;
132 class Object; 132 class Object;
133 struct StreamedSource;
134 template<typename T> class CustomArguments; 133 template<typename T> class CustomArguments;
135 class PropertyCallbackArguments; 134 class PropertyCallbackArguments;
136 class FunctionCallbackArguments; 135 class FunctionCallbackArguments;
137 class GlobalHandles; 136 class GlobalHandles;
138 } 137 }
139 138
140 139
141 /** 140 /**
142 * General purpose unique identifier. 141 * General purpose unique identifier.
143 */ 142 */
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 Handle<Integer> resource_line_offset; 1081 Handle<Integer> resource_line_offset;
1083 Handle<Integer> resource_column_offset; 1082 Handle<Integer> resource_column_offset;
1084 Handle<Boolean> resource_is_shared_cross_origin; 1083 Handle<Boolean> resource_is_shared_cross_origin;
1085 1084
1086 // Cached data from previous compilation (if a kConsume*Cache flag is 1085 // Cached data from previous compilation (if a kConsume*Cache flag is
1087 // set), or hold newly generated cache data (kProduce*Cache flags) are 1086 // set), or hold newly generated cache data (kProduce*Cache flags) are
1088 // set when calling a compile method. 1087 // set when calling a compile method.
1089 CachedData* cached_data; 1088 CachedData* cached_data;
1090 }; 1089 };
1091 1090
1092 /**
1093 * For streaming incomplete script data to V8. The embedder should implement a
1094 * subclass of this class.
1095 */
1096 class ExternalSourceStream {
1097 public:
1098 virtual ~ExternalSourceStream() {}
1099
1100 /**
1101 * V8 calls this to request the next chunk of data from the embedder. This
1102 * function will be called on a background thread, so it's OK to block and
1103 * wait for the data, if the embedder doesn't have data yet. Returns the
1104 * length of the data returned. When the data ends, GetMoreData should
1105 * return 0. Caller takes ownership of the data.
1106 *
1107 * When streaming UTF-8 data, V8 handles multi-byte characters split between
1108 * two data chunks, but doesn't handle multi-byte characters split between
1109 * more than two data chunks. The embedder can avoid this problem by always
1110 * returning at least 2 bytes of data.
1111 *
1112 * If the embedder wants to cancel the streaming, they should make the next
1113 * GetMoreData call return 0. V8 will interpret it as end of data (and most
1114 * probably, parsing will fail). The streaming task will return as soon as
1115 * V8 has parsed the data it received so far.
1116 */
1117 virtual size_t GetMoreData(const uint8_t** src) = 0;
1118 };
1119
1120
1121 /**
1122 * Source code which can be streamed into V8 in pieces. It will be parsed
1123 * while streaming. It can be compiled after the streaming is complete.
1124 * StreamedSource must be kept alive while the streaming task is ran (see
1125 * ScriptStreamingTask below).
1126 */
1127 class V8_EXPORT StreamedSource {
1128 public:
1129 enum Encoding { ONE_BYTE, TWO_BYTE, UTF8 };
1130
1131 StreamedSource(ExternalSourceStream* source_stream, Encoding encoding);
1132 ~StreamedSource();
1133
1134 // Ownership of the CachedData or its buffers is *not* transferred to the
1135 // caller. The CachedData object is alive as long as the StreamedSource
1136 // object is alive.
1137 const CachedData* GetCachedData() const;
1138
1139 internal::StreamedSource* impl() const { return impl_; }
1140
1141 private:
1142 // Prevent copying. Not implemented.
1143 StreamedSource(const StreamedSource&);
1144 StreamedSource& operator=(const StreamedSource&);
1145
1146 internal::StreamedSource* impl_;
1147 };
1148
1149 /**
1150 * A streaming task which the embedder must run on a background thread to
1151 * stream scripts into V8. Returned by ScriptCompiler::StartStreamingScript.
1152 */
1153 class ScriptStreamingTask {
1154 public:
1155 virtual ~ScriptStreamingTask() {}
1156 virtual void Run() = 0;
1157 };
1158
1159 enum CompileOptions { 1091 enum CompileOptions {
1160 kNoCompileOptions = 0, 1092 kNoCompileOptions = 0,
1161 kProduceParserCache, 1093 kProduceParserCache,
1162 kConsumeParserCache, 1094 kConsumeParserCache,
1163 kProduceCodeCache, 1095 kProduceCodeCache,
1164 kConsumeCodeCache, 1096 kConsumeCodeCache,
1165 1097
1166 // Support the previous API for a transition period. 1098 // Support the previous API for a transition period.
1167 kProduceDataToCache 1099 kProduceDataToCache
1168 }; 1100 };
(...skipping 22 matching lines...) Expand all
1191 * \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile() 1123 * \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile()
1192 * using pre_data speeds compilation if it's done multiple times. 1124 * using pre_data speeds compilation if it's done multiple times.
1193 * Owned by caller, no references are kept when this function returns. 1125 * Owned by caller, no references are kept when this function returns.
1194 * \return Compiled script object, bound to the context that was active 1126 * \return Compiled script object, bound to the context that was active
1195 * when this function was called. When run it will always use this 1127 * when this function was called. When run it will always use this
1196 * context. 1128 * context.
1197 */ 1129 */
1198 static Local<Script> Compile( 1130 static Local<Script> Compile(
1199 Isolate* isolate, Source* source, 1131 Isolate* isolate, Source* source,
1200 CompileOptions options = kNoCompileOptions); 1132 CompileOptions options = kNoCompileOptions);
1201
1202 /**
1203 * Returns a task which streams script data into V8, or NULL if the script
1204 * cannot be streamed. The user is responsible for running the task on a
1205 * background thread and deleting it. When ran, the task starts parsing the
1206 * script, and it will request data from the StreamedSource as needed. When
1207 * ScriptStreamingTask::Run exits, all data has been streamed and the script
1208 * can be compiled (see Compile below).
1209 *
1210 * This API allows to start the streaming with as little data as possible, and
1211 * the remaining data (for example, the ScriptOrigin) is passed to Compile.
1212 */
1213 static ScriptStreamingTask* StartStreamingScript(
1214 Isolate* isolate, StreamedSource* source,
1215 CompileOptions options = kNoCompileOptions);
1216
1217 /**
1218 * Compiles a streamed script (bound to current context).
1219 *
1220 * This can only be called after the streaming has finished
1221 * (ScriptStreamingTask has been run). V8 doesn't construct the source string
1222 * during streaming, so the embedder needs to pass the full source here.
1223 */
1224 static Local<Script> Compile(Isolate* isolate, StreamedSource* source,
1225 Handle<String> full_source_string,
1226 const ScriptOrigin& origin);
1227 }; 1133 };
1228 1134
1229 1135
1230 /** 1136 /**
1231 * An error message. 1137 * An error message.
1232 */ 1138 */
1233 class V8_EXPORT Message { 1139 class V8_EXPORT Message {
1234 public: 1140 public:
1235 Local<String> Get() const; 1141 Local<String> Get() const;
1236 Local<String> GetSourceLine() const; 1142 Local<String> GetSourceLine() const;
(...skipping 5689 matching lines...) Expand 10 before | Expand all | Expand 10 after
6926 */ 6832 */
6927 6833
6928 6834
6929 } // namespace v8 6835 } // namespace v8
6930 6836
6931 6837
6932 #undef TYPE_CHECK 6838 #undef TYPE_CHECK
6933 6839
6934 6840
6935 #endif // V8_H_ 6841 #endif // V8_H_
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698