Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(815)

Side by Side Diff: src/property.h

Issue 218683008: Cleanup property module. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/property.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Use of this source code is governed by a BSD-style license that can be
3 // modification, are permitted provided that the following conditions are 3 // found in the LICENSE file.
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 4
28 #ifndef V8_PROPERTY_H_ 5 #ifndef V8_PROPERTY_H_
29 #define V8_PROPERTY_H_ 6 #define V8_PROPERTY_H_
30 7
31 #include "allocation.h" 8 #include "isolate.h"
32 #include "transitions.h"
33 9
34 namespace v8 { 10 namespace v8 {
35 namespace internal { 11 namespace internal {
36 12
37
38 // Abstraction for elements in instance-descriptor arrays. 13 // Abstraction for elements in instance-descriptor arrays.
39 // 14 //
40 // Each descriptor has a key, property attributes, property type, 15 // Each descriptor has a key, property attributes, property type,
41 // property index (in the actual instance-descriptor array) and 16 // property index (in the actual instance-descriptor array) and
42 // optionally a piece of data. 17 // optionally a piece of data.
43 //
44
45 class Descriptor BASE_EMBEDDED { 18 class Descriptor BASE_EMBEDDED {
46 public: 19 public:
47 MUST_USE_RESULT MaybeObject* KeyToUniqueName() { 20 MUST_USE_RESULT MaybeObject* KeyToUniqueName() {
48 if (!key_->IsUniqueName()) { 21 if (!key_->IsUniqueName()) {
49 MaybeObject* maybe_result = 22 MaybeObject* maybe_result =
50 key_->GetIsolate()->heap()->InternalizeString(String::cast(key_)); 23 key_->GetIsolate()->heap()->InternalizeString(String::cast(key_));
51 if (!maybe_result->To(&key_)) return maybe_result; 24 if (!maybe_result->To(&key_)) return maybe_result;
52 } 25 }
53 return key_; 26 return key_;
54 } 27 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 Representation representation, 62 Representation representation,
90 int field_index = 0) 63 int field_index = 0)
91 : key_(key), 64 : key_(key),
92 value_(value), 65 value_(value),
93 details_(attributes, type, representation, field_index) { } 66 details_(attributes, type, representation, field_index) { }
94 67
95 friend class DescriptorArray; 68 friend class DescriptorArray;
96 }; 69 };
97 70
98 71
99 class FieldDescriptor: public Descriptor { 72 class FieldDescriptor V8_FINAL : public Descriptor {
100 public: 73 public:
101 FieldDescriptor(Name* key, 74 FieldDescriptor(Name* key,
102 int field_index, 75 int field_index,
103 PropertyAttributes attributes, 76 PropertyAttributes attributes,
104 Representation representation) 77 Representation representation)
105 : Descriptor(key, Smi::FromInt(0), attributes, 78 : Descriptor(key, Smi::FromInt(0), attributes,
106 FIELD, representation, field_index) {} 79 FIELD, representation, field_index) {}
107 }; 80 };
108 81
109 82
110 class ConstantDescriptor: public Descriptor { 83 class ConstantDescriptor V8_FINAL : public Descriptor {
111 public: 84 public:
112 ConstantDescriptor(Name* key, 85 ConstantDescriptor(Name* key,
113 Object* value, 86 Object* value,
114 PropertyAttributes attributes) 87 PropertyAttributes attributes)
115 : Descriptor(key, value, attributes, CONSTANT, 88 : Descriptor(key, value, attributes, CONSTANT,
116 value->OptimalRepresentation()) {} 89 value->OptimalRepresentation()) {}
117 }; 90 };
118 91
119 92
120 class CallbacksDescriptor: public Descriptor { 93 class CallbacksDescriptor V8_FINAL : public Descriptor {
121 public: 94 public:
122 CallbacksDescriptor(Name* key, 95 CallbacksDescriptor(Name* key,
123 Object* foreign, 96 Object* foreign,
124 PropertyAttributes attributes) 97 PropertyAttributes attributes)
125 : Descriptor(key, foreign, attributes, CALLBACKS, 98 : Descriptor(key, foreign, attributes, CALLBACKS,
126 Representation::Tagged()) {} 99 Representation::Tagged()) {}
127 }; 100 };
128 101
129 102
130 // Holds a property index value distinguishing if it is a field index or an 103 // Holds a property index value distinguishing if it is a field index or an
131 // index inside the object header. 104 // index inside the object header.
132 class PropertyIndex { 105 class PropertyIndex V8_FINAL {
133 public: 106 public:
134 static PropertyIndex NewFieldIndex(int index) { 107 static PropertyIndex NewFieldIndex(int index) {
135 return PropertyIndex(index, false); 108 return PropertyIndex(index, false);
136 } 109 }
137 static PropertyIndex NewHeaderIndex(int index) { 110 static PropertyIndex NewHeaderIndex(int index) {
138 return PropertyIndex(index, true); 111 return PropertyIndex(index, true);
139 } 112 }
140 113
141 bool is_field_index() { return (index_ & kHeaderIndexBit) == 0; } 114 bool is_field_index() { return (index_ & kHeaderIndexBit) == 0; }
142 bool is_header_index() { return (index_ & kHeaderIndexBit) != 0; } 115 bool is_header_index() { return (index_ & kHeaderIndexBit) != 0; }
(...skipping 27 matching lines...) Expand all
170 143
171 PropertyIndex(int index, bool is_header_based) 144 PropertyIndex(int index, bool is_header_based)
172 : index_(index | (is_header_based ? kHeaderIndexBit : 0)) { 145 : index_(index | (is_header_based ? kHeaderIndexBit : 0)) {
173 ASSERT(index <= kIndexMask); 146 ASSERT(index <= kIndexMask);
174 } 147 }
175 148
176 int index_; 149 int index_;
177 }; 150 };
178 151
179 152
180 class LookupResult BASE_EMBEDDED { 153 class LookupResult V8_FINAL BASE_EMBEDDED {
181 public: 154 public:
182 explicit LookupResult(Isolate* isolate) 155 explicit LookupResult(Isolate* isolate)
183 : isolate_(isolate), 156 : isolate_(isolate),
184 next_(isolate->top_lookup_result()), 157 next_(isolate->top_lookup_result()),
185 lookup_type_(NOT_FOUND), 158 lookup_type_(NOT_FOUND),
186 holder_(NULL), 159 holder_(NULL),
187 transition_(NULL), 160 transition_(NULL),
188 cacheable_(true), 161 cacheable_(true),
189 details_(NONE, NONEXISTENT, Representation::None()) { 162 details_(NONE, NONEXISTENT, Representation::None()) {
190 isolate->set_top_lookup_result(this); 163 isolate->set_top_lookup_result(this);
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 INTERCEPTOR_TYPE 454 INTERCEPTOR_TYPE
482 } lookup_type_; 455 } lookup_type_;
483 456
484 JSReceiver* holder_; 457 JSReceiver* holder_;
485 Map* transition_; 458 Map* transition_;
486 int number_; 459 int number_;
487 bool cacheable_; 460 bool cacheable_;
488 PropertyDetails details_; 461 PropertyDetails details_;
489 }; 462 };
490 463
491
492 } } // namespace v8::internal 464 } } // namespace v8::internal
493 465
494 #endif // V8_PROPERTY_H_ 466 #endif // V8_PROPERTY_H_
OLDNEW
« no previous file with comments | « no previous file | src/property.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698