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

Side by Side Diff: src/objects-inl.h

Issue 2101002: Cardmarking writebarrier. (Closed)
Patch Set: fixed review comments Created 10 years, 7 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
« no previous file with comments | « src/objects-debug.cc ('k') | src/runtime.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 752
753 // CONDITIONAL_WRITE_BARRIER must be issued after the actual 753 // CONDITIONAL_WRITE_BARRIER must be issued after the actual
754 // write due to the assert validating the written value. 754 // write due to the assert validating the written value.
755 #define CONDITIONAL_WRITE_BARRIER(object, offset, mode) \ 755 #define CONDITIONAL_WRITE_BARRIER(object, offset, mode) \
756 if (mode == UPDATE_WRITE_BARRIER) { \ 756 if (mode == UPDATE_WRITE_BARRIER) { \
757 Heap::RecordWrite(object->address(), offset); \ 757 Heap::RecordWrite(object->address(), offset); \
758 } else { \ 758 } else { \
759 ASSERT(mode == SKIP_WRITE_BARRIER); \ 759 ASSERT(mode == SKIP_WRITE_BARRIER); \
760 ASSERT(Heap::InNewSpace(object) || \ 760 ASSERT(Heap::InNewSpace(object) || \
761 !Heap::InNewSpace(READ_FIELD(object, offset)) || \ 761 !Heap::InNewSpace(READ_FIELD(object, offset)) || \
762 Page::IsRSetSet(object->address(), offset)); \ 762 Page::FromAddress(object->address())-> \
763 IsRegionDirty(object->address() + offset)); \
763 } 764 }
764 765
765 #define READ_DOUBLE_FIELD(p, offset) \ 766 #define READ_DOUBLE_FIELD(p, offset) \
766 (*reinterpret_cast<double*>(FIELD_ADDR(p, offset))) 767 (*reinterpret_cast<double*>(FIELD_ADDR(p, offset)))
767 768
768 #define WRITE_DOUBLE_FIELD(p, offset, value) \ 769 #define WRITE_DOUBLE_FIELD(p, offset, value) \
769 (*reinterpret_cast<double*>(FIELD_ADDR(p, offset)) = value) 770 (*reinterpret_cast<double*>(FIELD_ADDR(p, offset)) = value)
770 771
771 #define READ_INT_FIELD(p, offset) \ 772 #define READ_INT_FIELD(p, offset) \
772 (*reinterpret_cast<int*>(FIELD_ADDR(p, offset))) 773 (*reinterpret_cast<int*>(FIELD_ADDR(p, offset)))
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 1039
1039 Address MapWord::ToEncodedAddress() { 1040 Address MapWord::ToEncodedAddress() {
1040 return reinterpret_cast<Address>(value_); 1041 return reinterpret_cast<Address>(value_);
1041 } 1042 }
1042 1043
1043 1044
1044 #ifdef DEBUG 1045 #ifdef DEBUG
1045 void HeapObject::VerifyObjectField(int offset) { 1046 void HeapObject::VerifyObjectField(int offset) {
1046 VerifyPointer(READ_FIELD(this, offset)); 1047 VerifyPointer(READ_FIELD(this, offset));
1047 } 1048 }
1049
1050 void HeapObject::VerifySmiField(int offset) {
1051 ASSERT(READ_FIELD(this, offset)->IsSmi());
1052 }
1048 #endif 1053 #endif
1049 1054
1050 1055
1051 Map* HeapObject::map() { 1056 Map* HeapObject::map() {
1052 return map_word().ToMap(); 1057 return map_word().ToMap();
1053 } 1058 }
1054 1059
1055 1060
1056 void HeapObject::set_map(Map* value) { 1061 void HeapObject::set_map(Map* value) {
1057 set_map_word(MapWord::FromMap(value)); 1062 set_map_word(MapWord::FromMap(value));
1058 } 1063 }
1059 1064
1060 1065
1061 MapWord HeapObject::map_word() { 1066 MapWord HeapObject::map_word() {
1062 return MapWord(reinterpret_cast<uintptr_t>(READ_FIELD(this, kMapOffset))); 1067 return MapWord(reinterpret_cast<uintptr_t>(READ_FIELD(this, kMapOffset)));
1063 } 1068 }
1064 1069
1065 1070
1066 void HeapObject::set_map_word(MapWord map_word) { 1071 void HeapObject::set_map_word(MapWord map_word) {
1067 // WRITE_FIELD does not update the remembered set, but there is no need 1072 // WRITE_FIELD does not invoke write barrier, but there is no need
1068 // here. 1073 // here.
1069 WRITE_FIELD(this, kMapOffset, reinterpret_cast<Object*>(map_word.value_)); 1074 WRITE_FIELD(this, kMapOffset, reinterpret_cast<Object*>(map_word.value_));
1070 } 1075 }
1071 1076
1072 1077
1073 HeapObject* HeapObject::FromAddress(Address address) { 1078 HeapObject* HeapObject::FromAddress(Address address) {
1074 ASSERT_TAG_ALIGNED(address); 1079 ASSERT_TAG_ALIGNED(address);
1075 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); 1080 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag);
1076 } 1081 }
1077 1082
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 1160
1156 1161
1157 int HeapNumber::get_sign() { 1162 int HeapNumber::get_sign() {
1158 return READ_INT_FIELD(this, kExponentOffset) & kSignMask; 1163 return READ_INT_FIELD(this, kExponentOffset) & kSignMask;
1159 } 1164 }
1160 1165
1161 1166
1162 ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset) 1167 ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset)
1163 1168
1164 1169
1165 Array* JSObject::elements() { 1170 HeapObject* JSObject::elements() {
1166 Object* array = READ_FIELD(this, kElementsOffset); 1171 Object* array = READ_FIELD(this, kElementsOffset);
1167 // In the assert below Dictionary is covered under FixedArray. 1172 // In the assert below Dictionary is covered under FixedArray.
1168 ASSERT(array->IsFixedArray() || array->IsPixelArray() || 1173 ASSERT(array->IsFixedArray() || array->IsPixelArray() ||
1169 array->IsExternalArray()); 1174 array->IsExternalArray());
1170 return reinterpret_cast<Array*>(array); 1175 return reinterpret_cast<HeapObject*>(array);
1171 } 1176 }
1172 1177
1173 1178
1174 void JSObject::set_elements(Array* value, WriteBarrierMode mode) { 1179 void JSObject::set_elements(HeapObject* value, WriteBarrierMode mode) {
1175 // In the assert below Dictionary is covered under FixedArray. 1180 // In the assert below Dictionary is covered under FixedArray.
1176 ASSERT(value->IsFixedArray() || value->IsPixelArray() || 1181 ASSERT(value->IsFixedArray() || value->IsPixelArray() ||
1177 value->IsExternalArray()); 1182 value->IsExternalArray());
1178 WRITE_FIELD(this, kElementsOffset, value); 1183 WRITE_FIELD(this, kElementsOffset, value);
1179 CONDITIONAL_WRITE_BARRIER(this, kElementsOffset, mode); 1184 CONDITIONAL_WRITE_BARRIER(this, kElementsOffset, mode);
1180 } 1185 }
1181 1186
1182 1187
1183 void JSObject::initialize_properties() { 1188 void JSObject::initialize_properties() {
1184 ASSERT(!Heap::InNewSpace(Heap::empty_fixed_array())); 1189 ASSERT(!Heap::InNewSpace(Heap::empty_fixed_array()));
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 WRITE_FIELD(this, offset, value); 1340 WRITE_FIELD(this, offset, value);
1336 } 1341 }
1337 } 1342 }
1338 1343
1339 1344
1340 bool JSObject::HasFastProperties() { 1345 bool JSObject::HasFastProperties() {
1341 return !properties()->IsDictionary(); 1346 return !properties()->IsDictionary();
1342 } 1347 }
1343 1348
1344 1349
1345 bool Array::IndexFromObject(Object* object, uint32_t* index) { 1350 bool Object::ToArrayIndex(uint32_t* index) {
1346 if (object->IsSmi()) { 1351 if (IsSmi()) {
1347 int value = Smi::cast(object)->value(); 1352 int value = Smi::cast(this)->value();
1348 if (value < 0) return false; 1353 if (value < 0) return false;
1349 *index = value; 1354 *index = value;
1350 return true; 1355 return true;
1351 } 1356 }
1352 if (object->IsHeapNumber()) { 1357 if (IsHeapNumber()) {
1353 double value = HeapNumber::cast(object)->value(); 1358 double value = HeapNumber::cast(this)->value();
1354 uint32_t uint_value = static_cast<uint32_t>(value); 1359 uint32_t uint_value = static_cast<uint32_t>(value);
1355 if (value == static_cast<double>(uint_value)) { 1360 if (value == static_cast<double>(uint_value)) {
1356 *index = uint_value; 1361 *index = uint_value;
1357 return true; 1362 return true;
1358 } 1363 }
1359 } 1364 }
1360 return false; 1365 return false;
1361 } 1366 }
1362 1367
1363 1368
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 #undef MAKE_STRUCT_CAST 1663 #undef MAKE_STRUCT_CAST
1659 1664
1660 1665
1661 template <typename Shape, typename Key> 1666 template <typename Shape, typename Key>
1662 HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) { 1667 HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) {
1663 ASSERT(obj->IsHashTable()); 1668 ASSERT(obj->IsHashTable());
1664 return reinterpret_cast<HashTable*>(obj); 1669 return reinterpret_cast<HashTable*>(obj);
1665 } 1670 }
1666 1671
1667 1672
1668 INT_ACCESSORS(Array, length, kLengthOffset) 1673 SMI_ACCESSORS(FixedArray, length, kLengthOffset)
1674 SMI_ACCESSORS(ByteArray, length, kLengthOffset)
1675
1676 INT_ACCESSORS(PixelArray, length, kLengthOffset)
1677 INT_ACCESSORS(ExternalArray, length, kLengthOffset)
1669 1678
1670 1679
1671 SMI_ACCESSORS(String, length, kLengthOffset) 1680 SMI_ACCESSORS(String, length, kLengthOffset)
1672 1681
1673 1682
1674 uint32_t String::hash_field() { 1683 uint32_t String::hash_field() {
1675 return READ_UINT32_FIELD(this, kHashFieldOffset); 1684 return READ_UINT32_FIELD(this, kHashFieldOffset);
1676 } 1685 }
1677 1686
1678 1687
1679 void String::set_hash_field(uint32_t value) { 1688 void String::set_hash_field(uint32_t value) {
1680 WRITE_UINT32_FIELD(this, kHashFieldOffset, value); 1689 WRITE_UINT32_FIELD(this, kHashFieldOffset, value);
1690 #if V8_HOST_ARCH_64_BIT
1691 WRITE_UINT32_FIELD(this, kHashFieldOffset + kIntSize, 0);
1692 #endif
1681 } 1693 }
1682 1694
1683 1695
1684 bool String::Equals(String* other) { 1696 bool String::Equals(String* other) {
1685 if (other == this) return true; 1697 if (other == this) return true;
1686 if (StringShape(this).IsSymbol() && StringShape(other).IsSymbol()) { 1698 if (StringShape(this).IsSymbol() && StringShape(other).IsSymbol()) {
1687 return false; 1699 return false;
1688 } 1700 }
1689 return SlowEquals(other); 1701 return SlowEquals(other);
1690 } 1702 }
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
2443 BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_toplevel, 2455 BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_toplevel,
2444 kIsTopLevelBit) 2456 kIsTopLevelBit)
2445 BOOL_GETTER(SharedFunctionInfo, compiler_hints, 2457 BOOL_GETTER(SharedFunctionInfo, compiler_hints,
2446 has_only_simple_this_property_assignments, 2458 has_only_simple_this_property_assignments,
2447 kHasOnlySimpleThisPropertyAssignments) 2459 kHasOnlySimpleThisPropertyAssignments)
2448 BOOL_ACCESSORS(SharedFunctionInfo, 2460 BOOL_ACCESSORS(SharedFunctionInfo,
2449 compiler_hints, 2461 compiler_hints,
2450 try_full_codegen, 2462 try_full_codegen,
2451 kTryFullCodegen) 2463 kTryFullCodegen)
2452 2464
2453 INT_ACCESSORS(SharedFunctionInfo, length, kLengthOffset) 2465 #if V8_HOST_ARCH_32_BIT
2454 INT_ACCESSORS(SharedFunctionInfo, formal_parameter_count, 2466 SMI_ACCESSORS(SharedFunctionInfo, length, kLengthOffset)
2467 SMI_ACCESSORS(SharedFunctionInfo, formal_parameter_count,
2455 kFormalParameterCountOffset) 2468 kFormalParameterCountOffset)
2456 INT_ACCESSORS(SharedFunctionInfo, expected_nof_properties, 2469 SMI_ACCESSORS(SharedFunctionInfo, expected_nof_properties,
2457 kExpectedNofPropertiesOffset) 2470 kExpectedNofPropertiesOffset)
2458 INT_ACCESSORS(SharedFunctionInfo, num_literals, kNumLiteralsOffset) 2471 SMI_ACCESSORS(SharedFunctionInfo, num_literals, kNumLiteralsOffset)
2459 INT_ACCESSORS(SharedFunctionInfo, start_position_and_type, 2472 SMI_ACCESSORS(SharedFunctionInfo, start_position_and_type,
2460 kStartPositionAndTypeOffset) 2473 kStartPositionAndTypeOffset)
2461 INT_ACCESSORS(SharedFunctionInfo, end_position, kEndPositionOffset) 2474 SMI_ACCESSORS(SharedFunctionInfo, end_position, kEndPositionOffset)
2462 INT_ACCESSORS(SharedFunctionInfo, function_token_position, 2475 SMI_ACCESSORS(SharedFunctionInfo, function_token_position,
2463 kFunctionTokenPositionOffset) 2476 kFunctionTokenPositionOffset)
2464 INT_ACCESSORS(SharedFunctionInfo, compiler_hints, 2477 SMI_ACCESSORS(SharedFunctionInfo, compiler_hints,
2465 kCompilerHintsOffset) 2478 kCompilerHintsOffset)
2466 INT_ACCESSORS(SharedFunctionInfo, this_property_assignments_count, 2479 SMI_ACCESSORS(SharedFunctionInfo, this_property_assignments_count,
2467 kThisPropertyAssignmentsCountOffset) 2480 kThisPropertyAssignmentsCountOffset)
2481 #else
2468 2482
2483 #define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \
2484 int holder::name() { \
2485 int value = READ_INT_FIELD(this, offset); \
2486 ASSERT(kHeapObjectTag == 1); \
2487 ASSERT((value & kHeapObjectTag) == 0); \
2488 return value >> 1; \
2489 } \
2490 void holder::set_##name(int value) { \
2491 ASSERT(kHeapObjectTag == 1); \
2492 ASSERT((value & 0xC0000000) == 0xC0000000 || \
2493 (value & 0xC0000000) == 0x000000000); \
2494 WRITE_INT_FIELD(this, \
2495 offset, \
2496 (value << 1) & ~kHeapObjectTag); \
2497 }
2498
2499 #define PSEUDO_SMI_ACCESSORS_HI(holder, name, offset) \
2500 INT_ACCESSORS(holder, name, offset)
2501
2502
2503
2504 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, length, kLengthOffset)
2505 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, formal_parameter_count,
2506 kFormalParameterCountOffset)
2507
2508 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, expected_nof_properties,
2509 kExpectedNofPropertiesOffset)
2510 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, num_literals, kNumLiteralsOffset)
2511
2512 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, start_position_and_type,
2513 kStartPositionAndTypeOffset)
2514 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, end_position, kEndPositionOffset)
2515
2516 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, function_token_position,
2517 kFunctionTokenPositionOffset)
2518 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, compiler_hints,
2519 kCompilerHintsOffset)
2520
2521 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, this_property_assignments_count,
2522 kThisPropertyAssignmentsCountOffset)
2523 #endif
2469 2524
2470 ACCESSORS(CodeCache, default_cache, FixedArray, kDefaultCacheOffset) 2525 ACCESSORS(CodeCache, default_cache, FixedArray, kDefaultCacheOffset)
2471 ACCESSORS(CodeCache, normal_type_cache, Object, kNormalTypeCacheOffset) 2526 ACCESSORS(CodeCache, normal_type_cache, Object, kNormalTypeCacheOffset)
2472 2527
2473 bool Script::HasValidSource() { 2528 bool Script::HasValidSource() {
2474 Object* src = this->source(); 2529 Object* src = this->source();
2475 if (!src->IsString()) return true; 2530 if (!src->IsString()) return true;
2476 String* src_str = String::cast(src); 2531 String* src_str = String::cast(src);
2477 if (!StringShape(src_str).IsExternal()) return true; 2532 if (!StringShape(src_str).IsExternal()) return true;
2478 if (src_str->IsAsciiRepresentation()) { 2533 if (src_str->IsAsciiRepresentation()) {
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
2772 2827
2773 2828
2774 void JSRegExp::SetDataAt(int index, Object* value) { 2829 void JSRegExp::SetDataAt(int index, Object* value) {
2775 ASSERT(TypeTag() != NOT_COMPILED); 2830 ASSERT(TypeTag() != NOT_COMPILED);
2776 ASSERT(index >= kDataIndex); // Only implementation data can be set this way. 2831 ASSERT(index >= kDataIndex); // Only implementation data can be set this way.
2777 FixedArray::cast(data())->set(index, value); 2832 FixedArray::cast(data())->set(index, value);
2778 } 2833 }
2779 2834
2780 2835
2781 JSObject::ElementsKind JSObject::GetElementsKind() { 2836 JSObject::ElementsKind JSObject::GetElementsKind() {
2782 Array* array = elements(); 2837 HeapObject* array = elements();
2783 if (array->IsFixedArray()) { 2838 if (array->IsFixedArray()) {
2784 // FAST_ELEMENTS or DICTIONARY_ELEMENTS are both stored in a FixedArray. 2839 // FAST_ELEMENTS or DICTIONARY_ELEMENTS are both stored in a FixedArray.
2785 if (array->map() == Heap::fixed_array_map()) { 2840 if (array->map() == Heap::fixed_array_map()) {
2786 return FAST_ELEMENTS; 2841 return FAST_ELEMENTS;
2787 } 2842 }
2788 ASSERT(array->IsDictionary()); 2843 ASSERT(array->IsDictionary());
2789 return DICTIONARY_ELEMENTS; 2844 return DICTIONARY_ELEMENTS;
2790 } 2845 }
2791 if (array->IsExternalArray()) { 2846 if (array->IsExternalArray()) {
2792 switch (array->map()->instance_type()) { 2847 switch (array->map()->instance_type()) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2895 return StringDictionary::cast(properties()); 2950 return StringDictionary::cast(properties());
2896 } 2951 }
2897 2952
2898 2953
2899 NumberDictionary* JSObject::element_dictionary() { 2954 NumberDictionary* JSObject::element_dictionary() {
2900 ASSERT(HasDictionaryElements()); 2955 ASSERT(HasDictionaryElements());
2901 return NumberDictionary::cast(elements()); 2956 return NumberDictionary::cast(elements());
2902 } 2957 }
2903 2958
2904 2959
2960 bool String::IsHashFieldComputed(uint32_t field) {
2961 return (field & kHashNotComputedMask) == 0;
2962 }
2963
2964
2905 bool String::HasHashCode() { 2965 bool String::HasHashCode() {
2906 return (hash_field() & kHashComputedMask) != 0; 2966 return IsHashFieldComputed(hash_field());
2907 } 2967 }
2908 2968
2909 2969
2910 uint32_t String::Hash() { 2970 uint32_t String::Hash() {
2911 // Fast case: has hash code already been computed? 2971 // Fast case: has hash code already been computed?
2912 uint32_t field = hash_field(); 2972 uint32_t field = hash_field();
2913 if (field & kHashComputedMask) return field >> kHashShift; 2973 if (IsHashFieldComputed(field)) return field >> kHashShift;
2914 // Slow case: compute hash code and set it. 2974 // Slow case: compute hash code and set it.
2915 return ComputeAndSetHash(); 2975 return ComputeAndSetHash();
2916 } 2976 }
2917 2977
2918 2978
2919 StringHasher::StringHasher(int length) 2979 StringHasher::StringHasher(int length)
2920 : length_(length), 2980 : length_(length),
2921 raw_running_hash_(0), 2981 raw_running_hash_(0),
2922 array_index_(0), 2982 array_index_(0),
2923 is_array_index_(0 < length_ && length_ <= String::kMaxArrayIndexSize), 2983 is_array_index_(0 < length_ && length_ <= String::kMaxArrayIndexSize),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2976 result += (result << 15); 3036 result += (result << 15);
2977 if (result == 0) { 3037 if (result == 0) {
2978 result = 27; 3038 result = 27;
2979 } 3039 }
2980 return result; 3040 return result;
2981 } 3041 }
2982 3042
2983 3043
2984 bool String::AsArrayIndex(uint32_t* index) { 3044 bool String::AsArrayIndex(uint32_t* index) {
2985 uint32_t field = hash_field(); 3045 uint32_t field = hash_field();
2986 if ((field & kHashComputedMask) && !(field & kIsArrayIndexMask)) return false; 3046 if (IsHashFieldComputed(field) && !(field & kIsArrayIndexMask)) return false;
2987 return SlowAsArrayIndex(index); 3047 return SlowAsArrayIndex(index);
2988 } 3048 }
2989 3049
2990 3050
2991 Object* JSObject::GetPrototype() { 3051 Object* JSObject::GetPrototype() {
2992 return JSObject::cast(this)->map()->prototype(); 3052 return JSObject::cast(this)->map()->prototype();
2993 } 3053 }
2994 3054
2995 3055
2996 PropertyAttributes JSObject::GetPropertyAttribute(String* key) { 3056 PropertyAttributes JSObject::GetPropertyAttribute(String* key) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
3100 // No write barrier is needed since empty_fixed_array is not in new space. 3160 // No write barrier is needed since empty_fixed_array is not in new space.
3101 // Please note this function is used during marking: 3161 // Please note this function is used during marking:
3102 // - MarkCompactCollector::MarkUnmarkedObject 3162 // - MarkCompactCollector::MarkUnmarkedObject
3103 ASSERT(!Heap::InNewSpace(Heap::raw_unchecked_empty_fixed_array())); 3163 ASSERT(!Heap::InNewSpace(Heap::raw_unchecked_empty_fixed_array()));
3104 WRITE_FIELD(this, kCodeCacheOffset, Heap::raw_unchecked_empty_fixed_array()); 3164 WRITE_FIELD(this, kCodeCacheOffset, Heap::raw_unchecked_empty_fixed_array());
3105 } 3165 }
3106 3166
3107 3167
3108 void JSArray::EnsureSize(int required_size) { 3168 void JSArray::EnsureSize(int required_size) {
3109 ASSERT(HasFastElements()); 3169 ASSERT(HasFastElements());
3110 Array* elts = elements(); 3170 FixedArray* elts = FixedArray::cast(elements());
3111 const int kArraySizeThatFitsComfortablyInNewSpace = 128; 3171 const int kArraySizeThatFitsComfortablyInNewSpace = 128;
3112 if (elts->length() < required_size) { 3172 if (elts->length() < required_size) {
3113 // Doubling in size would be overkill, but leave some slack to avoid 3173 // Doubling in size would be overkill, but leave some slack to avoid
3114 // constantly growing. 3174 // constantly growing.
3115 Expand(required_size + (required_size >> 3)); 3175 Expand(required_size + (required_size >> 3));
3116 // It's a performance benefit to keep a frequently used array in new-space. 3176 // It's a performance benefit to keep a frequently used array in new-space.
3117 } else if (!Heap::new_space()->Contains(elts) && 3177 } else if (!Heap::new_space()->Contains(elts) &&
3118 required_size < kArraySizeThatFitsComfortablyInNewSpace) { 3178 required_size < kArraySizeThatFitsComfortablyInNewSpace) {
3119 // Expand will allocate a new backing store in new space even if the size 3179 // Expand will allocate a new backing store in new space even if the size
3120 // we asked for isn't larger than what we had before. 3180 // we asked for isn't larger than what we had before.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3157 #undef WRITE_INT_FIELD 3217 #undef WRITE_INT_FIELD
3158 #undef READ_SHORT_FIELD 3218 #undef READ_SHORT_FIELD
3159 #undef WRITE_SHORT_FIELD 3219 #undef WRITE_SHORT_FIELD
3160 #undef READ_BYTE_FIELD 3220 #undef READ_BYTE_FIELD
3161 #undef WRITE_BYTE_FIELD 3221 #undef WRITE_BYTE_FIELD
3162 3222
3163 3223
3164 } } // namespace v8::internal 3224 } } // namespace v8::internal
3165 3225
3166 #endif // V8_OBJECTS_INL_H_ 3226 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698