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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // ----------------------------------------------------------- | 190 // ----------------------------------------------------------- |
191 | 191 |
192 Isolate* isolate() const { | 192 Isolate* isolate() const { |
193 return isolate_; | 193 return isolate_; |
194 } | 194 } |
195 Zone* zone() { return zone_; } | 195 Zone* zone() { return zone_; } |
196 bool is_osr() const { return !osr_ast_id_.IsNone(); } | 196 bool is_osr() const { return !osr_ast_id_.IsNone(); } |
197 Handle<Code> code() const { return code_; } | 197 Handle<Code> code() const { return code_; } |
198 Code::Flags code_flags() const { return code_flags_; } | 198 Code::Flags code_flags() const { return code_flags_; } |
199 BailoutId osr_ast_id() const { return osr_ast_id_; } | 199 BailoutId osr_ast_id() const { return osr_ast_id_; } |
200 Handle<Code> unoptimized_code() const { return unoptimized_code_; } | |
201 int opt_count() const { return opt_count_; } | 200 int opt_count() const { return opt_count_; } |
202 int num_parameters() const; | 201 int num_parameters() const; |
203 int num_parameters_including_this() const; | 202 int num_parameters_including_this() const; |
204 bool is_this_defined() const; | 203 bool is_this_defined() const; |
205 int num_heap_slots() const; | 204 int num_heap_slots() const; |
206 | 205 |
207 void set_parameter_count(int parameter_count) { | 206 void set_parameter_count(int parameter_count) { |
208 DCHECK(IsStub()); | 207 DCHECK(IsStub()); |
209 parameter_count_ = parameter_count; | 208 parameter_count_ = parameter_count; |
210 } | 209 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 // Accessors for the different compilation modes. | 354 // Accessors for the different compilation modes. |
356 bool IsOptimizing() const { return mode_ == OPTIMIZE; } | 355 bool IsOptimizing() const { return mode_ == OPTIMIZE; } |
357 bool IsStub() const { return mode_ == STUB; } | 356 bool IsStub() const { return mode_ == STUB; } |
358 void SetOptimizing() { | 357 void SetOptimizing() { |
359 DCHECK(has_shared_info()); | 358 DCHECK(has_shared_info()); |
360 SetMode(OPTIMIZE); | 359 SetMode(OPTIMIZE); |
361 optimization_id_ = isolate()->NextOptimizationId(); | 360 optimization_id_ = isolate()->NextOptimizationId(); |
362 code_flags_ = | 361 code_flags_ = |
363 Code::KindField::update(code_flags_, Code::OPTIMIZED_FUNCTION); | 362 Code::KindField::update(code_flags_, Code::OPTIMIZED_FUNCTION); |
364 } | 363 } |
365 void SetOptimizingForOsr(BailoutId osr_ast_id, Handle<Code> unoptimized) { | 364 void SetOptimizingForOsr(BailoutId osr_ast_id) { |
366 SetOptimizing(); | 365 SetOptimizing(); |
367 osr_ast_id_ = osr_ast_id; | 366 osr_ast_id_ = osr_ast_id; |
368 unoptimized_code_ = unoptimized; | |
369 } | 367 } |
370 | 368 |
371 // Deoptimization support. | 369 // Deoptimization support. |
372 bool HasDeoptimizationSupport() const { | 370 bool HasDeoptimizationSupport() const { |
373 return GetFlag(kDeoptimizationSupport); | 371 return GetFlag(kDeoptimizationSupport); |
374 } | 372 } |
375 void EnableDeoptimizationSupport() { | 373 void EnableDeoptimizationSupport() { |
376 DCHECK_EQ(BASE, mode_); | 374 DCHECK_EQ(BASE, mode_); |
377 SetFlag(kDeoptimizationSupport); | 375 SetFlag(kDeoptimizationSupport); |
378 } | 376 } |
379 bool ShouldEnsureSpaceForLazyDeopt() { return !IsStub(); } | 377 bool ShouldEnsureSpaceForLazyDeopt() { return !IsStub(); } |
380 | 378 |
381 bool ExpectsJSReceiverAsReceiver(); | 379 bool ExpectsJSReceiverAsReceiver(); |
382 | 380 |
383 // Determines whether or not to insert a self-optimization header. | 381 // Determines whether or not to insert a self-optimization header. |
384 bool ShouldSelfOptimize(); | 382 bool ShouldSelfOptimize(); |
385 | 383 |
386 void set_deferred_handles(DeferredHandles* deferred_handles) { | 384 void set_deferred_handles(DeferredHandles* deferred_handles) { |
387 DCHECK(deferred_handles_ == NULL); | 385 DCHECK(deferred_handles_ == NULL); |
388 deferred_handles_ = deferred_handles; | 386 deferred_handles_ = deferred_handles; |
389 } | 387 } |
390 | 388 |
391 void ReopenHandlesInNewHandleScope() { | 389 void ReopenHandlesInNewHandleScope() { |
392 unoptimized_code_ = Handle<Code>(*unoptimized_code_); | 390 // Empty for now but will be needed once fields move from ParseInfo. |
393 } | 391 } |
394 | 392 |
395 void AbortOptimization(BailoutReason reason) { | 393 void AbortOptimization(BailoutReason reason) { |
396 DCHECK(reason != kNoReason); | 394 DCHECK(reason != kNoReason); |
397 if (bailout_reason_ == kNoReason) bailout_reason_ = reason; | 395 if (bailout_reason_ == kNoReason) bailout_reason_ = reason; |
398 SetFlag(kDisableFutureOptimization); | 396 SetFlag(kDisableFutureOptimization); |
399 } | 397 } |
400 | 398 |
401 void RetryOptimization(BailoutReason reason) { | 399 void RetryOptimization(BailoutReason reason) { |
402 DCHECK(reason != kNoReason); | 400 DCHECK(reason != kNoReason); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 | 533 |
536 // The compiled code. | 534 // The compiled code. |
537 Handle<Code> code_; | 535 Handle<Code> code_; |
538 | 536 |
539 // Used by codegen, ultimately kept rooted by the SharedFunctionInfo. | 537 // Used by codegen, ultimately kept rooted by the SharedFunctionInfo. |
540 Handle<TypeFeedbackVector> feedback_vector_; | 538 Handle<TypeFeedbackVector> feedback_vector_; |
541 | 539 |
542 // Compilation mode flag and whether deoptimization is allowed. | 540 // Compilation mode flag and whether deoptimization is allowed. |
543 Mode mode_; | 541 Mode mode_; |
544 BailoutId osr_ast_id_; | 542 BailoutId osr_ast_id_; |
545 // The unoptimized code we patched for OSR may not be the shared code | |
546 // afterwards, since we may need to compile it again to include deoptimization | |
547 // data. Keep track which code we patched. | |
548 Handle<Code> unoptimized_code_; | |
549 | 543 |
550 // Holds the bytecode array generated by the interpreter. | 544 // Holds the bytecode array generated by the interpreter. |
551 // TODO(rmcilroy/mstarzinger): Temporary work-around until compiler.cc is | 545 // TODO(rmcilroy/mstarzinger): Temporary work-around until compiler.cc is |
552 // refactored to avoid us needing to carry the BytcodeArray around. | 546 // refactored to avoid us needing to carry the BytcodeArray around. |
553 Handle<BytecodeArray> bytecode_array_; | 547 Handle<BytecodeArray> bytecode_array_; |
554 | 548 |
555 // The zone from which the compilation pipeline working on this | 549 // The zone from which the compilation pipeline working on this |
556 // CompilationInfo allocates. | 550 // CompilationInfo allocates. |
557 Zone* zone_; | 551 Zone* zone_; |
558 | 552 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 OptimizedCompileJob* job_; | 649 OptimizedCompileJob* job_; |
656 base::ElapsedTimer timer_; | 650 base::ElapsedTimer timer_; |
657 base::TimeDelta* location_; | 651 base::TimeDelta* location_; |
658 }; | 652 }; |
659 }; | 653 }; |
660 | 654 |
661 } // namespace internal | 655 } // namespace internal |
662 } // namespace v8 | 656 } // namespace v8 |
663 | 657 |
664 #endif // V8_COMPILER_H_ | 658 #endif // V8_COMPILER_H_ |
OLD | NEW |