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 9088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9099 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); | 9099 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); |
9100 return JSGlobalObject::cast(global)->global_receiver(); | 9100 return JSGlobalObject::cast(global)->global_receiver(); |
9101 } | 9101 } |
9102 | 9102 |
9103 | 9103 |
9104 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { | 9104 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { |
9105 HandleScope scope(isolate); | 9105 HandleScope scope(isolate); |
9106 ASSERT_EQ(1, args.length()); | 9106 ASSERT_EQ(1, args.length()); |
9107 CONVERT_ARG_CHECKED(String, source, 0); | 9107 CONVERT_ARG_CHECKED(String, source, 0); |
9108 | 9108 |
9109 source = Handle<String>(source->TryFlattenGetString()); | 9109 source = FlattenGetString(source); |
9110 // Optimized fast case where we only have ascii characters. | 9110 ASSERT(!source->IsConsString()); |
| 9111 ASSERT(!source->IsSlicedString()); |
9111 Handle<Object> result; | 9112 Handle<Object> result; |
9112 if (source->IsSeqAsciiString()) { | 9113 { |
9113 result = JsonParser<true>::Parse(source); | 9114 StringLock lock_representation(source); |
9114 } else { | 9115 if (source->IsSeqAsciiString()) { |
9115 result = JsonParser<false>::Parse(source); | 9116 result = JsonParser<SeqAsciiString>::Parse(source); |
| 9117 } else if (source->IsExternalTwoByteString()) { |
| 9118 result = JsonParser<ExternalTwoByteString>::Parse(source); |
| 9119 } else if (source->IsSeqTwoByteString()) { |
| 9120 result = JsonParser<SeqTwoByteString>::Parse(source); |
| 9121 } else { |
| 9122 ASSERT(source->IsExternalAsciiString()); |
| 9123 result = JsonParser<ExternalAsciiString>::Parse(source); |
| 9124 } |
9116 } | 9125 } |
9117 if (result.is_null()) { | 9126 if (result.is_null()) { |
9118 // Syntax error or stack overflow in scanner. | 9127 // Syntax error or stack overflow in scanner. |
9119 ASSERT(isolate->has_pending_exception()); | 9128 ASSERT(isolate->has_pending_exception()); |
9120 return Failure::Exception(); | 9129 return Failure::Exception(); |
9121 } | 9130 } |
9122 return *result; | 9131 return *result; |
9123 } | 9132 } |
9124 | 9133 |
9125 | 9134 |
(...skipping 4080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13206 } else { | 13215 } else { |
13207 // Handle last resort GC and make sure to allow future allocations | 13216 // Handle last resort GC and make sure to allow future allocations |
13208 // to grow the heap without causing GCs (if possible). | 13217 // to grow the heap without causing GCs (if possible). |
13209 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13218 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13210 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13219 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
13211 } | 13220 } |
13212 } | 13221 } |
13213 | 13222 |
13214 | 13223 |
13215 } } // namespace v8::internal | 13224 } } // namespace v8::internal |
OLD | NEW |