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 9033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9044 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); | 9044 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); |
9045 return JSGlobalObject::cast(global)->global_receiver(); | 9045 return JSGlobalObject::cast(global)->global_receiver(); |
9046 } | 9046 } |
9047 | 9047 |
9048 | 9048 |
9049 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { | 9049 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { |
9050 HandleScope scope(isolate); | 9050 HandleScope scope(isolate); |
9051 ASSERT_EQ(1, args.length()); | 9051 ASSERT_EQ(1, args.length()); |
9052 CONVERT_ARG_CHECKED(String, source, 0); | 9052 CONVERT_ARG_CHECKED(String, source, 0); |
9053 | 9053 |
9054 source = Handle<String>(source->TryFlattenGetString()); | 9054 source = FlattenGetString(source); |
Rico
2011/09/23 07:06:52
As discussed offline, please change comment in han
Lasse Reichstein
2011/09/23 09:54:39
Done.
| |
9055 // Optimized fast case where we only have ascii characters. | 9055 ASSERT(!source->IsConsString()); |
9056 ASSERT(!source->IsSlicedString()); | |
9056 Handle<Object> result; | 9057 Handle<Object> result; |
9057 if (source->IsSeqAsciiString()) { | 9058 { |
9058 result = JsonParser<true>::Parse(source); | 9059 StringLock lock_representation(source); |
9059 } else { | 9060 if (source->IsSeqAsciiString()) { |
9060 result = JsonParser<false>::Parse(source); | 9061 result = JsonParser<SeqAsciiString>::Parse(source); |
9062 } else if (source->IsExternalTwoByteString()) { | |
9063 result = JsonParser<ExternalTwoByteString>::Parse(source); | |
9064 } else if (source->IsSeqTwoByteString()) { | |
9065 result = JsonParser<SeqTwoByteString>::Parse(source); | |
9066 } else { | |
9067 ASSERT(source->IsExternalAsciiString()); | |
9068 result = JsonParser<ExternalAsciiString>::Parse(source); | |
9069 } | |
9061 } | 9070 } |
9062 if (result.is_null()) { | 9071 if (result.is_null()) { |
9063 // Syntax error or stack overflow in scanner. | 9072 // Syntax error or stack overflow in scanner. |
9064 ASSERT(isolate->has_pending_exception()); | 9073 ASSERT(isolate->has_pending_exception()); |
9065 return Failure::Exception(); | 9074 return Failure::Exception(); |
9066 } | 9075 } |
9067 return *result; | 9076 return *result; |
9068 } | 9077 } |
9069 | 9078 |
9070 | 9079 |
(...skipping 4078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13149 } else { | 13158 } else { |
13150 // Handle last resort GC and make sure to allow future allocations | 13159 // Handle last resort GC and make sure to allow future allocations |
13151 // to grow the heap without causing GCs (if possible). | 13160 // to grow the heap without causing GCs (if possible). |
13152 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13161 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13153 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13162 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
13154 } | 13163 } |
13155 } | 13164 } |
13156 | 13165 |
13157 | 13166 |
13158 } } // namespace v8::internal | 13167 } } // namespace v8::internal |
OLD | NEW |