| 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/ast.h" | 9 #include "src/ast/ast.h" |
| 10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 kInliningEnabled = 1 << 11, | 156 kInliningEnabled = 1 << 11, |
| 157 kTypingEnabled = 1 << 12, | 157 kTypingEnabled = 1 << 12, |
| 158 kDisableFutureOptimization = 1 << 13, | 158 kDisableFutureOptimization = 1 << 13, |
| 159 kSplittingEnabled = 1 << 14, | 159 kSplittingEnabled = 1 << 14, |
| 160 kDeoptimizationEnabled = 1 << 16, | 160 kDeoptimizationEnabled = 1 << 16, |
| 161 kSourcePositionsEnabled = 1 << 17, | 161 kSourcePositionsEnabled = 1 << 17, |
| 162 kFirstCompile = 1 << 18, | 162 kFirstCompile = 1 << 18, |
| 163 kBailoutOnUninitialized = 1 << 19, | 163 kBailoutOnUninitialized = 1 << 19, |
| 164 }; | 164 }; |
| 165 | 165 |
| 166 explicit CompilationInfo(ParseInfo* parse_info); | 166 CompilationInfo(ParseInfo* parse_info, Handle<JSFunction> closure); |
| 167 CompilationInfo(const char* debug_name, Isolate* isolate, Zone* zone, | 167 CompilationInfo(const char* debug_name, Isolate* isolate, Zone* zone, |
| 168 Code::Flags code_flags = Code::ComputeFlags(Code::STUB)); | 168 Code::Flags code_flags = Code::ComputeFlags(Code::STUB)); |
| 169 virtual ~CompilationInfo(); | 169 virtual ~CompilationInfo(); |
| 170 | 170 |
| 171 ParseInfo* parse_info() const { return parse_info_; } | 171 ParseInfo* parse_info() const { return parse_info_; } |
| 172 | 172 |
| 173 // ----------------------------------------------------------- | 173 // ----------------------------------------------------------- |
| 174 // TODO(titzer): inline and delete accessors of ParseInfo | 174 // TODO(titzer): inline and delete accessors of ParseInfo |
| 175 // ----------------------------------------------------------- | 175 // ----------------------------------------------------------- |
| 176 Handle<Script> script() const; | 176 Handle<Script> script() const; |
| 177 bool is_eval() const; | 177 bool is_eval() const; |
| 178 bool is_native() const; | 178 bool is_native() const; |
| 179 bool is_module() const; | 179 bool is_module() const; |
| 180 LanguageMode language_mode() const; | 180 LanguageMode language_mode() const; |
| 181 Handle<JSFunction> closure() const; | |
| 182 FunctionLiteral* literal() const; | 181 FunctionLiteral* literal() const; |
| 183 Scope* scope() const; | 182 Scope* scope() const; |
| 184 Handle<Context> context() const; | 183 Handle<Context> context() const; |
| 185 Handle<SharedFunctionInfo> shared_info() const; | 184 Handle<SharedFunctionInfo> shared_info() const; |
| 186 bool has_shared_info() const; | 185 bool has_shared_info() const; |
| 187 bool has_context() const; | 186 bool has_context() const; |
| 188 bool has_scope() const; | 187 bool has_scope() const; |
| 189 // ----------------------------------------------------------- | 188 // ----------------------------------------------------------- |
| 190 | 189 |
| 191 Isolate* isolate() const { | 190 Isolate* isolate() const { |
| 192 return isolate_; | 191 return isolate_; |
| 193 } | 192 } |
| 194 Zone* zone() { return zone_; } | 193 Zone* zone() { return zone_; } |
| 195 bool is_osr() const { return !osr_ast_id_.IsNone(); } | 194 bool is_osr() const { return !osr_ast_id_.IsNone(); } |
| 195 Handle<JSFunction> closure() const { return closure_; } |
| 196 Handle<Code> code() const { return code_; } | 196 Handle<Code> code() const { return code_; } |
| 197 Code::Flags code_flags() const { return code_flags_; } | 197 Code::Flags code_flags() const { return code_flags_; } |
| 198 BailoutId osr_ast_id() const { return osr_ast_id_; } | 198 BailoutId osr_ast_id() const { return osr_ast_id_; } |
| 199 int opt_count() const { return opt_count_; } | 199 int opt_count() const { return opt_count_; } |
| 200 int num_parameters() const; | 200 int num_parameters() const; |
| 201 int num_parameters_including_this() const; | 201 int num_parameters_including_this() const; |
| 202 bool is_this_defined() const; | 202 bool is_this_defined() const; |
| 203 int num_heap_slots() const; | 203 int num_heap_slots() const; |
| 204 | 204 |
| 205 void set_parameter_count(int parameter_count) { | 205 void set_parameter_count(int parameter_count) { |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 375 |
| 376 // Determines whether or not to insert a self-optimization header. | 376 // Determines whether or not to insert a self-optimization header. |
| 377 bool ShouldSelfOptimize(); | 377 bool ShouldSelfOptimize(); |
| 378 | 378 |
| 379 void set_deferred_handles(DeferredHandles* deferred_handles) { | 379 void set_deferred_handles(DeferredHandles* deferred_handles) { |
| 380 DCHECK(deferred_handles_ == NULL); | 380 DCHECK(deferred_handles_ == NULL); |
| 381 deferred_handles_ = deferred_handles; | 381 deferred_handles_ = deferred_handles; |
| 382 } | 382 } |
| 383 | 383 |
| 384 void ReopenHandlesInNewHandleScope() { | 384 void ReopenHandlesInNewHandleScope() { |
| 385 // Empty for now but will be needed once fields move from ParseInfo. | 385 closure_ = Handle<JSFunction>(*closure_); |
| 386 } | 386 } |
| 387 | 387 |
| 388 void AbortOptimization(BailoutReason reason) { | 388 void AbortOptimization(BailoutReason reason) { |
| 389 DCHECK(reason != kNoReason); | 389 DCHECK(reason != kNoReason); |
| 390 if (bailout_reason_ == kNoReason) bailout_reason_ = reason; | 390 if (bailout_reason_ == kNoReason) bailout_reason_ = reason; |
| 391 SetFlag(kDisableFutureOptimization); | 391 SetFlag(kDisableFutureOptimization); |
| 392 } | 392 } |
| 393 | 393 |
| 394 void RetryOptimization(BailoutReason reason) { | 394 void RetryOptimization(BailoutReason reason) { |
| 395 DCHECK(reason != kNoReason); | 395 DCHECK(reason != kNoReason); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 void SetFlag(Flag flag, bool value) { | 519 void SetFlag(Flag flag, bool value) { |
| 520 flags_ = value ? flags_ | flag : flags_ & ~flag; | 520 flags_ = value ? flags_ | flag : flags_ & ~flag; |
| 521 } | 521 } |
| 522 | 522 |
| 523 bool GetFlag(Flag flag) const { return (flags_ & flag) != 0; } | 523 bool GetFlag(Flag flag) const { return (flags_ & flag) != 0; } |
| 524 | 524 |
| 525 unsigned flags_; | 525 unsigned flags_; |
| 526 | 526 |
| 527 Code::Flags code_flags_; | 527 Code::Flags code_flags_; |
| 528 | 528 |
| 529 Handle<JSFunction> closure_; |
| 530 |
| 529 // The compiled code. | 531 // The compiled code. |
| 530 Handle<Code> code_; | 532 Handle<Code> code_; |
| 531 | 533 |
| 532 // Compilation mode flag and whether deoptimization is allowed. | 534 // Compilation mode flag and whether deoptimization is allowed. |
| 533 Mode mode_; | 535 Mode mode_; |
| 534 BailoutId osr_ast_id_; | 536 BailoutId osr_ast_id_; |
| 535 | 537 |
| 536 // Holds the bytecode array generated by the interpreter. | 538 // Holds the bytecode array generated by the interpreter. |
| 537 // TODO(rmcilroy/mstarzinger): Temporary work-around until compiler.cc is | 539 // TODO(rmcilroy/mstarzinger): Temporary work-around until compiler.cc is |
| 538 // refactored to avoid us needing to carry the BytcodeArray around. | 540 // refactored to avoid us needing to carry the BytcodeArray around. |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 OptimizedCompileJob* job_; | 643 OptimizedCompileJob* job_; |
| 642 base::ElapsedTimer timer_; | 644 base::ElapsedTimer timer_; |
| 643 base::TimeDelta* location_; | 645 base::TimeDelta* location_; |
| 644 }; | 646 }; |
| 645 }; | 647 }; |
| 646 | 648 |
| 647 } // namespace internal | 649 } // namespace internal |
| 648 } // namespace v8 | 650 } // namespace v8 |
| 649 | 651 |
| 650 #endif // V8_COMPILER_H_ | 652 #endif // V8_COMPILER_H_ |
| OLD | NEW |