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): Add support for holey elements. | 22 if (!map->IsJSObjectMap()) return false; |
23 return map->IsJSObjectMap() && | 23 if (map->is_access_check_needed()) return false; |
24 IsFastPackedElementsKind(map->elements_kind()) && | 24 if (map->has_indexed_interceptor()) return false; |
25 !map->has_indexed_interceptor() && !map->is_access_check_needed(); | 25 ElementsKind const elements_kind = map->elements_kind(); |
| 26 if (IsFastElementsKind(elements_kind)) return true; |
| 27 // TODO(bmeurer): Add support for other elements kind. |
| 28 return false; |
26 } | 29 } |
27 | 30 |
28 | 31 |
29 bool CanInlinePropertyAccess(Handle<Map> map) { | 32 bool CanInlinePropertyAccess(Handle<Map> map) { |
30 // We can inline property access to prototypes of all primitives, except | 33 // We can inline property access to prototypes of all primitives, except |
31 // the special Oddball ones that have no wrapper counterparts (i.e. Null, | 34 // the special Oddball ones that have no wrapper counterparts (i.e. Null, |
32 // Undefined and TheHole). | 35 // Undefined and TheHole). |
33 STATIC_ASSERT(ODDBALL_TYPE == LAST_PRIMITIVE_TYPE); | 36 STATIC_ASSERT(ODDBALL_TYPE == LAST_PRIMITIVE_TYPE); |
34 if (map->IsBooleanMap()) return true; | 37 if (map->IsBooleanMap()) return true; |
35 if (map->instance_type() < LAST_PRIMITIVE_TYPE) return true; | 38 if (map->instance_type() < LAST_PRIMITIVE_TYPE) return true; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 isolate_(native_context->GetIsolate()), | 133 isolate_(native_context->GetIsolate()), |
131 type_cache_(TypeCache::Get()), | 134 type_cache_(TypeCache::Get()), |
132 zone_(zone) {} | 135 zone_(zone) {} |
133 | 136 |
134 | 137 |
135 bool AccessInfoFactory::ComputeElementAccessInfo( | 138 bool AccessInfoFactory::ComputeElementAccessInfo( |
136 Handle<Map> map, AccessMode access_mode, ElementAccessInfo* access_info) { | 139 Handle<Map> map, AccessMode access_mode, ElementAccessInfo* access_info) { |
137 // Check if it is safe to inline element access for the {map}. | 140 // Check if it is safe to inline element access for the {map}. |
138 if (!CanInlineElementAccess(map)) return false; | 141 if (!CanInlineElementAccess(map)) return false; |
139 | 142 |
140 ElementsKind elements_kind = map->elements_kind(); | 143 ElementsKind const elements_kind = map->elements_kind(); |
| 144 if (access_mode == AccessMode::kLoad && |
| 145 elements_kind == FAST_HOLEY_DOUBLE_ELEMENTS) { |
| 146 // TODO(bmeurer): Add support for holey loads. |
| 147 return false; |
| 148 } |
141 | 149 |
142 // Certain (monomorphic) stores need a prototype chain check because shape | 150 // Certain (monomorphic) stores need a prototype chain check because shape |
143 // changes could allow callbacks on elements in the chain that are not | 151 // changes could allow callbacks on elements in the chain that are not |
144 // compatible with monomorphic keyed stores. | 152 // compatible with monomorphic keyed stores. |
145 MaybeHandle<JSObject> holder; | 153 MaybeHandle<JSObject> holder; |
146 if (access_mode == AccessMode::kStore && map->prototype()->IsJSObject()) { | 154 if (access_mode == AccessMode::kStore && map->prototype()->IsJSObject()) { |
147 for (PrototypeIterator i(map); !i.IsAtEnd(); i.Advance()) { | 155 for (PrototypeIterator i(map); !i.IsAtEnd(); i.Advance()) { |
148 Handle<JSReceiver> prototype = | 156 Handle<JSReceiver> prototype = |
149 PrototypeIterator::GetCurrent<JSReceiver>(i); | 157 PrototypeIterator::GetCurrent<JSReceiver>(i); |
150 if (!prototype->IsJSObject()) return false; | 158 if (!prototype->IsJSObject()) return false; |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 } | 452 } |
445 return false; | 453 return false; |
446 } | 454 } |
447 | 455 |
448 | 456 |
449 Factory* AccessInfoFactory::factory() const { return isolate()->factory(); } | 457 Factory* AccessInfoFactory::factory() const { return isolate()->factory(); } |
450 | 458 |
451 } // namespace compiler | 459 } // namespace compiler |
452 } // namespace internal | 460 } // namespace internal |
453 } // namespace v8 | 461 } // namespace v8 |
OLD | NEW |