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.h

Issue 366153002: Add script streaming API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased again? Created 6 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/background-parsing-task.cc ('k') | src/compiler.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 // 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 StrictMode strict_mode() const { 100 StrictMode strict_mode() const {
101 return GetFlag(kStrictMode) ? STRICT : SLOPPY; 101 return GetFlag(kStrictMode) ? STRICT : SLOPPY;
102 } 102 }
103 FunctionLiteral* function() const { return function_; } 103 FunctionLiteral* function() const { return function_; }
104 Scope* scope() const { return scope_; } 104 Scope* scope() const { return scope_; }
105 Scope* global_scope() const { return global_scope_; } 105 Scope* global_scope() const { return global_scope_; }
106 Handle<Code> code() const { return code_; } 106 Handle<Code> code() const { return code_; }
107 Handle<JSFunction> closure() const { return closure_; } 107 Handle<JSFunction> closure() const { return closure_; }
108 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } 108 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
109 Handle<Script> script() const { return script_; } 109 Handle<Script> script() const { return script_; }
110 void set_script(Handle<Script> script) { script_ = script; }
110 HydrogenCodeStub* code_stub() const {return code_stub_; } 111 HydrogenCodeStub* code_stub() const {return code_stub_; }
111 v8::Extension* extension() const { return extension_; } 112 v8::Extension* extension() const { return extension_; }
112 ScriptData** cached_data() const { return cached_data_; } 113 ScriptData** cached_data() const { return cached_data_; }
113 ScriptCompiler::CompileOptions compile_options() const { 114 ScriptCompiler::CompileOptions compile_options() const {
114 return compile_options_; 115 return compile_options_;
115 } 116 }
117 ScriptCompiler::ExternalSourceStream* source_stream() const {
118 return source_stream_;
119 }
120 ScriptCompiler::StreamedSource::Encoding source_stream_encoding() const {
121 return source_stream_encoding_;
122 }
116 Handle<Context> context() const { return context_; } 123 Handle<Context> context() const { return context_; }
117 BailoutId osr_ast_id() const { return osr_ast_id_; } 124 BailoutId osr_ast_id() const { return osr_ast_id_; }
118 Handle<Code> unoptimized_code() const { return unoptimized_code_; } 125 Handle<Code> unoptimized_code() const { return unoptimized_code_; }
119 int opt_count() const { return opt_count_; } 126 int opt_count() const { return opt_count_; }
120 int num_parameters() const; 127 int num_parameters() const;
121 int num_heap_slots() const; 128 int num_heap_slots() const;
122 Code::Flags flags() const; 129 Code::Flags flags() const;
123 130
124 void MarkAsEval() { 131 void MarkAsEval() {
125 DCHECK(!is_lazy()); 132 DCHECK(!is_lazy());
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 AstNode::IdGen* ast_node_id_gen() { return &ast_node_id_gen_; } 378 AstNode::IdGen* ast_node_id_gen() { return &ast_node_id_gen_; }
372 379
373 protected: 380 protected:
374 CompilationInfo(Handle<Script> script, 381 CompilationInfo(Handle<Script> script,
375 Zone* zone); 382 Zone* zone);
376 CompilationInfo(Handle<SharedFunctionInfo> shared_info, 383 CompilationInfo(Handle<SharedFunctionInfo> shared_info,
377 Zone* zone); 384 Zone* zone);
378 CompilationInfo(HydrogenCodeStub* stub, 385 CompilationInfo(HydrogenCodeStub* stub,
379 Isolate* isolate, 386 Isolate* isolate,
380 Zone* zone); 387 Zone* zone);
388 CompilationInfo(ScriptCompiler::ExternalSourceStream* source_stream,
389 ScriptCompiler::StreamedSource::Encoding encoding,
390 Isolate* isolate, Zone* zone);
391
381 392
382 private: 393 private:
383 Isolate* isolate_; 394 Isolate* isolate_;
384 395
385 // Compilation mode. 396 // Compilation mode.
386 // BASE is generated by the full codegen, optionally prepared for bailouts. 397 // BASE is generated by the full codegen, optionally prepared for bailouts.
387 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. 398 // OPTIMIZE is optimized code generated by the Hydrogen-based backend.
388 // NONOPT is generated by the full codegen and is not prepared for 399 // NONOPT is generated by the full codegen and is not prepared for
389 // recompilation/bailouts. These functions are never recompiled. 400 // recompilation/bailouts. These functions are never recompiled.
390 enum Mode { 401 enum Mode {
(...skipping 29 matching lines...) Expand all
420 Scope* global_scope_; 431 Scope* global_scope_;
421 // For compiled stubs, the stub object 432 // For compiled stubs, the stub object
422 HydrogenCodeStub* code_stub_; 433 HydrogenCodeStub* code_stub_;
423 // The compiled code. 434 // The compiled code.
424 Handle<Code> code_; 435 Handle<Code> code_;
425 436
426 // Possible initial inputs to the compilation process. 437 // Possible initial inputs to the compilation process.
427 Handle<JSFunction> closure_; 438 Handle<JSFunction> closure_;
428 Handle<SharedFunctionInfo> shared_info_; 439 Handle<SharedFunctionInfo> shared_info_;
429 Handle<Script> script_; 440 Handle<Script> script_;
441 ScriptCompiler::ExternalSourceStream* source_stream_; // Not owned.
442 ScriptCompiler::StreamedSource::Encoding source_stream_encoding_;
430 443
431 // Fields possibly needed for eager compilation, NULL by default. 444 // Fields possibly needed for eager compilation, NULL by default.
432 v8::Extension* extension_; 445 v8::Extension* extension_;
433 ScriptData** cached_data_; 446 ScriptData** cached_data_;
434 ScriptCompiler::CompileOptions compile_options_; 447 ScriptCompiler::CompileOptions compile_options_;
435 448
436 // The context of the caller for eval code, and the global context for a 449 // The context of the caller for eval code, and the global context for a
437 // global script. Will be a null handle otherwise. 450 // global script. Will be a null handle otherwise.
438 Handle<Context> context_; 451 Handle<Context> context_;
439 452
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 zone_(script->GetIsolate()) {} 514 zone_(script->GetIsolate()) {}
502 explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info) 515 explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info)
503 : CompilationInfo(shared_info, &zone_), 516 : CompilationInfo(shared_info, &zone_),
504 zone_(shared_info->GetIsolate()) {} 517 zone_(shared_info->GetIsolate()) {}
505 explicit CompilationInfoWithZone(Handle<JSFunction> closure) 518 explicit CompilationInfoWithZone(Handle<JSFunction> closure)
506 : CompilationInfo(closure, &zone_), 519 : CompilationInfo(closure, &zone_),
507 zone_(closure->GetIsolate()) {} 520 zone_(closure->GetIsolate()) {}
508 CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate) 521 CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate)
509 : CompilationInfo(stub, isolate, &zone_), 522 : CompilationInfo(stub, isolate, &zone_),
510 zone_(isolate) {} 523 zone_(isolate) {}
524 CompilationInfoWithZone(ScriptCompiler::ExternalSourceStream* stream,
525 ScriptCompiler::StreamedSource::Encoding encoding,
526 Isolate* isolate)
527 : CompilationInfo(stream, encoding, isolate, &zone_), zone_(isolate) {}
511 528
512 // Virtual destructor because a CompilationInfoWithZone has to exit the 529 // Virtual destructor because a CompilationInfoWithZone has to exit the
513 // zone scope and get rid of dependent maps even when the destructor is 530 // zone scope and get rid of dependent maps even when the destructor is
514 // called when cast as a CompilationInfo. 531 // called when cast as a CompilationInfo.
515 virtual ~CompilationInfoWithZone() { 532 virtual ~CompilationInfoWithZone() {
516 RollbackDependencies(); 533 RollbackDependencies();
517 } 534 }
518 535
519 private: 536 private:
520 Zone zone_; 537 Zone zone_;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 int scope_position); 677 int scope_position);
661 678
662 // Compile a String source within a context. 679 // Compile a String source within a context.
663 static Handle<SharedFunctionInfo> CompileScript( 680 static Handle<SharedFunctionInfo> CompileScript(
664 Handle<String> source, Handle<Object> script_name, int line_offset, 681 Handle<String> source, Handle<Object> script_name, int line_offset,
665 int column_offset, bool is_shared_cross_origin, Handle<Context> context, 682 int column_offset, bool is_shared_cross_origin, Handle<Context> context,
666 v8::Extension* extension, ScriptData** cached_data, 683 v8::Extension* extension, ScriptData** cached_data,
667 ScriptCompiler::CompileOptions compile_options, 684 ScriptCompiler::CompileOptions compile_options,
668 NativesFlag is_natives_code); 685 NativesFlag is_natives_code);
669 686
687 static Handle<SharedFunctionInfo> CompileStreamedScript(CompilationInfo* info,
688 int source_length);
689
670 // Create a shared function info object (the code may be lazily compiled). 690 // Create a shared function info object (the code may be lazily compiled).
671 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, 691 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node,
672 Handle<Script> script, 692 Handle<Script> script,
673 CompilationInfo* outer); 693 CompilationInfo* outer);
674 694
675 enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT }; 695 enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT };
676 696
677 // Generate and return optimized code or start a concurrent optimization job. 697 // Generate and return optimized code or start a concurrent optimization job.
678 // In the latter case, return the InOptimizationQueue builtin. On failure, 698 // In the latter case, return the InOptimizationQueue builtin. On failure,
679 // return the empty handle. 699 // return the empty handle.
680 MUST_USE_RESULT static MaybeHandle<Code> GetOptimizedCode( 700 MUST_USE_RESULT static MaybeHandle<Code> GetOptimizedCode(
681 Handle<JSFunction> function, 701 Handle<JSFunction> function,
682 Handle<Code> current_code, 702 Handle<Code> current_code,
683 ConcurrencyMode mode, 703 ConcurrencyMode mode,
684 BailoutId osr_ast_id = BailoutId::None()); 704 BailoutId osr_ast_id = BailoutId::None());
685 705
686 // Generate and return code from previously queued optimization job. 706 // Generate and return code from previously queued optimization job.
687 // On failure, return the empty handle. 707 // On failure, return the empty handle.
688 static Handle<Code> GetConcurrentlyOptimizedCode(OptimizedCompileJob* job); 708 static Handle<Code> GetConcurrentlyOptimizedCode(OptimizedCompileJob* job);
689 709
690 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, 710 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
691 CompilationInfo* info, 711 CompilationInfo* info,
692 Handle<SharedFunctionInfo> shared); 712 Handle<SharedFunctionInfo> shared);
713
714 static bool DebuggerWantsEagerCompilation(
715 CompilationInfo* info, bool allow_lazy_without_ctx = false);
693 }; 716 };
694 717
695 718
696 class CompilationPhase BASE_EMBEDDED { 719 class CompilationPhase BASE_EMBEDDED {
697 public: 720 public:
698 CompilationPhase(const char* name, CompilationInfo* info); 721 CompilationPhase(const char* name, CompilationInfo* info);
699 ~CompilationPhase(); 722 ~CompilationPhase();
700 723
701 protected: 724 protected:
702 bool ShouldProduceTraceOutput() const; 725 bool ShouldProduceTraceOutput() const;
703 726
704 const char* name() const { return name_; } 727 const char* name() const { return name_; }
705 CompilationInfo* info() const { return info_; } 728 CompilationInfo* info() const { return info_; }
706 Isolate* isolate() const { return info()->isolate(); } 729 Isolate* isolate() const { return info()->isolate(); }
707 Zone* zone() { return &zone_; } 730 Zone* zone() { return &zone_; }
708 731
709 private: 732 private:
710 const char* name_; 733 const char* name_;
711 CompilationInfo* info_; 734 CompilationInfo* info_;
712 Zone zone_; 735 Zone zone_;
713 unsigned info_zone_start_allocation_size_; 736 unsigned info_zone_start_allocation_size_;
714 base::ElapsedTimer timer_; 737 base::ElapsedTimer timer_;
715 738
716 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); 739 DISALLOW_COPY_AND_ASSIGN(CompilationPhase);
717 }; 740 };
718 741
719 } } // namespace v8::internal 742 } } // namespace v8::internal
720 743
721 #endif // V8_COMPILER_H_ 744 #endif // V8_COMPILER_H_
OLDNEW
« no previous file with comments | « src/background-parsing-task.cc ('k') | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698