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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str, | 85 MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str, |
86 PretenureFlag pretenure) { | 86 PretenureFlag pretenure) { |
87 // Check for ASCII first since this is the common case. | 87 // Check for ASCII first since this is the common case. |
88 const char* start = str.start(); | 88 const char* start = str.start(); |
89 int length = str.length(); | 89 int length = str.length(); |
90 int non_ascii_start = String::NonAsciiStart(start, length); | 90 int non_ascii_start = String::NonAsciiStart(start, length); |
91 if (non_ascii_start >= length) { | 91 if (non_ascii_start >= length) { |
92 // If the string is ASCII, we do not need to convert the characters | 92 // If the string is ASCII, we do not need to convert the characters |
93 // since UTF8 is backwards compatible with ASCII. | 93 // since UTF8 is backwards compatible with ASCII. |
94 return AllocateStringFromAscii(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 unibrow::Utf8InputBuffer<> buffer(str.start(), |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 AssertNoAllocation::~AssertNoAllocation() { } | 804 AssertNoAllocation::~AssertNoAllocation() { } |
805 DisableAssertNoAllocation::DisableAssertNoAllocation() { } | 805 DisableAssertNoAllocation::DisableAssertNoAllocation() { } |
806 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } | 806 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } |
807 | 807 |
808 #endif | 808 #endif |
809 | 809 |
810 | 810 |
811 } } // namespace v8::internal | 811 } } // namespace v8::internal |
812 | 812 |
813 #endif // V8_HEAP_INL_H_ | 813 #endif // V8_HEAP_INL_H_ |
OLD | NEW |