OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1604 offset += kPointerSize; | 1604 offset += kPointerSize; |
1605 } | 1605 } |
1606 } | 1606 } |
1607 | 1607 |
1608 | 1608 |
1609 bool JSObject::HasFastProperties() { | 1609 bool JSObject::HasFastProperties() { |
1610 return !properties()->IsDictionary(); | 1610 return !properties()->IsDictionary(); |
1611 } | 1611 } |
1612 | 1612 |
1613 | 1613 |
1614 int JSObject::MaxFastProperties() { | 1614 bool JSObject::TooManyFastProperties(int properties) { |
1615 // Allow extra fast properties if the object has more than | 1615 // Allow extra fast properties if the object has more than |
1616 // kMaxFastProperties in-object properties. When this is the case, | 1616 // kFastPropertiesSoftLimit in-object properties. When this is the case, |
1617 // it is very unlikely that the object is being used as a dictionary | 1617 // it is very unlikely that the object is being used as a dictionary |
1618 // and there is a good chance that allowing more map transitions | 1618 // and there is a good chance that allowing more map transitions |
1619 // will be worth it. | 1619 // will be worth it. |
1620 return Max(map()->inobject_properties(), kMaxFastProperties); | 1620 int inobject = map()->inobject_properties(); |
| 1621 |
| 1622 int limit; |
| 1623 if (map()->used_for_prototype()) { |
| 1624 limit = Max(inobject, kMaxFastProperties); |
| 1625 } else { |
| 1626 limit = Max(inobject, kFastPropertiesSoftLimit); |
| 1627 } |
| 1628 return properties > limit; |
1621 } | 1629 } |
1622 | 1630 |
1623 | 1631 |
1624 void Struct::InitializeBody(int object_size) { | 1632 void Struct::InitializeBody(int object_size) { |
1625 Object* value = GetHeap()->undefined_value(); | 1633 Object* value = GetHeap()->undefined_value(); |
1626 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { | 1634 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { |
1627 WRITE_FIELD(this, offset, value); | 1635 WRITE_FIELD(this, offset, value); |
1628 } | 1636 } |
1629 } | 1637 } |
1630 | 1638 |
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2942 } else { | 2950 } else { |
2943 set_bit_field3(bit_field3() & ~(1 << kIsShared)); | 2951 set_bit_field3(bit_field3() & ~(1 << kIsShared)); |
2944 } | 2952 } |
2945 } | 2953 } |
2946 | 2954 |
2947 bool Map::is_shared() { | 2955 bool Map::is_shared() { |
2948 return ((1 << kIsShared) & bit_field3()) != 0; | 2956 return ((1 << kIsShared) & bit_field3()) != 0; |
2949 } | 2957 } |
2950 | 2958 |
2951 | 2959 |
| 2960 void Map::set_used_for_prototype(bool value) { |
| 2961 if (value) { |
| 2962 set_bit_field3(bit_field3() | (1 << kUsedForPrototype)); |
| 2963 } else { |
| 2964 set_bit_field3(bit_field3() & ~(1 << kUsedForPrototype)); |
| 2965 } |
| 2966 } |
| 2967 |
| 2968 |
| 2969 bool Map::used_for_prototype() { |
| 2970 return ((1 << kUsedForPrototype) & bit_field3()) != 0; |
| 2971 } |
| 2972 |
| 2973 |
2952 JSFunction* Map::unchecked_constructor() { | 2974 JSFunction* Map::unchecked_constructor() { |
2953 return reinterpret_cast<JSFunction*>(READ_FIELD(this, kConstructorOffset)); | 2975 return reinterpret_cast<JSFunction*>(READ_FIELD(this, kConstructorOffset)); |
2954 } | 2976 } |
2955 | 2977 |
2956 | 2978 |
2957 Code::Flags Code::flags() { | 2979 Code::Flags Code::flags() { |
2958 return static_cast<Flags>(READ_INT_FIELD(this, kFlagsOffset)); | 2980 return static_cast<Flags>(READ_INT_FIELD(this, kFlagsOffset)); |
2959 } | 2981 } |
2960 | 2982 |
2961 | 2983 |
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4092 | 4114 |
4093 | 4115 |
4094 Object* JSFunction::prototype() { | 4116 Object* JSFunction::prototype() { |
4095 ASSERT(has_prototype()); | 4117 ASSERT(has_prototype()); |
4096 // If the function's prototype property has been set to a non-JSObject | 4118 // If the function's prototype property has been set to a non-JSObject |
4097 // value, that value is stored in the constructor field of the map. | 4119 // value, that value is stored in the constructor field of the map. |
4098 if (map()->has_non_instance_prototype()) return map()->constructor(); | 4120 if (map()->has_non_instance_prototype()) return map()->constructor(); |
4099 return instance_prototype(); | 4121 return instance_prototype(); |
4100 } | 4122 } |
4101 | 4123 |
| 4124 |
4102 bool JSFunction::should_have_prototype() { | 4125 bool JSFunction::should_have_prototype() { |
4103 return map()->function_with_prototype(); | 4126 return map()->function_with_prototype(); |
4104 } | 4127 } |
4105 | 4128 |
4106 | 4129 |
4107 bool JSFunction::is_compiled() { | 4130 bool JSFunction::is_compiled() { |
4108 return code() != GetIsolate()->builtins()->builtin(Builtins::kLazyCompile); | 4131 return code() != GetIsolate()->builtins()->builtin(Builtins::kLazyCompile); |
4109 } | 4132 } |
4110 | 4133 |
4111 | 4134 |
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5062 #undef WRITE_UINT32_FIELD | 5085 #undef WRITE_UINT32_FIELD |
5063 #undef READ_SHORT_FIELD | 5086 #undef READ_SHORT_FIELD |
5064 #undef WRITE_SHORT_FIELD | 5087 #undef WRITE_SHORT_FIELD |
5065 #undef READ_BYTE_FIELD | 5088 #undef READ_BYTE_FIELD |
5066 #undef WRITE_BYTE_FIELD | 5089 #undef WRITE_BYTE_FIELD |
5067 | 5090 |
5068 | 5091 |
5069 } } // namespace v8::internal | 5092 } } // namespace v8::internal |
5070 | 5093 |
5071 #endif // V8_OBJECTS_INL_H_ | 5094 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |