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 5091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 const SourceChar* read_cursor = characters.start(); | 5105 const SourceChar* read_cursor = characters.start(); |
5106 const SourceChar* end = read_cursor + characters.length(); | 5106 const SourceChar* end = read_cursor + characters.length(); |
5107 *(write_cursor++) = '"'; | 5107 *(write_cursor++) = '"'; |
5108 while (read_cursor < end) { | 5108 while (read_cursor < end) { |
5109 SourceChar c = *(read_cursor++); | 5109 SourceChar c = *(read_cursor++); |
5110 if (sizeof(SourceChar) > 1u && | 5110 if (sizeof(SourceChar) > 1u && |
5111 static_cast<unsigned>(c) >= kQuoteTableLength) { | 5111 static_cast<unsigned>(c) >= kQuoteTableLength) { |
5112 *(write_cursor++) = c; | 5112 *(write_cursor++) = static_cast<SinkChar>(c); |
Rico
2011/05/26 14:42:09
Well actually, consider making a comment why this
| |
5113 } else { | 5113 } else { |
5114 int len = JsonQuoteLengths[static_cast<unsigned>(c)]; | 5114 int len = JsonQuoteLengths[static_cast<unsigned>(c)]; |
5115 const char* replacement = JsonQuotes + | 5115 const char* replacement = JsonQuotes + |
5116 static_cast<unsigned>(c) * kJsonQuotesCharactersPerEntry; | 5116 static_cast<unsigned>(c) * kJsonQuotesCharactersPerEntry; |
5117 write_cursor[0] = replacement[0]; | 5117 write_cursor[0] = replacement[0]; |
5118 if (len > 1) { | 5118 if (len > 1) { |
5119 write_cursor[1] = replacement[1]; | 5119 write_cursor[1] = replacement[1]; |
5120 if (len > 2) { | 5120 if (len > 2) { |
5121 ASSERT(len == 6); | 5121 ASSERT(len == 6); |
5122 write_cursor[2] = replacement[2]; | 5122 write_cursor[2] = replacement[2]; |
(...skipping 7200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12323 } else { | 12323 } else { |
12324 // Handle last resort GC and make sure to allow future allocations | 12324 // Handle last resort GC and make sure to allow future allocations |
12325 // to grow the heap without causing GCs (if possible). | 12325 // to grow the heap without causing GCs (if possible). |
12326 isolate->counters()->gc_last_resort_from_js()->Increment(); | 12326 isolate->counters()->gc_last_resort_from_js()->Increment(); |
12327 isolate->heap()->CollectAllGarbage(false); | 12327 isolate->heap()->CollectAllGarbage(false); |
12328 } | 12328 } |
12329 } | 12329 } |
12330 | 12330 |
12331 | 12331 |
12332 } } // namespace v8::internal | 12332 } } // namespace v8::internal |
OLD | NEW |