| 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 inline void AddNoFrameRange(int from, int to) { | 339 inline void AddNoFrameRange(int from, int to) { |
| 340 if (no_frame_ranges_) no_frame_ranges_->Add(OffsetRange(from, to)); | 340 if (no_frame_ranges_) no_frame_ranges_->Add(OffsetRange(from, to)); |
| 341 } | 341 } |
| 342 | 342 |
| 343 List<OffsetRange>* ReleaseNoFrameRanges() { | 343 List<OffsetRange>* ReleaseNoFrameRanges() { |
| 344 List<OffsetRange>* result = no_frame_ranges_; | 344 List<OffsetRange>* result = no_frame_ranges_; |
| 345 no_frame_ranges_ = NULL; | 345 no_frame_ranges_ = NULL; |
| 346 return result; | 346 return result; |
| 347 } | 347 } |
| 348 | 348 |
| 349 std::vector<InlinedFunctionInfo>* inlined_function_infos() { | 349 int start_position_for(uint32_t inlining_id) { |
| 350 return inlined_function_infos_; | 350 return inlined_function_infos_.at(inlining_id).start_position; |
| 351 } | |
| 352 std::vector<InlinedFunctionInfo>* ReleaseInlinedFunctionInfos() { | |
| 353 std::vector<InlinedFunctionInfo>* tmp = inlined_function_infos_; | |
| 354 inlined_function_infos_ = NULL; | |
| 355 return tmp; | |
| 356 } | 351 } |
| 357 | 352 |
| 358 void LogDeoptCallPosition(int pc_offset, int inlining_id); | 353 void LogDeoptCallPosition(int pc_offset, int inlining_id); |
| 359 int TraceInlinedFunction(Handle<SharedFunctionInfo> shared, | 354 int TraceInlinedFunction(Handle<SharedFunctionInfo> shared, |
| 360 SourcePosition position, int pareint_id); | 355 SourcePosition position, int pareint_id); |
| 361 | 356 |
| 362 Handle<Foreign> object_wrapper() { | 357 Handle<Foreign> object_wrapper() { |
| 363 if (object_wrapper_.is_null()) { | 358 if (object_wrapper_.is_null()) { |
| 364 object_wrapper_ = | 359 object_wrapper_ = |
| 365 isolate()->factory()->NewForeign(reinterpret_cast<Address>(this)); | 360 isolate()->factory()->NewForeign(reinterpret_cast<Address>(this)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 protected: | 393 protected: |
| 399 ParseInfo* parse_info_; | 394 ParseInfo* parse_info_; |
| 400 | 395 |
| 401 void DisableFutureOptimization() { | 396 void DisableFutureOptimization() { |
| 402 if (GetFlag(kDisableFutureOptimization) && has_shared_info()) { | 397 if (GetFlag(kDisableFutureOptimization) && has_shared_info()) { |
| 403 shared_info()->DisableOptimization(bailout_reason()); | 398 shared_info()->DisableOptimization(bailout_reason()); |
| 404 } | 399 } |
| 405 } | 400 } |
| 406 | 401 |
| 407 private: | 402 private: |
| 408 Isolate* isolate_; | |
| 409 | |
| 410 // Compilation mode. | 403 // Compilation mode. |
| 411 // BASE is generated by the full codegen, optionally prepared for bailouts. | 404 // BASE is generated by the full codegen, optionally prepared for bailouts. |
| 412 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. | 405 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. |
| 413 // NONOPT is generated by the full codegen and is not prepared for | 406 // NONOPT is generated by the full codegen and is not prepared for |
| 414 // recompilation/bailouts. These functions are never recompiled. | 407 // recompilation/bailouts. These functions are never recompiled. |
| 415 enum Mode { | 408 enum Mode { |
| 416 BASE, | 409 BASE, |
| 417 OPTIMIZE, | 410 OPTIMIZE, |
| 418 NONOPT, | 411 NONOPT, |
| 419 STUB | 412 STUB |
| 420 }; | 413 }; |
| 421 | 414 |
| 422 void Initialize(Isolate* isolate, Mode mode, Zone* zone); | 415 CompilationInfo(ParseInfo* parse_info, CodeStub* code_stub, Mode mode, |
| 416 Isolate* isolate, Zone* zone); |
| 417 |
| 418 Isolate* isolate_; |
| 423 | 419 |
| 424 void SetMode(Mode mode) { | 420 void SetMode(Mode mode) { |
| 425 mode_ = mode; | 421 mode_ = mode; |
| 426 } | 422 } |
| 427 | 423 |
| 428 void SetFlag(Flag flag) { flags_ |= flag; } | 424 void SetFlag(Flag flag) { flags_ |= flag; } |
| 429 | 425 |
| 430 void SetFlag(Flag flag, bool value) { | 426 void SetFlag(Flag flag, bool value) { |
| 431 flags_ = value ? flags_ | flag : flags_ & ~flag; | 427 flags_ = value ? flags_ | flag : flags_ & ~flag; |
| 432 } | 428 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 457 | 453 |
| 458 DeferredHandles* deferred_handles_; | 454 DeferredHandles* deferred_handles_; |
| 459 | 455 |
| 460 ZoneList<Handle<HeapObject> >* dependencies_[DependentCode::kGroupCount]; | 456 ZoneList<Handle<HeapObject> >* dependencies_[DependentCode::kGroupCount]; |
| 461 | 457 |
| 462 BailoutReason bailout_reason_; | 458 BailoutReason bailout_reason_; |
| 463 | 459 |
| 464 int prologue_offset_; | 460 int prologue_offset_; |
| 465 | 461 |
| 466 List<OffsetRange>* no_frame_ranges_; | 462 List<OffsetRange>* no_frame_ranges_; |
| 467 std::vector<InlinedFunctionInfo>* inlined_function_infos_; | 463 std::vector<InlinedFunctionInfo> inlined_function_infos_; |
| 468 bool track_positions_; | 464 bool track_positions_; |
| 469 | 465 |
| 470 // A copy of shared_info()->opt_count() to avoid handle deref | 466 // A copy of shared_info()->opt_count() to avoid handle deref |
| 471 // during graph optimization. | 467 // during graph optimization. |
| 472 int opt_count_; | 468 int opt_count_; |
| 473 | 469 |
| 474 // Number of parameters used for compilation of stubs that require arguments. | 470 // Number of parameters used for compilation of stubs that require arguments. |
| 475 int parameter_count_; | 471 int parameter_count_; |
| 476 | 472 |
| 477 Handle<Foreign> object_wrapper_; | 473 Handle<Foreign> object_wrapper_; |
| 478 | 474 |
| 479 int optimization_id_; | 475 int optimization_id_; |
| 480 | 476 |
| 481 // This flag is used by the main thread to track whether this compilation | 477 // This flag is used by the main thread to track whether this compilation |
| 482 // should be abandoned due to dependency change. | 478 // should be abandoned due to dependency change. |
| 483 bool aborted_due_to_dependency_change_; | 479 bool aborted_due_to_dependency_change_; |
| 484 | 480 |
| 485 int osr_expr_stack_height_; | 481 int osr_expr_stack_height_; |
| 486 | 482 |
| 487 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); | 483 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); |
| 488 }; | 484 }; |
| 489 | 485 |
| 490 | 486 |
| 491 // Exactly like a CompilationInfo, except also creates and enters a | 487 // Exactly like a CompilationInfo, except also creates and enters a |
| 492 // Zone on construction and deallocates it on exit. | 488 // Zone on construction and deallocates it on exit. |
| 493 class CompilationInfoWithZone: public CompilationInfo { | 489 class CompilationInfoWithZone: public CompilationInfo { |
| 494 public: | 490 public: |
| 495 explicit CompilationInfoWithZone(Handle<Script> script); | 491 explicit CompilationInfoWithZone(Handle<Script> script); |
| 496 explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info); | |
| 497 explicit CompilationInfoWithZone(Handle<JSFunction> closure); | 492 explicit CompilationInfoWithZone(Handle<JSFunction> closure); |
| 498 CompilationInfoWithZone(CodeStub* stub, Isolate* isolate) | 493 CompilationInfoWithZone(CodeStub* stub, Isolate* isolate) |
| 499 : CompilationInfo(stub, isolate, &zone_) {} | 494 : CompilationInfo(stub, isolate, &zone_) {} |
| 500 | 495 |
| 501 // Virtual destructor because a CompilationInfoWithZone has to exit the | 496 // Virtual destructor because a CompilationInfoWithZone has to exit the |
| 502 // zone scope and get rid of dependent maps even when the destructor is | 497 // zone scope and get rid of dependent maps even when the destructor is |
| 503 // called when cast as a CompilationInfo. | 498 // called when cast as a CompilationInfo. |
| 504 virtual ~CompilationInfoWithZone(); | 499 virtual ~CompilationInfoWithZone(); |
| 505 | 500 |
| 506 private: | 501 private: |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 Zone zone_; | 701 Zone zone_; |
| 707 size_t info_zone_start_allocation_size_; | 702 size_t info_zone_start_allocation_size_; |
| 708 base::ElapsedTimer timer_; | 703 base::ElapsedTimer timer_; |
| 709 | 704 |
| 710 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 705 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
| 711 }; | 706 }; |
| 712 | 707 |
| 713 } } // namespace v8::internal | 708 } } // namespace v8::internal |
| 714 | 709 |
| 715 #endif // V8_COMPILER_H_ | 710 #endif // V8_COMPILER_H_ |
| OLD | NEW |