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 8462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8473 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); | 8473 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); |
8474 return JSGlobalObject::cast(global)->global_receiver(); | 8474 return JSGlobalObject::cast(global)->global_receiver(); |
8475 } | 8475 } |
8476 | 8476 |
8477 | 8477 |
8478 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { | 8478 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { |
8479 HandleScope scope(isolate); | 8479 HandleScope scope(isolate); |
8480 ASSERT_EQ(1, args.length()); | 8480 ASSERT_EQ(1, args.length()); |
8481 CONVERT_ARG_CHECKED(String, source, 0); | 8481 CONVERT_ARG_CHECKED(String, source, 0); |
8482 | 8482 |
8483 Handle<Object> result = JsonParser::Parse(source); | 8483 source = Handle<String>(source->TryFlattenGetString()); |
| 8484 // Optimized fast case where we only have ascii characters. |
| 8485 Handle<Object> result; |
| 8486 if (source->IsSeqAsciiString()) { |
| 8487 result = JsonParser<true>::Parse(source); |
| 8488 } else { |
| 8489 result = JsonParser<false>::Parse(source); |
| 8490 } |
8484 if (result.is_null()) { | 8491 if (result.is_null()) { |
8485 // Syntax error or stack overflow in scanner. | 8492 // Syntax error or stack overflow in scanner. |
8486 ASSERT(isolate->has_pending_exception()); | 8493 ASSERT(isolate->has_pending_exception()); |
8487 return Failure::Exception(); | 8494 return Failure::Exception(); |
8488 } | 8495 } |
8489 return *result; | 8496 return *result; |
8490 } | 8497 } |
8491 | 8498 |
8492 | 8499 |
8493 bool CodeGenerationFromStringsAllowed(Isolate* isolate, | 8500 bool CodeGenerationFromStringsAllowed(Isolate* isolate, |
(...skipping 3858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12352 } else { | 12359 } else { |
12353 // Handle last resort GC and make sure to allow future allocations | 12360 // Handle last resort GC and make sure to allow future allocations |
12354 // to grow the heap without causing GCs (if possible). | 12361 // to grow the heap without causing GCs (if possible). |
12355 isolate->counters()->gc_last_resort_from_js()->Increment(); | 12362 isolate->counters()->gc_last_resort_from_js()->Increment(); |
12356 isolate->heap()->CollectAllGarbage(false); | 12363 isolate->heap()->CollectAllGarbage(false); |
12357 } | 12364 } |
12358 } | 12365 } |
12359 | 12366 |
12360 | 12367 |
12361 } } // namespace v8::internal | 12368 } } // namespace v8::internal |
OLD | NEW |