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

Side by Side Diff: src/parser.cc

Issue 10828227: Force eager compilation of some function literals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Ulan Degenbaev. Created 8 years, 4 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 | « src/ast.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 result = ParseLazy(&stream, &zone_scope); 700 result = ParseLazy(&stream, &zone_scope);
701 } else { 701 } else {
702 GenericStringUtf16CharacterStream stream(source, 702 GenericStringUtf16CharacterStream stream(source,
703 shared_info->start_position(), 703 shared_info->start_position(),
704 shared_info->end_position()); 704 shared_info->end_position());
705 result = ParseLazy(&stream, &zone_scope); 705 result = ParseLazy(&stream, &zone_scope);
706 } 706 }
707 707
708 if (FLAG_trace_parse && result != NULL) { 708 if (FLAG_trace_parse && result != NULL) {
709 double ms = static_cast<double>(OS::Ticks() - start) / 1000; 709 double ms = static_cast<double>(OS::Ticks() - start) / 1000;
710 SmartArrayPointer<char> name_chars = result->name()->ToCString(); 710 SmartArrayPointer<char> name_chars = result->debug_name()->ToCString();
711 PrintF("[parsing function: %s - took %0.3f ms]\n", *name_chars, ms); 711 PrintF("[parsing function: %s - took %0.3f ms]\n", *name_chars, ms);
712 } 712 }
713 return result; 713 return result;
714 } 714 }
715 715
716 716
717 FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source, 717 FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source,
718 ZoneScope* zone_scope) { 718 ZoneScope* zone_scope) {
719 Handle<SharedFunctionInfo> shared_info = info()->shared_info(); 719 Handle<SharedFunctionInfo> shared_info = info()->shared_info();
720 scanner_.Initialize(source); 720 scanner_.Initialize(source);
(...skipping 2722 matching lines...) Expand 10 before | Expand all | Expand 10 after
3443 // For call of an identifier we want to report position of 3443 // For call of an identifier we want to report position of
3444 // the identifier as position of the call in the stack trace. 3444 // the identifier as position of the call in the stack trace.
3445 pos = scanner().location().beg_pos; 3445 pos = scanner().location().beg_pos;
3446 } else { 3446 } else {
3447 // For other kinds of calls we record position of the parenthesis as 3447 // For other kinds of calls we record position of the parenthesis as
3448 // position of the call. Note that this is extremely important for 3448 // position of the call. Note that this is extremely important for
3449 // expressions of the form function(){...}() for which call position 3449 // expressions of the form function(){...}() for which call position
3450 // should not point to the closing brace otherwise it will intersect 3450 // should not point to the closing brace otherwise it will intersect
3451 // with positions recorded for function literal and confuse debugger. 3451 // with positions recorded for function literal and confuse debugger.
3452 pos = scanner().peek_location().beg_pos; 3452 pos = scanner().peek_location().beg_pos;
3453 // Also the trailing parenthesis are a hint that the function will
3454 // be called immediately. If we happen to have parsed a preceding
3455 // function literal eagerly, we can also compile it eagerly.
3456 if (result->IsFunctionLiteral() && mode() == PARSE_EAGERLY) {
3457 result->AsFunctionLiteral()->set_parenthesized();
3458 }
3453 } 3459 }
3454 ZoneList<Expression*>* args = ParseArguments(CHECK_OK); 3460 ZoneList<Expression*>* args = ParseArguments(CHECK_OK);
3455 3461
3456 // Keep track of eval() calls since they disable all local variable 3462 // Keep track of eval() calls since they disable all local variable
3457 // optimizations. 3463 // optimizations.
3458 // The calls that need special treatment are the 3464 // The calls that need special treatment are the
3459 // direct eval calls. These calls are all of the form eval(...), with 3465 // direct eval calls. These calls are all of the form eval(...), with
3460 // no explicit receiver. 3466 // no explicit receiver.
3461 // These calls are marked as potentially direct eval calls. Whether 3467 // These calls are marked as potentially direct eval calls. Whether
3462 // they are actually direct calls to eval is determined at run time. 3468 // they are actually direct calls to eval is determined at run time.
(...skipping 2620 matching lines...) Expand 10 before | Expand all | Expand 10 after
6083 ASSERT(info->isolate()->has_pending_exception()); 6089 ASSERT(info->isolate()->has_pending_exception());
6084 } else { 6090 } else {
6085 result = parser.ParseProgram(); 6091 result = parser.ParseProgram();
6086 } 6092 }
6087 } 6093 }
6088 info->SetFunction(result); 6094 info->SetFunction(result);
6089 return (result != NULL); 6095 return (result != NULL);
6090 } 6096 }
6091 6097
6092 } } // namespace v8::internal 6098 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698