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

Side by Side Diff: src/compiler.cc

Issue 3538005: Cleanup of the parser. (Closed)
Patch Set: Created 10 years, 2 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
« no previous file with comments | « no previous file | src/parser.h » ('j') | src/parser.h » ('J')
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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 bool Compiler::CompileLazy(CompilationInfo* info) { 370 bool Compiler::CompileLazy(CompilationInfo* info) {
371 CompilationZoneScope zone_scope(DELETE_ON_EXIT); 371 CompilationZoneScope zone_scope(DELETE_ON_EXIT);
372 372
373 // The VM is in the COMPILER state until exiting this function. 373 // The VM is in the COMPILER state until exiting this function.
374 VMState state(COMPILER); 374 VMState state(COMPILER);
375 375
376 PostponeInterruptsScope postpone; 376 PostponeInterruptsScope postpone;
377 377
378 // Compute name, source code and script data. 378 // Compute name, source code and script data.
379 Handle<SharedFunctionInfo> shared = info->shared_info(); 379 Handle<SharedFunctionInfo> shared = info->shared_info();
380 Handle<String> name(String::cast(shared->name())); 380 int compiled_size = shared->end_position() - shared->start_position();
381 381 Counters::total_compile_size.Increment(compiled_size);
382 int start_position = shared->start_position();
383 int end_position = shared->end_position();
384 bool is_expression = shared->is_expression();
385 Counters::total_compile_size.Increment(end_position - start_position);
386 382
387 // Generate the AST for the lazily compiled function. The AST may be 383 // Generate the AST for the lazily compiled function. The AST may be
388 // NULL in case of parser stack overflow. 384 // NULL in case of parser stack overflow.
389 FunctionLiteral* lit = MakeLazyAST(info->script(), 385 FunctionLiteral* lit = MakeLazyAST(shared);
390 name,
391 start_position,
392 end_position,
393 is_expression);
394 386
395 // Check for parse errors. 387 // Check for parse errors.
396 if (lit == NULL) { 388 if (lit == NULL) {
397 ASSERT(Top::has_pending_exception()); 389 ASSERT(Top::has_pending_exception());
398 return false; 390 return false;
399 } 391 }
400 info->set_function(lit); 392 info->set_function(lit);
401 393
402 // Measure how long it takes to do the lazy compilation; only take 394 // Measure how long it takes to do the lazy compilation; only take
403 // the rest of the function into account to avoid overlap with the 395 // the rest of the function into account to avoid overlap with the
404 // lazy parsing statistics. 396 // lazy parsing statistics.
405 HistogramTimerScope timer(&Counters::compile_lazy); 397 HistogramTimerScope timer(&Counters::compile_lazy);
406 398
407 // Compile the code. 399 // Compile the code.
408 Handle<Code> code = MakeCode(Handle<Context>::null(), info); 400 Handle<Code> code = MakeCode(Handle<Context>::null(), info);
409 401
410 // Check for stack-overflow exception. 402 // Check for stack-overflow exception.
411 if (code.is_null()) { 403 if (code.is_null()) {
412 Top::StackOverflow(); 404 Top::StackOverflow();
413 return false; 405 return false;
414 } 406 }
415 407
416 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, 408 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG,
417 name, 409 Handle<String>(String::cast(shared->name())),
Lasse Reichstein 2010/09/30 09:11:41 Not your code, but how do we know that shared->nam
Kevin Millikin (Chromium) 2010/09/30 09:39:48 I actually think name should *be* a string so that
418 Handle<String>(shared->inferred_name()), 410 Handle<String>(shared->inferred_name()),
419 start_position, 411 shared->start_position(),
420 info->script(), 412 info->script(),
421 code); 413 code);
422 414
423 // Update the shared function info with the compiled code and the scope info. 415 // Update the shared function info with the compiled code and the scope info.
424 // Please note, that the order of the sharedfunction initialization is 416 // Please note, that the order of the sharedfunction initialization is
425 // important since SerializedScopeInfo::Create might trigger a GC, causing 417 // important since SerializedScopeInfo::Create might trigger a GC, causing
426 // the ASSERT below to be invalid if the code was flushed. By setting the code 418 // the ASSERT below to be invalid if the code was flushed. By setting the code
427 // object last we avoid this. 419 // object last we avoid this.
428 Handle<SerializedScopeInfo> scope_info = 420 Handle<SerializedScopeInfo> scope_info =
429 SerializedScopeInfo::Create(info->scope()); 421 SerializedScopeInfo::Create(info->scope());
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), 575 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script),
584 *code, *func_name)); 576 *code, *func_name));
585 OPROFILE(CreateNativeCodeRegion(*func_name, 577 OPROFILE(CreateNativeCodeRegion(*func_name,
586 code->instruction_start(), 578 code->instruction_start(),
587 code->instruction_size())); 579 code->instruction_size()));
588 } 580 }
589 } 581 }
590 } 582 }
591 583
592 } } // namespace v8::internal 584 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/parser.h » ('j') | src/parser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698