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

Side by Side Diff: src/property.h

Issue 430503007: Rename ASSERT* to DCHECK*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and fixes Created 6 years, 4 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 | « src/profile-generator.cc ('k') | src/property-details.h » ('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 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 "src/factory.h" 8 #include "src/factory.h"
9 #include "src/field-index.h" 9 #include "src/field-index.h"
10 #include "src/field-index-inl.h" 10 #include "src/field-index-inl.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 next_(isolate->top_lookup_result()), 118 next_(isolate->top_lookup_result()),
119 lookup_type_(NOT_FOUND), 119 lookup_type_(NOT_FOUND),
120 holder_(NULL), 120 holder_(NULL),
121 transition_(NULL), 121 transition_(NULL),
122 cacheable_(true), 122 cacheable_(true),
123 details_(NONE, NONEXISTENT, Representation::None()) { 123 details_(NONE, NONEXISTENT, Representation::None()) {
124 isolate->set_top_lookup_result(this); 124 isolate->set_top_lookup_result(this);
125 } 125 }
126 126
127 ~LookupResult() { 127 ~LookupResult() {
128 ASSERT(isolate()->top_lookup_result() == this); 128 DCHECK(isolate()->top_lookup_result() == this);
129 isolate()->set_top_lookup_result(next_); 129 isolate()->set_top_lookup_result(next_);
130 } 130 }
131 131
132 Isolate* isolate() const { return isolate_; } 132 Isolate* isolate() const { return isolate_; }
133 133
134 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { 134 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) {
135 lookup_type_ = DESCRIPTOR_TYPE; 135 lookup_type_ = DESCRIPTOR_TYPE;
136 holder_ = holder; 136 holder_ = holder;
137 transition_ = NULL; 137 transition_ = NULL;
138 details_ = details; 138 details_ = details;
139 number_ = number; 139 number_ = number;
140 } 140 }
141 141
142 bool CanHoldValue(Handle<Object> value) const { 142 bool CanHoldValue(Handle<Object> value) const {
143 switch (type()) { 143 switch (type()) {
144 case NORMAL: 144 case NORMAL:
145 return true; 145 return true;
146 case FIELD: 146 case FIELD:
147 return value->FitsRepresentation(representation()) && 147 return value->FitsRepresentation(representation()) &&
148 GetFieldType()->NowContains(value); 148 GetFieldType()->NowContains(value);
149 case CONSTANT: 149 case CONSTANT:
150 ASSERT(GetConstant() != *value || 150 DCHECK(GetConstant() != *value ||
151 value->FitsRepresentation(representation())); 151 value->FitsRepresentation(representation()));
152 return GetConstant() == *value; 152 return GetConstant() == *value;
153 case CALLBACKS: 153 case CALLBACKS:
154 case HANDLER: 154 case HANDLER:
155 case INTERCEPTOR: 155 case INTERCEPTOR:
156 return true; 156 return true;
157 case NONEXISTENT: 157 case NONEXISTENT:
158 UNREACHABLE(); 158 UNREACHABLE();
159 } 159 }
160 UNREACHABLE(); 160 UNREACHABLE();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } 193 }
194 194
195 void NotFound() { 195 void NotFound() {
196 lookup_type_ = NOT_FOUND; 196 lookup_type_ = NOT_FOUND;
197 details_ = PropertyDetails(NONE, NONEXISTENT, Representation::None()); 197 details_ = PropertyDetails(NONE, NONEXISTENT, Representation::None());
198 holder_ = NULL; 198 holder_ = NULL;
199 transition_ = NULL; 199 transition_ = NULL;
200 } 200 }
201 201
202 JSObject* holder() const { 202 JSObject* holder() const {
203 ASSERT(IsFound()); 203 DCHECK(IsFound());
204 return JSObject::cast(holder_); 204 return JSObject::cast(holder_);
205 } 205 }
206 206
207 JSProxy* proxy() const { 207 JSProxy* proxy() const {
208 ASSERT(IsHandler()); 208 DCHECK(IsHandler());
209 return JSProxy::cast(holder_); 209 return JSProxy::cast(holder_);
210 } 210 }
211 211
212 PropertyType type() const { 212 PropertyType type() const {
213 ASSERT(IsFound()); 213 DCHECK(IsFound());
214 return details_.type(); 214 return details_.type();
215 } 215 }
216 216
217 Representation representation() const { 217 Representation representation() const {
218 ASSERT(IsFound()); 218 DCHECK(IsFound());
219 ASSERT(details_.type() != NONEXISTENT); 219 DCHECK(details_.type() != NONEXISTENT);
220 return details_.representation(); 220 return details_.representation();
221 } 221 }
222 222
223 PropertyAttributes GetAttributes() const { 223 PropertyAttributes GetAttributes() const {
224 ASSERT(IsFound()); 224 DCHECK(IsFound());
225 ASSERT(details_.type() != NONEXISTENT); 225 DCHECK(details_.type() != NONEXISTENT);
226 return details_.attributes(); 226 return details_.attributes();
227 } 227 }
228 228
229 PropertyDetails GetPropertyDetails() const { 229 PropertyDetails GetPropertyDetails() const {
230 return details_; 230 return details_;
231 } 231 }
232 232
233 bool IsFastPropertyType() const { 233 bool IsFastPropertyType() const {
234 ASSERT(IsFound()); 234 DCHECK(IsFound());
235 return IsTransition() || type() != NORMAL; 235 return IsTransition() || type() != NORMAL;
236 } 236 }
237 237
238 // Property callbacks does not include transitions to callbacks. 238 // Property callbacks does not include transitions to callbacks.
239 bool IsPropertyCallbacks() const { 239 bool IsPropertyCallbacks() const {
240 ASSERT(!(details_.type() == CALLBACKS && !IsFound())); 240 DCHECK(!(details_.type() == CALLBACKS && !IsFound()));
241 return !IsTransition() && details_.type() == CALLBACKS; 241 return !IsTransition() && details_.type() == CALLBACKS;
242 } 242 }
243 243
244 bool IsReadOnly() const { 244 bool IsReadOnly() const {
245 ASSERT(IsFound()); 245 DCHECK(IsFound());
246 ASSERT(details_.type() != NONEXISTENT); 246 DCHECK(details_.type() != NONEXISTENT);
247 return details_.IsReadOnly(); 247 return details_.IsReadOnly();
248 } 248 }
249 249
250 bool IsField() const { 250 bool IsField() const {
251 ASSERT(!(details_.type() == FIELD && !IsFound())); 251 DCHECK(!(details_.type() == FIELD && !IsFound()));
252 return IsDescriptorOrDictionary() && type() == FIELD; 252 return IsDescriptorOrDictionary() && type() == FIELD;
253 } 253 }
254 254
255 bool IsNormal() const { 255 bool IsNormal() const {
256 ASSERT(!(details_.type() == NORMAL && !IsFound())); 256 DCHECK(!(details_.type() == NORMAL && !IsFound()));
257 return IsDescriptorOrDictionary() && type() == NORMAL; 257 return IsDescriptorOrDictionary() && type() == NORMAL;
258 } 258 }
259 259
260 bool IsConstant() const { 260 bool IsConstant() const {
261 ASSERT(!(details_.type() == CONSTANT && !IsFound())); 261 DCHECK(!(details_.type() == CONSTANT && !IsFound()));
262 return IsDescriptorOrDictionary() && type() == CONSTANT; 262 return IsDescriptorOrDictionary() && type() == CONSTANT;
263 } 263 }
264 264
265 bool IsConstantFunction() const { 265 bool IsConstantFunction() const {
266 return IsConstant() && GetConstant()->IsJSFunction(); 266 return IsConstant() && GetConstant()->IsJSFunction();
267 } 267 }
268 268
269 bool IsDontDelete() const { return details_.IsDontDelete(); } 269 bool IsDontDelete() const { return details_.IsDontDelete(); }
270 bool IsDontEnum() const { return details_.IsDontEnum(); } 270 bool IsDontEnum() const { return details_.IsDontEnum(); }
271 bool IsFound() const { return lookup_type_ != NOT_FOUND; } 271 bool IsFound() const { return lookup_type_ != NOT_FOUND; }
(...skipping 19 matching lines...) Expand all
291 291
292 case DESCRIPTOR_TYPE: 292 case DESCRIPTOR_TYPE:
293 case DICTIONARY_TYPE: 293 case DICTIONARY_TYPE:
294 switch (type()) { 294 switch (type()) {
295 case FIELD: 295 case FIELD:
296 case NORMAL: 296 case NORMAL:
297 case CONSTANT: 297 case CONSTANT:
298 return true; 298 return true;
299 case CALLBACKS: { 299 case CALLBACKS: {
300 Object* callback = GetCallbackObject(); 300 Object* callback = GetCallbackObject();
301 ASSERT(!callback->IsForeign()); 301 DCHECK(!callback->IsForeign());
302 return callback->IsAccessorInfo(); 302 return callback->IsAccessorInfo();
303 } 303 }
304 case HANDLER: 304 case HANDLER:
305 case INTERCEPTOR: 305 case INTERCEPTOR:
306 case NONEXISTENT: 306 case NONEXISTENT:
307 UNREACHABLE(); 307 UNREACHABLE();
308 return false; 308 return false;
309 } 309 }
310 } 310 }
311 UNREACHABLE(); 311 UNREACHABLE();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 case NONEXISTENT: 345 case NONEXISTENT:
346 UNREACHABLE(); 346 UNREACHABLE();
347 return NULL; 347 return NULL;
348 } 348 }
349 } 349 }
350 UNREACHABLE(); 350 UNREACHABLE();
351 return NULL; 351 return NULL;
352 } 352 }
353 353
354 Map* GetTransitionTarget() const { 354 Map* GetTransitionTarget() const {
355 ASSERT(IsTransition()); 355 DCHECK(IsTransition());
356 return transition_; 356 return transition_;
357 } 357 }
358 358
359 bool IsTransitionToField() const { 359 bool IsTransitionToField() const {
360 return IsTransition() && details_.type() == FIELD; 360 return IsTransition() && details_.type() == FIELD;
361 } 361 }
362 362
363 bool IsTransitionToConstant() const { 363 bool IsTransitionToConstant() const {
364 return IsTransition() && details_.type() == CONSTANT; 364 return IsTransition() && details_.type() == CONSTANT;
365 } 365 }
366 366
367 int GetDescriptorIndex() const { 367 int GetDescriptorIndex() const {
368 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); 368 DCHECK(lookup_type_ == DESCRIPTOR_TYPE);
369 return number_; 369 return number_;
370 } 370 }
371 371
372 FieldIndex GetFieldIndex() const { 372 FieldIndex GetFieldIndex() const {
373 ASSERT(lookup_type_ == DESCRIPTOR_TYPE || 373 DCHECK(lookup_type_ == DESCRIPTOR_TYPE ||
374 lookup_type_ == TRANSITION_TYPE); 374 lookup_type_ == TRANSITION_TYPE);
375 return FieldIndex::ForLookupResult(this); 375 return FieldIndex::ForLookupResult(this);
376 } 376 }
377 377
378 int GetLocalFieldIndexFromMap(Map* map) const { 378 int GetLocalFieldIndexFromMap(Map* map) const {
379 return GetFieldIndexFromMap(map) - map->inobject_properties(); 379 return GetFieldIndexFromMap(map) - map->inobject_properties();
380 } 380 }
381 381
382 int GetDictionaryEntry() const { 382 int GetDictionaryEntry() const {
383 ASSERT(lookup_type_ == DICTIONARY_TYPE); 383 DCHECK(lookup_type_ == DICTIONARY_TYPE);
384 return number_; 384 return number_;
385 } 385 }
386 386
387 JSFunction* GetConstantFunction() const { 387 JSFunction* GetConstantFunction() const {
388 ASSERT(type() == CONSTANT); 388 DCHECK(type() == CONSTANT);
389 return JSFunction::cast(GetValue()); 389 return JSFunction::cast(GetValue());
390 } 390 }
391 391
392 Object* GetConstantFromMap(Map* map) const { 392 Object* GetConstantFromMap(Map* map) const {
393 ASSERT(type() == CONSTANT); 393 DCHECK(type() == CONSTANT);
394 return GetValueFromMap(map); 394 return GetValueFromMap(map);
395 } 395 }
396 396
397 JSFunction* GetConstantFunctionFromMap(Map* map) const { 397 JSFunction* GetConstantFunctionFromMap(Map* map) const {
398 return JSFunction::cast(GetConstantFromMap(map)); 398 return JSFunction::cast(GetConstantFromMap(map));
399 } 399 }
400 400
401 Object* GetConstant() const { 401 Object* GetConstant() const {
402 ASSERT(type() == CONSTANT); 402 DCHECK(type() == CONSTANT);
403 return GetValue(); 403 return GetValue();
404 } 404 }
405 405
406 Object* GetCallbackObject() const { 406 Object* GetCallbackObject() const {
407 ASSERT(!IsTransition()); 407 DCHECK(!IsTransition());
408 ASSERT(type() == CALLBACKS); 408 DCHECK(type() == CALLBACKS);
409 return GetValue(); 409 return GetValue();
410 } 410 }
411 411
412 Object* GetValue() const { 412 Object* GetValue() const {
413 if (lookup_type_ == DESCRIPTOR_TYPE) { 413 if (lookup_type_ == DESCRIPTOR_TYPE) {
414 return GetValueFromMap(holder()->map()); 414 return GetValueFromMap(holder()->map());
415 } else if (lookup_type_ == TRANSITION_TYPE) { 415 } else if (lookup_type_ == TRANSITION_TYPE) {
416 return GetValueFromMap(transition_); 416 return GetValueFromMap(transition_);
417 } 417 }
418 // In the dictionary case, the data is held in the value field. 418 // In the dictionary case, the data is held in the value field.
419 ASSERT(lookup_type_ == DICTIONARY_TYPE); 419 DCHECK(lookup_type_ == DICTIONARY_TYPE);
420 return holder()->GetNormalizedProperty(this); 420 return holder()->GetNormalizedProperty(this);
421 } 421 }
422 422
423 Object* GetValueFromMap(Map* map) const { 423 Object* GetValueFromMap(Map* map) const {
424 ASSERT(lookup_type_ == DESCRIPTOR_TYPE || 424 DCHECK(lookup_type_ == DESCRIPTOR_TYPE ||
425 lookup_type_ == TRANSITION_TYPE); 425 lookup_type_ == TRANSITION_TYPE);
426 ASSERT(number_ < map->NumberOfOwnDescriptors()); 426 DCHECK(number_ < map->NumberOfOwnDescriptors());
427 return map->instance_descriptors()->GetValue(number_); 427 return map->instance_descriptors()->GetValue(number_);
428 } 428 }
429 429
430 int GetFieldIndexFromMap(Map* map) const { 430 int GetFieldIndexFromMap(Map* map) const {
431 ASSERT(lookup_type_ == DESCRIPTOR_TYPE || 431 DCHECK(lookup_type_ == DESCRIPTOR_TYPE ||
432 lookup_type_ == TRANSITION_TYPE); 432 lookup_type_ == TRANSITION_TYPE);
433 ASSERT(number_ < map->NumberOfOwnDescriptors()); 433 DCHECK(number_ < map->NumberOfOwnDescriptors());
434 return map->instance_descriptors()->GetFieldIndex(number_); 434 return map->instance_descriptors()->GetFieldIndex(number_);
435 } 435 }
436 436
437 HeapType* GetFieldType() const { 437 HeapType* GetFieldType() const {
438 ASSERT(type() == FIELD); 438 DCHECK(type() == FIELD);
439 if (lookup_type_ == DESCRIPTOR_TYPE) { 439 if (lookup_type_ == DESCRIPTOR_TYPE) {
440 return GetFieldTypeFromMap(holder()->map()); 440 return GetFieldTypeFromMap(holder()->map());
441 } 441 }
442 ASSERT(lookup_type_ == TRANSITION_TYPE); 442 DCHECK(lookup_type_ == TRANSITION_TYPE);
443 return GetFieldTypeFromMap(transition_); 443 return GetFieldTypeFromMap(transition_);
444 } 444 }
445 445
446 HeapType* GetFieldTypeFromMap(Map* map) const { 446 HeapType* GetFieldTypeFromMap(Map* map) const {
447 ASSERT(lookup_type_ == DESCRIPTOR_TYPE || 447 DCHECK(lookup_type_ == DESCRIPTOR_TYPE ||
448 lookup_type_ == TRANSITION_TYPE); 448 lookup_type_ == TRANSITION_TYPE);
449 ASSERT(number_ < map->NumberOfOwnDescriptors()); 449 DCHECK(number_ < map->NumberOfOwnDescriptors());
450 return map->instance_descriptors()->GetFieldType(number_); 450 return map->instance_descriptors()->GetFieldType(number_);
451 } 451 }
452 452
453 Map* GetFieldOwner() const { 453 Map* GetFieldOwner() const {
454 return GetFieldOwnerFromMap(holder()->map()); 454 return GetFieldOwnerFromMap(holder()->map());
455 } 455 }
456 456
457 Map* GetFieldOwnerFromMap(Map* map) const { 457 Map* GetFieldOwnerFromMap(Map* map) const {
458 ASSERT(lookup_type_ == DESCRIPTOR_TYPE || 458 DCHECK(lookup_type_ == DESCRIPTOR_TYPE ||
459 lookup_type_ == TRANSITION_TYPE); 459 lookup_type_ == TRANSITION_TYPE);
460 ASSERT(number_ < map->NumberOfOwnDescriptors()); 460 DCHECK(number_ < map->NumberOfOwnDescriptors());
461 return map->FindFieldOwner(number_); 461 return map->FindFieldOwner(number_);
462 } 462 }
463 463
464 bool ReceiverIsHolder(Handle<Object> receiver) { 464 bool ReceiverIsHolder(Handle<Object> receiver) {
465 if (*receiver == holder()) return true; 465 if (*receiver == holder()) return true;
466 if (lookup_type_ == TRANSITION_TYPE) return true; 466 if (lookup_type_ == TRANSITION_TYPE) return true;
467 return false; 467 return false;
468 } 468 }
469 469
470 void Iterate(ObjectVisitor* visitor); 470 void Iterate(ObjectVisitor* visitor);
(...skipping 17 matching lines...) Expand all
488 int number_; 488 int number_;
489 bool cacheable_; 489 bool cacheable_;
490 PropertyDetails details_; 490 PropertyDetails details_;
491 }; 491 };
492 492
493 493
494 OStream& operator<<(OStream& os, const LookupResult& r); 494 OStream& operator<<(OStream& os, const LookupResult& r);
495 } } // namespace v8::internal 495 } } // namespace v8::internal
496 496
497 #endif // V8_PROPERTY_H_ 497 #endif // V8_PROPERTY_H_
OLDNEW
« no previous file with comments | « src/profile-generator.cc ('k') | src/property-details.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698