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

Side by Side Diff: src/compiler.cc

Issue 12613007: Harden Function()'s parsing of function literals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Andreas Rossberg. Created 7 years, 9 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/compiler.h ('k') | src/parser.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 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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 674
675 if (result.is_null()) isolate->ReportPendingMessages(); 675 if (result.is_null()) isolate->ReportPendingMessages();
676 return result; 676 return result;
677 } 677 }
678 678
679 679
680 Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source, 680 Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source,
681 Handle<Context> context, 681 Handle<Context> context,
682 bool is_global, 682 bool is_global,
683 LanguageMode language_mode, 683 LanguageMode language_mode,
684 ParseRestriction restriction,
684 int scope_position) { 685 int scope_position) {
685 Isolate* isolate = source->GetIsolate(); 686 Isolate* isolate = source->GetIsolate();
686 int source_length = source->length(); 687 int source_length = source->length();
687 isolate->counters()->total_eval_size()->Increment(source_length); 688 isolate->counters()->total_eval_size()->Increment(source_length);
688 isolate->counters()->total_compile_size()->Increment(source_length); 689 isolate->counters()->total_compile_size()->Increment(source_length);
689 690
690 // The VM is in the COMPILER state until exiting this function. 691 // The VM is in the COMPILER state until exiting this function.
691 VMState state(isolate, COMPILER); 692 VMState state(isolate, COMPILER);
692 693
693 // Do a lookup in the compilation cache; if the entry is not there, invoke 694 // Do a lookup in the compilation cache; if the entry is not there, invoke
694 // the compiler and add the result to the cache. 695 // the compiler and add the result to the cache.
695 Handle<SharedFunctionInfo> result; 696 Handle<SharedFunctionInfo> result;
696 CompilationCache* compilation_cache = isolate->compilation_cache(); 697 CompilationCache* compilation_cache = isolate->compilation_cache();
697 result = compilation_cache->LookupEval(source, 698 result = compilation_cache->LookupEval(source,
698 context, 699 context,
699 is_global, 700 is_global,
700 language_mode, 701 language_mode,
701 scope_position); 702 scope_position);
702 703
703 if (result.is_null()) { 704 if (result.is_null()) {
704 // Create a script object describing the script to be compiled. 705 // Create a script object describing the script to be compiled.
705 Handle<Script> script = isolate->factory()->NewScript(source); 706 Handle<Script> script = isolate->factory()->NewScript(source);
706 CompilationInfoWithZone info(script); 707 CompilationInfoWithZone info(script);
707 info.MarkAsEval(); 708 info.MarkAsEval();
708 if (is_global) info.MarkAsGlobal(); 709 if (is_global) info.MarkAsGlobal();
709 info.SetLanguageMode(language_mode); 710 info.SetLanguageMode(language_mode);
711 info.SetParseRestriction(restriction);
710 info.SetContext(context); 712 info.SetContext(context);
711 result = MakeFunctionInfo(&info); 713 result = MakeFunctionInfo(&info);
712 if (!result.is_null()) { 714 if (!result.is_null()) {
713 // Explicitly disable optimization for eval code. We're not yet prepared 715 // Explicitly disable optimization for eval code. We're not yet prepared
714 // to handle eval-code in the optimizing compiler. 716 // to handle eval-code in the optimizing compiler.
715 result->DisableOptimization("eval"); 717 result->DisableOptimization("eval");
716 718
717 // If caller is strict mode, the result must be in strict mode or 719 // If caller is strict mode, the result must be in strict mode or
718 // extended mode as well, but not the other way around. Consider: 720 // extended mode as well, but not the other way around. Consider:
719 // eval("'use strict'; ..."); 721 // eval("'use strict'; ...");
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 } 1133 }
1132 } 1134 }
1133 1135
1134 GDBJIT(AddCode(Handle<String>(shared->DebugName()), 1136 GDBJIT(AddCode(Handle<String>(shared->DebugName()),
1135 Handle<Script>(info->script()), 1137 Handle<Script>(info->script()),
1136 Handle<Code>(info->code()), 1138 Handle<Code>(info->code()),
1137 info)); 1139 info));
1138 } 1140 }
1139 1141
1140 } } // namespace v8::internal 1142 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698