GeezerVison is showing github.com — deps: V8: backport f3cad8cec656 · nodejs/node@361a643
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: deps/v8/src/api/api.cc +6-3Lines changed: 6 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -483,7 +483,6 @@ SnapshotCreator::SnapshotCreator(const intptr_t* external_references, |
483 | 483 |
|
484 | 484 | SnapshotCreator::~SnapshotCreator() { |
485 | 485 | SnapshotCreatorData* data = SnapshotCreatorData::cast(data_); |
486 | | - DCHECK(data->created_); |
487 | 486 | Isolate* isolate = data->isolate_; |
488 | 487 | isolate->Exit(); |
489 | 488 | isolate->Dispose(); |
@@ -590,8 +589,12 @@ StartupData SnapshotCreator::CreateBlob( |
590 | 589 | SnapshotCreator::FunctionCodeHandling function_code_handling) { |
591 | 590 | SnapshotCreatorData* data = SnapshotCreatorData::cast(data_); |
592 | 591 | i::Isolate* isolate = reinterpret_cast<i::Isolate*>(data->isolate_); |
593 | | - DCHECK(!data->created_); |
594 | | - DCHECK(!data->default_context_.IsEmpty()); |
| 592 | + Utils::ApiCheck(!data->created_, "v8::SnapshotCreator::CreateBlob", |
| 593 | + "CreateBlob() cannot be called more than once on the same " |
| 594 | + "SnapshotCreator."); |
| 595 | + Utils::ApiCheck( |
| 596 | + !data->default_context_.IsEmpty(), "v8::SnapshotCreator::CreateBlob", |
| 597 | + "CreateBlob() cannot be called before the default context is set."); |
595 | 598 |
|
596 | 599 | const int num_additional_contexts = static_cast<int>(data->contexts_.Size()); |
597 | 600 | const int num_contexts = num_additional_contexts + 1; // The default context. |
|
Collapse file
Copy file name to clipboardExpand all lines: deps/v8/test/cctest/test-serialize.cc +25Lines changed: 25 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2840,6 +2840,31 @@ TEST(Regress503552) { |
2840 | 2840 | delete cache_data; |
2841 | 2841 | } |
2842 | 2842 |
|
| 2843 | +UNINITIALIZED_TEST(SnapshotCreatorBlobNotCreated) { |
| 2844 | + DisableAlwaysOpt(); |
| 2845 | + DisableEmbeddedBlobRefcounting(); |
| 2846 | + { |
| 2847 | + v8::SnapshotCreator creator; |
| 2848 | + v8::Isolate* isolate = creator.GetIsolate(); |
| 2849 | + { |
| 2850 | + v8::HandleScope handle_scope(isolate); |
| 2851 | + v8::Local<v8::Context> context = v8::Context::New(isolate); |
| 2852 | + v8::Context::Scope context_scope(context); |
| 2853 | + v8::TryCatch try_catch(isolate); |
| 2854 | + v8::Local<v8::String> code = v8_str("throw new Error('test');"); |
| 2855 | + CHECK(v8::Script::Compile(context, code) |
| 2856 | + .ToLocalChecked() |
| 2857 | + ->Run(context) |
| 2858 | + .IsEmpty()); |
| 2859 | + CHECK(try_catch.HasCaught()); |
| 2860 | + } |
| 2861 | + // SnapshotCreator should be destroyed just fine even when no |
| 2862 | + // blob is created. |
| 2863 | + } |
| 2864 | + |
| 2865 | + FreeCurrentEmbeddedBlob(); |
| 2866 | +} |
| 2867 | + |
2843 | 2868 | UNINITIALIZED_TEST(SnapshotCreatorMultipleContexts) { |
2844 | 2869 | DisableAlwaysOpt(); |
2845 | 2870 | DisableEmbeddedBlobRefcounting(); |
|