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

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: added tests + fixed compilation flags (!) 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
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 }
116 Handle<Context> context() const { return context_; } 120 Handle<Context> context() const { return context_; }
117 BailoutId osr_ast_id() const { return osr_ast_id_; } 121 BailoutId osr_ast_id() const { return osr_ast_id_; }
118 Handle<Code> unoptimized_code() const { return unoptimized_code_; } 122 Handle<Code> unoptimized_code() const { return unoptimized_code_; }
119 int opt_count() const { return opt_count_; } 123 int opt_count() const { return opt_count_; }
120 int num_parameters() const; 124 int num_parameters() const;
121 int num_heap_slots() const; 125 int num_heap_slots() const;
122 Code::Flags flags() const; 126 Code::Flags flags() const;
123 127
124 void MarkAsEval() { 128 void MarkAsEval() {
125 DCHECK(!is_lazy()); 129 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_; } 375 AstNode::IdGen* ast_node_id_gen() { return &ast_node_id_gen_; }
372 376
373 protected: 377 protected:
374 CompilationInfo(Handle<Script> script, 378 CompilationInfo(Handle<Script> script,
375 Zone* zone); 379 Zone* zone);
376 CompilationInfo(Handle<SharedFunctionInfo> shared_info, 380 CompilationInfo(Handle<SharedFunctionInfo> shared_info,
377 Zone* zone); 381 Zone* zone);
378 CompilationInfo(HydrogenCodeStub* stub, 382 CompilationInfo(HydrogenCodeStub* stub,
379 Isolate* isolate, 383 Isolate* isolate,
380 Zone* zone); 384 Zone* zone);
385 CompilationInfo(ScriptCompiler::ExternalSourceStream* source_stream,
386 Isolate* isolate, Zone* zone);
387
381 388
382 private: 389 private:
383 Isolate* isolate_; 390 Isolate* isolate_;
384 391
385 // Compilation mode. 392 // Compilation mode.
386 // BASE is generated by the full codegen, optionally prepared for bailouts. 393 // BASE is generated by the full codegen, optionally prepared for bailouts.
387 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. 394 // OPTIMIZE is optimized code generated by the Hydrogen-based backend.
388 // NONOPT is generated by the full codegen and is not prepared for 395 // NONOPT is generated by the full codegen and is not prepared for
389 // recompilation/bailouts. These functions are never recompiled. 396 // recompilation/bailouts. These functions are never recompiled.
390 enum Mode { 397 enum Mode {
(...skipping 29 matching lines...) Expand all
420 Scope* global_scope_; 427 Scope* global_scope_;
421 // For compiled stubs, the stub object 428 // For compiled stubs, the stub object
422 HydrogenCodeStub* code_stub_; 429 HydrogenCodeStub* code_stub_;
423 // The compiled code. 430 // The compiled code.
424 Handle<Code> code_; 431 Handle<Code> code_;
425 432
426 // Possible initial inputs to the compilation process. 433 // Possible initial inputs to the compilation process.
427 Handle<JSFunction> closure_; 434 Handle<JSFunction> closure_;
428 Handle<SharedFunctionInfo> shared_info_; 435 Handle<SharedFunctionInfo> shared_info_;
429 Handle<Script> script_; 436 Handle<Script> script_;
437 ScriptCompiler::ExternalSourceStream* source_stream_;
430 438
431 // Fields possibly needed for eager compilation, NULL by default. 439 // Fields possibly needed for eager compilation, NULL by default.
432 v8::Extension* extension_; 440 v8::Extension* extension_;
433 ScriptData** cached_data_; 441 ScriptData** cached_data_;
434 ScriptCompiler::CompileOptions compile_options_; 442 ScriptCompiler::CompileOptions compile_options_;
435 443
436 // The context of the caller for eval code, and the global context for a 444 // The context of the caller for eval code, and the global context for a
437 // global script. Will be a null handle otherwise. 445 // global script. Will be a null handle otherwise.
438 Handle<Context> context_; 446 Handle<Context> context_;
439 447
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 public: 506 public:
499 explicit CompilationInfoWithZone(Handle<Script> script) 507 explicit CompilationInfoWithZone(Handle<Script> script)
500 : CompilationInfo(script, &zone_), 508 : CompilationInfo(script, &zone_),
501 zone_(script->GetIsolate()) {} 509 zone_(script->GetIsolate()) {}
502 explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info) 510 explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info)
503 : CompilationInfo(shared_info, &zone_), 511 : CompilationInfo(shared_info, &zone_),
504 zone_(shared_info->GetIsolate()) {} 512 zone_(shared_info->GetIsolate()) {}
505 explicit CompilationInfoWithZone(Handle<JSFunction> closure) 513 explicit CompilationInfoWithZone(Handle<JSFunction> closure)
506 : CompilationInfo(closure, &zone_), 514 : CompilationInfo(closure, &zone_),
507 zone_(closure->GetIsolate()) {} 515 zone_(closure->GetIsolate()) {}
516 explicit CompilationInfoWithZone(ScriptCompiler::ExternalSourceStream* stream,
517 Isolate* isolate)
518 : CompilationInfo(stream, isolate, &zone_), zone_(isolate) {}
508 CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate) 519 CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate)
509 : CompilationInfo(stub, isolate, &zone_), 520 : CompilationInfo(stub, isolate, &zone_),
510 zone_(isolate) {} 521 zone_(isolate) {}
511 522
512 // Virtual destructor because a CompilationInfoWithZone has to exit the 523 // Virtual destructor because a CompilationInfoWithZone has to exit the
513 // zone scope and get rid of dependent maps even when the destructor is 524 // zone scope and get rid of dependent maps even when the destructor is
514 // called when cast as a CompilationInfo. 525 // called when cast as a CompilationInfo.
515 virtual ~CompilationInfoWithZone() { 526 virtual ~CompilationInfoWithZone() {
516 RollbackDependencies(); 527 RollbackDependencies();
517 } 528 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 int scope_position); 671 int scope_position);
661 672
662 // Compile a String source within a context. 673 // Compile a String source within a context.
663 static Handle<SharedFunctionInfo> CompileScript( 674 static Handle<SharedFunctionInfo> CompileScript(
664 Handle<String> source, Handle<Object> script_name, int line_offset, 675 Handle<String> source, Handle<Object> script_name, int line_offset,
665 int column_offset, bool is_shared_cross_origin, Handle<Context> context, 676 int column_offset, bool is_shared_cross_origin, Handle<Context> context,
666 v8::Extension* extension, ScriptData** cached_data, 677 v8::Extension* extension, ScriptData** cached_data,
667 ScriptCompiler::CompileOptions compile_options, 678 ScriptCompiler::CompileOptions compile_options,
668 NativesFlag is_natives_code); 679 NativesFlag is_natives_code);
669 680
681 static Handle<SharedFunctionInfo> CompileStreamedScript(CompilationInfo* info,
682 int source_length);
683
670 // Create a shared function info object (the code may be lazily compiled). 684 // Create a shared function info object (the code may be lazily compiled).
671 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, 685 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node,
672 Handle<Script> script, 686 Handle<Script> script,
673 CompilationInfo* outer); 687 CompilationInfo* outer);
674 688
675 enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT }; 689 enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT };
676 690
677 // Generate and return optimized code or start a concurrent optimization job. 691 // Generate and return optimized code or start a concurrent optimization job.
678 // In the latter case, return the InOptimizationQueue builtin. On failure, 692 // In the latter case, return the InOptimizationQueue builtin. On failure,
679 // return the empty handle. 693 // return the empty handle.
680 MUST_USE_RESULT static MaybeHandle<Code> GetOptimizedCode( 694 MUST_USE_RESULT static MaybeHandle<Code> GetOptimizedCode(
681 Handle<JSFunction> function, 695 Handle<JSFunction> function,
682 Handle<Code> current_code, 696 Handle<Code> current_code,
683 ConcurrencyMode mode, 697 ConcurrencyMode mode,
684 BailoutId osr_ast_id = BailoutId::None()); 698 BailoutId osr_ast_id = BailoutId::None());
685 699
686 // Generate and return code from previously queued optimization job. 700 // Generate and return code from previously queued optimization job.
687 // On failure, return the empty handle. 701 // On failure, return the empty handle.
688 static Handle<Code> GetConcurrentlyOptimizedCode(OptimizedCompileJob* job); 702 static Handle<Code> GetConcurrentlyOptimizedCode(OptimizedCompileJob* job);
689 703
690 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, 704 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
691 CompilationInfo* info, 705 CompilationInfo* info,
692 Handle<SharedFunctionInfo> shared); 706 Handle<SharedFunctionInfo> shared);
707
708 static bool DebuggerWantsEagerCompilation(
709 CompilationInfo* info, bool allow_lazy_without_ctx = false);
693 }; 710 };
694 711
695 712
696 class CompilationPhase BASE_EMBEDDED { 713 class CompilationPhase BASE_EMBEDDED {
697 public: 714 public:
698 CompilationPhase(const char* name, CompilationInfo* info); 715 CompilationPhase(const char* name, CompilationInfo* info);
699 ~CompilationPhase(); 716 ~CompilationPhase();
700 717
701 protected: 718 protected:
702 bool ShouldProduceTraceOutput() const; 719 bool ShouldProduceTraceOutput() const;
703 720
704 const char* name() const { return name_; } 721 const char* name() const { return name_; }
705 CompilationInfo* info() const { return info_; } 722 CompilationInfo* info() const { return info_; }
706 Isolate* isolate() const { return info()->isolate(); } 723 Isolate* isolate() const { return info()->isolate(); }
707 Zone* zone() { return &zone_; } 724 Zone* zone() { return &zone_; }
708 725
709 private: 726 private:
710 const char* name_; 727 const char* name_;
711 CompilationInfo* info_; 728 CompilationInfo* info_;
712 Zone zone_; 729 Zone zone_;
713 unsigned info_zone_start_allocation_size_; 730 unsigned info_zone_start_allocation_size_;
714 base::ElapsedTimer timer_; 731 base::ElapsedTimer timer_;
715 732
716 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); 733 DISALLOW_COPY_AND_ASSIGN(CompilationPhase);
717 }; 734 };
718 735
719 } } // namespace v8::internal 736 } } // namespace v8::internal
720 737
721 #endif // V8_COMPILER_H_ 738 #endif // V8_COMPILER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698