| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 int to; | 53 int to; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 // CompilationInfo encapsulates some information known at compile time. It | 56 // CompilationInfo encapsulates some information known at compile time. It |
| 57 // is constructed based on the resources available at compile-time. | 57 // is constructed based on the resources available at compile-time. |
| 58 class CompilationInfo { | 58 class CompilationInfo { |
| 59 public: | 59 public: |
| 60 CompilationInfo(Handle<JSFunction> closure, Zone* zone); | 60 CompilationInfo(Handle<JSFunction> closure, Zone* zone); |
| 61 virtual ~CompilationInfo(); | 61 virtual ~CompilationInfo(); |
| 62 | 62 |
| 63 Isolate* isolate() { | 63 Isolate* isolate() const { |
| 64 ASSERT(Isolate::Current() == isolate_); | |
| 65 return isolate_; | 64 return isolate_; |
| 66 } | 65 } |
| 67 Zone* zone() { return zone_; } | 66 Zone* zone() const { return zone_; } |
| 68 bool is_lazy() const { return IsLazy::decode(flags_); } | 67 bool is_lazy() const { return IsLazy::decode(flags_); } |
| 69 bool is_eval() const { return IsEval::decode(flags_); } | 68 bool is_eval() const { return IsEval::decode(flags_); } |
| 70 bool is_global() const { return IsGlobal::decode(flags_); } | 69 bool is_global() const { return IsGlobal::decode(flags_); } |
| 71 bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; } | 70 bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; } |
| 72 bool is_extended_mode() const { return language_mode() == EXTENDED_MODE; } | 71 bool is_extended_mode() const { return language_mode() == EXTENDED_MODE; } |
| 73 LanguageMode language_mode() const { | 72 LanguageMode language_mode() const { |
| 74 return LanguageModeField::decode(flags_); | 73 return LanguageModeField::decode(flags_); |
| 75 } | 74 } |
| 76 bool is_in_loop() const { return IsInLoop::decode(flags_); } | 75 bool is_in_loop() const { return IsInLoop::decode(flags_); } |
| 77 FunctionLiteral* function() const { return function_; } | 76 FunctionLiteral* function() const { return function_; } |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 void AbortDueToDependencyChange() { | 300 void AbortDueToDependencyChange() { |
| 302 ASSERT(!isolate()->optimizing_compiler_thread()->IsOptimizerThread()); | 301 ASSERT(!isolate()->optimizing_compiler_thread()->IsOptimizerThread()); |
| 303 abort_due_to_dependency_ = true; | 302 abort_due_to_dependency_ = true; |
| 304 } | 303 } |
| 305 | 304 |
| 306 bool HasAbortedDueToDependencyChange() { | 305 bool HasAbortedDueToDependencyChange() { |
| 307 ASSERT(!isolate()->optimizing_compiler_thread()->IsOptimizerThread()); | 306 ASSERT(!isolate()->optimizing_compiler_thread()->IsOptimizerThread()); |
| 308 return abort_due_to_dependency_; | 307 return abort_due_to_dependency_; |
| 309 } | 308 } |
| 310 | 309 |
| 310 void set_osr_pc_offset(uint32_t pc_offset) { |
| 311 osr_pc_offset_ = pc_offset; |
| 312 } |
| 313 |
| 314 bool HasSameOsrEntry(Handle<JSFunction> function, uint32_t pc_offset) { |
| 315 return osr_pc_offset_ == pc_offset && function.is_identical_to(closure_); |
| 316 } |
| 317 |
| 311 protected: | 318 protected: |
| 312 CompilationInfo(Handle<Script> script, | 319 CompilationInfo(Handle<Script> script, |
| 313 Zone* zone); | 320 Zone* zone); |
| 314 CompilationInfo(Handle<SharedFunctionInfo> shared_info, | 321 CompilationInfo(Handle<SharedFunctionInfo> shared_info, |
| 315 Zone* zone); | 322 Zone* zone); |
| 316 CompilationInfo(HydrogenCodeStub* stub, | 323 CompilationInfo(HydrogenCodeStub* stub, |
| 317 Isolate* isolate, | 324 Isolate* isolate, |
| 318 Zone* zone); | 325 Zone* zone); |
| 319 | 326 |
| 320 private: | 327 private: |
| 321 Isolate* isolate_; | 328 Isolate* isolate_; |
| 322 | 329 |
| 323 // Compilation mode. | 330 // Compilation mode. |
| 324 // BASE is generated by the full codegen, optionally prepared for bailouts. | 331 // BASE is generated by the full codegen, optionally prepared for bailouts. |
| 325 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. | 332 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. |
| 326 // NONOPT is generated by the full codegen and is not prepared for | 333 // NONOPT is generated by the full codegen and is not prepared for |
| 327 // recompilation/bailouts. These functions are never recompiled. | 334 // recompilation/bailouts. These functions are never recompiled. |
| 328 enum Mode { | 335 enum Mode { |
| 329 BASE, | 336 BASE, |
| 330 OPTIMIZE, | 337 OPTIMIZE, |
| 331 NONOPT, | 338 NONOPT, |
| 332 STUB | 339 STUB |
| 333 }; | 340 }; |
| 334 | 341 |
| 335 void Initialize(Isolate* isolate, Mode mode, Zone* zone); | 342 void Initialize(Isolate* isolate, Mode mode, Zone* zone); |
| 336 | 343 |
| 337 void SetMode(Mode mode) { | 344 void SetMode(Mode mode) { |
| 338 ASSERT(V8::UseCrankshaft()); | 345 ASSERT(isolate()->use_crankshaft()); |
| 339 mode_ = mode; | 346 mode_ = mode; |
| 340 } | 347 } |
| 341 | 348 |
| 342 // Flags using template class BitField<type, start, length>. All are | 349 // Flags using template class BitField<type, start, length>. All are |
| 343 // false by default. | 350 // false by default. |
| 344 // | 351 // |
| 345 // Compilation is either eager or lazy. | 352 // Compilation is either eager or lazy. |
| 346 class IsLazy: public BitField<bool, 0, 1> {}; | 353 class IsLazy: public BitField<bool, 0, 1> {}; |
| 347 // Flags that can be set for eager compilation. | 354 // Flags that can be set for eager compilation. |
| 348 class IsEval: public BitField<bool, 1, 1> {}; | 355 class IsEval: public BitField<bool, 1, 1> {}; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 v8::Extension* extension_; | 402 v8::Extension* extension_; |
| 396 ScriptDataImpl* pre_parse_data_; | 403 ScriptDataImpl* pre_parse_data_; |
| 397 | 404 |
| 398 // The context of the caller for eval code, and the global context for a | 405 // The context of the caller for eval code, and the global context for a |
| 399 // global script. Will be a null handle otherwise. | 406 // global script. Will be a null handle otherwise. |
| 400 Handle<Context> context_; | 407 Handle<Context> context_; |
| 401 | 408 |
| 402 // Compilation mode flag and whether deoptimization is allowed. | 409 // Compilation mode flag and whether deoptimization is allowed. |
| 403 Mode mode_; | 410 Mode mode_; |
| 404 BailoutId osr_ast_id_; | 411 BailoutId osr_ast_id_; |
| 412 // The pc_offset corresponding to osr_ast_id_ in unoptimized code. |
| 413 // We can look this up in the back edge table, but cache it for quick access. |
| 414 uint32_t osr_pc_offset_; |
| 405 | 415 |
| 406 // Flag whether compilation needs to be aborted due to dependency change. | 416 // Flag whether compilation needs to be aborted due to dependency change. |
| 407 bool abort_due_to_dependency_; | 417 bool abort_due_to_dependency_; |
| 408 | 418 |
| 409 // The zone from which the compilation pipeline working on this | 419 // The zone from which the compilation pipeline working on this |
| 410 // CompilationInfo allocates. | 420 // CompilationInfo allocates. |
| 411 Zone* zone_; | 421 Zone* zone_; |
| 412 | 422 |
| 413 DeferredHandles* deferred_handles_; | 423 DeferredHandles* deferred_handles_; |
| 414 | 424 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 Handle<Context> context, | 603 Handle<Context> context, |
| 594 bool is_global, | 604 bool is_global, |
| 595 LanguageMode language_mode, | 605 LanguageMode language_mode, |
| 596 ParseRestriction restriction, | 606 ParseRestriction restriction, |
| 597 int scope_position); | 607 int scope_position); |
| 598 | 608 |
| 599 // Compile from function info (used for lazy compilation). Returns true on | 609 // Compile from function info (used for lazy compilation). Returns true on |
| 600 // success and false if the compilation resulted in a stack overflow. | 610 // success and false if the compilation resulted in a stack overflow. |
| 601 static bool CompileLazy(CompilationInfo* info); | 611 static bool CompileLazy(CompilationInfo* info); |
| 602 | 612 |
| 603 static void RecompileConcurrent(Handle<JSFunction> function); | 613 static bool RecompileConcurrent(Handle<JSFunction> function, |
| 614 uint32_t osr_pc_offset = 0); |
| 604 | 615 |
| 605 // Compile a shared function info object (the function is possibly lazily | 616 // Compile a shared function info object (the function is possibly lazily |
| 606 // compiled). | 617 // compiled). |
| 607 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, | 618 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, |
| 608 Handle<Script> script); | 619 Handle<Script> script); |
| 609 | 620 |
| 610 // Set the function info for a newly compiled function. | 621 // Set the function info for a newly compiled function. |
| 611 static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info, | 622 static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info, |
| 612 FunctionLiteral* lit, | 623 FunctionLiteral* lit, |
| 613 bool is_toplevel, | 624 bool is_toplevel, |
| 614 Handle<Script> script); | 625 Handle<Script> script); |
| 615 | 626 |
| 616 static void InstallOptimizedCode(OptimizingCompiler* info); | 627 static bool InstallOptimizedCode(OptimizingCompiler* info); |
| 628 |
| 629 static BailoutId CompileForOnStackReplacement(Handle<JSFunction> function); |
| 630 |
| 631 static BailoutId CompileForConcurrentOSR(Handle<JSFunction> function); |
| 617 | 632 |
| 618 #ifdef ENABLE_DEBUGGER_SUPPORT | 633 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 619 static bool MakeCodeForLiveEdit(CompilationInfo* info); | 634 static bool MakeCodeForLiveEdit(CompilationInfo* info); |
| 620 #endif | 635 #endif |
| 621 | 636 |
| 622 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 637 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
| 623 CompilationInfo* info, | 638 CompilationInfo* info, |
| 624 Handle<SharedFunctionInfo> shared); | 639 Handle<SharedFunctionInfo> shared); |
| 625 }; | 640 }; |
| 626 | 641 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 645 unsigned info_zone_start_allocation_size_; | 660 unsigned info_zone_start_allocation_size_; |
| 646 ElapsedTimer timer_; | 661 ElapsedTimer timer_; |
| 647 | 662 |
| 648 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 663 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
| 649 }; | 664 }; |
| 650 | 665 |
| 651 | 666 |
| 652 } } // namespace v8::internal | 667 } } // namespace v8::internal |
| 653 | 668 |
| 654 #endif // V8_COMPILER_H_ | 669 #endif // V8_COMPILER_H_ |
| OLD | NEW |