OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 2109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2120 // Named property. | 2120 // Named property. |
2121 LookupResult result; | 2121 LookupResult result; |
2122 LocalLookup(name, &result); | 2122 LocalLookup(name, &result); |
2123 return GetPropertyAttribute(this, &result, name, false); | 2123 return GetPropertyAttribute(this, &result, name, false); |
2124 } | 2124 } |
2125 | 2125 |
2126 | 2126 |
2127 Object* JSObject::NormalizeProperties(PropertyNormalizationMode mode) { | 2127 Object* JSObject::NormalizeProperties(PropertyNormalizationMode mode) { |
2128 if (!HasFastProperties()) return this; | 2128 if (!HasFastProperties()) return this; |
2129 | 2129 |
2130 // Allocate new content | 2130 // The global object is always normalized. |
| 2131 ASSERT(!IsGlobalObject()); |
| 2132 |
| 2133 // Allocate new content. |
2131 Object* obj = | 2134 Object* obj = |
2132 StringDictionary::Allocate(map()->NumberOfDescribedProperties() * 2 + 4); | 2135 StringDictionary::Allocate(map()->NumberOfDescribedProperties() * 2 + 4); |
2133 if (obj->IsFailure()) return obj; | 2136 if (obj->IsFailure()) return obj; |
2134 StringDictionary* dictionary = StringDictionary::cast(obj); | 2137 StringDictionary* dictionary = StringDictionary::cast(obj); |
2135 | 2138 |
2136 DescriptorArray* descs = map()->instance_descriptors(); | 2139 DescriptorArray* descs = map()->instance_descriptors(); |
2137 for (int i = 0; i < descs->number_of_descriptors(); i++) { | 2140 for (int i = 0; i < descs->number_of_descriptors(); i++) { |
2138 PropertyDetails details = descs->GetDetails(i); | 2141 PropertyDetails details = descs->GetDetails(i); |
2139 switch (details.type()) { | 2142 switch (details.type()) { |
2140 case CONSTANT_FUNCTION: { | 2143 case CONSTANT_FUNCTION: { |
2141 PropertyDetails d = | 2144 PropertyDetails d = |
2142 PropertyDetails(details.attributes(), NORMAL, details.index()); | 2145 PropertyDetails(details.attributes(), NORMAL, details.index()); |
2143 Object* value = descs->GetConstantFunction(i); | 2146 Object* value = descs->GetConstantFunction(i); |
2144 if (IsGlobalObject()) { | |
2145 value = Heap::AllocateJSGlobalPropertyCell(value); | |
2146 if (value->IsFailure()) return value; | |
2147 } | |
2148 Object* result = dictionary->Add(descs->GetKey(i), value, d); | 2147 Object* result = dictionary->Add(descs->GetKey(i), value, d); |
2149 if (result->IsFailure()) return result; | 2148 if (result->IsFailure()) return result; |
2150 dictionary = StringDictionary::cast(result); | 2149 dictionary = StringDictionary::cast(result); |
2151 break; | 2150 break; |
2152 } | 2151 } |
2153 case FIELD: { | 2152 case FIELD: { |
2154 PropertyDetails d = | 2153 PropertyDetails d = |
2155 PropertyDetails(details.attributes(), NORMAL, details.index()); | 2154 PropertyDetails(details.attributes(), NORMAL, details.index()); |
2156 Object* value = FastPropertyAt(descs->GetFieldIndex(i)); | 2155 Object* value = FastPropertyAt(descs->GetFieldIndex(i)); |
2157 if (IsGlobalObject()) { | |
2158 value = Heap::AllocateJSGlobalPropertyCell(value); | |
2159 if (value->IsFailure()) return value; | |
2160 } | |
2161 Object* result = dictionary->Add(descs->GetKey(i), value, d); | 2156 Object* result = dictionary->Add(descs->GetKey(i), value, d); |
2162 if (result->IsFailure()) return result; | 2157 if (result->IsFailure()) return result; |
2163 dictionary = StringDictionary::cast(result); | 2158 dictionary = StringDictionary::cast(result); |
2164 break; | 2159 break; |
2165 } | 2160 } |
2166 case CALLBACKS: { | 2161 case CALLBACKS: { |
2167 PropertyDetails d = | 2162 PropertyDetails d = |
2168 PropertyDetails(details.attributes(), CALLBACKS, details.index()); | 2163 PropertyDetails(details.attributes(), CALLBACKS, details.index()); |
2169 Object* value = descs->GetCallbacksObject(i); | 2164 Object* value = descs->GetCallbacksObject(i); |
2170 if (IsGlobalObject()) { | |
2171 value = Heap::AllocateJSGlobalPropertyCell(value); | |
2172 if (value->IsFailure()) return value; | |
2173 } | |
2174 Object* result = dictionary->Add(descs->GetKey(i), value, d); | 2165 Object* result = dictionary->Add(descs->GetKey(i), value, d); |
2175 if (result->IsFailure()) return result; | 2166 if (result->IsFailure()) return result; |
2176 dictionary = StringDictionary::cast(result); | 2167 dictionary = StringDictionary::cast(result); |
2177 break; | 2168 break; |
2178 } | 2169 } |
2179 case MAP_TRANSITION: | 2170 case MAP_TRANSITION: |
2180 case CONSTANT_TRANSITION: | 2171 case CONSTANT_TRANSITION: |
2181 case NULL_DESCRIPTOR: | 2172 case NULL_DESCRIPTOR: |
2182 case INTERCEPTOR: | 2173 case INTERCEPTOR: |
2183 break; | 2174 break; |
2184 default: | 2175 default: |
2185 case NORMAL: | |
2186 UNREACHABLE(); | 2176 UNREACHABLE(); |
2187 break; | |
2188 } | 2177 } |
2189 } | 2178 } |
2190 | 2179 |
2191 // Copy the next enumeration index from instance descriptor. | 2180 // Copy the next enumeration index from instance descriptor. |
2192 int index = map()->instance_descriptors()->NextEnumerationIndex(); | 2181 int index = map()->instance_descriptors()->NextEnumerationIndex(); |
2193 dictionary->SetNextEnumerationIndex(index); | 2182 dictionary->SetNextEnumerationIndex(index); |
2194 | 2183 |
2195 // Allocate new map. | 2184 // Allocate new map. |
2196 obj = map()->CopyDropDescriptors(); | 2185 obj = map()->CopyDropDescriptors(); |
2197 if (obj->IsFailure()) return obj; | 2186 if (obj->IsFailure()) return obj; |
(...skipping 5728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7926 if (break_point_objects()->IsUndefined()) return 0; | 7915 if (break_point_objects()->IsUndefined()) return 0; |
7927 // Single beak point. | 7916 // Single beak point. |
7928 if (!break_point_objects()->IsFixedArray()) return 1; | 7917 if (!break_point_objects()->IsFixedArray()) return 1; |
7929 // Multiple break points. | 7918 // Multiple break points. |
7930 return FixedArray::cast(break_point_objects())->length(); | 7919 return FixedArray::cast(break_point_objects())->length(); |
7931 } | 7920 } |
7932 #endif | 7921 #endif |
7933 | 7922 |
7934 | 7923 |
7935 } } // namespace v8::internal | 7924 } } // namespace v8::internal |
OLD | NEW |