| 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.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-inl.h" | 10 #include "src/frames-inl.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 205 |
| 206 uint32_t pc_offset = | 206 uint32_t pc_offset = |
| 207 static_cast<uint32_t>(frame->pc() - caller_code->instruction_start()); | 207 static_cast<uint32_t>(frame->pc() - caller_code->instruction_start()); |
| 208 | 208 |
| 209 #ifdef DEBUG | 209 #ifdef DEBUG |
| 210 DCHECK_EQ(frame->function(), *function); | 210 DCHECK_EQ(frame->function(), *function); |
| 211 DCHECK_EQ(frame->LookupCode(), *caller_code); | 211 DCHECK_EQ(frame->LookupCode(), *caller_code); |
| 212 DCHECK(caller_code->contains(frame->pc())); | 212 DCHECK(caller_code->contains(frame->pc())); |
| 213 #endif // DEBUG | 213 #endif // DEBUG |
| 214 | 214 |
| 215 | |
| 216 BailoutId ast_id = caller_code->TranslatePcOffsetToAstId(pc_offset); | 215 BailoutId ast_id = caller_code->TranslatePcOffsetToAstId(pc_offset); |
| 217 DCHECK(!ast_id.IsNone()); | 216 DCHECK(!ast_id.IsNone()); |
| 218 | 217 |
| 219 // Disable concurrent OSR for asm.js, to enable frame specialization. | |
| 220 Compiler::ConcurrencyMode mode = (isolate->concurrent_osr_enabled() && | |
| 221 !function->shared()->asm_function() && | |
| 222 function->shared()->ast_node_count() > 512) | |
| 223 ? Compiler::CONCURRENT | |
| 224 : Compiler::NOT_CONCURRENT; | |
| 225 | |
| 226 OptimizedCompileJob* job = NULL; | |
| 227 if (mode == Compiler::CONCURRENT) { | |
| 228 // Gate the OSR entry with a stack check. | |
| 229 BackEdgeTable::AddStackCheck(caller_code, pc_offset); | |
| 230 // Poll already queued compilation jobs. | |
| 231 OptimizingCompileDispatcher* dispatcher = | |
| 232 isolate->optimizing_compile_dispatcher(); | |
| 233 if (dispatcher->IsQueuedForOSR(function, ast_id)) { | |
| 234 if (FLAG_trace_osr) { | |
| 235 PrintF("[OSR - Still waiting for queued: "); | |
| 236 function->PrintName(); | |
| 237 PrintF(" at AST id %d]\n", ast_id.ToInt()); | |
| 238 } | |
| 239 return NULL; | |
| 240 } | |
| 241 | |
| 242 job = dispatcher->FindReadyOSRCandidate(function, ast_id); | |
| 243 } | |
| 244 | |
| 245 MaybeHandle<Code> maybe_result; | 218 MaybeHandle<Code> maybe_result; |
| 246 if (job != NULL) { | 219 if (IsSuitableForOnStackReplacement(isolate, function)) { |
| 247 if (FLAG_trace_osr) { | |
| 248 PrintF("[OSR - Found ready: "); | |
| 249 function->PrintName(); | |
| 250 PrintF(" at AST id %d]\n", ast_id.ToInt()); | |
| 251 } | |
| 252 maybe_result = Compiler::GetConcurrentlyOptimizedCode(job); | |
| 253 } else if (IsSuitableForOnStackReplacement(isolate, function)) { | |
| 254 if (FLAG_trace_osr) { | 220 if (FLAG_trace_osr) { |
| 255 PrintF("[OSR - Compiling: "); | 221 PrintF("[OSR - Compiling: "); |
| 256 function->PrintName(); | 222 function->PrintName(); |
| 257 PrintF(" at AST id %d]\n", ast_id.ToInt()); | 223 PrintF(" at AST id %d]\n", ast_id.ToInt()); |
| 258 } | 224 } |
| 259 maybe_result = Compiler::GetOptimizedCodeForOSR( | 225 maybe_result = Compiler::GetOptimizedCodeForOSR(function, ast_id, frame); |
| 260 function, mode, ast_id, | |
| 261 (mode == Compiler::NOT_CONCURRENT) ? frame : nullptr); | |
| 262 Handle<Code> result; | |
| 263 if (maybe_result.ToHandle(&result) && | |
| 264 result.is_identical_to(isolate->builtins()->InOptimizationQueue())) { | |
| 265 // Optimization is queued. Return to check later. | |
| 266 return NULL; | |
| 267 } | |
| 268 } | 226 } |
| 269 | 227 |
| 270 // Revert the patched back edge table, regardless of whether OSR succeeds. | 228 // Revert the patched back edge table, regardless of whether OSR succeeds. |
| 271 BackEdgeTable::Revert(isolate, *caller_code); | 229 BackEdgeTable::Revert(isolate, *caller_code); |
| 272 | 230 |
| 273 // Check whether we ended up with usable optimized code. | 231 // Check whether we ended up with usable optimized code. |
| 274 Handle<Code> result; | 232 Handle<Code> result; |
| 275 if (maybe_result.ToHandle(&result) && | 233 if (maybe_result.ToHandle(&result) && |
| 276 result->kind() == Code::OPTIMIZED_FUNCTION) { | 234 result->kind() == Code::OPTIMIZED_FUNCTION) { |
| 277 DeoptimizationInputData* data = | 235 DeoptimizationInputData* data = |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 DCHECK(is_valid_language_mode(args.smi_at(3))); | 360 DCHECK(is_valid_language_mode(args.smi_at(3))); |
| 403 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3)); | 361 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3)); |
| 404 DCHECK(args[4]->IsSmi()); | 362 DCHECK(args[4]->IsSmi()); |
| 405 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), | 363 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), |
| 406 isolate); | 364 isolate); |
| 407 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, | 365 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, |
| 408 language_mode, args.smi_at(4)); | 366 language_mode, args.smi_at(4)); |
| 409 } | 367 } |
| 410 } // namespace internal | 368 } // namespace internal |
| 411 } // namespace v8 | 369 } // namespace v8 |
| OLD | NEW |