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 6606006: [Isolates] Merge 6500:6700 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 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/conversions.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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 } 551 }
552 } 552 }
553 553
554 if (result.is_null()) isolate->ReportPendingMessages(); 554 if (result.is_null()) isolate->ReportPendingMessages();
555 return result; 555 return result;
556 } 556 }
557 557
558 558
559 Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source, 559 Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source,
560 Handle<Context> context, 560 Handle<Context> context,
561 bool is_global) { 561 bool is_global,
562 StrictModeFlag strict_mode) {
562 Isolate* isolate = source->GetIsolate(); 563 Isolate* isolate = source->GetIsolate();
563 int source_length = source->length(); 564 int source_length = source->length();
564 isolate->counters()->total_eval_size()->Increment(source_length); 565 isolate->counters()->total_eval_size()->Increment(source_length);
565 isolate->counters()->total_compile_size()->Increment(source_length); 566 isolate->counters()->total_compile_size()->Increment(source_length);
566 567
567 // The VM is in the COMPILER state until exiting this function. 568 // The VM is in the COMPILER state until exiting this function.
568 VMState state(isolate, COMPILER); 569 VMState state(isolate, COMPILER);
569 570
570 // Do a lookup in the compilation cache; if the entry is not there, invoke 571 // Do a lookup in the compilation cache; if the entry is not there, invoke
571 // the compiler and add the result to the cache. 572 // the compiler and add the result to the cache.
572 Handle<SharedFunctionInfo> result; 573 Handle<SharedFunctionInfo> result;
573 CompilationCache* compilation_cache = isolate->compilation_cache(); 574 CompilationCache* compilation_cache = isolate->compilation_cache();
574 result = compilation_cache->LookupEval(source, context, is_global); 575 result = compilation_cache->LookupEval(source,
576 context,
577 is_global,
578 strict_mode);
575 579
576 if (result.is_null()) { 580 if (result.is_null()) {
577 // Create a script object describing the script to be compiled. 581 // Create a script object describing the script to be compiled.
578 Handle<Script> script = isolate->factory()->NewScript(source); 582 Handle<Script> script = isolate->factory()->NewScript(source);
579 CompilationInfo info(script); 583 CompilationInfo info(script);
580 info.MarkAsEval(); 584 info.MarkAsEval();
581 if (is_global) info.MarkAsGlobal(); 585 if (is_global) info.MarkAsGlobal();
586 if (strict_mode == kStrictMode) info.MarkAsStrict();
582 info.SetCallingContext(context); 587 info.SetCallingContext(context);
583 result = MakeFunctionInfo(&info); 588 result = MakeFunctionInfo(&info);
584 if (!result.is_null()) { 589 if (!result.is_null()) {
585 CompilationCache* compilation_cache = isolate->compilation_cache(); 590 CompilationCache* compilation_cache = isolate->compilation_cache();
591 // If caller is strict mode, the result must be strict as well,
592 // but not the other way around. Consider:
593 // eval("'use strict'; ...");
594 ASSERT(strict_mode == kNonStrictMode || result->strict_mode());
586 compilation_cache->PutEval(source, context, is_global, result); 595 compilation_cache->PutEval(source, context, is_global, result);
587 } 596 }
588 } 597 }
589 598
590 return result; 599 return result;
591 } 600 }
592 601
593 602
594 bool Compiler::CompileLazy(CompilationInfo* info) { 603 bool Compiler::CompileLazy(CompilationInfo* info) {
595 CompilationZoneScope zone_scope(DELETE_ON_EXIT); 604 CompilationZoneScope zone_scope(DELETE_ON_EXIT);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 function_info->set_start_position(lit->start_position()); 781 function_info->set_start_position(lit->start_position());
773 function_info->set_end_position(lit->end_position()); 782 function_info->set_end_position(lit->end_position());
774 function_info->set_is_expression(lit->is_expression()); 783 function_info->set_is_expression(lit->is_expression());
775 function_info->set_is_toplevel(is_toplevel); 784 function_info->set_is_toplevel(is_toplevel);
776 function_info->set_inferred_name(*lit->inferred_name()); 785 function_info->set_inferred_name(*lit->inferred_name());
777 function_info->SetThisPropertyAssignmentsInfo( 786 function_info->SetThisPropertyAssignmentsInfo(
778 lit->has_only_simple_this_property_assignments(), 787 lit->has_only_simple_this_property_assignments(),
779 *lit->this_property_assignments()); 788 *lit->this_property_assignments());
780 function_info->set_try_full_codegen(lit->try_full_codegen()); 789 function_info->set_try_full_codegen(lit->try_full_codegen());
781 function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation()); 790 function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation());
791 function_info->set_strict_mode(lit->strict_mode());
782 } 792 }
783 793
784 794
785 void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag, 795 void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag,
786 Handle<String> name, 796 Handle<String> name,
787 int start_position, 797 int start_position,
788 CompilationInfo* info) { 798 CompilationInfo* info) {
789 // Log the code generation. If source information is available include 799 // Log the code generation. If source information is available include
790 // script name and line number. Check explicitly whether logging is 800 // script name and line number. Check explicitly whether logging is
791 // enabled as finding the line number is not free. 801 // enabled as finding the line number is not free.
(...skipping 24 matching lines...) Expand all
816 code->instruction_size())); 826 code->instruction_size()));
817 } 827 }
818 } 828 }
819 829
820 GDBJIT(AddCode(name, 830 GDBJIT(AddCode(name,
821 Handle<Script>(info->script()), 831 Handle<Script>(info->script()),
822 Handle<Code>(info->code()))); 832 Handle<Code>(info->code())));
823 } 833 }
824 834
825 } } // namespace v8::internal 835 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/conversions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698