| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 void Run(); | 65 void Run(); |
| 66 void Stop(); | 66 void Stop(); |
| 67 void Flush(); | 67 void Flush(); |
| 68 void QueueForOptimization(OptimizingCompiler* optimizing_compiler); | 68 void QueueForOptimization(OptimizingCompiler* optimizing_compiler); |
| 69 void InstallOptimizedFunctions(); | 69 void InstallOptimizedFunctions(); |
| 70 OptimizingCompiler* FindReadyOSRCandidate(Handle<JSFunction> function, | 70 OptimizingCompiler* FindReadyOSRCandidate(Handle<JSFunction> function, |
| 71 uint32_t osr_pc_offset); | 71 uint32_t osr_pc_offset); |
| 72 bool IsQueuedForOSR(Handle<JSFunction> function, uint32_t osr_pc_offset); | 72 bool IsQueuedForOSR(Handle<JSFunction> function, uint32_t osr_pc_offset); |
| 73 | 73 |
| 74 // Remove the oldest OSR candidates that are ready so that we | 74 bool IsQueuedForOSR(JSFunction* function); |
| 75 // only have |limit| left waiting. | |
| 76 void RemoveStaleOSRCandidates(int limit = kReadyForOSRLimit); | |
| 77 | 75 |
| 78 inline bool IsQueueAvailable() { | 76 inline bool IsQueueAvailable() { |
| 79 // We don't need a barrier since we have a data dependency right | 77 // We don't need a barrier since we have a data dependency right |
| 80 // after. | 78 // after. |
| 81 Atomic32 current_length = NoBarrier_Load(&queue_length_); | 79 Atomic32 current_length = NoBarrier_Load(&queue_length_); |
| 82 | 80 |
| 83 // This can be queried only from the execution thread. | 81 // This can be queried only from the execution thread. |
| 84 ASSERT(!IsOptimizerThread()); | 82 ASSERT(!IsOptimizerThread()); |
| 85 // Since only the execution thread increments queue_length_ and | 83 // Since only the execution thread increments queue_length_ and |
| 86 // only one thread can run inside an Isolate at one time, a direct | 84 // only one thread can run inside an Isolate at one time, a direct |
| 87 // doesn't introduce a race -- queue_length_ may decreased in | 85 // doesn't introduce a race -- queue_length_ may decreased in |
| 88 // meantime, but not increased. | 86 // meantime, but not increased. |
| 89 return (current_length < FLAG_concurrent_recompilation_queue_length); | 87 return (current_length < FLAG_concurrent_recompilation_queue_length); |
| 90 } | 88 } |
| 91 | 89 |
| 92 #ifdef DEBUG | 90 #ifdef DEBUG |
| 93 bool IsOptimizerThread(); | 91 bool IsOptimizerThread(); |
| 94 #endif | 92 #endif |
| 95 | 93 |
| 96 private: | 94 private: |
| 97 enum StopFlag { CONTINUE, STOP, FLUSH }; | 95 enum StopFlag { CONTINUE, STOP, FLUSH }; |
| 98 | 96 |
| 97 // Remove the oldest OSR candidates that are ready so that we |
| 98 // only have |limit| left waiting. |
| 99 void RemoveStaleOSRCandidates(int limit = kReadyForOSRLimit); |
| 100 |
| 99 void FlushInputQueue(bool restore_function_code); | 101 void FlushInputQueue(bool restore_function_code); |
| 100 void FlushOutputQueue(bool restore_function_code); | 102 void FlushOutputQueue(bool restore_function_code); |
| 101 void CompileNext(); | 103 void CompileNext(); |
| 102 | 104 |
| 103 #ifdef DEBUG | 105 #ifdef DEBUG |
| 104 int thread_id_; | 106 int thread_id_; |
| 105 Mutex thread_id_mutex_; | 107 Mutex thread_id_mutex_; |
| 106 #endif | 108 #endif |
| 107 | 109 |
| 108 Isolate* isolate_; | 110 Isolate* isolate_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 127 Mutex osr_list_mutex_; | 129 Mutex osr_list_mutex_; |
| 128 int osr_hits_; | 130 int osr_hits_; |
| 129 int osr_attempts_; | 131 int osr_attempts_; |
| 130 | 132 |
| 131 static const int kReadyForOSRLimit = 4; | 133 static const int kReadyForOSRLimit = 4; |
| 132 }; | 134 }; |
| 133 | 135 |
| 134 } } // namespace v8::internal | 136 } } // namespace v8::internal |
| 135 | 137 |
| 136 #endif // V8_OPTIMIZING_COMPILER_THREAD_H_ | 138 #endif // V8_OPTIMIZING_COMPILER_THREAD_H_ |
| OLD | NEW |