Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_ARM | 7 #if V8_TARGET_ARCH_ARM |
| 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, | 23 void Builtins::Generate_Adaptor(MacroAssembler* masm, |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 862 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { | 863 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { |
| 863 Generate_JSEntryTrampolineHelper(masm, false); | 864 Generate_JSEntryTrampolineHelper(masm, false); |
| 864 } | 865 } |
| 865 | 866 |
| 866 | 867 |
| 867 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { | 868 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { |
| 868 Generate_JSEntryTrampolineHelper(masm, true); | 869 Generate_JSEntryTrampolineHelper(masm, true); |
| 869 } | 870 } |
| 870 | 871 |
| 871 | 872 |
| 873 // Generate code for entering a JS function with the interpreter. | |
| 874 // On entry to the function the receiver and arguments have been pushed on the | |
| 875 // stack left to right. The actual argument count matches the formal parameter | |
| 876 // count expected by the function. | |
| 877 // | |
| 878 // The live registers are: | |
| 879 // o r1: the JS function object being called. | |
| 880 // o cp: the context | |
| 881 // o pp: the caller's constant pool pointer (if enabled) | |
| 882 // o fp: the caller's frame pointer | |
| 883 // o sp: stack pointer | |
| 884 // o lr: return address | |
| 885 // | |
| 886 // The function builds a JS frame. Please see JavaScriptFrameConstants in | |
| 887 // frames-arm.h for its layout. | |
| 888 // TODO(rmcilroy): We will need to include the current bytecode pointer in the | |
| 889 // frame. | |
| 890 void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { | |
| 891 // Open a frame scope to indicate that there is a frame on the stack. The | |
| 892 // MANUAL indicates that the scope shouldn't actually generate code to set up | |
| 893 // the frame (that is done below). | |
| 894 FrameScope frame_scope(masm, StackFrame::MANUAL); | |
| 895 | |
| 896 __ PushFixedFrame(r1); | |
| 897 __ add(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp)); | |
| 898 | |
| 899 // Get the bytecode array from the function object and load the pointer to the | |
| 900 // first entry into kInterpreterBytecodeRegister. | |
| 901 __ ldr(r0, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); | |
| 902 __ ldr(kInterpreterBytecodeArrayRegister, | |
| 903 FieldMemOperand(r0, SharedFunctionInfo::kFunctionDataOffset)); | |
| 904 | |
| 905 if (FLAG_debug_code) { | |
| 906 // Check function data field is actually a BytecodeArray object. | |
| 907 __ SmiTst(kInterpreterBytecodeArrayRegister); | |
| 908 __ Assert(ne, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); | |
| 909 __ CompareObjectType(kInterpreterBytecodeArrayRegister, r0, no_reg, | |
| 910 BYTECODE_ARRAY_TYPE); | |
| 911 __ Assert(eq, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); | |
| 912 } | |
| 913 | |
| 914 // Allocate the local and temporary register file on the stack. | |
| 915 { | |
| 916 // Load frame size from the BytecodeArray object. | |
| 917 __ ldr(r4, FieldMemOperand(kInterpreterBytecodeArrayRegister, | |
| 918 BytecodeArray::kFrameSizeOffset)); | |
| 919 | |
| 920 // Do a stack check to ensure we don't go over the limit. | |
| 921 Label ok; | |
| 922 __ sub(r9, sp, Operand(r4)); | |
| 923 __ LoadRoot(r2, Heap::kRealStackLimitRootIndex); | |
| 924 __ cmp(r9, Operand(r2)); | |
| 925 __ b(hs, &ok); | |
| 926 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION); | |
| 927 __ bind(&ok); | |
| 928 | |
| 929 // If ok, push undefined as the initial value for all register file entries. | |
| 930 // Note: there should always be at least one stack slot for the return | |
| 931 // register in the register file. | |
| 932 Label loop_header; | |
| 933 __ LoadRoot(r9, Heap::kUndefinedValueRootIndex); | |
| 934 __ bind(&loop_header); | |
| 935 // TODO(rmcilroy): Consider doing more than one push per loop iteration. | |
| 936 __ push(r9); | |
| 937 // Continue loop if not done. | |
| 938 __ sub(r4, r4, Operand(kPointerSize), SetCC); | |
| 939 __ b(&loop_header, ne); | |
| 940 } | |
| 941 | |
| 942 // TODO(rmcilroy): List of things not currently dealt with here but done in | |
| 943 // fullcodegen's prologue. | |
| 944 // - Support profiler (specifically profiling_counter). | |
| 945 // - Call ProfileEntryHookStub when isolate has a function_entry_hook. | |
| 946 // - Allow simulator stop operations if FLAG_stop_at is set. | |
| 947 // - Deal with sloppy mode functions which need to replace the | |
| 948 // receiver with the global proxy when called as functions (without an | |
| 949 // explicit receiver object). | |
| 950 // - Code aging of the BytecodeArray object. | |
| 951 // - Allocating a new local context if applicable. | |
|
Benedikt Meurer
2015/07/28 13:06:53
Note: This should be explicit as in TurboFan.
rmcilroy
2015/07/30 07:18:15
Agreed, this was already my plan :). Rearranged th
| |
| 952 // - Setting up a local binding to the this function, which is used in | |
| 953 // derived constructors with super calls. | |
| 954 // - Setting new.target if required. | |
| 955 // - Dealing with REST parameters (only if | |
| 956 // https://codereview.chromium.org/1235153006 doesn't land by then). | |
| 957 // - Dealing with argument objects. | |
| 958 // - Supporting FLAG_trace. | |
| 959 // These should all either be added here or added as specific bytecodes in the | |
| 960 // BytecodeArray. | |
| 961 | |
| 962 // Perform stack guard check. | |
| 963 { | |
| 964 Label ok; | |
| 965 __ LoadRoot(ip, Heap::kStackLimitRootIndex); | |
| 966 __ cmp(sp, Operand(ip)); | |
| 967 __ b(hs, &ok); | |
| 968 __ CallRuntime(Runtime::kStackGuard, 0); | |
| 969 __ bind(&ok); | |
| 970 } | |
| 971 | |
| 972 // Load bytecode offset and dispatch table into registers. | |
| 973 __ mov(kInterpreterBytecodeOffsetRegister, | |
| 974 Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); | |
| 975 __ LoadRoot(kInterpreterDispatchTableRegister, | |
| 976 Heap::kInterpreterTableRootIndex); | |
| 977 __ add(kInterpreterDispatchTableRegister, kInterpreterDispatchTableRegister, | |
| 978 Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | |
| 979 | |
| 980 // Dispatch to the first bytecode handler for the function. | |
| 981 __ ldrb(r0, MemOperand(kInterpreterBytecodeArrayRegister, | |
| 982 kInterpreterBytecodeOffsetRegister)); | |
| 983 __ mov(r0, Operand(r0, LSL, kPointerSizeLog2)); | |
| 984 __ ldr(ip, MemOperand(kInterpreterDispatchTableRegister, r0)); | |
| 985 // TODO(rmcilroy): Make dispatch table point to code entrys to avoid untagging | |
| 986 // and header removal. | |
| 987 __ add(ip, ip, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
| 988 __ Jump(ip); | |
| 989 } | |
| 990 | |
| 991 | |
| 992 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { | |
| 993 // TODO(rmcilroy): List of things not currently dealt with here but done in | |
| 994 // fullcodegen's EmitReturnSequence. | |
| 995 // - Supporting FLAG_trace for Runtime::TraceExit. | |
| 996 // - Support profiler (specifically decrementing profiling_counter | |
| 997 // appropriately and calling out to HandleInterrupts if necessary). | |
| 998 // These should all either be added here or added as specific bytecodes in the | |
| 999 // BytecodeArray. | |
| 1000 | |
| 1001 // Load return value into r0. | |
| 1002 __ ldr(r0, MemOperand(fp, -kPointerSize - | |
| 1003 StandardFrameConstants::kFixedFrameSizeFromFp)); | |
| 1004 // Leave the frame (also dropping the register file). | |
| 1005 __ LeaveFrame(StackFrame::JAVA_SCRIPT); | |
| 1006 // Drop receiver + arguments. | |
| 1007 __ Drop(1); // TODO(rmcilroy): Get number of arguments from BytecodeArray. | |
| 1008 __ Jump(lr); | |
| 1009 } | |
| 1010 | |
| 1011 | |
| 872 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { | 1012 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
| 873 CallRuntimePassFunction(masm, Runtime::kCompileLazy); | 1013 CallRuntimePassFunction(masm, Runtime::kCompileLazy); |
| 874 GenerateTailCallToReturnedCode(masm); | 1014 GenerateTailCallToReturnedCode(masm); |
| 875 } | 1015 } |
| 876 | 1016 |
| 877 | 1017 |
| 878 static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) { | 1018 static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) { |
| 879 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 1019 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 880 // Push a copy of the function onto the stack. | 1020 // Push a copy of the function onto the stack. |
| 881 __ push(r1); | 1021 __ push(r1); |
| (...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1725 } | 1865 } |
| 1726 } | 1866 } |
| 1727 | 1867 |
| 1728 | 1868 |
| 1729 #undef __ | 1869 #undef __ |
| 1730 | 1870 |
| 1731 } // namespace internal | 1871 } // namespace internal |
| 1732 } // namespace v8 | 1872 } // namespace v8 |
| 1733 | 1873 |
| 1734 #endif // V8_TARGET_ARCH_ARM | 1874 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |