OLD | NEW |
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 17 matching lines...) Expand all Loading... |
28 #ifndef V8_COMPILER_H_ | 28 #ifndef V8_COMPILER_H_ |
29 #define V8_COMPILER_H_ | 29 #define V8_COMPILER_H_ |
30 | 30 |
31 #include "allocation.h" | 31 #include "allocation.h" |
32 #include "ast.h" | 32 #include "ast.h" |
33 #include "zone.h" | 33 #include "zone.h" |
34 | 34 |
35 namespace v8 { | 35 namespace v8 { |
36 namespace internal { | 36 namespace internal { |
37 | 37 |
38 class ScriptDataImpl; | 38 class ScriptData; |
39 class HydrogenCodeStub; | 39 class HydrogenCodeStub; |
40 | 40 |
41 // ParseRestriction is used to restrict the set of valid statements in a | 41 // ParseRestriction is used to restrict the set of valid statements in a |
42 // unit of compilation. Restriction violations cause a syntax error. | 42 // unit of compilation. Restriction violations cause a syntax error. |
43 enum ParseRestriction { | 43 enum ParseRestriction { |
44 NO_PARSE_RESTRICTION, // All expressions are allowed. | 44 NO_PARSE_RESTRICTION, // All expressions are allowed. |
45 ONLY_SINGLE_FUNCTION_LITERAL // Only a single FunctionLiteral expression. | 45 ONLY_SINGLE_FUNCTION_LITERAL // Only a single FunctionLiteral expression. |
46 }; | 46 }; |
47 | 47 |
48 enum CachedDataMode { | 48 enum CachedDataMode { |
(...skipping 27 matching lines...) Expand all Loading... |
76 bool is_in_loop() const { return IsInLoop::decode(flags_); } | 76 bool is_in_loop() const { return IsInLoop::decode(flags_); } |
77 FunctionLiteral* function() const { return function_; } | 77 FunctionLiteral* function() const { return function_; } |
78 Scope* scope() const { return scope_; } | 78 Scope* scope() const { return scope_; } |
79 Scope* global_scope() const { return global_scope_; } | 79 Scope* global_scope() const { return global_scope_; } |
80 Handle<Code> code() const { return code_; } | 80 Handle<Code> code() const { return code_; } |
81 Handle<JSFunction> closure() const { return closure_; } | 81 Handle<JSFunction> closure() const { return closure_; } |
82 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } | 82 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } |
83 Handle<Script> script() const { return script_; } | 83 Handle<Script> script() const { return script_; } |
84 HydrogenCodeStub* code_stub() const {return code_stub_; } | 84 HydrogenCodeStub* code_stub() const {return code_stub_; } |
85 v8::Extension* extension() const { return extension_; } | 85 v8::Extension* extension() const { return extension_; } |
86 ScriptDataImpl** cached_data() const { return cached_data_; } | 86 ScriptData** cached_data() const { return cached_data_; } |
87 CachedDataMode cached_data_mode() const { | 87 CachedDataMode cached_data_mode() const { |
88 return cached_data_mode_; | 88 return cached_data_mode_; |
89 } | 89 } |
90 Handle<Context> context() const { return context_; } | 90 Handle<Context> context() const { return context_; } |
91 BailoutId osr_ast_id() const { return osr_ast_id_; } | 91 BailoutId osr_ast_id() const { return osr_ast_id_; } |
92 Handle<Code> unoptimized_code() const { return unoptimized_code_; } | 92 Handle<Code> unoptimized_code() const { return unoptimized_code_; } |
93 int opt_count() const { return opt_count_; } | 93 int opt_count() const { return opt_count_; } |
94 int num_parameters() const; | 94 int num_parameters() const; |
95 int num_heap_slots() const; | 95 int num_heap_slots() const; |
96 Code::Flags flags() const; | 96 Code::Flags flags() const; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 void PrepareForCompilation(Scope* scope); | 182 void PrepareForCompilation(Scope* scope); |
183 void SetGlobalScope(Scope* global_scope) { | 183 void SetGlobalScope(Scope* global_scope) { |
184 ASSERT(global_scope_ == NULL); | 184 ASSERT(global_scope_ == NULL); |
185 global_scope_ = global_scope; | 185 global_scope_ = global_scope; |
186 } | 186 } |
187 void SetCode(Handle<Code> code) { code_ = code; } | 187 void SetCode(Handle<Code> code) { code_ = code; } |
188 void SetExtension(v8::Extension* extension) { | 188 void SetExtension(v8::Extension* extension) { |
189 ASSERT(!is_lazy()); | 189 ASSERT(!is_lazy()); |
190 extension_ = extension; | 190 extension_ = extension; |
191 } | 191 } |
192 void SetCachedData(ScriptDataImpl** cached_data, | 192 void SetCachedData(ScriptData** cached_data, |
193 CachedDataMode cached_data_mode) { | 193 CachedDataMode cached_data_mode) { |
194 cached_data_mode_ = cached_data_mode; | 194 cached_data_mode_ = cached_data_mode; |
195 if (cached_data_mode == NO_CACHED_DATA) { | 195 if (cached_data_mode == NO_CACHED_DATA) { |
196 cached_data_ = NULL; | 196 cached_data_ = NULL; |
197 } else { | 197 } else { |
198 ASSERT(!is_lazy()); | 198 ASSERT(!is_lazy()); |
199 cached_data_ = cached_data; | 199 cached_data_ = cached_data; |
200 } | 200 } |
201 } | 201 } |
202 void SetContext(Handle<Context> context) { | 202 void SetContext(Handle<Context> context) { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 // The compiled code. | 405 // The compiled code. |
406 Handle<Code> code_; | 406 Handle<Code> code_; |
407 | 407 |
408 // Possible initial inputs to the compilation process. | 408 // Possible initial inputs to the compilation process. |
409 Handle<JSFunction> closure_; | 409 Handle<JSFunction> closure_; |
410 Handle<SharedFunctionInfo> shared_info_; | 410 Handle<SharedFunctionInfo> shared_info_; |
411 Handle<Script> script_; | 411 Handle<Script> script_; |
412 | 412 |
413 // Fields possibly needed for eager compilation, NULL by default. | 413 // Fields possibly needed for eager compilation, NULL by default. |
414 v8::Extension* extension_; | 414 v8::Extension* extension_; |
415 ScriptDataImpl** cached_data_; | 415 ScriptData** cached_data_; |
416 CachedDataMode cached_data_mode_; | 416 CachedDataMode cached_data_mode_; |
417 | 417 |
418 // The context of the caller for eval code, and the global context for a | 418 // The context of the caller for eval code, and the global context for a |
419 // global script. Will be a null handle otherwise. | 419 // global script. Will be a null handle otherwise. |
420 Handle<Context> context_; | 420 Handle<Context> context_; |
421 | 421 |
422 // Compilation mode flag and whether deoptimization is allowed. | 422 // Compilation mode flag and whether deoptimization is allowed. |
423 Mode mode_; | 423 Mode mode_; |
424 BailoutId osr_ast_id_; | 424 BailoutId osr_ast_id_; |
425 // The unoptimized code we patched for OSR may not be the shared code | 425 // The unoptimized code we patched for OSR may not be the shared code |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 | 634 |
635 // Compile a String source within a context. | 635 // Compile a String source within a context. |
636 static Handle<SharedFunctionInfo> CompileScript( | 636 static Handle<SharedFunctionInfo> CompileScript( |
637 Handle<String> source, | 637 Handle<String> source, |
638 Handle<Object> script_name, | 638 Handle<Object> script_name, |
639 int line_offset, | 639 int line_offset, |
640 int column_offset, | 640 int column_offset, |
641 bool is_shared_cross_origin, | 641 bool is_shared_cross_origin, |
642 Handle<Context> context, | 642 Handle<Context> context, |
643 v8::Extension* extension, | 643 v8::Extension* extension, |
644 ScriptDataImpl** cached_data, | 644 ScriptData** cached_data, |
645 CachedDataMode cached_data_mode, | 645 CachedDataMode cached_data_mode, |
646 NativesFlag is_natives_code); | 646 NativesFlag is_natives_code); |
647 | 647 |
648 // Create a shared function info object (the code may be lazily compiled). | 648 // Create a shared function info object (the code may be lazily compiled). |
649 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, | 649 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, |
650 Handle<Script> script); | 650 Handle<Script> script); |
651 | 651 |
652 enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT }; | 652 enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT }; |
653 | 653 |
654 // Generate and return optimized code or start a concurrent optimization job. | 654 // Generate and return optimized code or start a concurrent optimization job. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 unsigned info_zone_start_allocation_size_; | 690 unsigned info_zone_start_allocation_size_; |
691 ElapsedTimer timer_; | 691 ElapsedTimer timer_; |
692 | 692 |
693 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 693 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
694 }; | 694 }; |
695 | 695 |
696 | 696 |
697 } } // namespace v8::internal | 697 } } // namespace v8::internal |
698 | 698 |
699 #endif // V8_COMPILER_H_ | 699 #endif // V8_COMPILER_H_ |
OLD | NEW |