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 9121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9132 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); | 9132 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); |
9133 return JSGlobalObject::cast(global)->global_receiver(); | 9133 return JSGlobalObject::cast(global)->global_receiver(); |
9134 } | 9134 } |
9135 | 9135 |
9136 | 9136 |
9137 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { | 9137 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { |
9138 HandleScope scope(isolate); | 9138 HandleScope scope(isolate); |
9139 ASSERT_EQ(1, args.length()); | 9139 ASSERT_EQ(1, args.length()); |
9140 CONVERT_ARG_CHECKED(String, source, 0); | 9140 CONVERT_ARG_CHECKED(String, source, 0); |
9141 | 9141 |
9142 source = FlattenGetString(source); | 9142 source = Handle<String>(source->TryFlattenGetString()); |
9143 ASSERT(!source->IsConsString()); | 9143 // Optimized fast case where we only have ascii characters. |
9144 ASSERT(!source->IsSlicedString()); | |
9145 Handle<Object> result; | 9144 Handle<Object> result; |
9146 { | 9145 if (source->IsSeqAsciiString()) { |
9147 StringLock lock_representation(source); | 9146 result = JsonParser<true>::Parse(source); |
9148 if (source->IsSeqAsciiString()) { | 9147 } else { |
9149 result = JsonParser<SeqAsciiString>::Parse(source); | 9148 result = JsonParser<false>::Parse(source); |
9150 } else if (source->IsExternalTwoByteString()) { | |
9151 result = JsonParser<ExternalTwoByteString>::Parse(source); | |
9152 } else if (source->IsSeqTwoByteString()) { | |
9153 result = JsonParser<SeqTwoByteString>::Parse(source); | |
9154 } else { | |
9155 ASSERT(source->IsExternalAsciiString()); | |
9156 result = JsonParser<ExternalAsciiString>::Parse(source); | |
9157 } | |
9158 } | 9149 } |
9159 if (result.is_null()) { | 9150 if (result.is_null()) { |
9160 // Syntax error or stack overflow in scanner. | 9151 // Syntax error or stack overflow in scanner. |
9161 ASSERT(isolate->has_pending_exception()); | 9152 ASSERT(isolate->has_pending_exception()); |
9162 return Failure::Exception(); | 9153 return Failure::Exception(); |
9163 } | 9154 } |
9164 return *result; | 9155 return *result; |
9165 } | 9156 } |
9166 | 9157 |
9167 | 9158 |
(...skipping 4080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13248 } else { | 13239 } else { |
13249 // Handle last resort GC and make sure to allow future allocations | 13240 // Handle last resort GC and make sure to allow future allocations |
13250 // to grow the heap without causing GCs (if possible). | 13241 // to grow the heap without causing GCs (if possible). |
13251 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13242 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13252 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13243 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
13253 } | 13244 } |
13254 } | 13245 } |
13255 | 13246 |
13256 | 13247 |
13257 } } // namespace v8::internal | 13248 } } // namespace v8::internal |
OLD | NEW |