OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <ostream> | 5 #include <ostream> |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/compilation-dependencies.h" | 8 #include "src/compilation-dependencies.h" |
9 #include "src/compiler/access-info.h" | 9 #include "src/compiler/access-info.h" |
10 #include "src/field-index-inl.h" | 10 #include "src/field-index-inl.h" |
11 #include "src/objects-inl.h" // TODO(mstarzinger): Temporary cycle breaker! | 11 #include "src/objects-inl.h" // TODO(mstarzinger): Temporary cycle breaker! |
12 #include "src/type-cache.h" | 12 #include "src/type-cache.h" |
13 #include "src/types-inl.h" | 13 #include "src/types-inl.h" |
14 | 14 |
15 namespace v8 { | 15 namespace v8 { |
16 namespace internal { | 16 namespace internal { |
17 namespace compiler { | 17 namespace compiler { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 bool CanInlineElementAccess(Handle<Map> map) { | 21 bool CanInlineElementAccess(Handle<Map> map) { |
22 // TODO(bmeurer): IsJSObjectMap | 22 // TODO(bmeurer): Add support for holey elements. |
23 // TODO(bmeurer): !map->has_dictionary_elements() | 23 return map->IsJSObjectMap() && |
24 // TODO(bmeurer): !map->has_sloppy_arguments_elements() | 24 IsFastPackedElementsKind(map->elements_kind()) && |
25 return map->IsJSArrayMap() && map->has_fast_elements() && | |
26 !map->has_indexed_interceptor() && !map->is_access_check_needed(); | 25 !map->has_indexed_interceptor() && !map->is_access_check_needed(); |
27 } | 26 } |
28 | 27 |
29 | 28 |
30 bool CanInlinePropertyAccess(Handle<Map> map) { | 29 bool CanInlinePropertyAccess(Handle<Map> map) { |
31 // We can inline property access to prototypes of all primitives, except | 30 // We can inline property access to prototypes of all primitives, except |
32 // the special Oddball ones that have no wrapper counterparts (i.e. Null, | 31 // the special Oddball ones that have no wrapper counterparts (i.e. Null, |
33 // Undefined and TheHole). | 32 // Undefined and TheHole). |
34 STATIC_ASSERT(ODDBALL_TYPE == LAST_PRIMITIVE_TYPE); | 33 STATIC_ASSERT(ODDBALL_TYPE == LAST_PRIMITIVE_TYPE); |
35 if (map->IsBooleanMap()) return true; | 34 if (map->IsBooleanMap()) return true; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 isolate_(native_context->GetIsolate()), | 122 isolate_(native_context->GetIsolate()), |
124 type_cache_(TypeCache::Get()), | 123 type_cache_(TypeCache::Get()), |
125 zone_(zone) {} | 124 zone_(zone) {} |
126 | 125 |
127 | 126 |
128 bool AccessInfoFactory::ComputeElementAccessInfo( | 127 bool AccessInfoFactory::ComputeElementAccessInfo( |
129 Handle<Map> map, AccessMode access_mode, ElementAccessInfo* access_info) { | 128 Handle<Map> map, AccessMode access_mode, ElementAccessInfo* access_info) { |
130 // Check if it is safe to inline element access for the {map}. | 129 // Check if it is safe to inline element access for the {map}. |
131 if (!CanInlineElementAccess(map)) return false; | 130 if (!CanInlineElementAccess(map)) return false; |
132 | 131 |
133 // TODO(bmeurer): Add support for holey elements. | |
134 ElementsKind elements_kind = map->elements_kind(); | 132 ElementsKind elements_kind = map->elements_kind(); |
135 if (IsHoleyElementsKind(elements_kind)) return false; | |
136 | 133 |
137 // Certain (monomorphic) stores need a prototype chain check because shape | 134 // Certain (monomorphic) stores need a prototype chain check because shape |
138 // changes could allow callbacks on elements in the chain that are not | 135 // changes could allow callbacks on elements in the chain that are not |
139 // compatible with monomorphic keyed stores. | 136 // compatible with monomorphic keyed stores. |
140 MaybeHandle<JSObject> holder; | 137 MaybeHandle<JSObject> holder; |
141 if (access_mode == AccessMode::kStore && map->prototype()->IsJSObject()) { | 138 if (access_mode == AccessMode::kStore && map->prototype()->IsJSObject()) { |
142 for (PrototypeIterator i(map); !i.IsAtEnd(); i.Advance()) { | 139 for (PrototypeIterator i(map); !i.IsAtEnd(); i.Advance()) { |
143 Handle<JSReceiver> prototype = | 140 Handle<JSReceiver> prototype = |
144 PrototypeIterator::GetCurrent<JSReceiver>(i); | 141 PrototypeIterator::GetCurrent<JSReceiver>(i); |
145 if (!prototype->IsJSObject()) return false; | 142 if (!prototype->IsJSObject()) return false; |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 } | 401 } |
405 return false; | 402 return false; |
406 } | 403 } |
407 | 404 |
408 | 405 |
409 Factory* AccessInfoFactory::factory() const { return isolate()->factory(); } | 406 Factory* AccessInfoFactory::factory() const { return isolate()->factory(); } |
410 | 407 |
411 } // namespace compiler | 408 } // namespace compiler |
412 } // namespace internal | 409 } // namespace internal |
413 } // namespace v8 | 410 } // namespace v8 |
OLD | NEW |