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 3485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3496 | 3496 |
3497 ASSERT(!is_shared()); | 3497 ASSERT(!is_shared()); |
3498 WRITE_FIELD(this, kInstanceDescriptorsOrBackPointerOffset, value); | 3498 WRITE_FIELD(this, kInstanceDescriptorsOrBackPointerOffset, value); |
3499 CONDITIONAL_WRITE_BARRIER( | 3499 CONDITIONAL_WRITE_BARRIER( |
3500 heap, this, kInstanceDescriptorsOrBackPointerOffset, value, mode); | 3500 heap, this, kInstanceDescriptorsOrBackPointerOffset, value, mode); |
3501 } | 3501 } |
3502 | 3502 |
3503 | 3503 |
3504 void Map::InitializeDescriptors(DescriptorArray* descriptors) { | 3504 void Map::InitializeDescriptors(DescriptorArray* descriptors) { |
3505 int len = descriptors->number_of_descriptors(); | 3505 int len = descriptors->number_of_descriptors(); |
| 3506 ASSERT(len <= DescriptorArray::kMaxNumberOfDescriptors); |
3506 SLOW_ASSERT(descriptors->IsSortedNoDuplicates()); | 3507 SLOW_ASSERT(descriptors->IsSortedNoDuplicates()); |
3507 | 3508 |
3508 #ifdef DEBUG | 3509 #ifdef DEBUG |
3509 bool* used_indices = | 3510 bool used_indices[DescriptorArray::kMaxNumberOfDescriptors]; |
3510 reinterpret_cast<bool*>(alloca(sizeof(*used_indices) * len)); | |
3511 for (int i = 0; i < len; ++i) used_indices[i] = false; | 3511 for (int i = 0; i < len; ++i) used_indices[i] = false; |
3512 | 3512 |
3513 // Ensure that all enumeration indexes between 1 and length occur uniquely in | 3513 // Ensure that all enumeration indexes between 1 and length occur uniquely in |
3514 // the descriptor array. | 3514 // the descriptor array. |
3515 for (int i = 0; i < len; ++i) { | 3515 for (int i = 0; i < len; ++i) { |
3516 int enum_index = descriptors->GetDetails(i).index() - | 3516 int enum_index = descriptors->GetDetails(i).index() - |
3517 PropertyDetails::kInitialIndex; | 3517 PropertyDetails::kInitialIndex; |
| 3518 ASSERT(0 <= enum_index && enum_index < len); |
3518 ASSERT(!used_indices[enum_index]); | 3519 ASSERT(!used_indices[enum_index]); |
3519 used_indices[enum_index] = true; | 3520 used_indices[enum_index] = true; |
3520 } | 3521 } |
3521 #endif | 3522 #endif |
3522 | 3523 |
3523 for (int i = 0; i < len; ++i) { | 3524 for (int i = 0; i < len; ++i) { |
3524 if (descriptors->GetDetails(i).index() == len) { | 3525 if (descriptors->GetDetails(i).index() == len) { |
3525 descriptors->SetLastAdded(i); | 3526 descriptors->SetLastAdded(i); |
3526 break; | 3527 break; |
3527 } | 3528 } |
(...skipping 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5368 #undef WRITE_UINT32_FIELD | 5369 #undef WRITE_UINT32_FIELD |
5369 #undef READ_SHORT_FIELD | 5370 #undef READ_SHORT_FIELD |
5370 #undef WRITE_SHORT_FIELD | 5371 #undef WRITE_SHORT_FIELD |
5371 #undef READ_BYTE_FIELD | 5372 #undef READ_BYTE_FIELD |
5372 #undef WRITE_BYTE_FIELD | 5373 #undef WRITE_BYTE_FIELD |
5373 | 5374 |
5374 | 5375 |
5375 } } // namespace v8::internal | 5376 } } // namespace v8::internal |
5376 | 5377 |
5377 #endif // V8_OBJECTS_INL_H_ | 5378 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |