OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 return Smi::FromInt(value_); | 60 return Smi::FromInt(value_); |
61 } | 61 } |
62 | 62 |
63 | 63 |
64 PropertyDetails PropertyDetails::AsDeleted() { | 64 PropertyDetails PropertyDetails::AsDeleted() { |
65 Smi* smi = Smi::FromInt(value_ | DeletedField::encode(1)); | 65 Smi* smi = Smi::FromInt(value_ | DeletedField::encode(1)); |
66 return PropertyDetails(smi); | 66 return PropertyDetails(smi); |
67 } | 67 } |
68 | 68 |
69 | 69 |
| 70 #define TYPE_CHECKER(type, instancetype) \ |
| 71 bool Object::Is##type() { \ |
| 72 return Object::IsHeapObject() && \ |
| 73 HeapObject::cast(this)->map()->instance_type() == instancetype; \ |
| 74 } |
| 75 |
| 76 |
70 #define CAST_ACCESSOR(type) \ | 77 #define CAST_ACCESSOR(type) \ |
71 type* type::cast(Object* object) { \ | 78 type* type::cast(Object* object) { \ |
72 ASSERT(object->Is##type()); \ | 79 ASSERT(object->Is##type()); \ |
73 return reinterpret_cast<type*>(object); \ | 80 return reinterpret_cast<type*>(object); \ |
74 } | 81 } |
75 | 82 |
76 | 83 |
77 #define INT_ACCESSORS(holder, name, offset) \ | 84 #define INT_ACCESSORS(holder, name, offset) \ |
78 int holder::name() { return READ_INT_FIELD(this, offset); } \ | 85 int holder::name() { return READ_INT_FIELD(this, offset); } \ |
79 void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); } | 86 void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); } |
(...skipping 25 matching lines...) Expand all Loading... |
105 | 112 |
106 #define BOOL_ACCESSORS(holder, field, name, offset) \ | 113 #define BOOL_ACCESSORS(holder, field, name, offset) \ |
107 bool holder::name() { \ | 114 bool holder::name() { \ |
108 return BooleanBit::get(field(), offset); \ | 115 return BooleanBit::get(field(), offset); \ |
109 } \ | 116 } \ |
110 void holder::set_##name(bool value) { \ | 117 void holder::set_##name(bool value) { \ |
111 set_##field(BooleanBit::set(field(), offset, value)); \ | 118 set_##field(BooleanBit::set(field(), offset, value)); \ |
112 } | 119 } |
113 | 120 |
114 | 121 |
| 122 bool Object::IsFixedArrayBase() { |
| 123 return IsFixedArray() || IsFixedDoubleArray(); |
| 124 } |
| 125 |
| 126 |
115 bool Object::IsInstanceOf(FunctionTemplateInfo* expected) { | 127 bool Object::IsInstanceOf(FunctionTemplateInfo* expected) { |
116 // There is a constraint on the object; check. | 128 // There is a constraint on the object; check. |
117 if (!this->IsJSObject()) return false; | 129 if (!this->IsJSObject()) return false; |
118 // Fetch the constructor function of the object. | 130 // Fetch the constructor function of the object. |
119 Object* cons_obj = JSObject::cast(this)->map()->constructor(); | 131 Object* cons_obj = JSObject::cast(this)->map()->constructor(); |
120 if (!cons_obj->IsJSFunction()) return false; | 132 if (!cons_obj->IsJSFunction()) return false; |
121 JSFunction* fun = JSFunction::cast(cons_obj); | 133 JSFunction* fun = JSFunction::cast(cons_obj); |
122 // Iterate through the chain of inheriting function templates to | 134 // Iterate through the chain of inheriting function templates to |
123 // see if the required one occurs. | 135 // see if the required one occurs. |
124 for (Object* type = fun->shared()->function_data(); | 136 for (Object* type = fun->shared()->function_data(); |
(...skipping 15 matching lines...) Expand all Loading... |
140 return Internals::HasHeapObjectTag(this); | 152 return Internals::HasHeapObjectTag(this); |
141 } | 153 } |
142 | 154 |
143 | 155 |
144 bool Object::NonFailureIsHeapObject() { | 156 bool Object::NonFailureIsHeapObject() { |
145 ASSERT(!this->IsFailure()); | 157 ASSERT(!this->IsFailure()); |
146 return (reinterpret_cast<intptr_t>(this) & kSmiTagMask) != 0; | 158 return (reinterpret_cast<intptr_t>(this) & kSmiTagMask) != 0; |
147 } | 159 } |
148 | 160 |
149 | 161 |
150 bool Object::IsHeapNumber() { | 162 TYPE_CHECKER(HeapNumber, HEAP_NUMBER_TYPE) |
151 return Object::IsHeapObject() | |
152 && HeapObject::cast(this)->map()->instance_type() == HEAP_NUMBER_TYPE; | |
153 } | |
154 | 163 |
155 | 164 |
156 bool Object::IsString() { | 165 bool Object::IsString() { |
157 return Object::IsHeapObject() | 166 return Object::IsHeapObject() |
158 && HeapObject::cast(this)->map()->instance_type() < FIRST_NONSTRING_TYPE; | 167 && HeapObject::cast(this)->map()->instance_type() < FIRST_NONSTRING_TYPE; |
159 } | 168 } |
160 | 169 |
161 | 170 |
162 bool Object::IsSpecObject() { | 171 bool Object::IsSpecObject() { |
163 return Object::IsHeapObject() | 172 return Object::IsHeapObject() |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 return static_cast<const uc16*>(start_)[index]; | 405 return static_cast<const uc16*>(start_)[index]; |
397 } | 406 } |
398 } | 407 } |
399 | 408 |
400 | 409 |
401 bool Object::IsNumber() { | 410 bool Object::IsNumber() { |
402 return IsSmi() || IsHeapNumber(); | 411 return IsSmi() || IsHeapNumber(); |
403 } | 412 } |
404 | 413 |
405 | 414 |
406 bool Object::IsByteArray() { | 415 TYPE_CHECKER(ByteArray, BYTE_ARRAY_TYPE) |
407 return Object::IsHeapObject() | 416 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE) |
408 && HeapObject::cast(this)->map()->instance_type() == BYTE_ARRAY_TYPE; | |
409 } | |
410 | |
411 | |
412 bool Object::IsFreeSpace() { | |
413 return Object::IsHeapObject() | |
414 && HeapObject::cast(this)->map()->instance_type() == FREE_SPACE_TYPE; | |
415 } | |
416 | 417 |
417 | 418 |
418 bool Object::IsFiller() { | 419 bool Object::IsFiller() { |
419 if (!Object::IsHeapObject()) return false; | 420 if (!Object::IsHeapObject()) return false; |
420 InstanceType instance_type = HeapObject::cast(this)->map()->instance_type(); | 421 InstanceType instance_type = HeapObject::cast(this)->map()->instance_type(); |
421 return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE; | 422 return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE; |
422 } | 423 } |
423 | 424 |
424 | 425 |
425 bool Object::IsExternalPixelArray() { | 426 TYPE_CHECKER(ExternalPixelArray, EXTERNAL_PIXEL_ARRAY_TYPE) |
426 return Object::IsHeapObject() && | |
427 HeapObject::cast(this)->map()->instance_type() == | |
428 EXTERNAL_PIXEL_ARRAY_TYPE; | |
429 } | |
430 | 427 |
431 | 428 |
432 bool Object::IsExternalArray() { | 429 bool Object::IsExternalArray() { |
433 if (!Object::IsHeapObject()) | 430 if (!Object::IsHeapObject()) |
434 return false; | 431 return false; |
435 InstanceType instance_type = | 432 InstanceType instance_type = |
436 HeapObject::cast(this)->map()->instance_type(); | 433 HeapObject::cast(this)->map()->instance_type(); |
437 return (instance_type >= FIRST_EXTERNAL_ARRAY_TYPE && | 434 return (instance_type >= FIRST_EXTERNAL_ARRAY_TYPE && |
438 instance_type <= LAST_EXTERNAL_ARRAY_TYPE); | 435 instance_type <= LAST_EXTERNAL_ARRAY_TYPE); |
439 } | 436 } |
440 | 437 |
441 | 438 |
442 bool Object::IsExternalByteArray() { | 439 TYPE_CHECKER(ExternalByteArray, EXTERNAL_BYTE_ARRAY_TYPE) |
443 return Object::IsHeapObject() && | 440 TYPE_CHECKER(ExternalUnsignedByteArray, EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) |
444 HeapObject::cast(this)->map()->instance_type() == | 441 TYPE_CHECKER(ExternalShortArray, EXTERNAL_SHORT_ARRAY_TYPE) |
445 EXTERNAL_BYTE_ARRAY_TYPE; | 442 TYPE_CHECKER(ExternalUnsignedShortArray, EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) |
446 } | 443 TYPE_CHECKER(ExternalIntArray, EXTERNAL_INT_ARRAY_TYPE) |
447 | 444 TYPE_CHECKER(ExternalUnsignedIntArray, EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) |
448 | 445 TYPE_CHECKER(ExternalFloatArray, EXTERNAL_FLOAT_ARRAY_TYPE) |
449 bool Object::IsExternalUnsignedByteArray() { | 446 TYPE_CHECKER(ExternalDoubleArray, EXTERNAL_DOUBLE_ARRAY_TYPE) |
450 return Object::IsHeapObject() && | |
451 HeapObject::cast(this)->map()->instance_type() == | |
452 EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE; | |
453 } | |
454 | |
455 | |
456 bool Object::IsExternalShortArray() { | |
457 return Object::IsHeapObject() && | |
458 HeapObject::cast(this)->map()->instance_type() == | |
459 EXTERNAL_SHORT_ARRAY_TYPE; | |
460 } | |
461 | |
462 | |
463 bool Object::IsExternalUnsignedShortArray() { | |
464 return Object::IsHeapObject() && | |
465 HeapObject::cast(this)->map()->instance_type() == | |
466 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE; | |
467 } | |
468 | |
469 | |
470 bool Object::IsExternalIntArray() { | |
471 return Object::IsHeapObject() && | |
472 HeapObject::cast(this)->map()->instance_type() == | |
473 EXTERNAL_INT_ARRAY_TYPE; | |
474 } | |
475 | |
476 | |
477 bool Object::IsExternalUnsignedIntArray() { | |
478 return Object::IsHeapObject() && | |
479 HeapObject::cast(this)->map()->instance_type() == | |
480 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE; | |
481 } | |
482 | |
483 | |
484 bool Object::IsExternalFloatArray() { | |
485 return Object::IsHeapObject() && | |
486 HeapObject::cast(this)->map()->instance_type() == | |
487 EXTERNAL_FLOAT_ARRAY_TYPE; | |
488 } | |
489 | |
490 | |
491 bool Object::IsExternalDoubleArray() { | |
492 return Object::IsHeapObject() && | |
493 HeapObject::cast(this)->map()->instance_type() == | |
494 EXTERNAL_DOUBLE_ARRAY_TYPE; | |
495 } | |
496 | 447 |
497 | 448 |
498 bool MaybeObject::IsFailure() { | 449 bool MaybeObject::IsFailure() { |
499 return HAS_FAILURE_TAG(this); | 450 return HAS_FAILURE_TAG(this); |
500 } | 451 } |
501 | 452 |
502 | 453 |
503 bool MaybeObject::IsRetryAfterGC() { | 454 bool MaybeObject::IsRetryAfterGC() { |
504 return HAS_FAILURE_TAG(this) | 455 return HAS_FAILURE_TAG(this) |
505 && Failure::cast(this)->type() == Failure::RETRY_AFTER_GC; | 456 && Failure::cast(this)->type() == Failure::RETRY_AFTER_GC; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 } | 493 } |
543 | 494 |
544 | 495 |
545 bool Object::IsJSProxy() { | 496 bool Object::IsJSProxy() { |
546 if (!Object::IsHeapObject()) return false; | 497 if (!Object::IsHeapObject()) return false; |
547 InstanceType type = HeapObject::cast(this)->map()->instance_type(); | 498 InstanceType type = HeapObject::cast(this)->map()->instance_type(); |
548 return FIRST_JS_PROXY_TYPE <= type && type <= LAST_JS_PROXY_TYPE; | 499 return FIRST_JS_PROXY_TYPE <= type && type <= LAST_JS_PROXY_TYPE; |
549 } | 500 } |
550 | 501 |
551 | 502 |
552 bool Object::IsJSFunctionProxy() { | 503 TYPE_CHECKER(JSFunctionProxy, JS_FUNCTION_PROXY_TYPE) |
553 return Object::IsHeapObject() && | 504 TYPE_CHECKER(JSSet, JS_SET_TYPE) |
554 HeapObject::cast(this)->map()->instance_type() == JS_FUNCTION_PROXY_TYPE; | 505 TYPE_CHECKER(JSMap, JS_MAP_TYPE) |
555 } | 506 TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE) |
556 | 507 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE) |
557 | 508 TYPE_CHECKER(Map, MAP_TYPE) |
558 bool Object::IsJSWeakMap() { | 509 TYPE_CHECKER(FixedArray, FIXED_ARRAY_TYPE) |
559 return Object::IsJSObject() && | 510 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE) |
560 HeapObject::cast(this)->map()->instance_type() == JS_WEAK_MAP_TYPE; | |
561 } | |
562 | |
563 | |
564 bool Object::IsJSContextExtensionObject() { | |
565 return IsHeapObject() | |
566 && (HeapObject::cast(this)->map()->instance_type() == | |
567 JS_CONTEXT_EXTENSION_OBJECT_TYPE); | |
568 } | |
569 | |
570 | |
571 bool Object::IsMap() { | |
572 return Object::IsHeapObject() | |
573 && HeapObject::cast(this)->map()->instance_type() == MAP_TYPE; | |
574 } | |
575 | |
576 | |
577 bool Object::IsFixedArray() { | |
578 return Object::IsHeapObject() | |
579 && HeapObject::cast(this)->map()->instance_type() == FIXED_ARRAY_TYPE; | |
580 } | |
581 | |
582 | |
583 bool Object::IsFixedDoubleArray() { | |
584 return Object::IsHeapObject() | |
585 && HeapObject::cast(this)->map()->instance_type() == | |
586 FIXED_DOUBLE_ARRAY_TYPE; | |
587 } | |
588 | 511 |
589 | 512 |
590 bool Object::IsDescriptorArray() { | 513 bool Object::IsDescriptorArray() { |
591 return IsFixedArray(); | 514 return IsFixedArray(); |
592 } | 515 } |
593 | 516 |
594 | 517 |
595 bool Object::IsDeoptimizationInputData() { | 518 bool Object::IsDeoptimizationInputData() { |
596 // Must be a fixed array. | 519 // Must be a fixed array. |
597 if (!IsFixedArray()) return false; | 520 if (!IsFixedArray()) return false; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 } | 563 } |
641 | 564 |
642 | 565 |
643 bool Object::IsSerializedScopeInfo() { | 566 bool Object::IsSerializedScopeInfo() { |
644 return Object::IsHeapObject() && | 567 return Object::IsHeapObject() && |
645 HeapObject::cast(this)->map() == | 568 HeapObject::cast(this)->map() == |
646 HeapObject::cast(this)->GetHeap()->serialized_scope_info_map(); | 569 HeapObject::cast(this)->GetHeap()->serialized_scope_info_map(); |
647 } | 570 } |
648 | 571 |
649 | 572 |
650 bool Object::IsJSFunction() { | 573 TYPE_CHECKER(JSFunction, JS_FUNCTION_TYPE) |
651 return Object::IsHeapObject() | |
652 && HeapObject::cast(this)->map()->instance_type() == JS_FUNCTION_TYPE; | |
653 } | |
654 | 574 |
655 | 575 |
656 template <> inline bool Is<JSFunction>(Object* obj) { | 576 template <> inline bool Is<JSFunction>(Object* obj) { |
657 return obj->IsJSFunction(); | 577 return obj->IsJSFunction(); |
658 } | 578 } |
659 | 579 |
660 | 580 |
661 bool Object::IsCode() { | 581 TYPE_CHECKER(Code, CODE_TYPE) |
662 return Object::IsHeapObject() | 582 TYPE_CHECKER(Oddball, ODDBALL_TYPE) |
663 && HeapObject::cast(this)->map()->instance_type() == CODE_TYPE; | 583 TYPE_CHECKER(JSGlobalPropertyCell, JS_GLOBAL_PROPERTY_CELL_TYPE) |
664 } | 584 TYPE_CHECKER(SharedFunctionInfo, SHARED_FUNCTION_INFO_TYPE) |
665 | 585 TYPE_CHECKER(JSValue, JS_VALUE_TYPE) |
666 | 586 TYPE_CHECKER(JSMessageObject, JS_MESSAGE_OBJECT_TYPE) |
667 bool Object::IsOddball() { | |
668 return Object::IsHeapObject() | |
669 && HeapObject::cast(this)->map()->instance_type() == ODDBALL_TYPE; | |
670 } | |
671 | |
672 | |
673 bool Object::IsJSGlobalPropertyCell() { | |
674 return Object::IsHeapObject() | |
675 && HeapObject::cast(this)->map()->instance_type() | |
676 == JS_GLOBAL_PROPERTY_CELL_TYPE; | |
677 } | |
678 | |
679 | |
680 bool Object::IsSharedFunctionInfo() { | |
681 return Object::IsHeapObject() && | |
682 (HeapObject::cast(this)->map()->instance_type() == | |
683 SHARED_FUNCTION_INFO_TYPE); | |
684 } | |
685 | |
686 | |
687 bool Object::IsJSValue() { | |
688 return Object::IsHeapObject() | |
689 && HeapObject::cast(this)->map()->instance_type() == JS_VALUE_TYPE; | |
690 } | |
691 | |
692 | |
693 bool Object::IsJSMessageObject() { | |
694 return Object::IsHeapObject() | |
695 && (HeapObject::cast(this)->map()->instance_type() == | |
696 JS_MESSAGE_OBJECT_TYPE); | |
697 } | |
698 | 587 |
699 | 588 |
700 bool Object::IsStringWrapper() { | 589 bool Object::IsStringWrapper() { |
701 return IsJSValue() && JSValue::cast(this)->value()->IsString(); | 590 return IsJSValue() && JSValue::cast(this)->value()->IsString(); |
702 } | 591 } |
703 | 592 |
704 | 593 |
705 bool Object::IsForeign() { | 594 TYPE_CHECKER(Foreign, FOREIGN_TYPE) |
706 return Object::IsHeapObject() | |
707 && HeapObject::cast(this)->map()->instance_type() == FOREIGN_TYPE; | |
708 } | |
709 | 595 |
710 | 596 |
711 bool Object::IsBoolean() { | 597 bool Object::IsBoolean() { |
712 return IsOddball() && | 598 return IsOddball() && |
713 ((Oddball::cast(this)->kind() & Oddball::kNotBooleanMask) == 0); | 599 ((Oddball::cast(this)->kind() & Oddball::kNotBooleanMask) == 0); |
714 } | 600 } |
715 | 601 |
716 | 602 |
717 bool Object::IsJSArray() { | 603 TYPE_CHECKER(JSArray, JS_ARRAY_TYPE) |
718 return Object::IsHeapObject() | 604 TYPE_CHECKER(JSRegExp, JS_REGEXP_TYPE) |
719 && HeapObject::cast(this)->map()->instance_type() == JS_ARRAY_TYPE; | |
720 } | |
721 | |
722 | |
723 bool Object::IsJSRegExp() { | |
724 return Object::IsHeapObject() | |
725 && HeapObject::cast(this)->map()->instance_type() == JS_REGEXP_TYPE; | |
726 } | |
727 | 605 |
728 | 606 |
729 template <> inline bool Is<JSArray>(Object* obj) { | 607 template <> inline bool Is<JSArray>(Object* obj) { |
730 return obj->IsJSArray(); | 608 return obj->IsJSArray(); |
731 } | 609 } |
732 | 610 |
733 | 611 |
734 bool Object::IsHashTable() { | 612 bool Object::IsHashTable() { |
735 return Object::IsHeapObject() && | 613 return Object::IsHeapObject() && |
736 HeapObject::cast(this)->map() == | 614 HeapObject::cast(this)->map() == |
(...skipping 16 matching lines...) Expand all Loading... |
753 bool Object::IsJSFunctionResultCache() { | 631 bool Object::IsJSFunctionResultCache() { |
754 if (!IsFixedArray()) return false; | 632 if (!IsFixedArray()) return false; |
755 FixedArray* self = FixedArray::cast(this); | 633 FixedArray* self = FixedArray::cast(this); |
756 int length = self->length(); | 634 int length = self->length(); |
757 if (length < JSFunctionResultCache::kEntriesIndex) return false; | 635 if (length < JSFunctionResultCache::kEntriesIndex) return false; |
758 if ((length - JSFunctionResultCache::kEntriesIndex) | 636 if ((length - JSFunctionResultCache::kEntriesIndex) |
759 % JSFunctionResultCache::kEntrySize != 0) { | 637 % JSFunctionResultCache::kEntrySize != 0) { |
760 return false; | 638 return false; |
761 } | 639 } |
762 #ifdef DEBUG | 640 #ifdef DEBUG |
763 reinterpret_cast<JSFunctionResultCache*>(this)->JSFunctionResultCacheVerify(); | 641 if (FLAG_verify_heap) { |
| 642 reinterpret_cast<JSFunctionResultCache*>(this)-> |
| 643 JSFunctionResultCacheVerify(); |
| 644 } |
764 #endif | 645 #endif |
765 return true; | 646 return true; |
766 } | 647 } |
767 | 648 |
768 | 649 |
769 bool Object::IsNormalizedMapCache() { | 650 bool Object::IsNormalizedMapCache() { |
770 if (!IsFixedArray()) return false; | 651 if (!IsFixedArray()) return false; |
771 if (FixedArray::cast(this)->length() != NormalizedMapCache::kEntries) { | 652 if (FixedArray::cast(this)->length() != NormalizedMapCache::kEntries) { |
772 return false; | 653 return false; |
773 } | 654 } |
774 #ifdef DEBUG | 655 #ifdef DEBUG |
775 reinterpret_cast<NormalizedMapCache*>(this)->NormalizedMapCacheVerify(); | 656 if (FLAG_verify_heap) { |
| 657 reinterpret_cast<NormalizedMapCache*>(this)->NormalizedMapCacheVerify(); |
| 658 } |
776 #endif | 659 #endif |
777 return true; | 660 return true; |
778 } | 661 } |
779 | 662 |
780 | 663 |
781 bool Object::IsCompilationCacheTable() { | 664 bool Object::IsCompilationCacheTable() { |
782 return IsHashTable(); | 665 return IsHashTable(); |
783 } | 666 } |
784 | 667 |
785 | 668 |
(...skipping 28 matching lines...) Expand all Loading... |
814 | 697 |
815 bool Object::IsGlobalObject() { | 698 bool Object::IsGlobalObject() { |
816 if (!IsHeapObject()) return false; | 699 if (!IsHeapObject()) return false; |
817 | 700 |
818 InstanceType type = HeapObject::cast(this)->map()->instance_type(); | 701 InstanceType type = HeapObject::cast(this)->map()->instance_type(); |
819 return type == JS_GLOBAL_OBJECT_TYPE || | 702 return type == JS_GLOBAL_OBJECT_TYPE || |
820 type == JS_BUILTINS_OBJECT_TYPE; | 703 type == JS_BUILTINS_OBJECT_TYPE; |
821 } | 704 } |
822 | 705 |
823 | 706 |
824 bool Object::IsJSGlobalObject() { | 707 TYPE_CHECKER(JSGlobalObject, JS_GLOBAL_OBJECT_TYPE) |
825 return IsHeapObject() && | 708 TYPE_CHECKER(JSBuiltinsObject, JS_BUILTINS_OBJECT_TYPE) |
826 (HeapObject::cast(this)->map()->instance_type() == | |
827 JS_GLOBAL_OBJECT_TYPE); | |
828 } | |
829 | |
830 | |
831 bool Object::IsJSBuiltinsObject() { | |
832 return IsHeapObject() && | |
833 (HeapObject::cast(this)->map()->instance_type() == | |
834 JS_BUILTINS_OBJECT_TYPE); | |
835 } | |
836 | 709 |
837 | 710 |
838 bool Object::IsUndetectableObject() { | 711 bool Object::IsUndetectableObject() { |
839 return IsHeapObject() | 712 return IsHeapObject() |
840 && HeapObject::cast(this)->map()->is_undetectable(); | 713 && HeapObject::cast(this)->map()->is_undetectable(); |
841 } | 714 } |
842 | 715 |
843 | 716 |
844 bool Object::IsAccessCheckNeeded() { | 717 bool Object::IsAccessCheckNeeded() { |
845 return IsHeapObject() | 718 return IsHeapObject() |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 int HeapNumber::get_sign() { | 1166 int HeapNumber::get_sign() { |
1294 return READ_INT_FIELD(this, kExponentOffset) & kSignMask; | 1167 return READ_INT_FIELD(this, kExponentOffset) & kSignMask; |
1295 } | 1168 } |
1296 | 1169 |
1297 | 1170 |
1298 ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset) | 1171 ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset) |
1299 | 1172 |
1300 | 1173 |
1301 FixedArrayBase* JSObject::elements() { | 1174 FixedArrayBase* JSObject::elements() { |
1302 Object* array = READ_FIELD(this, kElementsOffset); | 1175 Object* array = READ_FIELD(this, kElementsOffset); |
1303 ASSERT(array->HasValidElements()); | |
1304 return static_cast<FixedArrayBase*>(array); | 1176 return static_cast<FixedArrayBase*>(array); |
1305 } | 1177 } |
1306 | 1178 |
1307 void JSObject::ValidateSmiOnlyElements() { | 1179 void JSObject::ValidateSmiOnlyElements() { |
1308 #if DEBUG | 1180 #if DEBUG |
1309 if (map()->elements_kind() == FAST_SMI_ONLY_ELEMENTS) { | 1181 if (map()->elements_kind() == FAST_SMI_ONLY_ELEMENTS) { |
1310 Heap* heap = GetHeap(); | 1182 Heap* heap = GetHeap(); |
1311 // Don't use elements, since integrity checks will fail if there | 1183 // Don't use elements, since integrity checks will fail if there |
1312 // are filler pointers in the array. | 1184 // are filler pointers in the array. |
1313 FixedArray* fixed_array = | 1185 FixedArray* fixed_array = |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1733 | 1605 |
1734 void FixedDoubleArray::Initialize(FixedDoubleArray* from) { | 1606 void FixedDoubleArray::Initialize(FixedDoubleArray* from) { |
1735 int old_length = from->length(); | 1607 int old_length = from->length(); |
1736 ASSERT(old_length < length()); | 1608 ASSERT(old_length < length()); |
1737 if (old_length * kDoubleSize >= OS::kMinComplexMemCopy) { | 1609 if (old_length * kDoubleSize >= OS::kMinComplexMemCopy) { |
1738 OS::MemCopy(FIELD_ADDR(this, kHeaderSize), | 1610 OS::MemCopy(FIELD_ADDR(this, kHeaderSize), |
1739 FIELD_ADDR(from, kHeaderSize), | 1611 FIELD_ADDR(from, kHeaderSize), |
1740 old_length * kDoubleSize); | 1612 old_length * kDoubleSize); |
1741 } else { | 1613 } else { |
1742 for (int i = 0; i < old_length; ++i) { | 1614 for (int i = 0; i < old_length; ++i) { |
1743 set(i, from->get_scalar(i)); | 1615 if (from->is_the_hole(i)) { |
| 1616 set_the_hole(i); |
| 1617 } else { |
| 1618 set(i, from->get_scalar(i)); |
| 1619 } |
1744 } | 1620 } |
1745 } | 1621 } |
1746 int offset = kHeaderSize + old_length * kDoubleSize; | 1622 int offset = kHeaderSize + old_length * kDoubleSize; |
1747 for (int current = from->length(); current < length(); ++current) { | 1623 for (int current = from->length(); current < length(); ++current) { |
1748 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); | 1624 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); |
1749 offset += kDoubleSize; | 1625 offset += kDoubleSize; |
1750 } | 1626 } |
1751 } | 1627 } |
1752 | 1628 |
1753 | 1629 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1798 Object* value, | 1674 Object* value, |
1799 WriteBarrierMode mode) { | 1675 WriteBarrierMode mode) { |
1800 ASSERT(map() != HEAP->fixed_cow_array_map()); | 1676 ASSERT(map() != HEAP->fixed_cow_array_map()); |
1801 ASSERT(index >= 0 && index < this->length()); | 1677 ASSERT(index >= 0 && index < this->length()); |
1802 int offset = kHeaderSize + index * kPointerSize; | 1678 int offset = kHeaderSize + index * kPointerSize; |
1803 WRITE_FIELD(this, offset, value); | 1679 WRITE_FIELD(this, offset, value); |
1804 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); | 1680 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); |
1805 } | 1681 } |
1806 | 1682 |
1807 | 1683 |
1808 void FixedArray::fast_set(FixedArray* array, int index, Object* value) { | 1684 void FixedArray::NoWriteBarrierSet(FixedArray* array, |
| 1685 int index, |
| 1686 Object* value) { |
1809 ASSERT(array->map() != HEAP->raw_unchecked_fixed_cow_array_map()); | 1687 ASSERT(array->map() != HEAP->raw_unchecked_fixed_cow_array_map()); |
1810 ASSERT(index >= 0 && index < array->length()); | 1688 ASSERT(index >= 0 && index < array->length()); |
1811 ASSERT(!HEAP->InNewSpace(value)); | 1689 ASSERT(!HEAP->InNewSpace(value)); |
1812 WRITE_FIELD(array, kHeaderSize + index * kPointerSize, value); | 1690 WRITE_FIELD(array, kHeaderSize + index * kPointerSize, value); |
1813 array->GetHeap()->incremental_marking()->RecordWrite( | |
1814 array, | |
1815 HeapObject::RawField(array, kHeaderSize + index * kPointerSize), | |
1816 value); | |
1817 } | 1691 } |
1818 | 1692 |
1819 | 1693 |
1820 void FixedArray::set_undefined(int index) { | 1694 void FixedArray::set_undefined(int index) { |
1821 ASSERT(map() != HEAP->fixed_cow_array_map()); | 1695 ASSERT(map() != HEAP->fixed_cow_array_map()); |
1822 set_undefined(GetHeap(), index); | 1696 set_undefined(GetHeap(), index); |
1823 } | 1697 } |
1824 | 1698 |
1825 | 1699 |
1826 void FixedArray::set_undefined(Heap* heap, int index) { | 1700 void FixedArray::set_undefined(Heap* heap, int index) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1894 Object* storage = READ_FIELD(this, kBitField3StorageOffset); | 1768 Object* storage = READ_FIELD(this, kBitField3StorageOffset); |
1895 return Smi::cast(storage)->value(); | 1769 return Smi::cast(storage)->value(); |
1896 } | 1770 } |
1897 | 1771 |
1898 void DescriptorArray::set_bit_field3_storage(int value) { | 1772 void DescriptorArray::set_bit_field3_storage(int value) { |
1899 ASSERT(!IsEmpty()); | 1773 ASSERT(!IsEmpty()); |
1900 WRITE_FIELD(this, kBitField3StorageOffset, Smi::FromInt(value)); | 1774 WRITE_FIELD(this, kBitField3StorageOffset, Smi::FromInt(value)); |
1901 } | 1775 } |
1902 | 1776 |
1903 | 1777 |
1904 void DescriptorArray::fast_swap(FixedArray* array, int first, int second) { | 1778 void DescriptorArray::NoWriteBarrierSwap(FixedArray* array, |
| 1779 int first, |
| 1780 int second) { |
1905 Object* tmp = array->get(first); | 1781 Object* tmp = array->get(first); |
1906 fast_set(array, first, array->get(second)); | 1782 NoWriteBarrierSet(array, first, array->get(second)); |
1907 fast_set(array, second, tmp); | 1783 NoWriteBarrierSet(array, second, tmp); |
1908 } | 1784 } |
1909 | 1785 |
1910 | 1786 |
1911 int DescriptorArray::Search(String* name) { | 1787 int DescriptorArray::Search(String* name) { |
1912 SLOW_ASSERT(IsSortedNoDuplicates()); | 1788 SLOW_ASSERT(IsSortedNoDuplicates()); |
1913 | 1789 |
1914 // Check for empty descriptor array. | 1790 // Check for empty descriptor array. |
1915 int nof = number_of_descriptors(); | 1791 int nof = number_of_descriptors(); |
1916 if (nof == 0) return kNotFound; | 1792 if (nof == 0) return kNotFound; |
1917 | 1793 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2005 } | 1881 } |
2006 | 1882 |
2007 | 1883 |
2008 void DescriptorArray::Get(int descriptor_number, Descriptor* desc) { | 1884 void DescriptorArray::Get(int descriptor_number, Descriptor* desc) { |
2009 desc->Init(GetKey(descriptor_number), | 1885 desc->Init(GetKey(descriptor_number), |
2010 GetValue(descriptor_number), | 1886 GetValue(descriptor_number), |
2011 PropertyDetails(GetDetails(descriptor_number))); | 1887 PropertyDetails(GetDetails(descriptor_number))); |
2012 } | 1888 } |
2013 | 1889 |
2014 | 1890 |
2015 void DescriptorArray::Set(int descriptor_number, Descriptor* desc) { | 1891 void DescriptorArray::Set(int descriptor_number, |
| 1892 Descriptor* desc, |
| 1893 const WhitenessWitness&) { |
2016 // Range check. | 1894 // Range check. |
2017 ASSERT(descriptor_number < number_of_descriptors()); | 1895 ASSERT(descriptor_number < number_of_descriptors()); |
2018 | 1896 |
2019 // Make sure none of the elements in desc are in new space. | 1897 // Make sure none of the elements in desc are in new space. |
2020 ASSERT(!HEAP->InNewSpace(desc->GetKey())); | 1898 ASSERT(!HEAP->InNewSpace(desc->GetKey())); |
2021 ASSERT(!HEAP->InNewSpace(desc->GetValue())); | 1899 ASSERT(!HEAP->InNewSpace(desc->GetValue())); |
2022 | 1900 |
2023 fast_set(this, ToKeyIndex(descriptor_number), desc->GetKey()); | 1901 NoWriteBarrierSet(this, |
| 1902 ToKeyIndex(descriptor_number), |
| 1903 desc->GetKey()); |
2024 FixedArray* content_array = GetContentArray(); | 1904 FixedArray* content_array = GetContentArray(); |
2025 fast_set(content_array, ToValueIndex(descriptor_number), desc->GetValue()); | 1905 NoWriteBarrierSet(content_array, |
2026 fast_set(content_array, ToDetailsIndex(descriptor_number), | 1906 ToValueIndex(descriptor_number), |
2027 desc->GetDetails().AsSmi()); | 1907 desc->GetValue()); |
| 1908 NoWriteBarrierSet(content_array, |
| 1909 ToDetailsIndex(descriptor_number), |
| 1910 desc->GetDetails().AsSmi()); |
2028 } | 1911 } |
2029 | 1912 |
2030 | 1913 |
2031 void DescriptorArray::CopyFrom(int index, DescriptorArray* src, int src_index) { | 1914 void DescriptorArray::CopyFrom(int index, |
| 1915 DescriptorArray* src, |
| 1916 int src_index, |
| 1917 const WhitenessWitness& witness) { |
2032 Descriptor desc; | 1918 Descriptor desc; |
2033 src->Get(src_index, &desc); | 1919 src->Get(src_index, &desc); |
2034 Set(index, &desc); | 1920 Set(index, &desc, witness); |
2035 } | 1921 } |
2036 | 1922 |
2037 | 1923 |
2038 void DescriptorArray::Swap(int first, int second) { | 1924 void DescriptorArray::NoWriteBarrierSwapDescriptors(int first, int second) { |
2039 fast_swap(this, ToKeyIndex(first), ToKeyIndex(second)); | 1925 NoWriteBarrierSwap(this, ToKeyIndex(first), ToKeyIndex(second)); |
2040 FixedArray* content_array = GetContentArray(); | 1926 FixedArray* content_array = GetContentArray(); |
2041 fast_swap(content_array, ToValueIndex(first), ToValueIndex(second)); | 1927 NoWriteBarrierSwap(content_array, |
2042 fast_swap(content_array, ToDetailsIndex(first), ToDetailsIndex(second)); | 1928 ToValueIndex(first), |
| 1929 ToValueIndex(second)); |
| 1930 NoWriteBarrierSwap(content_array, |
| 1931 ToDetailsIndex(first), |
| 1932 ToDetailsIndex(second)); |
| 1933 } |
| 1934 |
| 1935 |
| 1936 DescriptorArray::WhitenessWitness::WhitenessWitness(DescriptorArray* array) |
| 1937 : marking_(array->GetHeap()->incremental_marking()) { |
| 1938 marking_->EnterNoMarkingScope(); |
| 1939 if (array->number_of_descriptors() > 0) { |
| 1940 ASSERT(Marking::Color(array) == Marking::WHITE_OBJECT); |
| 1941 ASSERT(Marking::Color(array->GetContentArray()) == Marking::WHITE_OBJECT); |
| 1942 } |
| 1943 } |
| 1944 |
| 1945 |
| 1946 DescriptorArray::WhitenessWitness::~WhitenessWitness() { |
| 1947 marking_->LeaveNoMarkingScope(); |
2043 } | 1948 } |
2044 | 1949 |
2045 | 1950 |
2046 template<typename Shape, typename Key> | 1951 template<typename Shape, typename Key> |
2047 int HashTable<Shape, Key>::ComputeCapacity(int at_least_space_for) { | 1952 int HashTable<Shape, Key>::ComputeCapacity(int at_least_space_for) { |
2048 const int kMinCapacity = 32; | 1953 const int kMinCapacity = 32; |
2049 int capacity = RoundUpToPowerOf2(at_least_space_for * 2); | 1954 int capacity = RoundUpToPowerOf2(at_least_space_for * 2); |
2050 if (capacity < kMinCapacity) { | 1955 if (capacity < kMinCapacity) { |
2051 capacity = kMinCapacity; // Guarantee min capacity. | 1956 capacity = kMinCapacity; // Guarantee min capacity. |
2052 } | 1957 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2135 CAST_ACCESSOR(JSFunction) | 2040 CAST_ACCESSOR(JSFunction) |
2136 CAST_ACCESSOR(GlobalObject) | 2041 CAST_ACCESSOR(GlobalObject) |
2137 CAST_ACCESSOR(JSGlobalProxy) | 2042 CAST_ACCESSOR(JSGlobalProxy) |
2138 CAST_ACCESSOR(JSGlobalObject) | 2043 CAST_ACCESSOR(JSGlobalObject) |
2139 CAST_ACCESSOR(JSBuiltinsObject) | 2044 CAST_ACCESSOR(JSBuiltinsObject) |
2140 CAST_ACCESSOR(Code) | 2045 CAST_ACCESSOR(Code) |
2141 CAST_ACCESSOR(JSArray) | 2046 CAST_ACCESSOR(JSArray) |
2142 CAST_ACCESSOR(JSRegExp) | 2047 CAST_ACCESSOR(JSRegExp) |
2143 CAST_ACCESSOR(JSProxy) | 2048 CAST_ACCESSOR(JSProxy) |
2144 CAST_ACCESSOR(JSFunctionProxy) | 2049 CAST_ACCESSOR(JSFunctionProxy) |
| 2050 CAST_ACCESSOR(JSSet) |
| 2051 CAST_ACCESSOR(JSMap) |
2145 CAST_ACCESSOR(JSWeakMap) | 2052 CAST_ACCESSOR(JSWeakMap) |
2146 CAST_ACCESSOR(Foreign) | 2053 CAST_ACCESSOR(Foreign) |
2147 CAST_ACCESSOR(ByteArray) | 2054 CAST_ACCESSOR(ByteArray) |
2148 CAST_ACCESSOR(FreeSpace) | 2055 CAST_ACCESSOR(FreeSpace) |
2149 CAST_ACCESSOR(ExternalArray) | 2056 CAST_ACCESSOR(ExternalArray) |
2150 CAST_ACCESSOR(ExternalByteArray) | 2057 CAST_ACCESSOR(ExternalByteArray) |
2151 CAST_ACCESSOR(ExternalUnsignedByteArray) | 2058 CAST_ACCESSOR(ExternalUnsignedByteArray) |
2152 CAST_ACCESSOR(ExternalShortArray) | 2059 CAST_ACCESSOR(ExternalShortArray) |
2153 CAST_ACCESSOR(ExternalUnsignedShortArray) | 2060 CAST_ACCESSOR(ExternalUnsignedShortArray) |
2154 CAST_ACCESSOR(ExternalIntArray) | 2061 CAST_ACCESSOR(ExternalIntArray) |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2972 | 2879 |
2973 | 2880 |
2974 void Code::set_has_debug_break_slots(bool value) { | 2881 void Code::set_has_debug_break_slots(bool value) { |
2975 ASSERT(kind() == FUNCTION); | 2882 ASSERT(kind() == FUNCTION); |
2976 byte flags = READ_BYTE_FIELD(this, kFullCodeFlags); | 2883 byte flags = READ_BYTE_FIELD(this, kFullCodeFlags); |
2977 flags = FullCodeFlagsHasDebugBreakSlotsField::update(flags, value); | 2884 flags = FullCodeFlagsHasDebugBreakSlotsField::update(flags, value); |
2978 WRITE_BYTE_FIELD(this, kFullCodeFlags, flags); | 2885 WRITE_BYTE_FIELD(this, kFullCodeFlags, flags); |
2979 } | 2886 } |
2980 | 2887 |
2981 | 2888 |
| 2889 bool Code::is_compiled_optimizable() { |
| 2890 ASSERT(kind() == FUNCTION); |
| 2891 byte flags = READ_BYTE_FIELD(this, kFullCodeFlags); |
| 2892 return FullCodeFlagsIsCompiledOptimizable::decode(flags); |
| 2893 } |
| 2894 |
| 2895 |
| 2896 void Code::set_compiled_optimizable(bool value) { |
| 2897 ASSERT(kind() == FUNCTION); |
| 2898 byte flags = READ_BYTE_FIELD(this, kFullCodeFlags); |
| 2899 flags = FullCodeFlagsIsCompiledOptimizable::update(flags, value); |
| 2900 WRITE_BYTE_FIELD(this, kFullCodeFlags, flags); |
| 2901 } |
| 2902 |
| 2903 |
2982 int Code::allow_osr_at_loop_nesting_level() { | 2904 int Code::allow_osr_at_loop_nesting_level() { |
2983 ASSERT(kind() == FUNCTION); | 2905 ASSERT(kind() == FUNCTION); |
2984 return READ_BYTE_FIELD(this, kAllowOSRAtLoopNestingLevelOffset); | 2906 return READ_BYTE_FIELD(this, kAllowOSRAtLoopNestingLevelOffset); |
2985 } | 2907 } |
2986 | 2908 |
2987 | 2909 |
2988 void Code::set_allow_osr_at_loop_nesting_level(int level) { | 2910 void Code::set_allow_osr_at_loop_nesting_level(int level) { |
2989 ASSERT(kind() == FUNCTION); | 2911 ASSERT(kind() == FUNCTION); |
2990 ASSERT(level >= 0 && level <= kMaxLoopNestingMarker); | 2912 ASSERT(level >= 0 && level <= kMaxLoopNestingMarker); |
2991 WRITE_BYTE_FIELD(this, kAllowOSRAtLoopNestingLevelOffset, level); | 2913 WRITE_BYTE_FIELD(this, kAllowOSRAtLoopNestingLevelOffset, level); |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3297 return reinterpret_cast<FixedArray*>( | 3219 return reinterpret_cast<FixedArray*>( |
3298 READ_FIELD(this, kPrototypeTransitionsOffset)); | 3220 READ_FIELD(this, kPrototypeTransitionsOffset)); |
3299 } | 3221 } |
3300 | 3222 |
3301 | 3223 |
3302 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) | 3224 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) |
3303 ACCESSORS(Map, prototype_transitions, FixedArray, kPrototypeTransitionsOffset) | 3225 ACCESSORS(Map, prototype_transitions, FixedArray, kPrototypeTransitionsOffset) |
3304 ACCESSORS(Map, constructor, Object, kConstructorOffset) | 3226 ACCESSORS(Map, constructor, Object, kConstructorOffset) |
3305 | 3227 |
3306 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) | 3228 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) |
3307 ACCESSORS(JSFunction, literals, FixedArray, kLiteralsOffset) | 3229 ACCESSORS(JSFunction, literals_or_bindings, FixedArray, kLiteralsOffset) |
3308 ACCESSORS(JSFunction, | 3230 ACCESSORS(JSFunction, |
3309 next_function_link, | 3231 next_function_link, |
3310 Object, | 3232 Object, |
3311 kNextFunctionLinkOffset) | 3233 kNextFunctionLinkOffset) |
3312 | 3234 |
3313 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) | 3235 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) |
3314 ACCESSORS(GlobalObject, global_context, Context, kGlobalContextOffset) | 3236 ACCESSORS(GlobalObject, global_context, Context, kGlobalContextOffset) |
3315 ACCESSORS(GlobalObject, global_receiver, JSObject, kGlobalReceiverOffset) | 3237 ACCESSORS(GlobalObject, global_receiver, JSObject, kGlobalReceiverOffset) |
3316 | 3238 |
3317 ACCESSORS(JSGlobalProxy, context, Object, kContextOffset) | 3239 ACCESSORS(JSGlobalProxy, context, Object, kContextOffset) |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3540 kOptimizationDisabled, | 3462 kOptimizationDisabled, |
3541 disable)); | 3463 disable)); |
3542 // If disabling optimizations we reflect that in the code object so | 3464 // If disabling optimizations we reflect that in the code object so |
3543 // it will not be counted as optimizable code. | 3465 // it will not be counted as optimizable code. |
3544 if ((code()->kind() == Code::FUNCTION) && disable) { | 3466 if ((code()->kind() == Code::FUNCTION) && disable) { |
3545 code()->set_optimizable(false); | 3467 code()->set_optimizable(false); |
3546 } | 3468 } |
3547 } | 3469 } |
3548 | 3470 |
3549 | 3471 |
3550 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, strict_mode, | 3472 StrictModeFlag SharedFunctionInfo::strict_mode_flag() { |
3551 kStrictModeFunction) | 3473 return BooleanBit::get(compiler_hints(), kStrictModeFunction) |
| 3474 ? kStrictMode : kNonStrictMode; |
| 3475 } |
| 3476 |
| 3477 |
| 3478 void SharedFunctionInfo::set_strict_mode_flag(StrictModeFlag strict_mode_flag) { |
| 3479 ASSERT(strict_mode_flag == kStrictMode || |
| 3480 strict_mode_flag == kNonStrictMode); |
| 3481 bool value = strict_mode_flag == kStrictMode; |
| 3482 set_compiler_hints( |
| 3483 BooleanBit::set(compiler_hints(), kStrictModeFunction, value)); |
| 3484 } |
| 3485 |
| 3486 |
| 3487 BOOL_GETTER(SharedFunctionInfo, compiler_hints, strict_mode, |
| 3488 kStrictModeFunction) |
3552 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative) | 3489 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative) |
3553 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, | 3490 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, |
3554 name_should_print_as_anonymous, | 3491 name_should_print_as_anonymous, |
3555 kNameShouldPrintAsAnonymous) | 3492 kNameShouldPrintAsAnonymous) |
3556 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, bound, kBoundFunction) | 3493 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, bound, kBoundFunction) |
3557 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_anonymous, kIsAnonymous) | 3494 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_anonymous, kIsAnonymous) |
3558 | 3495 |
3559 ACCESSORS(CodeCache, default_cache, FixedArray, kDefaultCacheOffset) | 3496 ACCESSORS(CodeCache, default_cache, FixedArray, kDefaultCacheOffset) |
3560 ACCESSORS(CodeCache, normal_type_cache, Object, kNormalTypeCacheOffset) | 3497 ACCESSORS(CodeCache, normal_type_cache, Object, kNormalTypeCacheOffset) |
3561 | 3498 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3816 bool JSFunction::should_have_prototype() { | 3753 bool JSFunction::should_have_prototype() { |
3817 return map()->function_with_prototype(); | 3754 return map()->function_with_prototype(); |
3818 } | 3755 } |
3819 | 3756 |
3820 | 3757 |
3821 bool JSFunction::is_compiled() { | 3758 bool JSFunction::is_compiled() { |
3822 return code() != GetIsolate()->builtins()->builtin(Builtins::kLazyCompile); | 3759 return code() != GetIsolate()->builtins()->builtin(Builtins::kLazyCompile); |
3823 } | 3760 } |
3824 | 3761 |
3825 | 3762 |
| 3763 FixedArray* JSFunction::literals() { |
| 3764 ASSERT(!shared()->bound()); |
| 3765 return literals_or_bindings(); |
| 3766 } |
| 3767 |
| 3768 |
| 3769 void JSFunction::set_literals(FixedArray* literals) { |
| 3770 ASSERT(!shared()->bound()); |
| 3771 set_literals_or_bindings(literals); |
| 3772 } |
| 3773 |
| 3774 |
| 3775 FixedArray* JSFunction::function_bindings() { |
| 3776 ASSERT(shared()->bound()); |
| 3777 return literals_or_bindings(); |
| 3778 } |
| 3779 |
| 3780 |
| 3781 void JSFunction::set_function_bindings(FixedArray* bindings) { |
| 3782 ASSERT(shared()->bound()); |
| 3783 // Bound function literal may be initialized to the empty fixed array |
| 3784 // before the bindings are set. |
| 3785 ASSERT(bindings == GetHeap()->empty_fixed_array() || |
| 3786 bindings->map() == GetHeap()->fixed_cow_array_map()); |
| 3787 set_literals_or_bindings(bindings); |
| 3788 } |
| 3789 |
| 3790 |
3826 int JSFunction::NumberOfLiterals() { | 3791 int JSFunction::NumberOfLiterals() { |
| 3792 ASSERT(!shared()->bound()); |
3827 return literals()->length(); | 3793 return literals()->length(); |
3828 } | 3794 } |
3829 | 3795 |
3830 | 3796 |
3831 Object* JSBuiltinsObject::javascript_builtin(Builtins::JavaScript id) { | 3797 Object* JSBuiltinsObject::javascript_builtin(Builtins::JavaScript id) { |
3832 ASSERT(id < kJSBuiltinsCount); // id is unsigned. | 3798 ASSERT(id < kJSBuiltinsCount); // id is unsigned. |
3833 return READ_FIELD(this, OffsetOfFunctionWithId(id)); | 3799 return READ_FIELD(this, OffsetOfFunctionWithId(id)); |
3834 } | 3800 } |
3835 | 3801 |
3836 | 3802 |
(...skipping 26 matching lines...) Expand all Loading... |
3863 | 3829 |
3864 | 3830 |
3865 void JSProxy::InitializeBody(int object_size, Object* value) { | 3831 void JSProxy::InitializeBody(int object_size, Object* value) { |
3866 ASSERT(!value->IsHeapObject() || !GetHeap()->InNewSpace(value)); | 3832 ASSERT(!value->IsHeapObject() || !GetHeap()->InNewSpace(value)); |
3867 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { | 3833 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { |
3868 WRITE_FIELD(this, offset, value); | 3834 WRITE_FIELD(this, offset, value); |
3869 } | 3835 } |
3870 } | 3836 } |
3871 | 3837 |
3872 | 3838 |
| 3839 ACCESSORS(JSSet, table, Object, kTableOffset) |
| 3840 ACCESSORS(JSMap, table, Object, kTableOffset) |
3873 ACCESSORS(JSWeakMap, table, Object, kTableOffset) | 3841 ACCESSORS(JSWeakMap, table, Object, kTableOffset) |
3874 ACCESSORS(JSWeakMap, next, Object, kNextOffset) | 3842 ACCESSORS(JSWeakMap, next, Object, kNextOffset) |
3875 | 3843 |
3876 | 3844 |
3877 ObjectHashTable* JSWeakMap::unchecked_table() { | 3845 ObjectHashTable* JSWeakMap::unchecked_table() { |
3878 return reinterpret_cast<ObjectHashTable*>(READ_FIELD(this, kTableOffset)); | 3846 return reinterpret_cast<ObjectHashTable*>(READ_FIELD(this, kTableOffset)); |
3879 } | 3847 } |
3880 | 3848 |
3881 | 3849 |
3882 Address Foreign::address() { | 3850 Address Foreign::address() { |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4049 } | 4017 } |
4050 | 4018 |
4051 | 4019 |
4052 ElementsKind JSObject::GetElementsKind() { | 4020 ElementsKind JSObject::GetElementsKind() { |
4053 ElementsKind kind = map()->elements_kind(); | 4021 ElementsKind kind = map()->elements_kind(); |
4054 #if DEBUG | 4022 #if DEBUG |
4055 FixedArrayBase* fixed_array = | 4023 FixedArrayBase* fixed_array = |
4056 reinterpret_cast<FixedArrayBase*>(READ_FIELD(this, kElementsOffset)); | 4024 reinterpret_cast<FixedArrayBase*>(READ_FIELD(this, kElementsOffset)); |
4057 Map* map = fixed_array->map(); | 4025 Map* map = fixed_array->map(); |
4058 ASSERT(((kind == FAST_ELEMENTS || kind == FAST_SMI_ONLY_ELEMENTS) && | 4026 ASSERT(((kind == FAST_ELEMENTS || kind == FAST_SMI_ONLY_ELEMENTS) && |
4059 (map == GetHeap()->fixed_array_map() || | 4027 (map == GetHeap()->fixed_array_map() || |
4060 map == GetHeap()->fixed_cow_array_map())) || | 4028 map == GetHeap()->fixed_cow_array_map())) || |
4061 (kind == FAST_DOUBLE_ELEMENTS && | 4029 (kind == FAST_DOUBLE_ELEMENTS && |
4062 fixed_array->IsFixedDoubleArray()) || | 4030 fixed_array->IsFixedDoubleArray()) || |
4063 (kind == DICTIONARY_ELEMENTS && | 4031 (kind == DICTIONARY_ELEMENTS && |
4064 fixed_array->IsFixedArray() && | 4032 fixed_array->IsFixedArray() && |
4065 fixed_array->IsDictionary()) || | 4033 fixed_array->IsDictionary()) || |
4066 (kind > DICTIONARY_ELEMENTS)); | 4034 (kind > DICTIONARY_ELEMENTS)); |
| 4035 ASSERT((kind != NON_STRICT_ARGUMENTS_ELEMENTS) || |
| 4036 (elements()->IsFixedArray() && elements()->length() >= 2)); |
4067 #endif | 4037 #endif |
4068 return kind; | 4038 return kind; |
4069 } | 4039 } |
4070 | 4040 |
4071 | 4041 |
4072 ElementsAccessor* JSObject::GetElementsAccessor() { | 4042 ElementsAccessor* JSObject::GetElementsAccessor() { |
4073 return ElementsAccessor::ForKind(GetElementsKind()); | 4043 return ElementsAccessor::ForKind(GetElementsKind()); |
4074 } | 4044 } |
4075 | 4045 |
4076 | 4046 |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4400 void Dictionary<Shape, Key>::SetEntry(int entry, | 4370 void Dictionary<Shape, Key>::SetEntry(int entry, |
4401 Object* key, | 4371 Object* key, |
4402 Object* value, | 4372 Object* value, |
4403 PropertyDetails details) { | 4373 PropertyDetails details) { |
4404 ASSERT(!key->IsString() || details.IsDeleted() || details.index() > 0); | 4374 ASSERT(!key->IsString() || details.IsDeleted() || details.index() > 0); |
4405 int index = HashTable<Shape, Key>::EntryToIndex(entry); | 4375 int index = HashTable<Shape, Key>::EntryToIndex(entry); |
4406 AssertNoAllocation no_gc; | 4376 AssertNoAllocation no_gc; |
4407 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); | 4377 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); |
4408 FixedArray::set(index, key, mode); | 4378 FixedArray::set(index, key, mode); |
4409 FixedArray::set(index+1, value, mode); | 4379 FixedArray::set(index+1, value, mode); |
4410 FixedArray::fast_set(this, index+2, details.AsSmi()); | 4380 FixedArray::set(index+2, details.AsSmi()); |
4411 } | 4381 } |
4412 | 4382 |
4413 | 4383 |
4414 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { | 4384 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { |
4415 ASSERT(other->IsNumber()); | 4385 ASSERT(other->IsNumber()); |
4416 return key == static_cast<uint32_t>(other->Number()); | 4386 return key == static_cast<uint32_t>(other->Number()); |
4417 } | 4387 } |
4418 | 4388 |
4419 | 4389 |
4420 uint32_t NumberDictionaryShape::Hash(uint32_t key) { | 4390 uint32_t NumberDictionaryShape::Hash(uint32_t key) { |
(...skipping 28 matching lines...) Expand all Loading... |
4449 uint32_t StringDictionaryShape::HashForObject(String* key, Object* other) { | 4419 uint32_t StringDictionaryShape::HashForObject(String* key, Object* other) { |
4450 return String::cast(other)->Hash(); | 4420 return String::cast(other)->Hash(); |
4451 } | 4421 } |
4452 | 4422 |
4453 | 4423 |
4454 MaybeObject* StringDictionaryShape::AsObject(String* key) { | 4424 MaybeObject* StringDictionaryShape::AsObject(String* key) { |
4455 return key; | 4425 return key; |
4456 } | 4426 } |
4457 | 4427 |
4458 | 4428 |
4459 bool ObjectHashTableShape::IsMatch(JSReceiver* key, Object* other) { | 4429 template <int entrysize> |
4460 return key == JSReceiver::cast(other); | 4430 bool ObjectHashTableShape<entrysize>::IsMatch(Object* key, Object* other) { |
| 4431 return key->SameValue(other); |
4461 } | 4432 } |
4462 | 4433 |
4463 | 4434 |
4464 uint32_t ObjectHashTableShape::Hash(JSReceiver* key) { | 4435 template <int entrysize> |
4465 MaybeObject* maybe_hash = key->GetIdentityHash(OMIT_CREATION); | 4436 uint32_t ObjectHashTableShape<entrysize>::Hash(Object* key) { |
4466 ASSERT(!maybe_hash->IsFailure()); | 4437 ASSERT(!key->IsUndefined() && !key->IsNull()); |
4467 return Smi::cast(maybe_hash->ToObjectUnchecked())->value(); | 4438 MaybeObject* maybe_hash = key->GetHash(OMIT_CREATION); |
| 4439 return Smi::cast(maybe_hash->ToObjectChecked())->value(); |
4468 } | 4440 } |
4469 | 4441 |
4470 | 4442 |
4471 uint32_t ObjectHashTableShape::HashForObject(JSReceiver* key, Object* other) { | 4443 template <int entrysize> |
4472 MaybeObject* maybe_hash = | 4444 uint32_t ObjectHashTableShape<entrysize>::HashForObject(Object* key, |
4473 JSReceiver::cast(other)->GetIdentityHash(OMIT_CREATION); | 4445 Object* other) { |
4474 ASSERT(!maybe_hash->IsFailure()); | 4446 ASSERT(!other->IsUndefined() && !other->IsNull()); |
4475 return Smi::cast(maybe_hash->ToObjectUnchecked())->value(); | 4447 MaybeObject* maybe_hash = other->GetHash(OMIT_CREATION); |
| 4448 return Smi::cast(maybe_hash->ToObjectChecked())->value(); |
4476 } | 4449 } |
4477 | 4450 |
4478 | 4451 |
4479 MaybeObject* ObjectHashTableShape::AsObject(JSReceiver* key) { | 4452 template <int entrysize> |
| 4453 MaybeObject* ObjectHashTableShape<entrysize>::AsObject(Object* key) { |
4480 return key; | 4454 return key; |
4481 } | 4455 } |
4482 | 4456 |
4483 | 4457 |
4484 void ObjectHashTable::RemoveEntry(int entry) { | 4458 void ObjectHashTable::RemoveEntry(int entry) { |
4485 RemoveEntry(entry, GetHeap()); | 4459 RemoveEntry(entry, GetHeap()); |
4486 } | 4460 } |
4487 | 4461 |
4488 | 4462 |
4489 void Map::ClearCodeCache(Heap* heap) { | 4463 void Map::ClearCodeCache(Heap* heap) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4527 return this; | 4501 return this; |
4528 } | 4502 } |
4529 | 4503 |
4530 | 4504 |
4531 MaybeObject* FixedArray::Copy() { | 4505 MaybeObject* FixedArray::Copy() { |
4532 if (length() == 0) return this; | 4506 if (length() == 0) return this; |
4533 return GetHeap()->CopyFixedArray(this); | 4507 return GetHeap()->CopyFixedArray(this); |
4534 } | 4508 } |
4535 | 4509 |
4536 | 4510 |
| 4511 MaybeObject* FixedDoubleArray::Copy() { |
| 4512 if (length() == 0) return this; |
| 4513 return GetHeap()->CopyFixedDoubleArray(this); |
| 4514 } |
| 4515 |
| 4516 |
4537 Relocatable::Relocatable(Isolate* isolate) { | 4517 Relocatable::Relocatable(Isolate* isolate) { |
4538 ASSERT(isolate == Isolate::Current()); | 4518 ASSERT(isolate == Isolate::Current()); |
4539 isolate_ = isolate; | 4519 isolate_ = isolate; |
4540 prev_ = isolate->relocatable_top(); | 4520 prev_ = isolate->relocatable_top(); |
4541 isolate->set_relocatable_top(this); | 4521 isolate->set_relocatable_top(this); |
4542 } | 4522 } |
4543 | 4523 |
4544 | 4524 |
4545 Relocatable::~Relocatable() { | 4525 Relocatable::~Relocatable() { |
4546 ASSERT(isolate_ == Isolate::Current()); | 4526 ASSERT(isolate_ == Isolate::Current()); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4634 #undef WRITE_INT_FIELD | 4614 #undef WRITE_INT_FIELD |
4635 #undef READ_SHORT_FIELD | 4615 #undef READ_SHORT_FIELD |
4636 #undef WRITE_SHORT_FIELD | 4616 #undef WRITE_SHORT_FIELD |
4637 #undef READ_BYTE_FIELD | 4617 #undef READ_BYTE_FIELD |
4638 #undef WRITE_BYTE_FIELD | 4618 #undef WRITE_BYTE_FIELD |
4639 | 4619 |
4640 | 4620 |
4641 } } // namespace v8::internal | 4621 } } // namespace v8::internal |
4642 | 4622 |
4643 #endif // V8_OBJECTS_INL_H_ | 4623 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |