| 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/asmjs/asm-js.h" | 8 #include "src/asmjs/asm-js.h" |
| 9 #include "src/compiler-dispatcher/optimizing-compile-dispatcher.h" | 9 #include "src/compiler-dispatcher/optimizing-compile-dispatcher.h" |
| 10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
| 11 #include "src/deoptimizer.h" | 11 #include "src/deoptimizer.h" |
| 12 #include "src/frames-inl.h" | 12 #include "src/frames-inl.h" |
| 13 #include "src/full-codegen/full-codegen.h" | 13 #include "src/full-codegen/full-codegen.h" |
| 14 #include "src/interpreter/bytecode-array-iterator.h" | |
| 15 #include "src/isolate-inl.h" | 14 #include "src/isolate-inl.h" |
| 16 #include "src/messages.h" | 15 #include "src/messages.h" |
| 17 #include "src/v8threads.h" | 16 #include "src/v8threads.h" |
| 18 #include "src/vm-state-inl.h" | 17 #include "src/vm-state-inl.h" |
| 19 | 18 |
| 20 namespace v8 { | 19 namespace v8 { |
| 21 namespace internal { | 20 namespace internal { |
| 22 | 21 |
| 23 RUNTIME_FUNCTION(Runtime_CompileLazy) { | 22 RUNTIME_FUNCTION(Runtime_CompileLazy) { |
| 24 HandleScope scope(isolate); | 23 HandleScope scope(isolate); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 caller_code = Handle<Code>(frame->LookupCode()); | 262 caller_code = Handle<Code>(frame->LookupCode()); |
| 264 } | 263 } |
| 265 | 264 |
| 266 DCHECK_EQ(frame->LookupCode(), *caller_code); | 265 DCHECK_EQ(frame->LookupCode(), *caller_code); |
| 267 DCHECK_EQ(Code::FUNCTION, caller_code->kind()); | 266 DCHECK_EQ(Code::FUNCTION, caller_code->kind()); |
| 268 DCHECK(caller_code->contains(frame->pc())); | 267 DCHECK(caller_code->contains(frame->pc())); |
| 269 | 268 |
| 270 // Revert the patched back edge table, regardless of whether OSR succeeds. | 269 // Revert the patched back edge table, regardless of whether OSR succeeds. |
| 271 BackEdgeTable::Revert(frame->isolate(), *caller_code); | 270 BackEdgeTable::Revert(frame->isolate(), *caller_code); |
| 272 | 271 |
| 272 // Return a BailoutId representing an AST id of the {IterationStatement}. |
| 273 uint32_t pc_offset = | 273 uint32_t pc_offset = |
| 274 static_cast<uint32_t>(frame->pc() - caller_code->instruction_start()); | 274 static_cast<uint32_t>(frame->pc() - caller_code->instruction_start()); |
| 275 | |
| 276 return caller_code->TranslatePcOffsetToAstId(pc_offset); | 275 return caller_code->TranslatePcOffsetToAstId(pc_offset); |
| 277 } | 276 } |
| 278 | 277 |
| 279 BailoutId DetermineEntryAndDisarmOSRForInterpreter(JavaScriptFrame* frame) { | 278 BailoutId DetermineEntryAndDisarmOSRForInterpreter(JavaScriptFrame* frame) { |
| 280 InterpretedFrame* iframe = reinterpret_cast<InterpretedFrame*>(frame); | 279 InterpretedFrame* iframe = reinterpret_cast<InterpretedFrame*>(frame); |
| 281 | 280 |
| 282 // Note that the bytecode array active on the stack might be different from | 281 // Note that the bytecode array active on the stack might be different from |
| 283 // the one installed on the function (e.g. patched by debugger). This however | 282 // the one installed on the function (e.g. patched by debugger). This however |
| 284 // is fine because we guarantee the layout to be in sync, hence any BailoutId | 283 // is fine because we guarantee the layout to be in sync, hence any BailoutId |
| 285 // representing the entry point will be valid for any copy of the bytecode. | 284 // representing the entry point will be valid for any copy of the bytecode. |
| 286 Handle<BytecodeArray> bytecode(iframe->GetBytecodeArray()); | 285 Handle<BytecodeArray> bytecode(iframe->GetBytecodeArray()); |
| 287 | 286 |
| 288 DCHECK(frame->LookupCode()->is_interpreter_trampoline_builtin()); | 287 DCHECK(frame->LookupCode()->is_interpreter_trampoline_builtin()); |
| 289 DCHECK(frame->function()->shared()->HasBytecodeArray()); | 288 DCHECK(frame->function()->shared()->HasBytecodeArray()); |
| 290 DCHECK(frame->is_interpreted()); | 289 DCHECK(frame->is_interpreted()); |
| 291 DCHECK(FLAG_ignition_osr); | 290 DCHECK(FLAG_ignition_osr); |
| 292 | 291 |
| 293 // Reset the OSR loop nesting depth to disarm back edges. | 292 // Reset the OSR loop nesting depth to disarm back edges. |
| 294 bytecode->set_osr_loop_nesting_level(0); | 293 bytecode->set_osr_loop_nesting_level(0); |
| 295 | 294 |
| 296 // Translate the offset of the jump instruction to the jump target offset of | 295 // Return a BailoutId representing the bytecode offset of the back branch. |
| 297 // that instruction so that the derived BailoutId points to the loop header. | 296 return BailoutId(iframe->GetBytecodeOffset()); |
| 298 // TODO(mstarzinger): This can be merged with {BytecodeBranchAnalysis} which | |
| 299 // already performs a pre-pass over the bytecode stream anyways. | |
| 300 int jump_offset = iframe->GetBytecodeOffset(); | |
| 301 interpreter::BytecodeArrayIterator iterator(bytecode); | |
| 302 while (iterator.current_offset() + iterator.current_prefix_offset() < | |
| 303 jump_offset) { | |
| 304 iterator.Advance(); | |
| 305 } | |
| 306 DCHECK(interpreter::Bytecodes::IsJump(iterator.current_bytecode())); | |
| 307 int jump_target_offset = iterator.GetJumpTargetOffset(); | |
| 308 | |
| 309 return BailoutId(jump_target_offset); | |
| 310 } | 297 } |
| 311 | 298 |
| 312 } // namespace | 299 } // namespace |
| 313 | 300 |
| 314 RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { | 301 RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { |
| 315 HandleScope scope(isolate); | 302 HandleScope scope(isolate); |
| 316 DCHECK(args.length() == 1); | 303 DCHECK(args.length() == 1); |
| 317 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 304 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 318 | 305 |
| 319 // We're not prepared to handle a function with arguments object. | 306 // We're not prepared to handle a function with arguments object. |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 DCHECK(is_valid_language_mode(args.smi_at(3))); | 470 DCHECK(is_valid_language_mode(args.smi_at(3))); |
| 484 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3)); | 471 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3)); |
| 485 DCHECK(args[4]->IsSmi()); | 472 DCHECK(args[4]->IsSmi()); |
| 486 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), | 473 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), |
| 487 isolate); | 474 isolate); |
| 488 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, | 475 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, |
| 489 language_mode, args.smi_at(4), args.smi_at(5)); | 476 language_mode, args.smi_at(4), args.smi_at(5)); |
| 490 } | 477 } |
| 491 } // namespace internal | 478 } // namespace internal |
| 492 } // namespace v8 | 479 } // namespace v8 |
| OLD | NEW |