Skip to content

Commit 5c278f6

Browse files
verwaestCommit bot
authored andcommitted
Minor performance improvements to the LookupIterator
This change changes bootstrapping semantics for intercepted global objects. Unlike before, we'll now also call into the interceptor during bootstrapping. This affects properties loaded from within the runtime, such as global.Array and global.Symbol. The embedder will need to make sure that those values are the expected values during bootstrapping. BUG=chromium:505998 LOG=n Review URL: https://codereview.chromium.org/1220813005 Cr-Commit-Position: refs/heads/master@{#29414}
1 parent b913e2a commit 5c278f6

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

src/lookup-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace internal {
1515

1616
JSReceiver* LookupIterator::NextHolder(Map* map) {
1717
DisallowHeapAllocation no_gc;
18-
if (map->prototype()->IsNull()) return NULL;
18+
if (!map->prototype()->IsJSReceiver()) return NULL;
1919

2020
JSReceiver* next = JSReceiver::cast(map->prototype());
2121
DCHECK(!next->map()->IsGlobalObjectMap() ||

src/lookup.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ Handle<JSObject> LookupIterator::GetStoreTarget() const {
8787
}
8888

8989

90-
bool LookupIterator::IsBootstrapping() const {
91-
return isolate_->bootstrapper()->IsActive();
92-
}
93-
94-
9590
bool LookupIterator::HasAccess() const {
9691
DCHECK_EQ(ACCESS_CHECK, state_);
9792
return isolate_->MayAccess(GetHolder<JSObject>());

src/lookup.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,9 @@ class LookupIterator final BASE_EMBEDDED {
259259
bool InternalHolderIsReceiverOrHiddenPrototype() const;
260260
InterceptorInfo* GetInterceptor(JSObject* holder) const;
261261

262-
bool IsBootstrapping() const;
263-
264262
bool check_hidden() const { return (configuration_ & kHidden) != 0; }
265263
bool check_interceptor() const {
266-
return !IsBootstrapping() && (configuration_ & kInterceptor) != 0;
264+
return (configuration_ & kInterceptor) != 0;
267265
}
268266
bool check_prototype_chain() const {
269267
return (configuration_ & kPrototypeChain) != 0;

test/cctest/test-api.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13273,18 +13273,19 @@ TEST(ForceSet) {
1327313273

1327413274

1327513275
TEST(ForceSetWithInterceptor) {
13276-
force_set_get_count = 0;
13277-
force_set_set_count = 0;
13278-
pass_on_get = false;
13279-
1328013276
v8::Isolate* isolate = CcTest::isolate();
1328113277
v8::HandleScope scope(isolate);
1328213278
v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
1328313279
templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
1328413280
ForceSetInterceptGetter, ForceSetInterceptSetter));
13281+
pass_on_get = true;
1328513282
LocalContext context(NULL, templ);
1328613283
v8::Handle<v8::Object> global = context->Global();
1328713284

13285+
force_set_get_count = 0;
13286+
force_set_set_count = 0;
13287+
pass_on_get = false;
13288+
1328813289
v8::Handle<v8::String> some_property =
1328913290
v8::String::NewFromUtf8(isolate, "a");
1329013291
CHECK_EQ(0, force_set_set_count);

test/cctest/test-decls.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ void DeclarationContext::InitializeIfNeeded() {
130130
context_.Reset(isolate, context);
131131
context->Enter();
132132
is_initialized_ = true;
133+
// Reset counts. Bootstrapping might have called into the interceptor.
134+
get_count_ = 0;
135+
set_count_ = 0;
136+
query_count_ = 0;
133137
PostInitializeContext(context);
134138
}
135139

0 commit comments

Comments
 (0)