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

Side by Side Diff: src/compiler.cc

Issue 10872084: Allocate block-scoped global bindings to global context. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 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/heap.cc » ('j') | src/objects.cc » ('J')
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 flags_(LanguageModeField::encode(CLASSIC_MODE) | 91 flags_(LanguageModeField::encode(CLASSIC_MODE) |
92 IsLazy::encode(true)), 92 IsLazy::encode(true)),
93 function_(NULL), 93 function_(NULL),
94 scope_(NULL), 94 scope_(NULL),
95 global_scope_(NULL), 95 global_scope_(NULL),
96 closure_(closure), 96 closure_(closure),
97 shared_info_(Handle<SharedFunctionInfo>(closure->shared())), 97 shared_info_(Handle<SharedFunctionInfo>(closure->shared())),
98 script_(Handle<Script>(Script::cast(shared_info_->script()))), 98 script_(Handle<Script>(Script::cast(shared_info_->script()))),
99 extension_(NULL), 99 extension_(NULL),
100 pre_parse_data_(NULL), 100 pre_parse_data_(NULL),
101 context_(closure->context()),
101 osr_ast_id_(BailoutId::None()), 102 osr_ast_id_(BailoutId::None()),
102 zone_(zone), 103 zone_(zone),
103 deferred_handles_(NULL) { 104 deferred_handles_(NULL) {
104 Initialize(BASE); 105 Initialize(BASE);
105 } 106 }
106 107
107 108
108 CompilationInfo::~CompilationInfo() { 109 CompilationInfo::~CompilationInfo() {
109 delete deferred_handles_; 110 delete deferred_handles_;
110 } 111 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 // performance of the hydrogen-based compiler. 280 // performance of the hydrogen-based compiler.
280 Timer t(this, &time_taken_to_create_graph_); 281 Timer t(this, &time_taken_to_create_graph_);
281 bool should_recompile = !info()->shared_info()->has_deoptimization_support(); 282 bool should_recompile = !info()->shared_info()->has_deoptimization_support();
282 if (should_recompile || FLAG_hydrogen_stats) { 283 if (should_recompile || FLAG_hydrogen_stats) {
283 HPhase phase(HPhase::kFullCodeGen); 284 HPhase phase(HPhase::kFullCodeGen);
284 CompilationInfoWithZone unoptimized(info()->shared_info()); 285 CompilationInfoWithZone unoptimized(info()->shared_info());
285 // Note that we use the same AST that we will use for generating the 286 // Note that we use the same AST that we will use for generating the
286 // optimized code. 287 // optimized code.
287 unoptimized.SetFunction(info()->function()); 288 unoptimized.SetFunction(info()->function());
288 unoptimized.SetScope(info()->scope()); 289 unoptimized.SetScope(info()->scope());
290 unoptimized.SetContext(info()->context());
289 if (should_recompile) unoptimized.EnableDeoptimizationSupport(); 291 if (should_recompile) unoptimized.EnableDeoptimizationSupport();
290 bool succeeded = FullCodeGenerator::MakeCode(&unoptimized); 292 bool succeeded = FullCodeGenerator::MakeCode(&unoptimized);
291 if (should_recompile) { 293 if (should_recompile) {
292 if (!succeeded) return SetLastStatus(FAILED); 294 if (!succeeded) return SetLastStatus(FAILED);
293 Handle<SharedFunctionInfo> shared = info()->shared_info(); 295 Handle<SharedFunctionInfo> shared = info()->shared_info();
294 shared->EnableDeoptimizationSupport(*unoptimized.code()); 296 shared->EnableDeoptimizationSupport(*unoptimized.code());
295 // The existing unoptimized code was replaced with the new one. 297 // The existing unoptimized code was replaced with the new one.
296 Compiler::RecordFunctionCompilation( 298 Compiler::RecordFunctionCompilation(
297 Logger::LAZY_COMPILE_TAG, &unoptimized, shared); 299 Logger::LAZY_COMPILE_TAG, &unoptimized, shared);
298 } 300 }
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 } 581 }
580 582
581 script->set_data(script_data.is_null() ? HEAP->undefined_value() 583 script->set_data(script_data.is_null() ? HEAP->undefined_value()
582 : *script_data); 584 : *script_data);
583 585
584 // Compile the function and add it to the cache. 586 // Compile the function and add it to the cache.
585 CompilationInfoWithZone info(script); 587 CompilationInfoWithZone info(script);
586 info.MarkAsGlobal(); 588 info.MarkAsGlobal();
587 info.SetExtension(extension); 589 info.SetExtension(extension);
588 info.SetPreParseData(pre_data); 590 info.SetPreParseData(pre_data);
591 info.SetContext(context);
589 if (FLAG_use_strict) { 592 if (FLAG_use_strict) {
590 info.SetLanguageMode(FLAG_harmony_scoping ? EXTENDED_MODE : STRICT_MODE); 593 info.SetLanguageMode(FLAG_harmony_scoping ? EXTENDED_MODE : STRICT_MODE);
591 } 594 }
592 result = MakeFunctionInfo(&info); 595 result = MakeFunctionInfo(&info);
593 if (extension == NULL && !result.is_null() && !result->dont_cache()) { 596 if (extension == NULL && !result.is_null() && !result->dont_cache()) {
594 compilation_cache->PutScript(source, context, result); 597 compilation_cache->PutScript(source, context, result);
595 } 598 }
596 } else { 599 } else {
597 if (result->ic_age() != HEAP->global_ic_age()) { 600 if (result->ic_age() != HEAP->global_ic_age()) {
598 result->ResetForNewContext(HEAP->global_ic_age()); 601 result->ResetForNewContext(HEAP->global_ic_age());
(...skipping 28 matching lines...) Expand all
627 language_mode, 630 language_mode,
628 scope_position); 631 scope_position);
629 632
630 if (result.is_null()) { 633 if (result.is_null()) {
631 // Create a script object describing the script to be compiled. 634 // Create a script object describing the script to be compiled.
632 Handle<Script> script = isolate->factory()->NewScript(source); 635 Handle<Script> script = isolate->factory()->NewScript(source);
633 CompilationInfoWithZone info(script); 636 CompilationInfoWithZone info(script);
634 info.MarkAsEval(); 637 info.MarkAsEval();
635 if (is_global) info.MarkAsGlobal(); 638 if (is_global) info.MarkAsGlobal();
636 info.SetLanguageMode(language_mode); 639 info.SetLanguageMode(language_mode);
637 info.SetCallingContext(context); 640 info.SetContext(context);
638 result = MakeFunctionInfo(&info); 641 result = MakeFunctionInfo(&info);
639 if (!result.is_null()) { 642 if (!result.is_null()) {
640 // Explicitly disable optimization for eval code. We're not yet prepared 643 // Explicitly disable optimization for eval code. We're not yet prepared
641 // to handle eval-code in the optimizing compiler. 644 // to handle eval-code in the optimizing compiler.
642 result->DisableOptimization(); 645 result->DisableOptimization();
643 646
644 // If caller is strict mode, the result must be in strict mode or 647 // If caller is strict mode, the result must be in strict mode or
645 // extended mode as well, but not the other way around. Consider: 648 // extended mode as well, but not the other way around. Consider:
646 // eval("'use strict'; ..."); 649 // eval("'use strict'; ...");
647 ASSERT(language_mode != STRICT_MODE || !result->is_classic_mode()); 650 ASSERT(language_mode != STRICT_MODE || !result->is_classic_mode());
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 } 1032 }
1030 } 1033 }
1031 1034
1032 GDBJIT(AddCode(Handle<String>(shared->DebugName()), 1035 GDBJIT(AddCode(Handle<String>(shared->DebugName()),
1033 Handle<Script>(info->script()), 1036 Handle<Script>(info->script()),
1034 Handle<Code>(info->code()), 1037 Handle<Code>(info->code()),
1035 info)); 1038 info));
1036 } 1039 }
1037 1040
1038 } } // namespace v8::internal 1041 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/heap.cc » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698