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

Side by Side Diff: src/compiler.h

Issue 366153002: Add script streaming API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: special chars fix Created 6 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_COMPILER_H_ 5 #ifndef V8_COMPILER_H_
6 #define V8_COMPILER_H_ 6 #define V8_COMPILER_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/zone.h" 10 #include "src/zone.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 bool is_eval() const { return IsEval::decode(flags_); } 75 bool is_eval() const { return IsEval::decode(flags_); }
76 bool is_global() const { return IsGlobal::decode(flags_); } 76 bool is_global() const { return IsGlobal::decode(flags_); }
77 StrictMode strict_mode() const { return StrictModeField::decode(flags_); } 77 StrictMode strict_mode() const { return StrictModeField::decode(flags_); }
78 FunctionLiteral* function() const { return function_; } 78 FunctionLiteral* function() const { return function_; }
79 Scope* scope() const { return scope_; } 79 Scope* scope() const { return scope_; }
80 Scope* global_scope() const { return global_scope_; } 80 Scope* global_scope() const { return global_scope_; }
81 Handle<Code> code() const { return code_; } 81 Handle<Code> code() const { return code_; }
82 Handle<JSFunction> closure() const { return closure_; } 82 Handle<JSFunction> closure() const { return closure_; }
83 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } 83 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
84 Handle<Script> script() const { return script_; } 84 Handle<Script> script() const { return script_; }
85 void set_script(Handle<Script> script) { script_ = script; }
85 HydrogenCodeStub* code_stub() const {return code_stub_; } 86 HydrogenCodeStub* code_stub() const {return code_stub_; }
86 v8::Extension* extension() const { return extension_; } 87 v8::Extension* extension() const { return extension_; }
87 ScriptData** cached_data() const { return cached_data_; } 88 ScriptData** cached_data() const { return cached_data_; }
88 ScriptCompiler::CompileOptions compile_options() const { 89 ScriptCompiler::CompileOptions compile_options() const {
89 return compile_options_; 90 return compile_options_;
90 } 91 }
92 ExternalSourceStream* source_stream() const { return source_stream_; }
91 Handle<Context> context() const { return context_; } 93 Handle<Context> context() const { return context_; }
92 BailoutId osr_ast_id() const { return osr_ast_id_; } 94 BailoutId osr_ast_id() const { return osr_ast_id_; }
93 Handle<Code> unoptimized_code() const { return unoptimized_code_; } 95 Handle<Code> unoptimized_code() const { return unoptimized_code_; }
94 int opt_count() const { return opt_count_; } 96 int opt_count() const { return opt_count_; }
95 int num_parameters() const; 97 int num_parameters() const;
96 int num_heap_slots() const; 98 int num_heap_slots() const;
97 Code::Flags flags() const; 99 Code::Flags flags() const;
98 100
99 void MarkAsEval() { 101 void MarkAsEval() {
100 DCHECK(!is_lazy()); 102 DCHECK(!is_lazy());
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 } 368 }
367 369
368 protected: 370 protected:
369 CompilationInfo(Handle<Script> script, 371 CompilationInfo(Handle<Script> script,
370 Zone* zone); 372 Zone* zone);
371 CompilationInfo(Handle<SharedFunctionInfo> shared_info, 373 CompilationInfo(Handle<SharedFunctionInfo> shared_info,
372 Zone* zone); 374 Zone* zone);
373 CompilationInfo(HydrogenCodeStub* stub, 375 CompilationInfo(HydrogenCodeStub* stub,
374 Isolate* isolate, 376 Isolate* isolate,
375 Zone* zone); 377 Zone* zone);
378 CompilationInfo(ExternalSourceStream* source_stream, Isolate* isolate,
379 Zone* zone);
380
376 381
377 private: 382 private:
378 Isolate* isolate_; 383 Isolate* isolate_;
379 384
380 // Compilation mode. 385 // Compilation mode.
381 // BASE is generated by the full codegen, optionally prepared for bailouts. 386 // BASE is generated by the full codegen, optionally prepared for bailouts.
382 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. 387 // OPTIMIZE is optimized code generated by the Hydrogen-based backend.
383 // NONOPT is generated by the full codegen and is not prepared for 388 // NONOPT is generated by the full codegen and is not prepared for
384 // recompilation/bailouts. These functions are never recompiled. 389 // recompilation/bailouts. These functions are never recompiled.
385 enum Mode { 390 enum Mode {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 Scope* global_scope_; 448 Scope* global_scope_;
444 // For compiled stubs, the stub object 449 // For compiled stubs, the stub object
445 HydrogenCodeStub* code_stub_; 450 HydrogenCodeStub* code_stub_;
446 // The compiled code. 451 // The compiled code.
447 Handle<Code> code_; 452 Handle<Code> code_;
448 453
449 // Possible initial inputs to the compilation process. 454 // Possible initial inputs to the compilation process.
450 Handle<JSFunction> closure_; 455 Handle<JSFunction> closure_;
451 Handle<SharedFunctionInfo> shared_info_; 456 Handle<SharedFunctionInfo> shared_info_;
452 Handle<Script> script_; 457 Handle<Script> script_;
458 ExternalSourceStream* source_stream_;
453 459
454 // Fields possibly needed for eager compilation, NULL by default. 460 // Fields possibly needed for eager compilation, NULL by default.
455 v8::Extension* extension_; 461 v8::Extension* extension_;
456 ScriptData** cached_data_; 462 ScriptData** cached_data_;
457 ScriptCompiler::CompileOptions compile_options_; 463 ScriptCompiler::CompileOptions compile_options_;
458 464
459 // The context of the caller for eval code, and the global context for a 465 // The context of the caller for eval code, and the global context for a
460 // global script. Will be a null handle otherwise. 466 // global script. Will be a null handle otherwise.
461 Handle<Context> context_; 467 Handle<Context> context_;
462 468
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 public: 528 public:
523 explicit CompilationInfoWithZone(Handle<Script> script) 529 explicit CompilationInfoWithZone(Handle<Script> script)
524 : CompilationInfo(script, &zone_), 530 : CompilationInfo(script, &zone_),
525 zone_(script->GetIsolate()) {} 531 zone_(script->GetIsolate()) {}
526 explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info) 532 explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info)
527 : CompilationInfo(shared_info, &zone_), 533 : CompilationInfo(shared_info, &zone_),
528 zone_(shared_info->GetIsolate()) {} 534 zone_(shared_info->GetIsolate()) {}
529 explicit CompilationInfoWithZone(Handle<JSFunction> closure) 535 explicit CompilationInfoWithZone(Handle<JSFunction> closure)
530 : CompilationInfo(closure, &zone_), 536 : CompilationInfo(closure, &zone_),
531 zone_(closure->GetIsolate()) {} 537 zone_(closure->GetIsolate()) {}
538 explicit CompilationInfoWithZone(ExternalSourceStream* stream,
539 Isolate* isolate)
540 : CompilationInfo(stream, isolate, &zone_), zone_(isolate) {}
532 CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate) 541 CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate)
533 : CompilationInfo(stub, isolate, &zone_), 542 : CompilationInfo(stub, isolate, &zone_),
534 zone_(isolate) {} 543 zone_(isolate) {}
535 544
536 // Virtual destructor because a CompilationInfoWithZone has to exit the 545 // Virtual destructor because a CompilationInfoWithZone has to exit the
537 // zone scope and get rid of dependent maps even when the destructor is 546 // zone scope and get rid of dependent maps even when the destructor is
538 // called when cast as a CompilationInfo. 547 // called when cast as a CompilationInfo.
539 virtual ~CompilationInfoWithZone() { 548 virtual ~CompilationInfoWithZone() {
540 RollbackDependencies(); 549 RollbackDependencies();
541 } 550 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 int scope_position); 693 int scope_position);
685 694
686 // Compile a String source within a context. 695 // Compile a String source within a context.
687 static Handle<SharedFunctionInfo> CompileScript( 696 static Handle<SharedFunctionInfo> CompileScript(
688 Handle<String> source, Handle<Object> script_name, int line_offset, 697 Handle<String> source, Handle<Object> script_name, int line_offset,
689 int column_offset, bool is_shared_cross_origin, Handle<Context> context, 698 int column_offset, bool is_shared_cross_origin, Handle<Context> context,
690 v8::Extension* extension, ScriptData** cached_data, 699 v8::Extension* extension, ScriptData** cached_data,
691 ScriptCompiler::CompileOptions compile_options, 700 ScriptCompiler::CompileOptions compile_options,
692 NativesFlag is_natives_code); 701 NativesFlag is_natives_code);
693 702
703 static Handle<SharedFunctionInfo> CompileStreamedScript(CompilationInfo* info,
704 int source_length);
705
694 // Create a shared function info object (the code may be lazily compiled). 706 // Create a shared function info object (the code may be lazily compiled).
695 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, 707 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node,
696 Handle<Script> script, 708 Handle<Script> script,
697 CompilationInfo* outer); 709 CompilationInfo* outer);
698 710
699 enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT }; 711 enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT };
700 712
701 // Generate and return optimized code or start a concurrent optimization job. 713 // Generate and return optimized code or start a concurrent optimization job.
702 // In the latter case, return the InOptimizationQueue builtin. On failure, 714 // In the latter case, return the InOptimizationQueue builtin. On failure,
703 // return the empty handle. 715 // return the empty handle.
704 MUST_USE_RESULT static MaybeHandle<Code> GetOptimizedCode( 716 MUST_USE_RESULT static MaybeHandle<Code> GetOptimizedCode(
705 Handle<JSFunction> function, 717 Handle<JSFunction> function,
706 Handle<Code> current_code, 718 Handle<Code> current_code,
707 ConcurrencyMode mode, 719 ConcurrencyMode mode,
708 BailoutId osr_ast_id = BailoutId::None()); 720 BailoutId osr_ast_id = BailoutId::None());
709 721
710 // Generate and return code from previously queued optimization job. 722 // Generate and return code from previously queued optimization job.
711 // On failure, return the empty handle. 723 // On failure, return the empty handle.
712 static Handle<Code> GetConcurrentlyOptimizedCode(OptimizedCompileJob* job); 724 static Handle<Code> GetConcurrentlyOptimizedCode(OptimizedCompileJob* job);
713 725
714 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, 726 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
715 CompilationInfo* info, 727 CompilationInfo* info,
716 Handle<SharedFunctionInfo> shared); 728 Handle<SharedFunctionInfo> shared);
729
730 static bool DebuggerWantsEagerCompilation(
731 CompilationInfo* info, bool allow_lazy_without_ctx = false);
717 }; 732 };
718 733
719 734
720 class CompilationPhase BASE_EMBEDDED { 735 class CompilationPhase BASE_EMBEDDED {
721 public: 736 public:
722 CompilationPhase(const char* name, CompilationInfo* info); 737 CompilationPhase(const char* name, CompilationInfo* info);
723 ~CompilationPhase(); 738 ~CompilationPhase();
724 739
725 protected: 740 protected:
726 bool ShouldProduceTraceOutput() const; 741 bool ShouldProduceTraceOutput() const;
727 742
728 const char* name() const { return name_; } 743 const char* name() const { return name_; }
729 CompilationInfo* info() const { return info_; } 744 CompilationInfo* info() const { return info_; }
730 Isolate* isolate() const { return info()->isolate(); } 745 Isolate* isolate() const { return info()->isolate(); }
731 Zone* zone() { return &zone_; } 746 Zone* zone() { return &zone_; }
732 747
733 private: 748 private:
734 const char* name_; 749 const char* name_;
735 CompilationInfo* info_; 750 CompilationInfo* info_;
736 Zone zone_; 751 Zone zone_;
737 unsigned info_zone_start_allocation_size_; 752 unsigned info_zone_start_allocation_size_;
738 base::ElapsedTimer timer_; 753 base::ElapsedTimer timer_;
739 754
740 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); 755 DISALLOW_COPY_AND_ASSIGN(CompilationPhase);
741 }; 756 };
742 757
743 } } // namespace v8::internal 758 } } // namespace v8::internal
744 759
745 #endif // V8_COMPILER_H_ 760 #endif // V8_COMPILER_H_
OLDNEW
« include/v8.h ('K') | « src/background-parser-thread.cc ('k') | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698