Line data Source code
1 : // Copyright 2017 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_OBJECTS_MAP_INL_H_
6 : #define V8_OBJECTS_MAP_INL_H_
7 :
8 : #include "src/field-type.h"
9 : #include "src/objects/map.h"
10 :
11 : // Has to be the last include (doesn't have include guards):
12 : #include "src/objects/object-macros.h"
13 :
14 : namespace v8 {
15 : namespace internal {
16 :
17 : CAST_ACCESSOR(Map)
18 :
19 : InterceptorInfo* Map::GetNamedInterceptor() {
20 : DCHECK(has_named_interceptor());
21 1630328 : FunctionTemplateInfo* info = GetFunctionTemplateInfo();
22 : return InterceptorInfo::cast(info->named_property_handler());
23 : }
24 :
25 : InterceptorInfo* Map::GetIndexedInterceptor() {
26 : DCHECK(has_indexed_interceptor());
27 621674 : FunctionTemplateInfo* info = GetFunctionTemplateInfo();
28 : return InterceptorInfo::cast(info->indexed_property_handler());
29 : }
30 :
31 : bool Map::IsInplaceGeneralizableField(PropertyConstness constness,
32 : Representation representation,
33 : FieldType* field_type) {
34 : if (FLAG_track_constant_fields && FLAG_modify_map_inplace &&
35 : (constness == kConst)) {
36 : // kConst -> kMutable field generalization may happen in-place.
37 : return true;
38 : }
39 1084001 : if (representation.IsHeapObject() && !field_type->IsAny()) {
40 : return true;
41 : }
42 : return false;
43 : }
44 :
45 : int NormalizedMapCache::GetIndex(Handle<Map> map) {
46 957501 : return map->Hash() % NormalizedMapCache::kEntries;
47 : }
48 :
49 : bool NormalizedMapCache::IsNormalizedMapCache(const HeapObject* obj) {
50 : if (!obj->IsFixedArray()) return false;
51 : if (FixedArray::cast(obj)->length() != NormalizedMapCache::kEntries) {
52 : return false;
53 : }
54 : #ifdef VERIFY_HEAP
55 : if (FLAG_verify_heap) {
56 : reinterpret_cast<NormalizedMapCache*>(const_cast<HeapObject*>(obj))
57 : ->NormalizedMapCacheVerify();
58 : }
59 : #endif
60 : return true;
61 : }
62 :
63 : } // namespace internal
64 : } // namespace v8
65 :
66 : #include "src/objects/object-macros-undef.h"
67 :
68 : #endif // V8_OBJECTS_MAP_INL_H_
|