Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a1a454e
deps: update V8 to 7.9.317.22
targos Nov 17, 2019
221731d
build: reset embedder string to "-node.0"
targos Nov 17, 2019
387c68e
deps: V8: un-cherry-pick bd019bd
refack Mar 27, 2019
3681050
deps: V8: silence irrelevant warnings
targos Mar 27, 2019
b8d4407
deps: patch V8 to run on older XCode versions
ryzokuken Sep 14, 2019
4c39b44
deps: update V8's postmortem script
cjihrig Sep 27, 2019
b759c02
deps: update V8's postmortem script
cjihrig Oct 15, 2019
ed719e5
deps: V8: patch register-arm64.h
refack May 22, 2019
3963d0e
deps: V8: forward declaration of `Rtl*FunctionTable`
refack May 22, 2019
db1d9c5
deps: make v8.h compatible with VS2015
joaocgreis Nov 1, 2019
5592f5b
deps: V8: cherry-pick f2d92ec
targos Oct 18, 2019
cd87768
deps: V8: cherry-pick 3e82c8d
targos Oct 21, 2019
46d8252
deps: V8: cherry-pick cfe9172
targos Oct 21, 2019
ec321fe
deps: V8: cherry-pick bba5f1f
targos Oct 24, 2019
5f26d51
deps: V8: cherry-pick 6b0a953
targos Oct 24, 2019
722e070
deps: V8: cherry-pick 7228ef8
targos Oct 24, 2019
e080455
deps: V8: cherry-pick 777fa98
targos Oct 28, 2019
3337633
deps: V8: backport 07ee86a5a28b
targos Oct 23, 2019
73766e8
deps: V8: backport 5e755c6ee6d3
targos Oct 31, 2019
6db7865
deps: V8: cherry-pick e5dbc95
Oct 30, 2019
204ab5f
deps: V8: cherry-pick 50031fae736f
targos Nov 4, 2019
493311b
deps: V8: cherry-pick a7dffcd767be
cclauss Nov 3, 2019
d9e7e11
build,tools: update V8 gypfiles for V8 7.9
targos Sep 11, 2019
2fb1da4
test: update test-postmortem-metadata.js
cjihrig Oct 15, 2019
65df1aa
src: update v8abbr.h for V8 update
cjihrig Oct 15, 2019
88b02e5
test: increase limit again for network space overhead test
targos Oct 23, 2019
ba985b2
src: remove custom tracking for SharedArrayBuffers
addaleax Oct 22, 2019
42b9d19
deps: patch V8 to be API/ABI compatible with 7.8 (from 7.9)
targos Nov 17, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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 <[email protected]>
    Reviewed-by: Georg Neis <[email protected]>
    Commit-Queue: Dan Clark <[email protected]>
    Cr-Commit-Position: refs/heads/master@{#64438}

Refs: v8/v8@777fa98

PR-URL: #30020
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
  • Loading branch information
targos committed Nov 17, 2019
commit e080455959c4aa43c47ba488c9d95508ba7a87bd
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.14',
'v8_embedder_string': '-node.15',

##### V8 defaults for Node.js #####

Expand Down
12 changes: 10 additions & 2 deletions deps/v8/include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -1560,9 +1560,17 @@ class V8_EXPORT Module : public Data {
/**
* Set this module's exported value for the name export_name to the specified
* export_value. This method must be called only on Modules created via
* CreateSyntheticModule. export_name must be one of the export_names that
* were passed in that CreateSyntheticModule call.
* CreateSyntheticModule. An error will be thrown if export_name is not one
* of the export_names that were passed in that CreateSyntheticModule call.
* Returns Just(true) on success, Nothing<bool>() if an error was thrown.
*/
V8_WARN_UNUSED_RESULT Maybe<bool> SetSyntheticModuleExport(
Isolate* isolate, Local<String> export_name, Local<Value> export_value);
V8_DEPRECATE_SOON(
"Use the preceding SetSyntheticModuleExport with an Isolate parameter, "
"instead of the one that follows. The former will throw a runtime "
"error if called for an export that doesn't exist (as per spec); "
"the latter will crash with a failed CHECK().")
void SetSyntheticModuleExport(Local<String> export_name,
Local<Value> export_value);
};
Expand Down
28 changes: 25 additions & 3 deletions deps/v8/src/api/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions deps/v8/src/logging/counters.h
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ class RuntimeCallTimer final {
V(Message_GetStartColumn) \
V(Module_Evaluate) \
V(Module_InstantiateModule) \
V(Module_SetSyntheticModuleExport) \
V(NumberObject_New) \
V(NumberObject_NumberValue) \
V(Object_CallAsConstructor) \
Expand Down
30 changes: 25 additions & 5 deletions deps/v8/src/objects/synthetic-module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,36 @@ namespace internal {

// Implements SetSyntheticModuleBinding:
// https://heycam.github.io/webidl/#setsyntheticmoduleexport
void SyntheticModule::SetExport(Isolate* isolate,
Handle<SyntheticModule> module,
Handle<String> export_name,
Handle<Object> export_value) {
Maybe<bool> SyntheticModule::SetExport(Isolate* isolate,
Handle<SyntheticModule> module,
Handle<String> export_name,
Handle<Object> export_value) {
Handle<ObjectHashTable> exports(module->exports(), isolate);
Handle<Object> export_object(exports->Lookup(export_name), isolate);
CHECK(export_object->IsCell());

if (!export_object->IsCell()) {
isolate->Throw(*isolate->factory()->NewReferenceError(
MessageTemplate::kModuleExportUndefined, export_name));
return Nothing<bool>();
}

Handle<Cell> export_cell(Handle<Cell>::cast(export_object));
// Spec step 2: Set the mutable binding of export_name to export_value
export_cell->set_value(*export_value);

return Just(true);
}

void SyntheticModule::SetExportStrict(Isolate* isolate,
Handle<SyntheticModule> module,
Handle<String> export_name,
Handle<Object> export_value) {
Handle<ObjectHashTable> exports(module->exports(), isolate);
Handle<Object> export_object(exports->Lookup(export_name), isolate);
CHECK(export_object->IsCell());
Maybe<bool> set_export_result =
SetExport(isolate, module, export_name, export_value);
CHECK(set_export_result.FromJust());
}

// Implements Synthetic Module Record's ResolveExport concrete method:
Expand Down
18 changes: 15 additions & 3 deletions deps/v8/src/objects/synthetic-module.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,21 @@ class SyntheticModule
DECL_VERIFIER(SyntheticModule)
DECL_PRINTER(SyntheticModule)

static void SetExport(Isolate* isolate, Handle<SyntheticModule> module,
Handle<String> export_name,
Handle<Object> export_value);
// Set module's exported value for the specified export_name to the specified
// export_value. An error will be thrown if export_name is not one
// of the export_names that were supplied during module construction.
// Returns Just(true) on success, Nothing<bool>() if an error was thrown.
static Maybe<bool> SetExport(Isolate* isolate, Handle<SyntheticModule> module,
Handle<String> export_name,
Handle<Object> export_value);
// The following redundant method should be deleted when the deprecated
// version of v8::SetSyntheticModuleExport is removed. It differs from
// SetExport in that it crashes rather than throwing an error if the caller
// attempts to set an export_name that was not present during construction of
// the module.
static void SetExportStrict(Isolate* isolate, Handle<SyntheticModule> module,
Handle<String> export_name,
Handle<Object> export_value);

using BodyDescriptor = SubclassBodyDescriptor<
Module::BodyDescriptor,
Expand Down
36 changes: 34 additions & 2 deletions deps/v8/test/cctest/test-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23721,7 +23721,9 @@ v8::MaybeLocal<Value> SyntheticModuleEvaluationStepsCallbackFail(

v8::MaybeLocal<Value> SyntheticModuleEvaluationStepsCallbackSetExport(
Local<Context> context, Local<Module> module) {
module->SetSyntheticModuleExport(v8_str("test_export"), v8_num(42));
Maybe<bool> set_export_result = module->SetSyntheticModuleExport(
context->GetIsolate(), v8_str("test_export"), v8_num(42));
CHECK(set_export_result.FromJust());
return v8::Undefined(reinterpret_cast<v8::Isolate*>(context->GetIsolate()));
}

Expand Down Expand Up @@ -23940,7 +23942,9 @@ TEST(SyntheticModuleSetExports) {
// undefined.
CHECK(foo_cell->value().IsUndefined());

module->SetSyntheticModuleExport(foo_string, bar_string);
Maybe<bool> set_export_result =
module->SetSyntheticModuleExport(isolate, foo_string, bar_string);
CHECK(set_export_result.FromJust());

// After setting the export the Cell should still have the same idenitity.
CHECK_EQ(exports->Lookup(v8::Utils::OpenHandle(*foo_string)), *foo_cell);
Expand All @@ -23951,6 +23955,34 @@ TEST(SyntheticModuleSetExports) {
->Equals(*v8::Utils::OpenHandle(*bar_string)));
}

TEST(SyntheticModuleSetMissingExport) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
auto i_isolate = reinterpret_cast<i::Isolate*>(isolate);
v8::Isolate::Scope iscope(isolate);
v8::HandleScope scope(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate);
v8::Context::Scope cscope(context);

Local<String> foo_string = v8_str("foo");
Local<String> bar_string = v8_str("bar");

Local<Module> module = CreateAndInstantiateSyntheticModule(
isolate, v8_str("SyntheticModuleSetExports-TestSyntheticModule"), context,
std::vector<v8::Local<v8::String>>(),
UnexpectedSyntheticModuleEvaluationStepsCallback);

i::Handle<i::SyntheticModule> i_module =
i::Handle<i::SyntheticModule>::cast(v8::Utils::OpenHandle(*module));
i::Handle<i::ObjectHashTable> exports(i_module->exports(), i_isolate);

TryCatch try_catch(isolate);
Maybe<bool> set_export_result =
module->SetSyntheticModuleExport(isolate, foo_string, bar_string);
CHECK(set_export_result.IsNothing());
CHECK(try_catch.HasCaught());
}

TEST(SyntheticModuleEvaluationStepsNoThrow) {
synthetic_module_callback_count = 0;
LocalContext env;
Expand Down