OLD | NEW |
---|---|
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 6223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6234 /** | 6234 /** |
6235 * Returns the number of wrappers that are still to be traced by the embedder. | 6235 * Returns the number of wrappers that are still to be traced by the embedder. |
6236 */ | 6236 */ |
6237 virtual size_t NumberOfWrappersToTrace() { return 0; } | 6237 virtual size_t NumberOfWrappersToTrace() { return 0; } |
6238 | 6238 |
6239 protected: | 6239 protected: |
6240 virtual ~EmbedderHeapTracer() = default; | 6240 virtual ~EmbedderHeapTracer() = default; |
6241 }; | 6241 }; |
6242 | 6242 |
6243 /** | 6243 /** |
6244 * Callback to the embedder used in SnapshotCreator to handle internal fields. | |
6245 */ | |
6246 typedef StartupData (*SerializeInternalFieldsCallback)(Local<Object> holder, | |
6247 int index); | |
jochen (gone - plz use gerrit)
2016/10/27 12:40:51
size_t ?
Yang
2016/10/27 12:49:27
v8::Object::SetInternalField uses int, so I'd like
| |
6248 | |
6249 /** | |
6250 * Callback to the embedder used to deserialize internal fields. | |
6251 */ | |
6252 typedef void (*DeserializeInternalFieldsCallback)(Local<Object> holder, | |
6253 int index, | |
6254 StartupData payload); | |
6255 | |
6256 /** | |
6244 * Isolate represents an isolated instance of the V8 engine. V8 isolates have | 6257 * Isolate represents an isolated instance of the V8 engine. V8 isolates have |
6245 * completely separate states. Objects from one isolate must not be used in | 6258 * completely separate states. Objects from one isolate must not be used in |
6246 * other isolates. The embedder can create multiple isolates and use them in | 6259 * other isolates. The embedder can create multiple isolates and use them in |
6247 * parallel in multiple threads. An isolate can be entered by at most one | 6260 * parallel in multiple threads. An isolate can be entered by at most one |
6248 * thread at any given time. The Locker/Unlocker API must be used to | 6261 * thread at any given time. The Locker/Unlocker API must be used to |
6249 * synchronize. | 6262 * synchronize. |
6250 */ | 6263 */ |
6251 class V8_EXPORT Isolate { | 6264 class V8_EXPORT Isolate { |
6252 public: | 6265 public: |
6253 /** | 6266 /** |
6254 * Initial configuration parameters for a new Isolate. | 6267 * Initial configuration parameters for a new Isolate. |
6255 */ | 6268 */ |
6256 struct CreateParams { | 6269 struct CreateParams { |
6257 CreateParams() | 6270 CreateParams() |
6258 : entry_hook(nullptr), | 6271 : entry_hook(nullptr), |
6259 code_event_handler(nullptr), | 6272 code_event_handler(nullptr), |
6260 snapshot_blob(nullptr), | 6273 snapshot_blob(nullptr), |
6261 counter_lookup_callback(nullptr), | 6274 counter_lookup_callback(nullptr), |
6262 create_histogram_callback(nullptr), | 6275 create_histogram_callback(nullptr), |
6263 add_histogram_sample_callback(nullptr), | 6276 add_histogram_sample_callback(nullptr), |
6264 array_buffer_allocator(nullptr), | 6277 array_buffer_allocator(nullptr), |
6265 external_references(nullptr) {} | 6278 external_references(nullptr), |
6279 deserialize_internal_fields_callback(nullptr) {} | |
6266 | 6280 |
6267 /** | 6281 /** |
6268 * The optional entry_hook allows the host application to provide the | 6282 * The optional entry_hook allows the host application to provide the |
6269 * address of a function that's invoked on entry to every V8-generated | 6283 * address of a function that's invoked on entry to every V8-generated |
6270 * function. Note that entry_hook is invoked at the very start of each | 6284 * function. Note that entry_hook is invoked at the very start of each |
6271 * generated function. Furthermore, if an entry_hook is given, V8 will | 6285 * generated function. Furthermore, if an entry_hook is given, V8 will |
6272 * not use a snapshot, including custom snapshots. | 6286 * not use a snapshot, including custom snapshots. |
6273 */ | 6287 */ |
6274 FunctionEntryHook entry_hook; | 6288 FunctionEntryHook entry_hook; |
6275 | 6289 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6311 */ | 6325 */ |
6312 ArrayBuffer::Allocator* array_buffer_allocator; | 6326 ArrayBuffer::Allocator* array_buffer_allocator; |
6313 | 6327 |
6314 /** | 6328 /** |
6315 * Specifies an optional nullptr-terminated array of raw addresses in the | 6329 * Specifies an optional nullptr-terminated array of raw addresses in the |
6316 * embedder that V8 can match against during serialization and use for | 6330 * embedder that V8 can match against during serialization and use for |
6317 * deserialization. This array and its content must stay valid for the | 6331 * deserialization. This array and its content must stay valid for the |
6318 * entire lifetime of the isolate. | 6332 * entire lifetime of the isolate. |
6319 */ | 6333 */ |
6320 intptr_t* external_references; | 6334 intptr_t* external_references; |
6335 | |
6336 /** | |
6337 * Specifies an optional callback to deserialize internal fields. It | |
6338 * should match the SerializeInternalFieldCallback used to serialize. | |
6339 */ | |
6340 DeserializeInternalFieldsCallback deserialize_internal_fields_callback; | |
6321 }; | 6341 }; |
6322 | 6342 |
6323 | 6343 |
6324 /** | 6344 /** |
6325 * Stack-allocated class which sets the isolate for all operations | 6345 * Stack-allocated class which sets the isolate for all operations |
6326 * executed within a local scope. | 6346 * executed within a local scope. |
6327 */ | 6347 */ |
6328 class V8_EXPORT Scope { | 6348 class V8_EXPORT Scope { |
6329 public: | 6349 public: |
6330 explicit Scope(Isolate* isolate) : isolate_(isolate) { | 6350 explicit Scope(Isolate* isolate) : isolate_(isolate) { |
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7576 * Add a template to be included in the snapshot blob. | 7596 * Add a template to be included in the snapshot blob. |
7577 * \returns the index of the template in the snapshot blob. | 7597 * \returns the index of the template in the snapshot blob. |
7578 */ | 7598 */ |
7579 size_t AddTemplate(Local<Template> template_obj); | 7599 size_t AddTemplate(Local<Template> template_obj); |
7580 | 7600 |
7581 /** | 7601 /** |
7582 * Created a snapshot data blob. | 7602 * Created a snapshot data blob. |
7583 * This must not be called from within a handle scope. | 7603 * This must not be called from within a handle scope. |
7584 * \param function_code_handling whether to include compiled function code | 7604 * \param function_code_handling whether to include compiled function code |
7585 * in the snapshot. | 7605 * in the snapshot. |
7606 * \param callback to serialize embedder-set internal fields. | |
7586 * \returns { nullptr, 0 } on failure, and a startup snapshot on success. The | 7607 * \returns { nullptr, 0 } on failure, and a startup snapshot on success. The |
7587 * caller acquires ownership of the data array in the return value. | 7608 * caller acquires ownership of the data array in the return value. |
7588 */ | 7609 */ |
7589 StartupData CreateBlob(FunctionCodeHandling function_code_handling); | 7610 StartupData CreateBlob(FunctionCodeHandling function_code_handling, |
7611 SerializeInternalFieldsCallback callback = nullptr); | |
7590 | 7612 |
7591 // Disallow copying and assigning. | 7613 // Disallow copying and assigning. |
7592 SnapshotCreator(const SnapshotCreator&) = delete; | 7614 SnapshotCreator(const SnapshotCreator&) = delete; |
7593 void operator=(const SnapshotCreator&) = delete; | 7615 void operator=(const SnapshotCreator&) = delete; |
7594 | 7616 |
7595 private: | 7617 private: |
7596 void* data_; | 7618 void* data_; |
7597 }; | 7619 }; |
7598 | 7620 |
7599 /** | 7621 /** |
(...skipping 2067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9667 */ | 9689 */ |
9668 | 9690 |
9669 | 9691 |
9670 } // namespace v8 | 9692 } // namespace v8 |
9671 | 9693 |
9672 | 9694 |
9673 #undef TYPE_CHECK | 9695 #undef TYPE_CHECK |
9674 | 9696 |
9675 | 9697 |
9676 #endif // INCLUDE_V8_H_ | 9698 #endif // INCLUDE_V8_H_ |
OLD | NEW |