Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(489)

Side by Side Diff: src/compiler.cc

Issue 2959007: Fix preparsing from a source string that is not external.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/scanner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // Notify debugger 268 // Notify debugger
269 Debugger::OnAfterCompile(script, Debugger::NO_AFTER_COMPILE_FLAGS); 269 Debugger::OnAfterCompile(script, Debugger::NO_AFTER_COMPILE_FLAGS);
270 #endif 270 #endif
271 271
272 live_edit_tracker.RecordFunctionInfo(result, lit); 272 live_edit_tracker.RecordFunctionInfo(result, lit);
273 273
274 return result; 274 return result;
275 } 275 }
276 276
277 277
278 static StaticResource<SafeStringInputBuffer> safe_string_input_buffer;
279
280
281 Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source, 278 Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source,
282 Handle<Object> script_name, 279 Handle<Object> script_name,
283 int line_offset, 280 int line_offset,
284 int column_offset, 281 int column_offset,
285 v8::Extension* extension, 282 v8::Extension* extension,
286 ScriptDataImpl* input_pre_data, 283 ScriptDataImpl* input_pre_data,
287 Handle<Object> script_data, 284 Handle<Object> script_data,
288 NativesFlag natives) { 285 NativesFlag natives) {
289 int source_length = source->length(); 286 int source_length = source->length();
290 Counters::total_load_size.Increment(source_length); 287 Counters::total_load_size.Increment(source_length);
291 Counters::total_compile_size.Increment(source_length); 288 Counters::total_compile_size.Increment(source_length);
292 289
293 // The VM is in the COMPILER state until exiting this function. 290 // The VM is in the COMPILER state until exiting this function.
294 VMState state(COMPILER); 291 VMState state(COMPILER);
295 292
296 // Do a lookup in the compilation cache but not for extensions. 293 // Do a lookup in the compilation cache but not for extensions.
297 Handle<SharedFunctionInfo> result; 294 Handle<SharedFunctionInfo> result;
298 if (extension == NULL) { 295 if (extension == NULL) {
299 result = CompilationCache::LookupScript(source, 296 result = CompilationCache::LookupScript(source,
300 script_name, 297 script_name,
301 line_offset, 298 line_offset,
302 column_offset); 299 column_offset);
303 } 300 }
304 301
305 if (result.is_null()) { 302 if (result.is_null()) {
306 // No cache entry found. Do pre-parsing and compile the script. 303 // No cache entry found. Do pre-parsing and compile the script.
307 ScriptDataImpl* pre_data = input_pre_data; 304 ScriptDataImpl* pre_data = input_pre_data;
308 if (pre_data == NULL && source_length >= FLAG_min_preparse_length) { 305 if (pre_data == NULL && source_length >= FLAG_min_preparse_length) {
309 Access<SafeStringInputBuffer> buf(&safe_string_input_buffer); 306 pre_data = PreParse(source, NULL, extension);
310 buf->Reset(source.location());
311 pre_data = PreParse(source, buf.value(), extension);
312 } 307 }
313 308
314 // Create a script object describing the script to be compiled. 309 // Create a script object describing the script to be compiled.
315 Handle<Script> script = Factory::NewScript(source); 310 Handle<Script> script = Factory::NewScript(source);
316 if (natives == NATIVES_CODE) { 311 if (natives == NATIVES_CODE) {
317 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); 312 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
318 } 313 }
319 if (!script_name.is_null()) { 314 if (!script_name.is_null()) {
320 script->set_name(*script_name); 315 script->set_name(*script_name);
321 script->set_line_offset(Smi::FromInt(line_offset)); 316 script->set_line_offset(Smi::FromInt(line_offset));
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), 628 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script),
634 *code, *func_name)); 629 *code, *func_name));
635 OPROFILE(CreateNativeCodeRegion(*func_name, 630 OPROFILE(CreateNativeCodeRegion(*func_name,
636 code->instruction_start(), 631 code->instruction_start(),
637 code->instruction_size())); 632 code->instruction_size()));
638 } 633 }
639 } 634 }
640 } 635 }
641 636
642 } } // namespace v8::internal 637 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698