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 5084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5095 *(write_cursor++) = '"'; | 5095 *(write_cursor++) = '"'; |
5096 return new_string; | 5096 return new_string; |
5097 } | 5097 } |
5098 | 5098 |
5099 | 5099 |
5100 template <typename SinkChar, typename SourceChar> | 5100 template <typename SinkChar, typename SourceChar> |
5101 static inline SinkChar* WriteQuoteJsonString( | 5101 static inline SinkChar* WriteQuoteJsonString( |
5102 Isolate* isolate, | 5102 Isolate* isolate, |
5103 SinkChar* write_cursor, | 5103 SinkChar* write_cursor, |
5104 Vector<const SourceChar> characters) { | 5104 Vector<const SourceChar> characters) { |
| 5105 // SinkChar is only char if SourceChar is guaranteed to be char. |
| 5106 ASSERT(sizeof(SinkChar) >= sizeof(SourceChar)); |
5105 const SourceChar* read_cursor = characters.start(); | 5107 const SourceChar* read_cursor = characters.start(); |
5106 const SourceChar* end = read_cursor + characters.length(); | 5108 const SourceChar* end = read_cursor + characters.length(); |
5107 *(write_cursor++) = '"'; | 5109 *(write_cursor++) = '"'; |
5108 while (read_cursor < end) { | 5110 while (read_cursor < end) { |
5109 SourceChar c = *(read_cursor++); | 5111 SourceChar c = *(read_cursor++); |
5110 if (sizeof(SourceChar) > 1u && | 5112 if (sizeof(SourceChar) > 1u && |
5111 static_cast<unsigned>(c) >= kQuoteTableLength) { | 5113 static_cast<unsigned>(c) >= kQuoteTableLength) { |
5112 *(write_cursor++) = static_cast<SinkChar>(c); | 5114 *(write_cursor++) = static_cast<SinkChar>(c); |
5113 } else { | 5115 } else { |
5114 int len = JsonQuoteLengths[static_cast<unsigned>(c)]; | 5116 int len = JsonQuoteLengths[static_cast<unsigned>(c)]; |
(...skipping 7208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12323 } else { | 12325 } else { |
12324 // Handle last resort GC and make sure to allow future allocations | 12326 // Handle last resort GC and make sure to allow future allocations |
12325 // to grow the heap without causing GCs (if possible). | 12327 // to grow the heap without causing GCs (if possible). |
12326 isolate->counters()->gc_last_resort_from_js()->Increment(); | 12328 isolate->counters()->gc_last_resort_from_js()->Increment(); |
12327 isolate->heap()->CollectAllGarbage(false); | 12329 isolate->heap()->CollectAllGarbage(false); |
12328 } | 12330 } |
12329 } | 12331 } |
12330 | 12332 |
12331 | 12333 |
12332 } } // namespace v8::internal | 12334 } } // namespace v8::internal |
OLD | NEW |