Skip to content

Commit

Permalink
deps: cherry-pick 9eb96bb from upstream V8
Browse files Browse the repository at this point in the history
Original commit message:

    [api] Avoid needlessly calling descriptor interceptors

    Reland part of https://chromium-review.googlesource.com/c/v8/v8/+/816515.

    Change-Id: I72ad85ffd162fc0563fc25cdf35189e894f9dc82
    Reviewed-on: https://chromium-review.googlesource.com/1138808
    Commit-Queue: Timothy Gu <timothygu@chromium.org>
    Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
    Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#54492}

PR-URL: #22390
Fixes: #17480
Fixes: #17481
Refs: v8/v8@9eb96bb
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
TimothyGu authored and targos committed Sep 3, 2018
1 parent 219da67 commit 0fde4e9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,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.15',
'v8_embedder_string': '-node.16',

# Enable disassembler for `--print-code` v8 options
'v8_enable_disassembler': 1,
Expand Down
14 changes: 9 additions & 5 deletions deps/v8/src/objects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7662,13 +7662,17 @@ namespace {

Maybe<bool> GetPropertyDescriptorWithInterceptor(LookupIterator* it,
PropertyDescriptor* desc) {
bool has_access = true;
if (it->state() == LookupIterator::ACCESS_CHECK) {
has_access = it->HasAccess() || JSObject::AllCanRead(it);
it->Next();
if (it->HasAccess()) {
it->Next();
} else if (!JSObject::AllCanRead(it) ||
it->state() != LookupIterator::INTERCEPTOR) {
it->Restart();
return Just(false);
}
}

if (has_access && it->state() == LookupIterator::INTERCEPTOR) {
if (it->state() == LookupIterator::INTERCEPTOR) {
Isolate* isolate = it->isolate();
Handle<InterceptorInfo> interceptor = it->GetInterceptor();
if (!interceptor->descriptor()->IsUndefined(isolate)) {
Expand Down Expand Up @@ -7700,9 +7704,9 @@ Maybe<bool> GetPropertyDescriptorWithInterceptor(LookupIterator* it,

return Just(true);
}
it->Next();
}
}
it->Restart();
return Just(false);
}
} // namespace
Expand Down
12 changes: 6 additions & 6 deletions deps/v8/test/cctest/test-api-interceptors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4768,7 +4768,7 @@ TEST(NamedAllCanReadInterceptor) {
ExpectInt32("checked.whatever", 17);
CHECK(!CompileRun("Object.getOwnPropertyDescriptor(checked, 'whatever')")
->IsUndefined());
CHECK_EQ(6, access_check_data.count);
CHECK_EQ(5, access_check_data.count);

access_check_data.result = false;
ExpectInt32("checked.whatever", intercept_data_0.value);
Expand All @@ -4777,7 +4777,7 @@ TEST(NamedAllCanReadInterceptor) {
CompileRun("Object.getOwnPropertyDescriptor(checked, 'whatever')");
CHECK(try_catch.HasCaught());
}
CHECK_EQ(9, access_check_data.count);
CHECK_EQ(8, access_check_data.count);

intercept_data_1.should_intercept = true;
ExpectInt32("checked.whatever", intercept_data_1.value);
Expand All @@ -4786,7 +4786,7 @@ TEST(NamedAllCanReadInterceptor) {
CompileRun("Object.getOwnPropertyDescriptor(checked, 'whatever')");
CHECK(try_catch.HasCaught());
}
CHECK_EQ(12, access_check_data.count);
CHECK_EQ(11, access_check_data.count);
g_access_check_data = nullptr;
}

Expand Down Expand Up @@ -4855,7 +4855,7 @@ TEST(IndexedAllCanReadInterceptor) {
ExpectInt32("checked[15]", 17);
CHECK(!CompileRun("Object.getOwnPropertyDescriptor(checked, '15')")
->IsUndefined());
CHECK_EQ(6, access_check_data.count);
CHECK_EQ(5, access_check_data.count);

access_check_data.result = false;
ExpectInt32("checked[15]", intercept_data_0.value);
Expand All @@ -4864,7 +4864,7 @@ TEST(IndexedAllCanReadInterceptor) {
CompileRun("Object.getOwnPropertyDescriptor(checked, '15')");
CHECK(try_catch.HasCaught());
}
CHECK_EQ(9, access_check_data.count);
CHECK_EQ(8, access_check_data.count);

intercept_data_1.should_intercept = true;
ExpectInt32("checked[15]", intercept_data_1.value);
Expand All @@ -4873,7 +4873,7 @@ TEST(IndexedAllCanReadInterceptor) {
CompileRun("Object.getOwnPropertyDescriptor(checked, '15')");
CHECK(try_catch.HasCaught());
}
CHECK_EQ(12, access_check_data.count);
CHECK_EQ(11, access_check_data.count);

g_access_check_data = nullptr;
}
Expand Down

0 comments on commit 0fde4e9

Please sign in to comment.