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

Side by Side Diff: src/ppc/builtins-ppc.cc

Issue 1266053002: PPC: [interpreter] Add Interpreter{Entry,Exit}Trampoline builtins. Port c5dd553cf3a44cd8c17958a5951… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « src/ppc/assembler-ppc.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_PPC 7 #if V8_TARGET_ARCH_PPC
8 8
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/debug.h" 10 #include "src/debug.h"
11 #include "src/deoptimizer.h" 11 #include "src/deoptimizer.h"
12 #include "src/full-codegen/full-codegen.h" 12 #include "src/full-codegen/full-codegen.h"
13 #include "src/interpreter/bytecodes.h"
13 #include "src/runtime/runtime.h" 14 #include "src/runtime/runtime.h"
14 15
15 namespace v8 { 16 namespace v8 {
16 namespace internal { 17 namespace internal {
17 18
18 19
19 #define __ ACCESS_MASM(masm) 20 #define __ ACCESS_MASM(masm)
20 21
21 22
22 void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, 23 void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id,
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { 849 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) {
849 Generate_JSEntryTrampolineHelper(masm, false); 850 Generate_JSEntryTrampolineHelper(masm, false);
850 } 851 }
851 852
852 853
853 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { 854 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
854 Generate_JSEntryTrampolineHelper(masm, true); 855 Generate_JSEntryTrampolineHelper(masm, true);
855 } 856 }
856 857
857 858
859 // Generate code for entering a JS function with the interpreter.
860 // On entry to the function the receiver and arguments have been pushed on the
861 // stack left to right. The actual argument count matches the formal parameter
862 // count expected by the function.
863 //
864 // The live registers are:
865 // o r4: the JS function object being called.
866 // o cp: our context
867 // o pp: the caller's constant pool pointer (if enabled)
868 // o fp: the caller's frame pointer
869 // o sp: stack pointer
870 // o lr: return address
871 //
872 // The function builds a JS frame. Please see JavaScriptFrameConstants in
873 // frames-ppc.h for its layout.
874 // TODO(rmcilroy): We will need to include the current bytecode pointer in the
875 // frame.
876 void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
877 // Open a frame scope to indicate that there is a frame on the stack. The
878 // MANUAL indicates that the scope shouldn't actually generate code to set up
879 // the frame (that is done below).
880 FrameScope frame_scope(masm, StackFrame::MANUAL);
881 __ PushFixedFrame(r4);
882 __ addi(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
883
884 // Get the bytecode array from the function object and load the pointer to the
885 // first entry into kInterpreterBytecodeRegister.
886 __ LoadP(r3, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset));
887 __ LoadP(kInterpreterBytecodeArrayRegister,
888 FieldMemOperand(r3, SharedFunctionInfo::kFunctionDataOffset));
889
890 if (FLAG_debug_code) {
891 // Check function data field is actually a BytecodeArray object.
892 __ TestIfSmi(kInterpreterBytecodeArrayRegister, r0);
893 __ Assert(ne, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry);
894 __ CompareObjectType(kInterpreterBytecodeArrayRegister, r3, no_reg,
895 BYTECODE_ARRAY_TYPE);
896 __ Assert(eq, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry);
897 }
898
899 // Allocate the local and temporary register file on the stack.
900 {
901 // Load frame size from the BytecodeArray object.
902 __ LoadP(r5, FieldMemOperand(kInterpreterBytecodeArrayRegister,
903 BytecodeArray::kFrameSizeOffset));
904
905 // Do a stack check to ensure we don't go over the limit.
906 Label ok;
907 __ sub(r6, sp, r5);
908 __ LoadRoot(r0, Heap::kRealStackLimitRootIndex);
909 __ cmp(r6, r0);
910 __ bge(&ok);
911 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION);
912 __ bind(&ok);
913
914 // If ok, push undefined as the initial value for all register file entries.
915 // Note: there should always be at least one stack slot for the return
916 // register in the register file.
917 // TODO(rmcilroy): Consider doing more than one push per loop iteration.
918 Label loop_header;
919 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex);
920 __ ShiftRightImm(r5, r5, Operand(kPointerSizeLog2));
921 __ bind(&loop_header);
922 __ push(r6);
923 __ bdnz(&loop_header);
924 }
925
926 // TODO(rmcilroy): List of things not currently dealt with here but done in
927 // fullcodegen's prologue:
928 // - Support profiler (specifically profiling_counter).
929 // - Call ProfileEntryHookStub when isolate has a function_entry_hook.
930 // - Allow simulator stop operations if FLAG_stop_at is set.
931 // - Deal with sloppy mode functions which need to replace the
932 // receiver with the global proxy when called as functions (without an
933 // explicit receiver object).
934 // - Code aging of the BytecodeArray object.
935 // - Supporting FLAG_trace.
936 //
937 // The following items are also not done here, and will probably be done using
938 // explicit bytecodes instead:
939 // - Allocating a new local context if applicable.
940 // - Setting up a local binding to the this function, which is used in
941 // derived constructors with super calls.
942 // - Setting new.target if required.
943 // - Dealing with REST parameters (only if
944 // https://codereview.chromium.org/1235153006 doesn't land by then).
945 // - Dealing with argument objects.
946
947 // Perform stack guard check.
948 {
949 Label ok;
950 __ LoadRoot(r0, Heap::kStackLimitRootIndex);
951 __ cmp(sp, r0);
952 __ bge(&ok);
953 __ CallRuntime(Runtime::kStackGuard, 0);
954 __ bind(&ok);
955 }
956
957 // Load bytecode offset and dispatch table into registers.
958 __ mov(kInterpreterBytecodeOffsetRegister,
959 Operand(BytecodeArray::kHeaderSize - kHeapObjectTag));
960 __ LoadRoot(kInterpreterDispatchTableRegister,
961 Heap::kInterpreterTableRootIndex);
962 __ addi(kInterpreterDispatchTableRegister, kInterpreterDispatchTableRegister,
963 Operand(FixedArray::kHeaderSize - kHeapObjectTag));
964
965 // Dispatch to the first bytecode handler for the function.
966 __ lbzx(r3, MemOperand(kInterpreterBytecodeArrayRegister,
967 kInterpreterBytecodeOffsetRegister));
968 __ ShiftLeftImm(ip, r3, Operand(kPointerSizeLog2));
969 __ LoadPX(ip, MemOperand(kInterpreterDispatchTableRegister, ip));
970 // TODO(rmcilroy): Make dispatch table point to code entrys to avoid untagging
971 // and header removal.
972 __ addi(ip, ip, Operand(Code::kHeaderSize - kHeapObjectTag));
973 __ Jump(ip);
974 }
975
976
977 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) {
978 // TODO(rmcilroy): List of things not currently dealt with here but done in
979 // fullcodegen's EmitReturnSequence.
980 // - Supporting FLAG_trace for Runtime::TraceExit.
981 // - Support profiler (specifically decrementing profiling_counter
982 // appropriately and calling out to HandleInterrupts if necessary).
983
984 // Load return value into r3.
985 __ LoadP(r3,
986 MemOperand(fp, -kPointerSize -
987 StandardFrameConstants::kFixedFrameSizeFromFp));
988 // Leave the frame (also dropping the register file).
989 __ LeaveFrame(StackFrame::JAVA_SCRIPT);
990 // Drop receiver + arguments.
991 __ Drop(1); // TODO(rmcilroy): Get number of arguments from BytecodeArray.
992 __ blr();
993 }
994
995
858 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { 996 void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
859 CallRuntimePassFunction(masm, Runtime::kCompileLazy); 997 CallRuntimePassFunction(masm, Runtime::kCompileLazy);
860 GenerateTailCallToReturnedCode(masm); 998 GenerateTailCallToReturnedCode(masm);
861 } 999 }
862 1000
863 1001
864 static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) { 1002 static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) {
865 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); 1003 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
866 // Push a copy of the function onto the stack. 1004 // Push a copy of the function onto the stack.
867 // Push function as parameter to the runtime call. 1005 // Push function as parameter to the runtime call.
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
1778 __ bkpt(0); 1916 __ bkpt(0);
1779 } 1917 }
1780 } 1918 }
1781 1919
1782 1920
1783 #undef __ 1921 #undef __
1784 } // namespace internal 1922 } // namespace internal
1785 } // namespace v8 1923 } // namespace v8
1786 1924
1787 #endif // V8_TARGET_ARCH_PPC 1925 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « src/ppc/assembler-ppc.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698