| 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 // ----------------------------------------------------------- | 186 // ----------------------------------------------------------- |
| 188 | 187 |
| 189 Isolate* isolate() const { | 188 Isolate* isolate() const { |
| 190 return isolate_; | 189 return isolate_; |
| 191 } | 190 } |
| 192 Zone* zone() { return zone_; } | 191 Zone* zone() { return zone_; } |
| 193 bool is_osr() const { return !osr_ast_id_.IsNone(); } | 192 bool is_osr() const { return !osr_ast_id_.IsNone(); } |
| 193 Handle<JSFunction> closure() const { return closure_; } |
| 194 Handle<Code> code() const { return code_; } | 194 Handle<Code> code() const { return code_; } |
| 195 Code::Flags code_flags() const { return code_flags_; } | 195 Code::Flags code_flags() const { return code_flags_; } |
| 196 BailoutId osr_ast_id() const { return osr_ast_id_; } | 196 BailoutId osr_ast_id() const { return osr_ast_id_; } |
| 197 int num_parameters() const; | 197 int num_parameters() const; |
| 198 int num_parameters_including_this() const; | 198 int num_parameters_including_this() const; |
| 199 bool is_this_defined() const; | 199 bool is_this_defined() const; |
| 200 | 200 |
| 201 void set_parameter_count(int parameter_count) { | 201 void set_parameter_count(int parameter_count) { |
| 202 DCHECK(IsStub()); | 202 DCHECK(IsStub()); |
| 203 parameter_count_ = parameter_count; | 203 parameter_count_ = parameter_count; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 371 |
| 372 // Determines whether or not to insert a self-optimization header. | 372 // Determines whether or not to insert a self-optimization header. |
| 373 bool ShouldSelfOptimize(); | 373 bool ShouldSelfOptimize(); |
| 374 | 374 |
| 375 void set_deferred_handles(DeferredHandles* deferred_handles) { | 375 void set_deferred_handles(DeferredHandles* deferred_handles) { |
| 376 DCHECK(deferred_handles_ == NULL); | 376 DCHECK(deferred_handles_ == NULL); |
| 377 deferred_handles_ = deferred_handles; | 377 deferred_handles_ = deferred_handles; |
| 378 } | 378 } |
| 379 | 379 |
| 380 void ReopenHandlesInNewHandleScope() { | 380 void ReopenHandlesInNewHandleScope() { |
| 381 // Empty for now but will be needed once fields move from ParseInfo. | 381 closure_ = Handle<JSFunction>(*closure_); |
| 382 } | 382 } |
| 383 | 383 |
| 384 void AbortOptimization(BailoutReason reason) { | 384 void AbortOptimization(BailoutReason reason) { |
| 385 DCHECK(reason != kNoReason); | 385 DCHECK(reason != kNoReason); |
| 386 if (bailout_reason_ == kNoReason) bailout_reason_ = reason; | 386 if (bailout_reason_ == kNoReason) bailout_reason_ = reason; |
| 387 SetFlag(kDisableFutureOptimization); | 387 SetFlag(kDisableFutureOptimization); |
| 388 } | 388 } |
| 389 | 389 |
| 390 void RetryOptimization(BailoutReason reason) { | 390 void RetryOptimization(BailoutReason reason) { |
| 391 DCHECK(reason != kNoReason); | 391 DCHECK(reason != kNoReason); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 void SetFlag(Flag flag, bool value) { | 515 void SetFlag(Flag flag, bool value) { |
| 516 flags_ = value ? flags_ | flag : flags_ & ~flag; | 516 flags_ = value ? flags_ | flag : flags_ & ~flag; |
| 517 } | 517 } |
| 518 | 518 |
| 519 bool GetFlag(Flag flag) const { return (flags_ & flag) != 0; } | 519 bool GetFlag(Flag flag) const { return (flags_ & flag) != 0; } |
| 520 | 520 |
| 521 unsigned flags_; | 521 unsigned flags_; |
| 522 | 522 |
| 523 Code::Flags code_flags_; | 523 Code::Flags code_flags_; |
| 524 | 524 |
| 525 Handle<JSFunction> closure_; |
| 526 |
| 525 // The compiled code. | 527 // The compiled code. |
| 526 Handle<Code> code_; | 528 Handle<Code> code_; |
| 527 | 529 |
| 528 // Compilation mode flag and whether deoptimization is allowed. | 530 // Compilation mode flag and whether deoptimization is allowed. |
| 529 Mode mode_; | 531 Mode mode_; |
| 530 BailoutId osr_ast_id_; | 532 BailoutId osr_ast_id_; |
| 531 | 533 |
| 532 // Holds the bytecode array generated by the interpreter. | 534 // Holds the bytecode array generated by the interpreter. |
| 533 // TODO(rmcilroy/mstarzinger): Temporary work-around until compiler.cc is | 535 // TODO(rmcilroy/mstarzinger): Temporary work-around until compiler.cc is |
| 534 // refactored to avoid us needing to carry the BytcodeArray around. | 536 // refactored to avoid us needing to carry the BytcodeArray around. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 OptimizedCompileJob* job_; | 635 OptimizedCompileJob* job_; |
| 634 base::ElapsedTimer timer_; | 636 base::ElapsedTimer timer_; |
| 635 base::TimeDelta* location_; | 637 base::TimeDelta* location_; |
| 636 }; | 638 }; |
| 637 }; | 639 }; |
| 638 | 640 |
| 639 } // namespace internal | 641 } // namespace internal |
| 640 } // namespace v8 | 642 } // namespace v8 |
| 641 | 643 |
| 642 #endif // V8_COMPILER_H_ | 644 #endif // V8_COMPILER_H_ |
| OLD | NEW |