summaryrefslogtreecommitdiff
path: root/deps/v8/src/api/api.cc
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2019-10-28 11:12:22 +0100
committerMichaël Zasso <targos@protonmail.com>2019-11-08 15:50:51 +0100
commitd9fab1fdb76ae3a69b5812a7f2190cf3e58f6d75 (patch)
treec1c9b3dcb745a0c7bd9cc71802692816448b2180 /deps/v8/src/api/api.cc
parent53e925a5605675c0f534128c0a317f232229b0f3 (diff)
downloadandroid-node-v8-d9fab1fdb76ae3a69b5812a7f2190cf3e58f6d75.tar.gz
android-node-v8-d9fab1fdb76ae3a69b5812a7f2190cf3e58f6d75.tar.bz2
android-node-v8-d9fab1fdb76ae3a69b5812a7f2190cf3e58f6d75.zip
deps: V8: cherry-pick 777fa98
Original commit message: Make SetSyntheticModuleExport throw instead of crash for nonexistent export name Per spec, Module::SetSyntheticModuleExport should throw a ReferenceError when called with an export name that was not supplied when constructing that SyntheticModule. Instead, the current implementation crashes with a failed CHECK(). Add a new Module::SyntheticModuleSetExport that throws (without an ensuing crash) for this case, and deprecate the old Module::SetSyntheticModuleExport. Bug: v8:9828 Change-Id: I3b3d353064c3851882781818099bd8f6ee74c809 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1860996 Reviewed-by: Adam Klein <adamk@chromium.org> Reviewed-by: Georg Neis <neis@chromium.org> Commit-Queue: Dan Clark <daniec@microsoft.com> Cr-Commit-Position: refs/heads/master@{#64438} Refs: https://github.com/v8/v8/commit/777fa98cc47ac32f0fde3d9aafd830949deb5d23 PR-URL: https://github.com/nodejs/node/pull/30020 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'deps/v8/src/api/api.cc')
-rw-r--r--deps/v8/src/api/api.cc28
1 files changed, 25 insertions, 3 deletions
diff --git a/deps/v8/src/api/api.cc b/deps/v8/src/api/api.cc
index cb503015c1..fffee36c5a 100644
--- a/deps/v8/src/api/api.cc
+++ b/deps/v8/src/api/api.cc
@@ -2362,6 +2362,28 @@ Local<Module> Module::CreateSyntheticModule(
i_module_name, i_export_names, evaluation_steps)));
}
+Maybe<bool> Module::SetSyntheticModuleExport(Isolate* isolate,
+ Local<String> export_name,
+ Local<v8::Value> export_value) {
+ auto i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ i::Handle<i::String> i_export_name = Utils::OpenHandle(*export_name);
+ i::Handle<i::Object> i_export_value = Utils::OpenHandle(*export_value);
+ i::Handle<i::Module> self = Utils::OpenHandle(this);
+ Utils::ApiCheck(self->IsSyntheticModule(),
+ "v8::Module::SyntheticModuleSetExport",
+ "v8::Module::SyntheticModuleSetExport must only be called on "
+ "a SyntheticModule");
+ ENTER_V8_NO_SCRIPT(i_isolate, isolate->GetCurrentContext(), Module,
+ SetSyntheticModuleExport, Nothing<bool>(), i::HandleScope);
+ has_pending_exception =
+ i::SyntheticModule::SetExport(i_isolate,
+ i::Handle<i::SyntheticModule>::cast(self),
+ i_export_name, i_export_value)
+ .IsNothing();
+ RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
+ return Just(true);
+}
+
void Module::SetSyntheticModuleExport(Local<String> export_name,
Local<v8::Value> export_value) {
i::Handle<i::String> i_export_name = Utils::OpenHandle(*export_name);
@@ -2371,9 +2393,9 @@ void Module::SetSyntheticModuleExport(Local<String> export_name,
"v8::Module::SetSyntheticModuleExport",
"v8::Module::SetSyntheticModuleExport must only be called on "
"a SyntheticModule");
- i::SyntheticModule::SetExport(self->GetIsolate(),
- i::Handle<i::SyntheticModule>::cast(self),
- i_export_name, i_export_value);
+ i::SyntheticModule::SetExportStrict(self->GetIsolate(),
+ i::Handle<i::SyntheticModule>::cast(self),
+ i_export_name, i_export_value);
}
namespace {