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

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

Issue 7050039: Revert 8122 (stub call asserts) while test failures are investigated. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | src/x64/regexp-macro-assembler-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 26 matching lines...) Expand all
37 #include "debug.h" 37 #include "debug.h"
38 #include "heap.h" 38 #include "heap.h"
39 39
40 namespace v8 { 40 namespace v8 {
41 namespace internal { 41 namespace internal {
42 42
43 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size) 43 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size)
44 : Assembler(arg_isolate, buffer, size), 44 : Assembler(arg_isolate, buffer, size),
45 generating_stub_(false), 45 generating_stub_(false),
46 allow_stub_calls_(true), 46 allow_stub_calls_(true),
47 has_frame_(false),
48 root_array_available_(true) { 47 root_array_available_(true) {
49 if (isolate() != NULL) { 48 if (isolate() != NULL) {
50 code_object_ = Handle<Object>(isolate()->heap()->undefined_value(), 49 code_object_ = Handle<Object>(isolate()->heap()->undefined_value(),
51 isolate()); 50 isolate());
52 } 51 }
53 } 52 }
54 53
55 54
56 static intptr_t RootRegisterDelta(ExternalReference other, Isolate* isolate) { 55 static intptr_t RootRegisterDelta(ExternalReference other, Isolate* isolate) {
57 Address roots_register_value = kRootRegisterBias + 56 Address roots_register_value = kRootRegisterBias +
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 Abort("JSObject with fast elements map has slow elements"); 390 Abort("JSObject with fast elements map has slow elements");
392 bind(&ok); 391 bind(&ok);
393 } 392 }
394 } 393 }
395 394
396 395
397 void MacroAssembler::Check(Condition cc, const char* msg) { 396 void MacroAssembler::Check(Condition cc, const char* msg) {
398 Label L; 397 Label L;
399 j(cc, &L, Label::kNear); 398 j(cc, &L, Label::kNear);
400 Abort(msg); 399 Abort(msg);
401 // Control will not return here. 400 // will not return here
402 bind(&L); 401 bind(&L);
403 } 402 }
404 403
405 404
406 void MacroAssembler::CheckStackAlignment() { 405 void MacroAssembler::CheckStackAlignment() {
407 int frame_alignment = OS::ActivationFrameAlignment(); 406 int frame_alignment = OS::ActivationFrameAlignment();
408 int frame_alignment_mask = frame_alignment - 1; 407 int frame_alignment_mask = frame_alignment - 1;
409 if (frame_alignment > kPointerSize) { 408 if (frame_alignment > kPointerSize) {
410 ASSERT(IsPowerOf2(frame_alignment)); 409 ASSERT(IsPowerOf2(frame_alignment));
411 Label alignment_as_expected; 410 Label alignment_as_expected;
(...skipping 27 matching lines...) Expand all
439 intptr_t p1 = reinterpret_cast<intptr_t>(msg); 438 intptr_t p1 = reinterpret_cast<intptr_t>(msg);
440 intptr_t p0 = (p1 & ~kSmiTagMask) + kSmiTag; 439 intptr_t p0 = (p1 & ~kSmiTagMask) + kSmiTag;
441 // Note: p0 might not be a valid Smi *value*, but it has a valid Smi tag. 440 // Note: p0 might not be a valid Smi *value*, but it has a valid Smi tag.
442 ASSERT(reinterpret_cast<Object*>(p0)->IsSmi()); 441 ASSERT(reinterpret_cast<Object*>(p0)->IsSmi());
443 #ifdef DEBUG 442 #ifdef DEBUG
444 if (msg != NULL) { 443 if (msg != NULL) {
445 RecordComment("Abort message: "); 444 RecordComment("Abort message: ");
446 RecordComment(msg); 445 RecordComment(msg);
447 } 446 }
448 #endif 447 #endif
448 // Disable stub call restrictions to always allow calls to abort.
449 AllowStubCallsScope allow_scope(this, true);
450
449 push(rax); 451 push(rax);
450 movq(kScratchRegister, p0, RelocInfo::NONE); 452 movq(kScratchRegister, p0, RelocInfo::NONE);
451 push(kScratchRegister); 453 push(kScratchRegister);
452 movq(kScratchRegister, 454 movq(kScratchRegister,
453 reinterpret_cast<intptr_t>(Smi::FromInt(static_cast<int>(p1 - p0))), 455 reinterpret_cast<intptr_t>(Smi::FromInt(static_cast<int>(p1 - p0))),
454 RelocInfo::NONE); 456 RelocInfo::NONE);
455 push(kScratchRegister); 457 push(kScratchRegister);
456 458 CallRuntime(Runtime::kAbort, 2);
457 if (!has_frame_) { 459 // will not return here
458 // We don't actually want to generate a pile of code for this, so just
459 // claim there is a stack frame, without generating one.
460 FrameScope scope(this, StackFrame::NONE);
461 CallRuntime(Runtime::kAbort, 2);
462 } else {
463 CallRuntime(Runtime::kAbort, 2);
464 }
465 // Control will not return here.
466 int3(); 460 int3();
467 } 461 }
468 462
469 463
470 void MacroAssembler::CallStub(CodeStub* stub, unsigned ast_id) { 464 void MacroAssembler::CallStub(CodeStub* stub, unsigned ast_id) {
471 ASSERT(AllowThisStubCall(stub)); // Calls are not allowed in some stubs 465 ASSERT(allow_stub_calls()); // calls are not allowed in some stubs
472 Call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id); 466 Call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id);
473 } 467 }
474 468
475 469
476 MaybeObject* MacroAssembler::TryCallStub(CodeStub* stub) { 470 MaybeObject* MacroAssembler::TryCallStub(CodeStub* stub) {
477 ASSERT(AllowThisStubCall(stub)); // Calls are not allowed in some stubs. 471 ASSERT(allow_stub_calls()); // Calls are not allowed in some stubs.
478 MaybeObject* result = stub->TryGetCode(); 472 MaybeObject* result = stub->TryGetCode();
479 if (!result->IsFailure()) { 473 if (!result->IsFailure()) {
480 call(Handle<Code>(Code::cast(result->ToObjectUnchecked())), 474 call(Handle<Code>(Code::cast(result->ToObjectUnchecked())),
481 RelocInfo::CODE_TARGET); 475 RelocInfo::CODE_TARGET);
482 } 476 }
483 return result; 477 return result;
484 } 478 }
485 479
486 480
487 void MacroAssembler::TailCallStub(CodeStub* stub) { 481 void MacroAssembler::TailCallStub(CodeStub* stub) {
488 ASSERT(stub->CompilingCallsToThisStubIsGCSafe() || allow_stub_calls_); 482 ASSERT(allow_stub_calls()); // Calls are not allowed in some stubs.
489 Jump(stub->GetCode(), RelocInfo::CODE_TARGET); 483 Jump(stub->GetCode(), RelocInfo::CODE_TARGET);
490 } 484 }
491 485
492 486
493 MaybeObject* MacroAssembler::TryTailCallStub(CodeStub* stub) { 487 MaybeObject* MacroAssembler::TryTailCallStub(CodeStub* stub) {
488 ASSERT(allow_stub_calls()); // Calls are not allowed in some stubs.
494 MaybeObject* result = stub->TryGetCode(); 489 MaybeObject* result = stub->TryGetCode();
495 if (!result->IsFailure()) { 490 if (!result->IsFailure()) {
496 jmp(Handle<Code>(Code::cast(result->ToObjectUnchecked())), 491 jmp(Handle<Code>(Code::cast(result->ToObjectUnchecked())),
497 RelocInfo::CODE_TARGET); 492 RelocInfo::CODE_TARGET);
498 } 493 }
499 return result; 494 return result;
500 } 495 }
501 496
502 497
503 void MacroAssembler::StubReturn(int argc) { 498 void MacroAssembler::StubReturn(int argc) {
504 ASSERT(argc >= 1 && generating_stub()); 499 ASSERT(argc >= 1 && generating_stub());
505 ret((argc - 1) * kPointerSize); 500 ret((argc - 1) * kPointerSize);
506 } 501 }
507 502
508 503
509 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) {
510 if (!has_frame_ && stub->SometimesSetsUpAFrame()) return false;
511 return stub->CompilingCallsToThisStubIsGCSafe() || allow_stub_calls_;
512 }
513
514
515 void MacroAssembler::IllegalOperation(int num_arguments) { 504 void MacroAssembler::IllegalOperation(int num_arguments) {
516 if (num_arguments > 0) { 505 if (num_arguments > 0) {
517 addq(rsp, Immediate(num_arguments * kPointerSize)); 506 addq(rsp, Immediate(num_arguments * kPointerSize));
518 } 507 }
519 LoadRoot(rax, Heap::kUndefinedValueRootIndex); 508 LoadRoot(rax, Heap::kUndefinedValueRootIndex);
520 } 509 }
521 510
522 511
523 void MacroAssembler::IndexFromHash(Register hash, Register index) { 512 void MacroAssembler::IndexFromHash(Register hash, Register index) {
524 // The assert checks that the constants for the maximum number of digits 513 // The assert checks that the constants for the maximum number of digits
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 // Set the entry point and jump to the C entry runtime stub. 785 // Set the entry point and jump to the C entry runtime stub.
797 LoadAddress(rbx, ext); 786 LoadAddress(rbx, ext);
798 CEntryStub ces(result_size); 787 CEntryStub ces(result_size);
799 return TryTailCallStub(&ces); 788 return TryTailCallStub(&ces);
800 } 789 }
801 790
802 791
803 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, 792 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id,
804 InvokeFlag flag, 793 InvokeFlag flag,
805 const CallWrapper& call_wrapper) { 794 const CallWrapper& call_wrapper) {
806 // You can't call a builtin without a valid frame. 795 // Calls are not allowed in some stubs.
807 ASSERT(flag == JUMP_FUNCTION || has_frame()); 796 ASSERT(flag == JUMP_FUNCTION || allow_stub_calls());
808 797
809 // Rely on the assertion to check that the number of provided 798 // Rely on the assertion to check that the number of provided
810 // arguments match the expected number of arguments. Fake a 799 // arguments match the expected number of arguments. Fake a
811 // parameter count to avoid emitting code to do the check. 800 // parameter count to avoid emitting code to do the check.
812 ParameterCount expected(0); 801 ParameterCount expected(0);
813 GetBuiltinEntry(rdx, id); 802 GetBuiltinEntry(rdx, id);
814 InvokeCode(rdx, expected, expected, flag, call_wrapper, CALL_AS_METHOD); 803 InvokeCode(rdx, expected, expected, flag, call_wrapper, CALL_AS_METHOD);
815 } 804 }
816 805
817 806
(...skipping 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after
2775 decl(counter_operand); 2764 decl(counter_operand);
2776 } else { 2765 } else {
2777 subl(counter_operand, Immediate(value)); 2766 subl(counter_operand, Immediate(value));
2778 } 2767 }
2779 } 2768 }
2780 } 2769 }
2781 2770
2782 2771
2783 #ifdef ENABLE_DEBUGGER_SUPPORT 2772 #ifdef ENABLE_DEBUGGER_SUPPORT
2784 void MacroAssembler::DebugBreak() { 2773 void MacroAssembler::DebugBreak() {
2774 ASSERT(allow_stub_calls());
2785 Set(rax, 0); // No arguments. 2775 Set(rax, 0); // No arguments.
2786 LoadAddress(rbx, ExternalReference(Runtime::kDebugBreak, isolate())); 2776 LoadAddress(rbx, ExternalReference(Runtime::kDebugBreak, isolate()));
2787 CEntryStub ces(1); 2777 CEntryStub ces(1);
2788 ASSERT(AllowThisStubCall(&ces));
2789 Call(ces.GetCode(), RelocInfo::DEBUG_BREAK); 2778 Call(ces.GetCode(), RelocInfo::DEBUG_BREAK);
2790 } 2779 }
2791 #endif // ENABLE_DEBUGGER_SUPPORT 2780 #endif // ENABLE_DEBUGGER_SUPPORT
2792 2781
2793 2782
2794 void MacroAssembler::SetCallKind(Register dst, CallKind call_kind) { 2783 void MacroAssembler::SetCallKind(Register dst, CallKind call_kind) {
2795 // This macro takes the dst register to make the code more readable 2784 // This macro takes the dst register to make the code more readable
2796 // at the call sites. However, the dst register has to be rcx to 2785 // at the call sites. However, the dst register has to be rcx to
2797 // follow the calling convention which requires the call type to be 2786 // follow the calling convention which requires the call type to be
2798 // in rcx. 2787 // in rcx.
2799 ASSERT(dst.is(rcx)); 2788 ASSERT(dst.is(rcx));
2800 if (call_kind == CALL_AS_FUNCTION) { 2789 if (call_kind == CALL_AS_FUNCTION) {
2801 LoadSmiConstant(dst, Smi::FromInt(1)); 2790 LoadSmiConstant(dst, Smi::FromInt(1));
2802 } else { 2791 } else {
2803 LoadSmiConstant(dst, Smi::FromInt(0)); 2792 LoadSmiConstant(dst, Smi::FromInt(0));
2804 } 2793 }
2805 } 2794 }
2806 2795
2807 2796
2808 void MacroAssembler::InvokeCode(Register code, 2797 void MacroAssembler::InvokeCode(Register code,
2809 const ParameterCount& expected, 2798 const ParameterCount& expected,
2810 const ParameterCount& actual, 2799 const ParameterCount& actual,
2811 InvokeFlag flag, 2800 InvokeFlag flag,
2812 const CallWrapper& call_wrapper, 2801 const CallWrapper& call_wrapper,
2813 CallKind call_kind) { 2802 CallKind call_kind) {
2814 // You can't call a function without a valid frame.
2815 ASSERT(flag == JUMP_FUNCTION || has_frame());
2816
2817 Label done; 2803 Label done;
2818 InvokePrologue(expected, 2804 InvokePrologue(expected,
2819 actual, 2805 actual,
2820 Handle<Code>::null(), 2806 Handle<Code>::null(),
2821 code, 2807 code,
2822 &done, 2808 &done,
2823 flag, 2809 flag,
2824 Label::kNear, 2810 Label::kNear,
2825 call_wrapper, 2811 call_wrapper,
2826 call_kind); 2812 call_kind);
(...skipping 11 matching lines...) Expand all
2838 } 2824 }
2839 2825
2840 2826
2841 void MacroAssembler::InvokeCode(Handle<Code> code, 2827 void MacroAssembler::InvokeCode(Handle<Code> code,
2842 const ParameterCount& expected, 2828 const ParameterCount& expected,
2843 const ParameterCount& actual, 2829 const ParameterCount& actual,
2844 RelocInfo::Mode rmode, 2830 RelocInfo::Mode rmode,
2845 InvokeFlag flag, 2831 InvokeFlag flag,
2846 const CallWrapper& call_wrapper, 2832 const CallWrapper& call_wrapper,
2847 CallKind call_kind) { 2833 CallKind call_kind) {
2848 // You can't call a function without a valid frame.
2849 ASSERT(flag == JUMP_FUNCTION || has_frame());
2850
2851 Label done; 2834 Label done;
2852 Register dummy = rax; 2835 Register dummy = rax;
2853 InvokePrologue(expected, 2836 InvokePrologue(expected,
2854 actual, 2837 actual,
2855 code, 2838 code,
2856 dummy, 2839 dummy,
2857 &done, 2840 &done,
2858 flag, 2841 flag,
2859 Label::kNear, 2842 Label::kNear,
2860 call_wrapper, 2843 call_wrapper,
(...skipping 10 matching lines...) Expand all
2871 } 2854 }
2872 bind(&done); 2855 bind(&done);
2873 } 2856 }
2874 2857
2875 2858
2876 void MacroAssembler::InvokeFunction(Register function, 2859 void MacroAssembler::InvokeFunction(Register function,
2877 const ParameterCount& actual, 2860 const ParameterCount& actual,
2878 InvokeFlag flag, 2861 InvokeFlag flag,
2879 const CallWrapper& call_wrapper, 2862 const CallWrapper& call_wrapper,
2880 CallKind call_kind) { 2863 CallKind call_kind) {
2881 // You can't call a function without a valid frame.
2882 ASSERT(flag == JUMP_FUNCTION || has_frame());
2883
2884 ASSERT(function.is(rdi)); 2864 ASSERT(function.is(rdi));
2885 movq(rdx, FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); 2865 movq(rdx, FieldOperand(function, JSFunction::kSharedFunctionInfoOffset));
2886 movq(rsi, FieldOperand(function, JSFunction::kContextOffset)); 2866 movq(rsi, FieldOperand(function, JSFunction::kContextOffset));
2887 movsxlq(rbx, 2867 movsxlq(rbx,
2888 FieldOperand(rdx, SharedFunctionInfo::kFormalParameterCountOffset)); 2868 FieldOperand(rdx, SharedFunctionInfo::kFormalParameterCountOffset));
2889 // Advances rdx to the end of the Code object header, to the start of 2869 // Advances rdx to the end of the Code object header, to the start of
2890 // the executable code. 2870 // the executable code.
2891 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); 2871 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
2892 2872
2893 ParameterCount expected(rbx); 2873 ParameterCount expected(rbx);
2894 InvokeCode(rdx, expected, actual, flag, call_wrapper, call_kind); 2874 InvokeCode(rdx, expected, actual, flag, call_wrapper, call_kind);
2895 } 2875 }
2896 2876
2897 2877
2898 void MacroAssembler::InvokeFunction(JSFunction* function, 2878 void MacroAssembler::InvokeFunction(JSFunction* function,
2899 const ParameterCount& actual, 2879 const ParameterCount& actual,
2900 InvokeFlag flag, 2880 InvokeFlag flag,
2901 const CallWrapper& call_wrapper, 2881 const CallWrapper& call_wrapper,
2902 CallKind call_kind) { 2882 CallKind call_kind) {
2903 // You can't call a function without a valid frame.
2904 ASSERT(flag == JUMP_FUNCTION || has_frame());
2905
2906 ASSERT(function->is_compiled()); 2883 ASSERT(function->is_compiled());
2907 // Get the function and setup the context. 2884 // Get the function and setup the context.
2908 Move(rdi, Handle<JSFunction>(function)); 2885 Move(rdi, Handle<JSFunction>(function));
2909 movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); 2886 movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
2910 2887
2911 if (V8::UseCrankshaft()) { 2888 if (V8::UseCrankshaft()) {
2912 // Since Crankshaft can recompile a function, we need to load 2889 // Since Crankshaft can recompile a function, we need to load
2913 // the Code object every time we call the function. 2890 // the Code object every time we call the function.
2914 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); 2891 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
2915 ParameterCount expected(function->shared()->formal_parameter_count()); 2892 ParameterCount expected(function->shared()->formal_parameter_count());
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
3724 3701
3725 3702
3726 void MacroAssembler::CallCFunction(ExternalReference function, 3703 void MacroAssembler::CallCFunction(ExternalReference function,
3727 int num_arguments) { 3704 int num_arguments) {
3728 LoadAddress(rax, function); 3705 LoadAddress(rax, function);
3729 CallCFunction(rax, num_arguments); 3706 CallCFunction(rax, num_arguments);
3730 } 3707 }
3731 3708
3732 3709
3733 void MacroAssembler::CallCFunction(Register function, int num_arguments) { 3710 void MacroAssembler::CallCFunction(Register function, int num_arguments) {
3734 ASSERT(has_frame());
3735 // Check stack alignment. 3711 // Check stack alignment.
3736 if (emit_debug_code()) { 3712 if (emit_debug_code()) {
3737 CheckStackAlignment(); 3713 CheckStackAlignment();
3738 } 3714 }
3739 3715
3740 call(function); 3716 call(function);
3741 ASSERT(OS::ActivationFrameAlignment() != 0); 3717 ASSERT(OS::ActivationFrameAlignment() != 0);
3742 ASSERT(num_arguments >= 0); 3718 ASSERT(num_arguments >= 0);
3743 int argument_slots_on_stack = 3719 int argument_slots_on_stack =
3744 ArgumentStackSlotsForCFunctionCall(num_arguments); 3720 ArgumentStackSlotsForCFunctionCall(num_arguments);
(...skipping 17 matching lines...) Expand all
3762 CPU::FlushICache(address_, size_); 3738 CPU::FlushICache(address_, size_);
3763 3739
3764 // Check that the code was patched as expected. 3740 // Check that the code was patched as expected.
3765 ASSERT(masm_.pc_ == address_ + size_); 3741 ASSERT(masm_.pc_ == address_ + size_);
3766 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 3742 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
3767 } 3743 }
3768 3744
3769 } } // namespace v8::internal 3745 } } // namespace v8::internal
3770 3746
3771 #endif // V8_TARGET_ARCH_X64 3747 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | src/x64/regexp-macro-assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698