Commit 5c278f63 authored by verwaest's avatar verwaest Committed by Commit bot

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}
parent b913e2a9
...@@ -15,7 +15,7 @@ namespace internal { ...@@ -15,7 +15,7 @@ namespace internal {
JSReceiver* LookupIterator::NextHolder(Map* map) { JSReceiver* LookupIterator::NextHolder(Map* map) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
if (map->prototype()->IsNull()) return NULL; if (!map->prototype()->IsJSReceiver()) return NULL;
JSReceiver* next = JSReceiver::cast(map->prototype()); JSReceiver* next = JSReceiver::cast(map->prototype());
DCHECK(!next->map()->IsGlobalObjectMap() || DCHECK(!next->map()->IsGlobalObjectMap() ||
......
...@@ -87,11 +87,6 @@ Handle<JSObject> LookupIterator::GetStoreTarget() const { ...@@ -87,11 +87,6 @@ Handle<JSObject> LookupIterator::GetStoreTarget() const {
} }
bool LookupIterator::IsBootstrapping() const {
return isolate_->bootstrapper()->IsActive();
}
bool LookupIterator::HasAccess() const { bool LookupIterator::HasAccess() const {
DCHECK_EQ(ACCESS_CHECK, state_); DCHECK_EQ(ACCESS_CHECK, state_);
return isolate_->MayAccess(GetHolder<JSObject>()); return isolate_->MayAccess(GetHolder<JSObject>());
......
...@@ -259,11 +259,9 @@ class LookupIterator final BASE_EMBEDDED { ...@@ -259,11 +259,9 @@ class LookupIterator final BASE_EMBEDDED {
bool InternalHolderIsReceiverOrHiddenPrototype() const; bool InternalHolderIsReceiverOrHiddenPrototype() const;
InterceptorInfo* GetInterceptor(JSObject* holder) const; InterceptorInfo* GetInterceptor(JSObject* holder) const;
bool IsBootstrapping() const;
bool check_hidden() const { return (configuration_ & kHidden) != 0; } bool check_hidden() const { return (configuration_ & kHidden) != 0; }
bool check_interceptor() const { bool check_interceptor() const {
return !IsBootstrapping() && (configuration_ & kInterceptor) != 0; return (configuration_ & kInterceptor) != 0;
} }
bool check_prototype_chain() const { bool check_prototype_chain() const {
return (configuration_ & kPrototypeChain) != 0; return (configuration_ & kPrototypeChain) != 0;
......
...@@ -13273,18 +13273,19 @@ TEST(ForceSet) { ...@@ -13273,18 +13273,19 @@ TEST(ForceSet) {
TEST(ForceSetWithInterceptor) { TEST(ForceSetWithInterceptor) {
force_set_get_count = 0;
force_set_set_count = 0;
pass_on_get = false;
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
templ->SetHandler(v8::NamedPropertyHandlerConfiguration( templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
ForceSetInterceptGetter, ForceSetInterceptSetter)); ForceSetInterceptGetter, ForceSetInterceptSetter));
pass_on_get = true;
LocalContext context(NULL, templ); LocalContext context(NULL, templ);
v8::Handle<v8::Object> global = context->Global(); v8::Handle<v8::Object> global = context->Global();
force_set_get_count = 0;
force_set_set_count = 0;
pass_on_get = false;
v8::Handle<v8::String> some_property = v8::Handle<v8::String> some_property =
v8::String::NewFromUtf8(isolate, "a"); v8::String::NewFromUtf8(isolate, "a");
CHECK_EQ(0, force_set_set_count); CHECK_EQ(0, force_set_set_count);
......
...@@ -130,6 +130,10 @@ void DeclarationContext::InitializeIfNeeded() { ...@@ -130,6 +130,10 @@ void DeclarationContext::InitializeIfNeeded() {
context_.Reset(isolate, context); context_.Reset(isolate, context);
context->Enter(); context->Enter();
is_initialized_ = true; is_initialized_ = true;
// Reset counts. Bootstrapping might have called into the interceptor.
get_count_ = 0;
set_count_ = 0;
query_count_ = 0;
PostInitializeContext(context); PostInitializeContext(context);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment