Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: src/arm64/macro-assembler-arm64.cc

Issue 1463803002: [debugger] flood function for stepping before calling it. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase, ports, deoptimize builtins Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 #if V8_TARGET_ARCH_ARM64 5 #if V8_TARGET_ARCH_ARM64
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/base/division-by-constant.h" 8 #include "src/base/division-by-constant.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 2521 matching lines...) Expand 10 before | Expand all | Expand 10 after
2532 // adaptor. 2532 // adaptor.
2533 if (!definitely_matches) { 2533 if (!definitely_matches) {
2534 Handle<Code> adaptor = 2534 Handle<Code> adaptor =
2535 isolate()->builtins()->ArgumentsAdaptorTrampoline(); 2535 isolate()->builtins()->ArgumentsAdaptorTrampoline();
2536 if (flag == CALL_FUNCTION) { 2536 if (flag == CALL_FUNCTION) {
2537 call_wrapper.BeforeCall(CallSize(adaptor)); 2537 call_wrapper.BeforeCall(CallSize(adaptor));
2538 Call(adaptor); 2538 Call(adaptor);
2539 call_wrapper.AfterCall(); 2539 call_wrapper.AfterCall();
2540 if (!*definitely_mismatches) { 2540 if (!*definitely_mismatches) {
2541 // If the arg counts don't match, no extra code is emitted by 2541 // If the arg counts don't match, no extra code is emitted by
2542 // MAsm::InvokeCode and we can just fall through. 2542 // MAsm::InvokeFunctionCode and we can just fall through.
2543 B(done); 2543 B(done);
2544 } 2544 }
2545 } else { 2545 } else {
2546 Jump(adaptor, RelocInfo::CODE_TARGET); 2546 Jump(adaptor, RelocInfo::CODE_TARGET);
2547 } 2547 }
2548 } 2548 }
2549 Bind(&regular_invoke); 2549 Bind(&regular_invoke);
2550 } 2550 }
2551 2551
2552 2552
2553 void MacroAssembler::InvokeCode(Register code, 2553 void MacroAssembler::FloodFunctionIfStepping(Register fun, Register new_target,
2554 Register new_target, 2554 const ParameterCount& expected,
2555 const ParameterCount& expected, 2555 const ParameterCount& actual) {
2556 const ParameterCount& actual, 2556 Label skip_flooding;
2557 InvokeFlag flag, 2557 ExternalReference debug_step_action =
2558 const CallWrapper& call_wrapper) { 2558 ExternalReference::debug_last_step_action_address(isolate());
2559 Mov(x4, Operand(debug_step_action));
2560 ldrb(x4, MemOperand(x4));
2561 CompareAndBranch(x4, Operand(StepIn), ne, &skip_flooding);
2562 {
2563 FrameScope frame(this,
2564 has_frame() ? StackFrame::NONE : StackFrame::INTERNAL);
2565 if (expected.is_reg()) {
2566 SmiTag(expected.reg());
2567 Push(expected.reg());
2568 }
2569 if (actual.is_reg()) {
2570 SmiTag(actual.reg());
2571 Push(actual.reg());
2572 }
2573 if (new_target.is_valid()) {
2574 Push(new_target);
2575 }
2576 Push(fun);
2577 Push(fun);
2578 CallRuntime(Runtime::kDebugPrepareStepInIfStepping, 1);
2579 Pop(fun);
2580 if (new_target.is_valid()) {
2581 Pop(new_target);
2582 }
2583 if (actual.is_reg()) {
2584 Pop(actual.reg());
2585 SmiUntag(actual.reg());
2586 }
2587 if (expected.is_reg()) {
2588 Pop(expected.reg());
2589 SmiUntag(expected.reg());
2590 }
2591 }
2592 bind(&skip_flooding);
2593 }
2594
2595
2596 void MacroAssembler::InvokeFunctionCode(Register function, Register new_target,
2597 const ParameterCount& expected,
2598 const ParameterCount& actual,
2599 InvokeFlag flag,
2600 const CallWrapper& call_wrapper) {
2559 // You can't call a function without a valid frame. 2601 // You can't call a function without a valid frame.
2560 DCHECK(flag == JUMP_FUNCTION || has_frame()); 2602 DCHECK(flag == JUMP_FUNCTION || has_frame());
2603 DCHECK(function.is(x1));
2604 DCHECK_IMPLIES(new_target.is_valid(), new_target.is(x3));
2561 2605
2562 // Ensure new target is passed in the correct register. Otherwise clear the 2606 FloodFunctionIfStepping(function, new_target, expected, actual);
2563 // appropriate register in case new target is not given. 2607
2564 DCHECK_IMPLIES(new_target.is_valid(), new_target.is(x3)); 2608 // Clear the new.target register if not given.
2565 if (!new_target.is_valid()) { 2609 if (!new_target.is_valid()) {
2566 LoadRoot(x3, Heap::kUndefinedValueRootIndex); 2610 LoadRoot(x3, Heap::kUndefinedValueRootIndex);
2567 } 2611 }
2568 2612
2569 Label done; 2613 Label done;
2570 bool definitely_mismatches = false; 2614 bool definitely_mismatches = false;
2571 InvokePrologue(expected, actual, &done, flag, &definitely_mismatches, 2615 InvokePrologue(expected, actual, &done, flag, &definitely_mismatches,
2572 call_wrapper); 2616 call_wrapper);
2573 2617
2574 // If we are certain that actual != expected, then we know InvokePrologue will 2618 // If we are certain that actual != expected, then we know InvokePrologue will
2575 // have handled the call through the argument adaptor mechanism. 2619 // have handled the call through the argument adaptor mechanism.
2576 // The called function expects the call kind in x5. 2620 // The called function expects the call kind in x5.
2577 if (!definitely_mismatches) { 2621 if (!definitely_mismatches) {
2622 // We call indirectly through the code field in the function to
2623 // allow recompilation to take effect without changing any of the
2624 // call sites.
2625 Register code = x4;
2626 Ldr(code, FieldMemOperand(function, JSFunction::kCodeEntryOffset));
2578 if (flag == CALL_FUNCTION) { 2627 if (flag == CALL_FUNCTION) {
2579 call_wrapper.BeforeCall(CallSize(code)); 2628 call_wrapper.BeforeCall(CallSize(code));
2580 Call(code); 2629 Call(code);
2581 call_wrapper.AfterCall(); 2630 call_wrapper.AfterCall();
2582 } else { 2631 } else {
2583 DCHECK(flag == JUMP_FUNCTION); 2632 DCHECK(flag == JUMP_FUNCTION);
2584 Jump(code); 2633 Jump(code);
2585 } 2634 }
2586 } 2635 }
2587 2636
2588 // Continue here if InvokePrologue does handle the invocation due to 2637 // Continue here if InvokePrologue does handle the invocation due to
2589 // mismatched parameter counts. 2638 // mismatched parameter counts.
2590 Bind(&done); 2639 Bind(&done);
2591 } 2640 }
2592 2641
2593 2642
2594 void MacroAssembler::InvokeFunction(Register function, 2643 void MacroAssembler::InvokeFunction(Register function,
2595 Register new_target, 2644 Register new_target,
2596 const ParameterCount& actual, 2645 const ParameterCount& actual,
2597 InvokeFlag flag, 2646 InvokeFlag flag,
2598 const CallWrapper& call_wrapper) { 2647 const CallWrapper& call_wrapper) {
2599 // You can't call a function without a valid frame. 2648 // You can't call a function without a valid frame.
2600 DCHECK(flag == JUMP_FUNCTION || has_frame()); 2649 DCHECK(flag == JUMP_FUNCTION || has_frame());
2601 2650
2602 // Contract with called JS functions requires that function is passed in x1. 2651 // Contract with called JS functions requires that function is passed in x1.
2603 // (See FullCodeGenerator::Generate().) 2652 // (See FullCodeGenerator::Generate().)
2604 DCHECK(function.is(x1)); 2653 DCHECK(function.is(x1));
2605 2654
2606 Register expected_reg = x2; 2655 Register expected_reg = x2;
2607 Register code_reg = x4;
2608 2656
2609 Ldr(cp, FieldMemOperand(function, JSFunction::kContextOffset)); 2657 Ldr(cp, FieldMemOperand(function, JSFunction::kContextOffset));
2610 // The number of arguments is stored as an int32_t, and -1 is a marker 2658 // The number of arguments is stored as an int32_t, and -1 is a marker
2611 // (SharedFunctionInfo::kDontAdaptArgumentsSentinel), so we need sign 2659 // (SharedFunctionInfo::kDontAdaptArgumentsSentinel), so we need sign
2612 // extension to correctly handle it. 2660 // extension to correctly handle it.
2613 Ldr(expected_reg, FieldMemOperand(function, 2661 Ldr(expected_reg, FieldMemOperand(function,
2614 JSFunction::kSharedFunctionInfoOffset)); 2662 JSFunction::kSharedFunctionInfoOffset));
2615 Ldrsw(expected_reg, 2663 Ldrsw(expected_reg,
2616 FieldMemOperand(expected_reg, 2664 FieldMemOperand(expected_reg,
2617 SharedFunctionInfo::kFormalParameterCountOffset)); 2665 SharedFunctionInfo::kFormalParameterCountOffset));
2618 Ldr(code_reg,
2619 FieldMemOperand(function, JSFunction::kCodeEntryOffset));
2620 2666
2621 ParameterCount expected(expected_reg); 2667 ParameterCount expected(expected_reg);
2622 InvokeCode(code_reg, new_target, expected, actual, flag, call_wrapper); 2668 InvokeFunctionCode(function, new_target, expected, actual, flag,
2669 call_wrapper);
2623 } 2670 }
2624 2671
2625 2672
2626 void MacroAssembler::InvokeFunction(Register function, 2673 void MacroAssembler::InvokeFunction(Register function,
2627 const ParameterCount& expected, 2674 const ParameterCount& expected,
2628 const ParameterCount& actual, 2675 const ParameterCount& actual,
2629 InvokeFlag flag, 2676 InvokeFlag flag,
2630 const CallWrapper& call_wrapper) { 2677 const CallWrapper& call_wrapper) {
2631 // You can't call a function without a valid frame. 2678 // You can't call a function without a valid frame.
2632 DCHECK(flag == JUMP_FUNCTION || has_frame()); 2679 DCHECK(flag == JUMP_FUNCTION || has_frame());
2633 2680
2634 // Contract with called JS functions requires that function is passed in x1. 2681 // Contract with called JS functions requires that function is passed in x1.
2635 // (See FullCodeGenerator::Generate().) 2682 // (See FullCodeGenerator::Generate().)
2636 DCHECK(function.Is(x1)); 2683 DCHECK(function.Is(x1));
2637 2684
2638 Register code_reg = x4;
2639
2640 // Set up the context. 2685 // Set up the context.
2641 Ldr(cp, FieldMemOperand(function, JSFunction::kContextOffset)); 2686 Ldr(cp, FieldMemOperand(function, JSFunction::kContextOffset));
2642 2687
2643 // We call indirectly through the code field in the function to 2688 InvokeFunctionCode(function, no_reg, expected, actual, flag, call_wrapper);
2644 // allow recompilation to take effect without changing any of the
2645 // call sites.
2646 Ldr(code_reg, FieldMemOperand(function, JSFunction::kCodeEntryOffset));
2647 InvokeCode(code_reg, no_reg, expected, actual, flag, call_wrapper);
2648 } 2689 }
2649 2690
2650 2691
2651 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, 2692 void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
2652 const ParameterCount& expected, 2693 const ParameterCount& expected,
2653 const ParameterCount& actual, 2694 const ParameterCount& actual,
2654 InvokeFlag flag, 2695 InvokeFlag flag,
2655 const CallWrapper& call_wrapper) { 2696 const CallWrapper& call_wrapper) {
2656 // Contract with called JS functions requires that function is passed in x1. 2697 // Contract with called JS functions requires that function is passed in x1.
2657 // (See FullCodeGenerator::Generate().) 2698 // (See FullCodeGenerator::Generate().)
(...skipping 2416 matching lines...) Expand 10 before | Expand all | Expand 10 after
5074 } 5115 }
5075 5116
5076 5117
5077 #undef __ 5118 #undef __
5078 5119
5079 5120
5080 } // namespace internal 5121 } // namespace internal
5081 } // namespace v8 5122 } // namespace v8
5082 5123
5083 #endif // V8_TARGET_ARCH_ARM64 5124 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « src/arm64/macro-assembler-arm64.h ('k') | src/assembler.h » ('j') | src/builtins.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698