OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/frames.h" | 10 #include "src/frames.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // unconditionally if the code is not already marked for deoptimization. | 161 // unconditionally if the code is not already marked for deoptimization. |
162 // If there is an index by shared function info, all the better. | 162 // If there is an index by shared function info, all the better. |
163 Deoptimizer::DeoptimizeFunction(*function); | 163 Deoptimizer::DeoptimizeFunction(*function); |
164 } | 164 } |
165 | 165 |
166 return isolate->heap()->undefined_value(); | 166 return isolate->heap()->undefined_value(); |
167 } | 167 } |
168 | 168 |
169 | 169 |
170 static bool IsSuitableForOnStackReplacement(Isolate* isolate, | 170 static bool IsSuitableForOnStackReplacement(Isolate* isolate, |
171 Handle<JSFunction> function, | 171 Handle<JSFunction> function) { |
172 Handle<Code> current_code) { | |
173 // Keep track of whether we've succeeded in optimizing. | 172 // Keep track of whether we've succeeded in optimizing. |
174 if (!current_code->optimizable()) return false; | 173 if (function->shared()->optimization_disabled()) return false; |
175 // If we are trying to do OSR when there are already optimized | 174 // If we are trying to do OSR when there are already optimized |
176 // activations of the function, it means (a) the function is directly or | 175 // activations of the function, it means (a) the function is directly or |
177 // indirectly recursive and (b) an optimized invocation has been | 176 // indirectly recursive and (b) an optimized invocation has been |
178 // deoptimized so that we are currently in an unoptimized activation. | 177 // deoptimized so that we are currently in an unoptimized activation. |
179 // Check for optimized activations of this function. | 178 // Check for optimized activations of this function. |
180 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) { | 179 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) { |
181 JavaScriptFrame* frame = it.frame(); | 180 JavaScriptFrame* frame = it.frame(); |
182 if (frame->is_optimized() && frame->function() == *function) return false; | 181 if (frame->is_optimized() && frame->function() == *function) return false; |
183 } | 182 } |
184 | 183 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 job = dispatcher->FindReadyOSRCandidate(function, ast_id); | 245 job = dispatcher->FindReadyOSRCandidate(function, ast_id); |
247 } | 246 } |
248 | 247 |
249 if (job != NULL) { | 248 if (job != NULL) { |
250 if (FLAG_trace_osr) { | 249 if (FLAG_trace_osr) { |
251 PrintF("[OSR - Found ready: "); | 250 PrintF("[OSR - Found ready: "); |
252 function->PrintName(); | 251 function->PrintName(); |
253 PrintF(" at AST id %d]\n", ast_id.ToInt()); | 252 PrintF(" at AST id %d]\n", ast_id.ToInt()); |
254 } | 253 } |
255 result = Compiler::GetConcurrentlyOptimizedCode(job); | 254 result = Compiler::GetConcurrentlyOptimizedCode(job); |
256 } else if (IsSuitableForOnStackReplacement(isolate, function, caller_code)) { | 255 } else if (IsSuitableForOnStackReplacement(isolate, function)) { |
257 if (FLAG_trace_osr) { | 256 if (FLAG_trace_osr) { |
258 PrintF("[OSR - Compiling: "); | 257 PrintF("[OSR - Compiling: "); |
259 function->PrintName(); | 258 function->PrintName(); |
260 PrintF(" at AST id %d]\n", ast_id.ToInt()); | 259 PrintF(" at AST id %d]\n", ast_id.ToInt()); |
261 } | 260 } |
262 MaybeHandle<Code> maybe_result = | 261 MaybeHandle<Code> maybe_result = |
263 Compiler::GetOptimizedCode(function, caller_code, mode, ast_id); | 262 Compiler::GetOptimizedCode(function, caller_code, mode, ast_id); |
264 if (maybe_result.ToHandle(&result) && | 263 if (maybe_result.ToHandle(&result) && |
265 result.is_identical_to(isolate->builtins()->InOptimizationQueue())) { | 264 result.is_identical_to(isolate->builtins()->InOptimizationQueue())) { |
266 // Optimization is queued. Return to check later. | 265 // Optimization is queued. Return to check later. |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 DCHECK(is_valid_language_mode(args.smi_at(4))); | 435 DCHECK(is_valid_language_mode(args.smi_at(4))); |
437 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(4)); | 436 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(4)); |
438 DCHECK(args[5]->IsSmi()); | 437 DCHECK(args[5]->IsSmi()); |
439 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), | 438 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), |
440 isolate); | 439 isolate); |
441 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, | 440 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, |
442 args.at<Object>(3), language_mode, args.smi_at(5)); | 441 args.at<Object>(3), language_mode, args.smi_at(5)); |
443 } | 442 } |
444 } // namespace internal | 443 } // namespace internal |
445 } // namespace v8 | 444 } // namespace v8 |
OLD | NEW |