OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/ast/ast.h" | 10 #include "src/ast/ast.h" |
(...skipping 1033 matching lines...) Loading... |
1044 isolate->counters()->total_parse_size()->Increment(source->length()); | 1044 isolate->counters()->total_parse_size()->Increment(source->length()); |
1045 base::ElapsedTimer timer; | 1045 base::ElapsedTimer timer; |
1046 if (FLAG_trace_parse) { | 1046 if (FLAG_trace_parse) { |
1047 timer.Start(); | 1047 timer.Start(); |
1048 } | 1048 } |
1049 Handle<SharedFunctionInfo> shared_info = info->shared_info(); | 1049 Handle<SharedFunctionInfo> shared_info = info->shared_info(); |
1050 | 1050 |
1051 // Initialize parser state. | 1051 // Initialize parser state. |
1052 source = String::Flatten(source); | 1052 source = String::Flatten(source); |
1053 FunctionLiteral* result; | 1053 FunctionLiteral* result; |
1054 if (source->IsExternalTwoByteString()) { | 1054 { |
1055 ExternalTwoByteStringUtf16CharacterStream stream( | 1055 std::unique_ptr<Utf16CharacterStream> stream; |
1056 Handle<ExternalTwoByteString>::cast(source), | 1056 if (source->IsExternalTwoByteString()) { |
1057 shared_info->start_position(), | 1057 stream.reset(new ExternalTwoByteStringUtf16CharacterStream( |
1058 shared_info->end_position()); | 1058 Handle<ExternalTwoByteString>::cast(source), |
1059 result = ParseLazy(isolate, info, &stream); | 1059 shared_info->start_position(), shared_info->end_position())); |
1060 } else { | 1060 } else if (source->IsExternalOneByteString()) { |
1061 GenericStringUtf16CharacterStream stream(source, | 1061 stream.reset(new ExternalOneByteStringUtf16CharacterStream( |
1062 shared_info->start_position(), | 1062 Handle<ExternalOneByteString>::cast(source), |
1063 shared_info->end_position()); | 1063 shared_info->start_position(), shared_info->end_position())); |
1064 result = ParseLazy(isolate, info, &stream); | 1064 } else { |
| 1065 stream.reset(new GenericStringUtf16CharacterStream( |
| 1066 source, shared_info->start_position(), shared_info->end_position())); |
| 1067 } |
| 1068 result = ParseLazy(isolate, info, stream.get()); |
1065 } | 1069 } |
1066 | 1070 |
1067 if (FLAG_trace_parse && result != NULL) { | 1071 if (FLAG_trace_parse && result != NULL) { |
1068 double ms = timer.Elapsed().InMillisecondsF(); | 1072 double ms = timer.Elapsed().InMillisecondsF(); |
1069 std::unique_ptr<char[]> name_chars = result->debug_name()->ToCString(); | 1073 std::unique_ptr<char[]> name_chars = result->debug_name()->ToCString(); |
1070 PrintF("[parsing function: %s - took %0.3f ms]\n", name_chars.get(), ms); | 1074 PrintF("[parsing function: %s - took %0.3f ms]\n", name_chars.get(), ms); |
1071 } | 1075 } |
1072 return result; | 1076 return result; |
1073 } | 1077 } |
1074 | 1078 |
(...skipping 6021 matching lines...) Loading... |
7096 node->Print(Isolate::Current()); | 7100 node->Print(Isolate::Current()); |
7097 } | 7101 } |
7098 #endif // DEBUG | 7102 #endif // DEBUG |
7099 | 7103 |
7100 #undef CHECK_OK | 7104 #undef CHECK_OK |
7101 #undef CHECK_OK_VOID | 7105 #undef CHECK_OK_VOID |
7102 #undef CHECK_FAILED | 7106 #undef CHECK_FAILED |
7103 | 7107 |
7104 } // namespace internal | 7108 } // namespace internal |
7105 } // namespace v8 | 7109 } // namespace v8 |
OLD | NEW |