OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 3957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3968 } | 3968 } |
3969 return result; | 3969 return result; |
3970 } | 3970 } |
3971 | 3971 |
3972 | 3972 |
3973 Map* Heap::SymbolMapForString(String* string) { | 3973 Map* Heap::SymbolMapForString(String* string) { |
3974 // If the string is in new space it cannot be used as a symbol. | 3974 // If the string is in new space it cannot be used as a symbol. |
3975 if (InNewSpace(string)) return NULL; | 3975 if (InNewSpace(string)) return NULL; |
3976 | 3976 |
3977 // Find the corresponding symbol map for strings. | 3977 // Find the corresponding symbol map for strings. |
3978 Map* map = string->map(); | 3978 switch (string->map()->instance_type()) { |
3979 if (map == ascii_string_map()) { | 3979 case STRING_TYPE: return symbol_map(); |
3980 return ascii_symbol_map(); | 3980 case ASCII_STRING_TYPE: return ascii_symbol_map(); |
| 3981 case CONS_STRING_TYPE: return cons_symbol_map(); |
| 3982 case CONS_ASCII_STRING_TYPE: return cons_ascii_symbol_map(); |
| 3983 case EXTERNAL_STRING_TYPE: return external_symbol_map(); |
| 3984 case EXTERNAL_ASCII_STRING_TYPE: return external_ascii_symbol_map(); |
| 3985 case EXTERNAL_STRING_WITH_ASCII_DATA_TYPE: |
| 3986 return external_symbol_with_ascii_data_map(); |
| 3987 case SHORT_EXTERNAL_STRING_TYPE: return short_external_symbol_map(); |
| 3988 case SHORT_EXTERNAL_ASCII_STRING_TYPE: |
| 3989 return short_external_ascii_symbol_map(); |
| 3990 case SHORT_EXTERNAL_STRING_WITH_ASCII_DATA_TYPE: |
| 3991 return short_external_symbol_with_ascii_data_map(); |
| 3992 default: return NULL; // No match found. |
3981 } | 3993 } |
3982 if (map == string_map()) { | |
3983 return symbol_map(); | |
3984 } | |
3985 if (map == cons_string_map()) { | |
3986 return cons_symbol_map(); | |
3987 } | |
3988 if (map == cons_ascii_string_map()) { | |
3989 return cons_ascii_symbol_map(); | |
3990 } | |
3991 if (map == external_string_map()) { | |
3992 return external_symbol_map(); | |
3993 } | |
3994 if (map == external_ascii_string_map()) { | |
3995 return external_ascii_symbol_map(); | |
3996 } | |
3997 if (map == external_string_with_ascii_data_map()) { | |
3998 return external_symbol_with_ascii_data_map(); | |
3999 } | |
4000 if (map == short_external_string_map()) { | |
4001 return short_external_symbol_map(); | |
4002 } | |
4003 if (map == short_external_ascii_string_map()) { | |
4004 return short_external_ascii_symbol_map(); | |
4005 } | |
4006 if (map == short_external_string_with_ascii_data_map()) { | |
4007 return short_external_symbol_with_ascii_data_map(); | |
4008 } | |
4009 | |
4010 // No match found. | |
4011 return NULL; | |
4012 } | 3994 } |
4013 | 3995 |
4014 | 3996 |
4015 MaybeObject* Heap::AllocateInternalSymbol(unibrow::CharacterStream* buffer, | 3997 MaybeObject* Heap::AllocateInternalSymbol(unibrow::CharacterStream* buffer, |
4016 int chars, | 3998 int chars, |
4017 uint32_t hash_field) { | 3999 uint32_t hash_field) { |
4018 ASSERT(chars >= 0); | 4000 ASSERT(chars >= 0); |
4019 // Ensure the chars matches the number of characters in the buffer. | 4001 // Ensure the chars matches the number of characters in the buffer. |
4020 ASSERT(static_cast<unsigned>(chars) == buffer->Length()); | 4002 ASSERT(static_cast<unsigned>(chars) == buffer->Length()); |
4021 // Determine whether the string is ascii. | 4003 // Determine whether the string is ascii. |
(...skipping 2445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6467 isolate_->heap()->store_buffer()->Compact(); | 6449 isolate_->heap()->store_buffer()->Compact(); |
6468 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); | 6450 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); |
6469 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { | 6451 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { |
6470 next = chunk->next_chunk(); | 6452 next = chunk->next_chunk(); |
6471 isolate_->memory_allocator()->Free(chunk); | 6453 isolate_->memory_allocator()->Free(chunk); |
6472 } | 6454 } |
6473 chunks_queued_for_free_ = NULL; | 6455 chunks_queued_for_free_ = NULL; |
6474 } | 6456 } |
6475 | 6457 |
6476 } } // namespace v8::internal | 6458 } } // namespace v8::internal |
OLD | NEW |