| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 uc16 buffer_[kPushBackSize + kBufferSize]; | 161 uc16 buffer_[kPushBackSize + kBufferSize]; |
| 162 // Limit of pushbacks before new allocation is necessary. | 162 // Limit of pushbacks before new allocation is necessary. |
| 163 uc16* pushback_buffer_; | 163 uc16* pushback_buffer_; |
| 164 // Only if that pushback buffer at the start of buffer_ isn't sufficient | 164 // Only if that pushback buffer at the start of buffer_ isn't sufficient |
| 165 // is the following used. | 165 // is the following used. |
| 166 const uc16* pushback_buffer_end_cache_; | 166 const uc16* pushback_buffer_end_cache_; |
| 167 uc16* pushback_buffer_backing_; | 167 uc16* pushback_buffer_backing_; |
| 168 unsigned pushback_buffer_backing_size_; | 168 unsigned pushback_buffer_backing_size_; |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 | |
| 172 // Functions declared by allocation.h and implemented in both api.cc (for v8) | |
| 173 // or here (for a stand-alone preparser). | |
| 174 | |
| 175 void FatalProcessOutOfMemory(const char* reason) { | |
| 176 V8_Fatal(__FILE__, __LINE__, reason); | |
| 177 } | |
| 178 | |
| 179 bool EnableSlowAsserts() { return true; } | |
| 180 | |
| 181 } // namespace internal. | 171 } // namespace internal. |
| 182 | 172 |
| 183 | 173 |
| 184 UnicodeInputStream::~UnicodeInputStream() { } | 174 UnicodeInputStream::~UnicodeInputStream() { } |
| 185 | 175 |
| 186 | 176 |
| 187 PreParserData Preparse(UnicodeInputStream* input, size_t max_stack) { | 177 PreParserData Preparse(UnicodeInputStream* input, size_t max_stack) { |
| 188 internal::InputStreamUtf16Buffer buffer(input); | 178 internal::InputStreamUtf16Buffer buffer(input); |
| 189 uintptr_t stack_limit = reinterpret_cast<uintptr_t>(&buffer) - max_stack; | 179 uintptr_t stack_limit = reinterpret_cast<uintptr_t>(&buffer) - max_stack; |
| 190 internal::UnicodeCache unicode_cache; | 180 internal::UnicodeCache unicode_cache; |
| 191 internal::Scanner scanner(&unicode_cache); | 181 internal::Scanner scanner(&unicode_cache); |
| 192 scanner.Initialize(&buffer); | 182 scanner.Initialize(&buffer); |
| 193 internal::CompleteParserRecorder recorder; | 183 internal::CompleteParserRecorder recorder; |
| 194 preparser::PreParser preparser(&scanner, &recorder, stack_limit); | 184 preparser::PreParser preparser(&scanner, &recorder, stack_limit); |
| 195 preparser.set_allow_lazy(true); | 185 preparser.set_allow_lazy(true); |
| 196 preparser::PreParser::PreParseResult result = preparser.PreParseProgram(); | 186 preparser::PreParser::PreParseResult result = preparser.PreParseProgram(); |
| 197 if (result == preparser::PreParser::kPreParseStackOverflow) { | 187 if (result == preparser::PreParser::kPreParseStackOverflow) { |
| 198 return PreParserData::StackOverflow(); | 188 return PreParserData::StackOverflow(); |
| 199 } | 189 } |
| 200 internal::Vector<unsigned> pre_data = recorder.ExtractData(); | 190 internal::Vector<unsigned> pre_data = recorder.ExtractData(); |
| 201 size_t size = pre_data.length() * sizeof(pre_data[0]); | 191 size_t size = pre_data.length() * sizeof(pre_data[0]); |
| 202 unsigned char* data = reinterpret_cast<unsigned char*>(pre_data.start()); | 192 unsigned char* data = reinterpret_cast<unsigned char*>(pre_data.start()); |
| 203 return PreParserData(size, data); | 193 return PreParserData(size, data); |
| 204 } | 194 } |
| 205 | 195 |
| 206 } // namespace v8. | 196 } // namespace v8. |
| 207 | |
| 208 | |
| 209 // Used by ASSERT macros and other immediate exits. | |
| 210 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) { | |
| 211 exit(EXIT_FAILURE); | |
| 212 } | |
| OLD | NEW |