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

Side by Side Diff: src/compiler.cc

Issue 6286043: Direct call to eval passes strict mode through. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Extra argument to Resolve*Eval* Created 9 years, 10 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
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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 } 541 }
542 } 542 }
543 543
544 if (result.is_null()) Top::ReportPendingMessages(); 544 if (result.is_null()) Top::ReportPendingMessages();
545 return result; 545 return result;
546 } 546 }
547 547
548 548
549 Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source, 549 Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source,
550 Handle<Context> context, 550 Handle<Context> context,
551 bool is_global) { 551 bool is_global,
552 bool is_strict) {
552 int source_length = source->length(); 553 int source_length = source->length();
553 Counters::total_eval_size.Increment(source_length); 554 Counters::total_eval_size.Increment(source_length);
554 Counters::total_compile_size.Increment(source_length); 555 Counters::total_compile_size.Increment(source_length);
555 556
556 // The VM is in the COMPILER state until exiting this function. 557 // The VM is in the COMPILER state until exiting this function.
557 VMState state(COMPILER); 558 VMState state(COMPILER);
558 559
559 // Do a lookup in the compilation cache; if the entry is not there, invoke 560 // Do a lookup in the compilation cache; if the entry is not there, invoke
560 // the compiler and add the result to the cache. 561 // the compiler and add the result to the cache.
561 Handle<SharedFunctionInfo> result; 562 Handle<SharedFunctionInfo> result;
562 result = CompilationCache::LookupEval(source, context, is_global); 563 result = CompilationCache::LookupEval(source, context, is_global, is_strict);
563 564
564 if (result.is_null()) { 565 if (result.is_null()) {
565 // Create a script object describing the script to be compiled. 566 // Create a script object describing the script to be compiled.
566 Handle<Script> script = Factory::NewScript(source); 567 Handle<Script> script = Factory::NewScript(source);
567 CompilationInfo info(script); 568 CompilationInfo info(script);
568 info.MarkAsEval(); 569 info.MarkAsEval();
569 if (is_global) info.MarkAsGlobal(); 570 if (is_global) info.MarkAsGlobal();
571 if (is_strict) info.MarkAsStrict();
570 info.SetCallingContext(context); 572 info.SetCallingContext(context);
571 result = MakeFunctionInfo(&info); 573 result = MakeFunctionInfo(&info);
572 if (!result.is_null()) { 574 if (!result.is_null()) {
575 ASSERT(is_strict == result->strict_mode());
573 CompilationCache::PutEval(source, context, is_global, result); 576 CompilationCache::PutEval(source, context, is_global, result);
574 } 577 }
575 } 578 }
576 579
577 return result; 580 return result;
578 } 581 }
579 582
580 583
581 bool Compiler::CompileLazy(CompilationInfo* info) { 584 bool Compiler::CompileLazy(CompilationInfo* info) {
582 CompilationZoneScope zone_scope(DELETE_ON_EXIT); 585 CompilationZoneScope zone_scope(DELETE_ON_EXIT);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 function_info->set_start_position(lit->start_position()); 758 function_info->set_start_position(lit->start_position());
756 function_info->set_end_position(lit->end_position()); 759 function_info->set_end_position(lit->end_position());
757 function_info->set_is_expression(lit->is_expression()); 760 function_info->set_is_expression(lit->is_expression());
758 function_info->set_is_toplevel(is_toplevel); 761 function_info->set_is_toplevel(is_toplevel);
759 function_info->set_inferred_name(*lit->inferred_name()); 762 function_info->set_inferred_name(*lit->inferred_name());
760 function_info->SetThisPropertyAssignmentsInfo( 763 function_info->SetThisPropertyAssignmentsInfo(
761 lit->has_only_simple_this_property_assignments(), 764 lit->has_only_simple_this_property_assignments(),
762 *lit->this_property_assignments()); 765 *lit->this_property_assignments());
763 function_info->set_try_full_codegen(lit->try_full_codegen()); 766 function_info->set_try_full_codegen(lit->try_full_codegen());
764 function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation()); 767 function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation());
768 function_info->set_strict_mode(lit->strict_mode());
765 } 769 }
766 770
767 771
768 void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag, 772 void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag,
769 Handle<String> name, 773 Handle<String> name,
770 int start_position, 774 int start_position,
771 CompilationInfo* info) { 775 CompilationInfo* info) {
772 // Log the code generation. If source information is available include 776 // Log the code generation. If source information is available include
773 // script name and line number. Check explicitly whether logging is 777 // script name and line number. Check explicitly whether logging is
774 // enabled as finding the line number is not free. 778 // enabled as finding the line number is not free.
(...skipping 24 matching lines...) Expand all
799 code->instruction_size())); 803 code->instruction_size()));
800 } 804 }
801 } 805 }
802 806
803 GDBJIT(AddCode(name, 807 GDBJIT(AddCode(name,
804 Handle<Script>(info->script()), 808 Handle<Script>(info->script()),
805 Handle<Code>(info->code()))); 809 Handle<Code>(info->code())));
806 } 810 }
807 811
808 } } // namespace v8::internal 812 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698