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 #include "src/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
508 Isolate* isolate = reinterpret_cast<Isolate*>(internal_isolate); | 508 Isolate* isolate = reinterpret_cast<Isolate*>(internal_isolate); |
509 SnapshotCreatorData* data = new SnapshotCreatorData(isolate); | 509 SnapshotCreatorData* data = new SnapshotCreatorData(isolate); |
510 data->isolate_ = isolate; | 510 data->isolate_ = isolate; |
511 internal_isolate->set_array_buffer_allocator(&data->allocator_); | 511 internal_isolate->set_array_buffer_allocator(&data->allocator_); |
512 internal_isolate->set_api_external_references(external_references); | 512 internal_isolate->set_api_external_references(external_references); |
513 isolate->Enter(); | 513 isolate->Enter(); |
514 if (existing_snapshot) { | 514 if (existing_snapshot) { |
515 internal_isolate->set_snapshot_blob(existing_snapshot); | 515 internal_isolate->set_snapshot_blob(existing_snapshot); |
516 i::Snapshot::Initialize(internal_isolate); | 516 i::Snapshot::Initialize(internal_isolate); |
517 } else { | 517 } else { |
518 internal_isolate->Init(nullptr); | 518 // If we have a snapshot, use it for bootstrapping; otherwise start |
519 // from scratch. | |
520 const StartupData* snapshot_blob = i::Snapshot::DefaultSnapshotBlob(); | |
Yang
2017/03/07 11:28:11
We could also make this the default parameter for
Jakob Kummerow
2017/03/07 12:39:15
Done.
| |
521 if (snapshot_blob != nullptr && snapshot_blob->raw_size > 0) { | |
522 internal_isolate->set_snapshot_blob(snapshot_blob); | |
523 i::Snapshot::Initialize(internal_isolate); | |
524 } else { | |
525 internal_isolate->Init(nullptr); | |
526 } | |
519 } | 527 } |
520 data_ = data; | 528 data_ = data; |
521 } | 529 } |
522 | 530 |
523 SnapshotCreator::~SnapshotCreator() { | 531 SnapshotCreator::~SnapshotCreator() { |
524 SnapshotCreatorData* data = SnapshotCreatorData::cast(data_); | 532 SnapshotCreatorData* data = SnapshotCreatorData::cast(data_); |
525 DCHECK(data->created_); | 533 DCHECK(data->created_); |
526 Isolate* isolate = data->isolate_; | 534 Isolate* isolate = data->isolate_; |
527 isolate->Exit(); | 535 isolate->Exit(); |
528 isolate->Dispose(); | 536 isolate->Dispose(); |
(...skipping 9728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10257 Address callback_address = | 10265 Address callback_address = |
10258 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10266 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
10259 VMState<EXTERNAL> state(isolate); | 10267 VMState<EXTERNAL> state(isolate); |
10260 ExternalCallbackScope call_scope(isolate, callback_address); | 10268 ExternalCallbackScope call_scope(isolate, callback_address); |
10261 callback(info); | 10269 callback(info); |
10262 } | 10270 } |
10263 | 10271 |
10264 | 10272 |
10265 } // namespace internal | 10273 } // namespace internal |
10266 } // namespace v8 | 10274 } // namespace v8 |
OLD | NEW |