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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 return AllocateStringFromOneByte(str, pretenure); | 94 return AllocateStringFromOneByte(str, pretenure); |
95 } | 95 } |
96 // Non-ASCII and we need to decode. | 96 // Non-ASCII and we need to decode. |
97 return AllocateStringFromUtf8Slow(str, non_ascii_start, pretenure); | 97 return AllocateStringFromUtf8Slow(str, non_ascii_start, pretenure); |
98 } | 98 } |
99 | 99 |
100 | 100 |
101 MaybeObject* Heap::AllocateSymbol(Vector<const char> str, | 101 MaybeObject* Heap::AllocateSymbol(Vector<const char> str, |
102 int chars, | 102 int chars, |
103 uint32_t hash_field) { | 103 uint32_t hash_field) { |
104 unibrow::Utf8InputBuffer<> buffer(str.start(), | 104 // Must be ascii. |
105 static_cast<unsigned>(str.length())); | 105 if (chars == str.length()) return AllocateAsciiSymbol(str, hash_field); |
Yang
2012/12/17 14:30:34
Maybe we could encapsulate this logic by replacing
| |
106 return AllocateInternalSymbol(&buffer, chars, hash_field); | 106 return AllocateInternalSymbol(str, chars, hash_field); |
107 } | 107 } |
108 | 108 |
109 | 109 |
110 MaybeObject* Heap::AllocateAsciiSymbol(Vector<const char> str, | 110 MaybeObject* Heap::AllocateAsciiSymbol(Vector<const char> str, |
111 uint32_t hash_field) { | 111 uint32_t hash_field) { |
112 if (str.length() > SeqOneByteString::kMaxLength) { | 112 if (str.length() > SeqOneByteString::kMaxLength) { |
113 return Failure::OutOfMemoryException(); | 113 return Failure::OutOfMemoryException(); |
114 } | 114 } |
115 // Compute map and object size. | 115 // Compute map and object size. |
116 Map* map = ascii_symbol_map(); | 116 Map* map = ascii_symbol_map(); |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
817 AssertNoAllocation::~AssertNoAllocation() { } | 817 AssertNoAllocation::~AssertNoAllocation() { } |
818 DisableAssertNoAllocation::DisableAssertNoAllocation() { } | 818 DisableAssertNoAllocation::DisableAssertNoAllocation() { } |
819 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } | 819 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } |
820 | 820 |
821 #endif | 821 #endif |
822 | 822 |
823 | 823 |
824 } } // namespace v8::internal | 824 } } // namespace v8::internal |
825 | 825 |
826 #endif // V8_HEAP_INL_H_ | 826 #endif // V8_HEAP_INL_H_ |
OLD | NEW |