OLD | NEW |
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/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 Zone* zone() { return zone_; } | 98 Zone* zone() { return zone_; } |
99 bool is_osr() const { return !osr_ast_id_.IsNone(); } | 99 bool is_osr() const { return !osr_ast_id_.IsNone(); } |
100 bool is_lazy() const { return GetFlag(kLazy); } | 100 bool is_lazy() const { return GetFlag(kLazy); } |
101 bool is_eval() const { return GetFlag(kEval); } | 101 bool is_eval() const { return GetFlag(kEval); } |
102 bool is_global() const { return GetFlag(kGlobal); } | 102 bool is_global() const { return GetFlag(kGlobal); } |
103 StrictMode strict_mode() const { | 103 StrictMode strict_mode() const { |
104 return GetFlag(kStrictMode) ? STRICT : SLOPPY; | 104 return GetFlag(kStrictMode) ? STRICT : SLOPPY; |
105 } | 105 } |
106 FunctionLiteral* function() const { return function_; } | 106 FunctionLiteral* function() const { return function_; } |
107 Scope* scope() const { return scope_; } | 107 Scope* scope() const { return scope_; } |
108 Scope* global_scope() const { return global_scope_; } | 108 Scope* script_scope() const { return script_scope_; } |
109 Handle<Code> code() const { return code_; } | 109 Handle<Code> code() const { return code_; } |
110 Handle<JSFunction> closure() const { return closure_; } | 110 Handle<JSFunction> closure() const { return closure_; } |
111 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } | 111 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } |
112 Handle<Script> script() const { return script_; } | 112 Handle<Script> script() const { return script_; } |
113 void set_script(Handle<Script> script) { script_ = script; } | 113 void set_script(Handle<Script> script) { script_ = script; } |
114 HydrogenCodeStub* code_stub() const {return code_stub_; } | 114 HydrogenCodeStub* code_stub() const {return code_stub_; } |
115 v8::Extension* extension() const { return extension_; } | 115 v8::Extension* extension() const { return extension_; } |
116 ScriptData** cached_data() const { return cached_data_; } | 116 ScriptData** cached_data() const { return cached_data_; } |
117 ScriptCompiler::CompileOptions compile_options() const { | 117 ScriptCompiler::CompileOptions compile_options() const { |
118 return compile_options_; | 118 return compile_options_; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 ParseRestriction parse_restriction() const { | 224 ParseRestriction parse_restriction() const { |
225 return GetFlag(kParseRestriction) ? ONLY_SINGLE_FUNCTION_LITERAL | 225 return GetFlag(kParseRestriction) ? ONLY_SINGLE_FUNCTION_LITERAL |
226 : NO_PARSE_RESTRICTION; | 226 : NO_PARSE_RESTRICTION; |
227 } | 227 } |
228 | 228 |
229 void SetFunction(FunctionLiteral* literal) { | 229 void SetFunction(FunctionLiteral* literal) { |
230 DCHECK(function_ == NULL); | 230 DCHECK(function_ == NULL); |
231 function_ = literal; | 231 function_ = literal; |
232 } | 232 } |
233 void PrepareForCompilation(Scope* scope); | 233 void PrepareForCompilation(Scope* scope); |
234 void SetGlobalScope(Scope* global_scope) { | 234 void SetScriptScope(Scope* script_scope) { |
235 DCHECK(global_scope_ == NULL); | 235 DCHECK(script_scope_ == NULL); |
236 global_scope_ = global_scope; | 236 script_scope_ = script_scope; |
237 } | 237 } |
238 Handle<TypeFeedbackVector> feedback_vector() const { | 238 Handle<TypeFeedbackVector> feedback_vector() const { |
239 return feedback_vector_; | 239 return feedback_vector_; |
240 } | 240 } |
241 void SetCode(Handle<Code> code) { code_ = code; } | 241 void SetCode(Handle<Code> code) { code_ = code; } |
242 void SetExtension(v8::Extension* extension) { | 242 void SetExtension(v8::Extension* extension) { |
243 DCHECK(!is_lazy()); | 243 DCHECK(!is_lazy()); |
244 extension_ = extension; | 244 extension_ = extension; |
245 } | 245 } |
246 void SetCachedData(ScriptData** cached_data, | 246 void SetCachedData(ScriptData** cached_data, |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 bool GetFlag(Flag flag) const { return (flags_ & flag) != 0; } | 434 bool GetFlag(Flag flag) const { return (flags_ & flag) != 0; } |
435 | 435 |
436 unsigned flags_; | 436 unsigned flags_; |
437 | 437 |
438 // Fields filled in by the compilation pipeline. | 438 // Fields filled in by the compilation pipeline. |
439 // AST filled in by the parser. | 439 // AST filled in by the parser. |
440 FunctionLiteral* function_; | 440 FunctionLiteral* function_; |
441 // The scope of the function literal as a convenience. Set to indicate | 441 // The scope of the function literal as a convenience. Set to indicate |
442 // that scopes have been analyzed. | 442 // that scopes have been analyzed. |
443 Scope* scope_; | 443 Scope* scope_; |
444 // The global scope provided as a convenience. | 444 // The script scope provided as a convenience. |
445 Scope* global_scope_; | 445 Scope* script_scope_; |
446 // For compiled stubs, the stub object | 446 // For compiled stubs, the stub object |
447 HydrogenCodeStub* code_stub_; | 447 HydrogenCodeStub* code_stub_; |
448 // The compiled code. | 448 // The compiled code. |
449 Handle<Code> code_; | 449 Handle<Code> code_; |
450 | 450 |
451 // Possible initial inputs to the compilation process. | 451 // Possible initial inputs to the compilation process. |
452 Handle<JSFunction> closure_; | 452 Handle<JSFunction> closure_; |
453 Handle<SharedFunctionInfo> shared_info_; | 453 Handle<SharedFunctionInfo> shared_info_; |
454 Handle<Script> script_; | 454 Handle<Script> script_; |
455 ScriptCompiler::ExternalSourceStream* source_stream_; // Not owned. | 455 ScriptCompiler::ExternalSourceStream* source_stream_; // Not owned. |
456 ScriptCompiler::StreamedSource::Encoding source_stream_encoding_; | 456 ScriptCompiler::StreamedSource::Encoding source_stream_encoding_; |
457 | 457 |
458 // Fields possibly needed for eager compilation, NULL by default. | 458 // Fields possibly needed for eager compilation, NULL by default. |
459 v8::Extension* extension_; | 459 v8::Extension* extension_; |
460 ScriptData** cached_data_; | 460 ScriptData** cached_data_; |
461 ScriptCompiler::CompileOptions compile_options_; | 461 ScriptCompiler::CompileOptions compile_options_; |
462 | 462 |
463 // The context of the caller for eval code, and the global context for a | 463 // The context of the caller for eval code, and the script context for a |
464 // global script. Will be a null handle otherwise. | 464 // global script. Will be a null handle otherwise. |
465 Handle<Context> context_; | 465 Handle<Context> context_; |
466 | 466 |
467 // Used by codegen, ultimately kept rooted by the SharedFunctionInfo. | 467 // Used by codegen, ultimately kept rooted by the SharedFunctionInfo. |
468 Handle<TypeFeedbackVector> feedback_vector_; | 468 Handle<TypeFeedbackVector> feedback_vector_; |
469 | 469 |
470 // Compilation mode flag and whether deoptimization is allowed. | 470 // Compilation mode flag and whether deoptimization is allowed. |
471 Mode mode_; | 471 Mode mode_; |
472 BailoutId osr_ast_id_; | 472 BailoutId osr_ast_id_; |
473 // The unoptimized code we patched for OSR may not be the shared code | 473 // The unoptimized code we patched for OSR may not be the shared code |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 Zone zone_; | 748 Zone zone_; |
749 unsigned info_zone_start_allocation_size_; | 749 unsigned info_zone_start_allocation_size_; |
750 base::ElapsedTimer timer_; | 750 base::ElapsedTimer timer_; |
751 | 751 |
752 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 752 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
753 }; | 753 }; |
754 | 754 |
755 } } // namespace v8::internal | 755 } } // namespace v8::internal |
756 | 756 |
757 #endif // V8_COMPILER_H_ | 757 #endif // V8_COMPILER_H_ |
OLD | NEW |