Inline LookupInHolder and NextHolder
BUG= R=jkummerow@chromium.org Review URL: https://codereview.chromium.org/437513002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22853 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
356ac42def
commit
62714a58cd
1
BUILD.gn
1
BUILD.gn
@ -747,6 +747,7 @@ source_set("v8_base") {
|
||||
"src/log-utils.h",
|
||||
"src/log.cc",
|
||||
"src/log.h",
|
||||
"src/lookup-inl.h",
|
||||
"src/lookup.cc",
|
||||
"src/lookup.h",
|
||||
"src/macro-assembler.h",
|
||||
|
68
src/lookup-inl.h
Normal file
68
src/lookup-inl.h
Normal file
@ -0,0 +1,68 @@
|
||||
// Copyright 2014 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_LOOKUP_INL_H_
|
||||
#define V8_LOOKUP_INL_H_
|
||||
|
||||
#include "src/lookup.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
|
||||
JSReceiver* LookupIterator::NextHolder(Map* map) {
|
||||
DisallowHeapAllocation no_gc;
|
||||
if (map->prototype()->IsNull()) return NULL;
|
||||
|
||||
JSReceiver* next = JSReceiver::cast(map->prototype());
|
||||
DCHECK(!next->map()->IsGlobalObjectMap() ||
|
||||
next->map()->is_hidden_prototype());
|
||||
|
||||
if (!check_derived() &&
|
||||
!(check_hidden() && next->map()->is_hidden_prototype())) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
|
||||
LookupIterator::State LookupIterator::LookupInHolder(Map* map) {
|
||||
DisallowHeapAllocation no_gc;
|
||||
switch (state_) {
|
||||
case NOT_FOUND:
|
||||
if (map->IsJSProxyMap()) {
|
||||
return JSPROXY;
|
||||
}
|
||||
if (check_access_check() && map->is_access_check_needed()) {
|
||||
return ACCESS_CHECK;
|
||||
}
|
||||
// Fall through.
|
||||
case ACCESS_CHECK:
|
||||
if (check_interceptor() && map->has_named_interceptor()) {
|
||||
return INTERCEPTOR;
|
||||
}
|
||||
// Fall through.
|
||||
case INTERCEPTOR:
|
||||
if (map->is_dictionary_map()) {
|
||||
property_encoding_ = DICTIONARY;
|
||||
} else {
|
||||
DescriptorArray* descriptors = map->instance_descriptors();
|
||||
number_ = descriptors->SearchWithCache(*name_, map);
|
||||
if (number_ == DescriptorArray::kNotFound) return NOT_FOUND;
|
||||
property_encoding_ = DESCRIPTOR;
|
||||
}
|
||||
return PROPERTY;
|
||||
case PROPERTY:
|
||||
return NOT_FOUND;
|
||||
case JSPROXY:
|
||||
UNREACHABLE();
|
||||
}
|
||||
UNREACHABLE();
|
||||
return state_;
|
||||
}
|
||||
}
|
||||
} // namespace v8::internal
|
||||
|
||||
#endif // V8_LOOKUP_INL_H_
|
@ -6,16 +6,36 @@
|
||||
|
||||
#include "src/bootstrapper.h"
|
||||
#include "src/lookup.h"
|
||||
#include "src/lookup-inl.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
|
||||
void LookupIterator::Next() {
|
||||
DisallowHeapAllocation no_gc;
|
||||
has_property_ = false;
|
||||
do {
|
||||
state_ = LookupInHolder();
|
||||
} while (!IsFound() && NextHolder());
|
||||
|
||||
JSReceiver* holder = NULL;
|
||||
Map* map = *holder_map_;
|
||||
|
||||
// Perform lookup on current holder.
|
||||
state_ = LookupInHolder(map);
|
||||
|
||||
// Continue lookup if lookup on current holder failed.
|
||||
while (!IsFound()) {
|
||||
JSReceiver* maybe_holder = NextHolder(map);
|
||||
if (maybe_holder == NULL) break;
|
||||
holder = maybe_holder;
|
||||
map = holder->map();
|
||||
state_ = LookupInHolder(map);
|
||||
}
|
||||
|
||||
// Either was found in the receiver, or the receiver has no prototype.
|
||||
if (holder == NULL) return;
|
||||
|
||||
maybe_holder_ = handle(holder);
|
||||
holder_map_ = handle(map);
|
||||
}
|
||||
|
||||
|
||||
@ -36,62 +56,6 @@ Handle<Map> LookupIterator::GetReceiverMap() const {
|
||||
}
|
||||
|
||||
|
||||
bool LookupIterator::NextHolder() {
|
||||
if (holder_map_->prototype()->IsNull()) return false;
|
||||
|
||||
Handle<JSReceiver> next(JSReceiver::cast(holder_map_->prototype()));
|
||||
|
||||
if (!check_derived() &&
|
||||
!(check_hidden() &&
|
||||
// TODO(verwaest): Check if this is actually necessary currently. If it
|
||||
// is, this should be handled by setting is_hidden_prototype on the
|
||||
// global object behind the proxy.
|
||||
(holder_map_->IsJSGlobalProxyMap() ||
|
||||
next->map()->is_hidden_prototype()))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
holder_map_ = handle(next->map());
|
||||
maybe_holder_ = next;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
LookupIterator::State LookupIterator::LookupInHolder() {
|
||||
switch (state_) {
|
||||
case NOT_FOUND:
|
||||
if (holder_map_->IsJSProxyMap()) {
|
||||
return JSPROXY;
|
||||
}
|
||||
if (check_access_check() && holder_map_->is_access_check_needed()) {
|
||||
return ACCESS_CHECK;
|
||||
}
|
||||
// Fall through.
|
||||
case ACCESS_CHECK:
|
||||
if (check_interceptor() && holder_map_->has_named_interceptor()) {
|
||||
return INTERCEPTOR;
|
||||
}
|
||||
// Fall through.
|
||||
case INTERCEPTOR:
|
||||
if (holder_map_->is_dictionary_map()) {
|
||||
property_encoding_ = DICTIONARY;
|
||||
} else {
|
||||
DescriptorArray* descriptors = holder_map_->instance_descriptors();
|
||||
number_ = descriptors->SearchWithCache(*name_, *holder_map_);
|
||||
if (number_ == DescriptorArray::kNotFound) return NOT_FOUND;
|
||||
property_encoding_ = DESCRIPTOR;
|
||||
}
|
||||
return PROPERTY;
|
||||
case PROPERTY:
|
||||
return NOT_FOUND;
|
||||
case JSPROXY:
|
||||
UNREACHABLE();
|
||||
}
|
||||
UNREACHABLE();
|
||||
return state_;
|
||||
}
|
||||
|
||||
|
||||
bool LookupIterator::IsBootstrapping() const {
|
||||
return isolate_->bootstrapper()->IsActive();
|
||||
}
|
||||
@ -190,7 +154,7 @@ void LookupIterator::TransitionToDataProperty(
|
||||
// Reload the information.
|
||||
state_ = NOT_FOUND;
|
||||
configuration_ = CHECK_OWN_REAL;
|
||||
state_ = LookupInHolder();
|
||||
state_ = LookupInHolder(*holder_map_);
|
||||
DCHECK(IsFound());
|
||||
HasProperty();
|
||||
}
|
||||
|
@ -150,8 +150,8 @@ class LookupIterator V8_FINAL BASE_EMBEDDED {
|
||||
private:
|
||||
Handle<Map> GetReceiverMap() const;
|
||||
|
||||
MUST_USE_RESULT bool NextHolder();
|
||||
State LookupInHolder();
|
||||
MUST_USE_RESULT inline JSReceiver* NextHolder(Map* map);
|
||||
inline State LookupInHolder(Map* map);
|
||||
Handle<Object> FetchValue() const;
|
||||
|
||||
bool IsBootstrapping() const;
|
||||
|
@ -649,6 +649,7 @@
|
||||
'../../src/log-utils.h',
|
||||
'../../src/log.cc',
|
||||
'../../src/log.h',
|
||||
'../../src/lookup-inl.h',
|
||||
'../../src/lookup.cc',
|
||||
'../../src/lookup.h',
|
||||
'../../src/macro-assembler.h',
|
||||
|
Loading…
Reference in New Issue
Block a user