OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef V8_PROPERTY_H_ | 5 #ifndef V8_PROPERTY_H_ |
6 #define V8_PROPERTY_H_ | 6 #define V8_PROPERTY_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/factory.h" | 10 #include "src/factory.h" |
11 #include "src/isolate.h" | 11 #include "src/isolate.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 // Abstraction for elements in instance-descriptor arrays. | 16 // Abstraction for elements in instance-descriptor arrays. |
17 // | 17 // |
18 // Each descriptor has a key, property attributes, property type, | 18 // Each descriptor has a key, property attributes, property type, |
19 // property index (in the actual instance-descriptor array) and | 19 // property index (in the actual instance-descriptor array) and |
20 // optionally a piece of data. | 20 // optionally a piece of data. |
21 class Descriptor BASE_EMBEDDED { | 21 class Descriptor BASE_EMBEDDED { |
22 public: | 22 public: |
23 void KeyToUniqueName() { | |
24 if (!key_->IsUniqueName()) { | |
25 key_ = key_->GetIsolate()->factory()->InternalizeString( | |
26 Handle<String>::cast(key_)); | |
27 } | |
28 } | |
29 | |
30 Handle<Name> GetKey() const { return key_; } | 23 Handle<Name> GetKey() const { return key_; } |
31 Handle<Object> GetValue() const { return value_; } | 24 Handle<Object> GetValue() const { return value_; } |
32 PropertyDetails GetDetails() const { return details_; } | 25 PropertyDetails GetDetails() const { return details_; } |
33 | 26 |
34 void SetSortedKeyIndex(int index) { details_ = details_.set_pointer(index); } | 27 void SetSortedKeyIndex(int index) { details_ = details_.set_pointer(index); } |
35 | 28 |
36 private: | 29 private: |
37 Handle<Name> key_; | 30 Handle<Name> key_; |
38 Handle<Object> value_; | 31 Handle<Object> value_; |
39 PropertyDetails details_; | 32 PropertyDetails details_; |
40 | 33 |
41 protected: | 34 protected: |
42 Descriptor() : details_(Smi::FromInt(0)) {} | 35 Descriptor() : details_(Smi::FromInt(0)) {} |
43 | 36 |
44 void Init(Handle<Name> key, Handle<Object> value, PropertyDetails details) { | 37 void Init(Handle<Name> key, Handle<Object> value, PropertyDetails details) { |
| 38 DCHECK(key->IsUniqueName()); |
45 key_ = key; | 39 key_ = key; |
46 value_ = value; | 40 value_ = value; |
47 details_ = details; | 41 details_ = details; |
48 } | 42 } |
49 | 43 |
50 Descriptor(Handle<Name> key, Handle<Object> value, PropertyDetails details) | 44 Descriptor(Handle<Name> key, Handle<Object> value, PropertyDetails details) |
| 45 : key_(key), value_(value), details_(details) { |
| 46 DCHECK(key->IsUniqueName()); |
| 47 } |
| 48 |
| 49 Descriptor(Handle<Name> key, Handle<Object> value, |
| 50 PropertyAttributes attributes, PropertyType type, |
| 51 Representation representation, int field_index = 0) |
51 : key_(key), | 52 : key_(key), |
52 value_(value), | 53 value_(value), |
53 details_(details) { } | 54 details_(attributes, type, representation, field_index) { |
54 | 55 DCHECK(key->IsUniqueName()); |
55 Descriptor(Handle<Name> key, | 56 } |
56 Handle<Object> value, | |
57 PropertyAttributes attributes, | |
58 PropertyType type, | |
59 Representation representation, | |
60 int field_index = 0) | |
61 : key_(key), | |
62 value_(value), | |
63 details_(attributes, type, representation, field_index) { } | |
64 | 57 |
65 friend class DescriptorArray; | 58 friend class DescriptorArray; |
66 friend class Map; | 59 friend class Map; |
67 }; | 60 }; |
68 | 61 |
69 | 62 |
70 std::ostream& operator<<(std::ostream& os, const Descriptor& d); | 63 std::ostream& operator<<(std::ostream& os, const Descriptor& d); |
71 | 64 |
72 | 65 |
73 class DataDescriptor final : public Descriptor { | 66 class DataDescriptor final : public Descriptor { |
(...skipping 26 matching lines...) Expand all Loading... |
100 PropertyAttributes attributes) | 93 PropertyAttributes attributes) |
101 : Descriptor(key, foreign, attributes, ACCESSOR_CONSTANT, | 94 : Descriptor(key, foreign, attributes, ACCESSOR_CONSTANT, |
102 Representation::Tagged()) {} | 95 Representation::Tagged()) {} |
103 }; | 96 }; |
104 | 97 |
105 | 98 |
106 } // namespace internal | 99 } // namespace internal |
107 } // namespace v8 | 100 } // namespace v8 |
108 | 101 |
109 #endif // V8_PROPERTY_H_ | 102 #endif // V8_PROPERTY_H_ |
OLD | NEW |