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

Side by Side Diff: src/ia32/codegen-ia32.cc

Issue 341082: Reverting 3174. Aka reapplying 3150, 3151 and 3159. Aka api accessor (Closed)
Patch Set: Created 11 years, 1 month 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
« no previous file with comments | « src/handles.cc ('k') | src/ia32/frames-ia32.h » ('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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 7668 matching lines...) Expand 10 before | Expand all | Expand 10 after
7679 __ cmp(ebp, 0); 7679 __ cmp(ebp, 0);
7680 __ j(equal, &skip, not_taken); 7680 __ j(equal, &skip, not_taken);
7681 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 7681 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
7682 __ bind(&skip); 7682 __ bind(&skip);
7683 7683
7684 ASSERT(StackHandlerConstants::kPCOffset == 3 * kPointerSize); 7684 ASSERT(StackHandlerConstants::kPCOffset == 3 * kPointerSize);
7685 __ ret(0); 7685 __ ret(0);
7686 } 7686 }
7687 7687
7688 7688
7689 // If true, a Handle<T> passed by value is passed and returned by
7690 // using the location_ field directly. If false, it is passed and
7691 // returned as a pointer to a handle.
7692 #ifdef USING_MAC_ABI
7693 static const bool kPassHandlesDirectly = true;
7694 #else
7695 static const bool kPassHandlesDirectly = false;
7696 #endif
7697
7698
7699 void ApiGetterEntryStub::Generate(MacroAssembler* masm) {
7700 Label get_result;
7701 Label prologue;
7702 Label promote_scheduled_exception;
7703 __ EnterApiExitFrame(ExitFrame::MODE_NORMAL, kStackSpace, kArgc);
7704 ASSERT_EQ(kArgc, 4);
7705 if (kPassHandlesDirectly) {
7706 // When handles as passed directly we don't have to allocate extra
7707 // space for and pass an out parameter.
7708 __ mov(Operand(esp, 0 * kPointerSize), ebx); // name.
7709 __ mov(Operand(esp, 1 * kPointerSize), eax); // arguments pointer.
7710 } else {
7711 // The function expects three arguments to be passed but we allocate
7712 // four to get space for the output cell. The argument slots are filled
7713 // as follows:
7714 //
7715 // 3: output cell
7716 // 2: arguments pointer
7717 // 1: name
7718 // 0: pointer to the output cell
7719 //
7720 // Note that this is one more "argument" than the function expects
7721 // so the out cell will have to be popped explicitly after returning
7722 // from the function.
7723 __ mov(Operand(esp, 1 * kPointerSize), ebx); // name.
7724 __ mov(Operand(esp, 2 * kPointerSize), eax); // arguments pointer.
7725 __ mov(ebx, esp);
7726 __ add(Operand(ebx), Immediate(3 * kPointerSize));
7727 __ mov(Operand(esp, 0 * kPointerSize), ebx); // output
7728 __ mov(Operand(esp, 3 * kPointerSize), Immediate(0)); // out cell.
7729 }
7730 // Call the api function!
7731 __ call(fun()->address(), RelocInfo::RUNTIME_ENTRY);
7732 // Check if the function scheduled an exception.
7733 ExternalReference scheduled_exception_address =
7734 ExternalReference::scheduled_exception_address();
7735 __ cmp(Operand::StaticVariable(scheduled_exception_address),
7736 Immediate(Factory::the_hole_value()));
7737 __ j(not_equal, &promote_scheduled_exception, not_taken);
7738 if (!kPassHandlesDirectly) {
7739 // The returned value is a pointer to the handle holding the result.
7740 // Dereference this to get to the location.
7741 __ mov(eax, Operand(eax, 0));
7742 }
7743 // Check if the result handle holds 0
7744 __ test(eax, Operand(eax));
7745 __ j(not_zero, &get_result, taken);
7746 // It was zero; the result is undefined.
7747 __ mov(eax, Factory::undefined_value());
7748 __ jmp(&prologue);
7749 // It was non-zero. Dereference to get the result value.
7750 __ bind(&get_result);
7751 __ mov(eax, Operand(eax, 0));
7752 __ bind(&prologue);
7753 __ LeaveExitFrame(ExitFrame::MODE_NORMAL);
7754 __ ret(0);
7755 __ bind(&promote_scheduled_exception);
7756 __ TailCallRuntime(ExternalReference(Runtime::kPromoteScheduledException),
7757 0,
7758 1);
7759 }
7760
7761
7689 void CEntryStub::GenerateCore(MacroAssembler* masm, 7762 void CEntryStub::GenerateCore(MacroAssembler* masm,
7690 Label* throw_normal_exception, 7763 Label* throw_normal_exception,
7691 Label* throw_termination_exception, 7764 Label* throw_termination_exception,
7692 Label* throw_out_of_memory_exception, 7765 Label* throw_out_of_memory_exception,
7693 StackFrame::Type frame_type, 7766 ExitFrame::Mode mode,
7694 bool do_gc, 7767 bool do_gc,
7695 bool always_allocate_scope) { 7768 bool always_allocate_scope) {
7696 // eax: result parameter for PerformGC, if any 7769 // eax: result parameter for PerformGC, if any
7697 // ebx: pointer to C function (C callee-saved) 7770 // ebx: pointer to C function (C callee-saved)
7698 // ebp: frame pointer (restored after C call) 7771 // ebp: frame pointer (restored after C call)
7699 // esp: stack pointer (restored after C call) 7772 // esp: stack pointer (restored after C call)
7700 // edi: number of arguments including receiver (C callee-saved) 7773 // edi: number of arguments including receiver (C callee-saved)
7701 // esi: pointer to the first argument (C callee-saved) 7774 // esi: pointer to the first argument (C callee-saved)
7702 7775
7703 if (do_gc) { 7776 if (do_gc) {
(...skipping 29 matching lines...) Expand all
7733 7806
7734 // Check for failure result. 7807 // Check for failure result.
7735 Label failure_returned; 7808 Label failure_returned;
7736 ASSERT(((kFailureTag + 1) & kFailureTagMask) == 0); 7809 ASSERT(((kFailureTag + 1) & kFailureTagMask) == 0);
7737 __ lea(ecx, Operand(eax, 1)); 7810 __ lea(ecx, Operand(eax, 1));
7738 // Lower 2 bits of ecx are 0 iff eax has failure tag. 7811 // Lower 2 bits of ecx are 0 iff eax has failure tag.
7739 __ test(ecx, Immediate(kFailureTagMask)); 7812 __ test(ecx, Immediate(kFailureTagMask));
7740 __ j(zero, &failure_returned, not_taken); 7813 __ j(zero, &failure_returned, not_taken);
7741 7814
7742 // Exit the JavaScript to C++ exit frame. 7815 // Exit the JavaScript to C++ exit frame.
7743 __ LeaveExitFrame(frame_type); 7816 __ LeaveExitFrame(mode);
7744 __ ret(0); 7817 __ ret(0);
7745 7818
7746 // Handling of failure. 7819 // Handling of failure.
7747 __ bind(&failure_returned); 7820 __ bind(&failure_returned);
7748 7821
7749 Label retry; 7822 Label retry;
7750 // If the returned exception is RETRY_AFTER_GC continue at retry label 7823 // If the returned exception is RETRY_AFTER_GC continue at retry label
7751 ASSERT(Failure::RETRY_AFTER_GC == 0); 7824 ASSERT(Failure::RETRY_AFTER_GC == 0);
7752 __ test(eax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); 7825 __ test(eax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize));
7753 __ j(zero, &retry, taken); 7826 __ j(zero, &retry, taken);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
7832 // ebx: pointer to C function (C callee-saved) 7905 // ebx: pointer to C function (C callee-saved)
7833 // ebp: frame pointer (restored after C call) 7906 // ebp: frame pointer (restored after C call)
7834 // esp: stack pointer (restored after C call) 7907 // esp: stack pointer (restored after C call)
7835 // esi: current context (C callee-saved) 7908 // esi: current context (C callee-saved)
7836 // edi: JS function of the caller (C callee-saved) 7909 // edi: JS function of the caller (C callee-saved)
7837 7910
7838 // NOTE: Invocations of builtins may return failure objects instead 7911 // NOTE: Invocations of builtins may return failure objects instead
7839 // of a proper result. The builtin entry handles this by performing 7912 // of a proper result. The builtin entry handles this by performing
7840 // a garbage collection and retrying the builtin (twice). 7913 // a garbage collection and retrying the builtin (twice).
7841 7914
7842 StackFrame::Type frame_type = is_debug_break ? 7915 ExitFrame::Mode mode = is_debug_break
7843 StackFrame::EXIT_DEBUG : 7916 ? ExitFrame::MODE_DEBUG
7844 StackFrame::EXIT; 7917 : ExitFrame::MODE_NORMAL;
7845 7918
7846 // Enter the exit frame that transitions from JavaScript to C++. 7919 // Enter the exit frame that transitions from JavaScript to C++.
7847 __ EnterExitFrame(frame_type); 7920 __ EnterExitFrame(mode);
7848 7921
7849 // eax: result parameter for PerformGC, if any (setup below) 7922 // eax: result parameter for PerformGC, if any (setup below)
7850 // ebx: pointer to builtin function (C callee-saved) 7923 // ebx: pointer to builtin function (C callee-saved)
7851 // ebp: frame pointer (restored after C call) 7924 // ebp: frame pointer (restored after C call)
7852 // esp: stack pointer (restored after C call) 7925 // esp: stack pointer (restored after C call)
7853 // edi: number of arguments including receiver (C callee-saved) 7926 // edi: number of arguments including receiver (C callee-saved)
7854 // esi: argv pointer (C callee-saved) 7927 // esi: argv pointer (C callee-saved)
7855 7928
7856 Label throw_normal_exception; 7929 Label throw_normal_exception;
7857 Label throw_termination_exception; 7930 Label throw_termination_exception;
7858 Label throw_out_of_memory_exception; 7931 Label throw_out_of_memory_exception;
7859 7932
7860 // Call into the runtime system. 7933 // Call into the runtime system.
7861 GenerateCore(masm, 7934 GenerateCore(masm,
7862 &throw_normal_exception, 7935 &throw_normal_exception,
7863 &throw_termination_exception, 7936 &throw_termination_exception,
7864 &throw_out_of_memory_exception, 7937 &throw_out_of_memory_exception,
7865 frame_type, 7938 mode,
7866 false, 7939 false,
7867 false); 7940 false);
7868 7941
7869 // Do space-specific GC and retry runtime call. 7942 // Do space-specific GC and retry runtime call.
7870 GenerateCore(masm, 7943 GenerateCore(masm,
7871 &throw_normal_exception, 7944 &throw_normal_exception,
7872 &throw_termination_exception, 7945 &throw_termination_exception,
7873 &throw_out_of_memory_exception, 7946 &throw_out_of_memory_exception,
7874 frame_type, 7947 mode,
7875 true, 7948 true,
7876 false); 7949 false);
7877 7950
7878 // Do full GC and retry runtime call one final time. 7951 // Do full GC and retry runtime call one final time.
7879 Failure* failure = Failure::InternalError(); 7952 Failure* failure = Failure::InternalError();
7880 __ mov(eax, Immediate(reinterpret_cast<int32_t>(failure))); 7953 __ mov(eax, Immediate(reinterpret_cast<int32_t>(failure)));
7881 GenerateCore(masm, 7954 GenerateCore(masm,
7882 &throw_normal_exception, 7955 &throw_normal_exception,
7883 &throw_termination_exception, 7956 &throw_termination_exception,
7884 &throw_out_of_memory_exception, 7957 &throw_out_of_memory_exception,
7885 frame_type, 7958 mode,
7886 true, 7959 true,
7887 true); 7960 true);
7888 7961
7889 __ bind(&throw_out_of_memory_exception); 7962 __ bind(&throw_out_of_memory_exception);
7890 GenerateThrowUncatchable(masm, OUT_OF_MEMORY); 7963 GenerateThrowUncatchable(masm, OUT_OF_MEMORY);
7891 7964
7892 __ bind(&throw_termination_exception); 7965 __ bind(&throw_termination_exception);
7893 GenerateThrowUncatchable(masm, TERMINATION); 7966 GenerateThrowUncatchable(masm, TERMINATION);
7894 7967
7895 __ bind(&throw_normal_exception); 7968 __ bind(&throw_normal_exception);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
8055 8128
8056 int CompareStub::MinorKey() { 8129 int CompareStub::MinorKey() {
8057 // Encode the two parameters in a unique 16 bit value. 8130 // Encode the two parameters in a unique 16 bit value.
8058 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); 8131 ASSERT(static_cast<unsigned>(cc_) < (1 << 15));
8059 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); 8132 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0);
8060 } 8133 }
8061 8134
8062 #undef __ 8135 #undef __
8063 8136
8064 } } // namespace v8::internal 8137 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/handles.cc ('k') | src/ia32/frames-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698