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 4936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4947 if (HasContentArray()) *ContentHeader() = Smi::FromInt(0); | 4947 if (HasContentArray()) *ContentHeader() = Smi::FromInt(0); |
4948 } | 4948 } |
4949 | 4949 |
4950 bool IsIterating() { | 4950 bool IsIterating() { |
4951 return HasContentArray() && (*ContentHeader())->IsSmi(); | 4951 return HasContentArray() && (*ContentHeader())->IsSmi(); |
4952 } | 4952 } |
4953 | 4953 |
4954 Map* Next() { | 4954 Map* Next() { |
4955 ASSERT(IsIterating()); | 4955 ASSERT(IsIterating()); |
4956 FixedArray* contents = ContentArray(); | 4956 FixedArray* contents = ContentArray(); |
| 4957 // Attention, tricky index manipulation ahead: Every entry in the contents |
| 4958 // array consists of a value/details pair, so the index is typically even. |
| 4959 // An exception is made for CALLBACKS entries: An even index means we look |
| 4960 // at its getter, and an odd index means we look at its setter. |
4957 int index = Smi::cast(*ContentHeader())->value(); | 4961 int index = Smi::cast(*ContentHeader())->value(); |
4958 while (index < contents->length()) { | 4962 while (index < contents->length()) { |
4959 int next_index = index + 2; | 4963 PropertyDetails details(Smi::cast(contents->get(index | 1))); |
4960 PropertyDetails details(Smi::cast(contents->get(index + 1))); | 4964 switch (details.type()) { |
4961 if (details.IsTransition()) { | 4965 case MAP_TRANSITION: |
4962 *ContentHeader() = Smi::FromInt(next_index); | 4966 case CONSTANT_TRANSITION: |
4963 return static_cast<Map*>(contents->get(index)); | 4967 case ELEMENTS_TRANSITION: |
| 4968 // We definitely have a map transition. |
| 4969 *ContentHeader() = Smi::FromInt(index + 2); |
| 4970 return static_cast<Map*>(contents->get(index)); |
| 4971 case CALLBACKS: { |
| 4972 // We might have a map transition in a getter or in a setter. |
| 4973 AccessorPair* accessors = |
| 4974 static_cast<AccessorPair*>(contents->get(index & ~1)); |
| 4975 Object* accessor = |
| 4976 ((index & 1) == 0) ? accessors->getter() : accessors->setter(); |
| 4977 index++; |
| 4978 if (accessor->IsMap()) { |
| 4979 *ContentHeader() = Smi::FromInt(index); |
| 4980 return static_cast<Map*>(accessor); |
| 4981 } |
| 4982 break; |
| 4983 } |
| 4984 case NORMAL: |
| 4985 case FIELD: |
| 4986 case CONSTANT_FUNCTION: |
| 4987 case HANDLER: |
| 4988 case INTERCEPTOR: |
| 4989 case NULL_DESCRIPTOR: |
| 4990 // We definitely have no map transition. |
| 4991 index += 2; |
| 4992 break; |
4964 } | 4993 } |
4965 index = next_index; | |
4966 } | 4994 } |
4967 *ContentHeader() = descriptor_array_->GetHeap()->fixed_array_map(); | 4995 *ContentHeader() = descriptor_array_->GetHeap()->fixed_array_map(); |
4968 return NULL; | 4996 return NULL; |
4969 } | 4997 } |
4970 | 4998 |
4971 private: | 4999 private: |
4972 bool HasContentArray() { | 5000 bool HasContentArray() { |
4973 return descriptor_array_-> length() > DescriptorArray::kContentArrayIndex; | 5001 return descriptor_array_-> length() > DescriptorArray::kContentArrayIndex; |
4974 } | 5002 } |
4975 | 5003 |
(...skipping 7949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12925 if (break_point_objects()->IsUndefined()) return 0; | 12953 if (break_point_objects()->IsUndefined()) return 0; |
12926 // Single break point. | 12954 // Single break point. |
12927 if (!break_point_objects()->IsFixedArray()) return 1; | 12955 if (!break_point_objects()->IsFixedArray()) return 1; |
12928 // Multiple break points. | 12956 // Multiple break points. |
12929 return FixedArray::cast(break_point_objects())->length(); | 12957 return FixedArray::cast(break_point_objects())->length(); |
12930 } | 12958 } |
12931 #endif // ENABLE_DEBUGGER_SUPPORT | 12959 #endif // ENABLE_DEBUGGER_SUPPORT |
12932 | 12960 |
12933 | 12961 |
12934 } } // namespace v8::internal | 12962 } } // namespace v8::internal |
OLD | NEW |