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 #if V8_TARGET_ARCH_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
6 | 6 |
7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 __ lw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); | 945 __ lw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); |
946 __ SmiUntag(a2); | 946 __ SmiUntag(a2); |
947 __ Addu(a3, a3, Operand(a2)); | 947 __ Addu(a3, a3, Operand(a2)); |
948 __ li(a2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); | 948 __ li(a2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); |
949 __ sw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); | 949 __ sw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); |
950 __ Move(v0, a1); // Continuation expects generator object in v0. | 950 __ Move(v0, a1); // Continuation expects generator object in v0. |
951 __ Jump(a3); | 951 __ Jump(a3); |
952 } | 952 } |
953 } | 953 } |
954 | 954 |
| 955 static void LeaveInterpreterFrame(MacroAssembler* masm, Register scratch) { |
| 956 Register args_count = scratch; |
| 957 |
| 958 // Get the arguments + receiver count. |
| 959 __ lw(args_count, |
| 960 MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); |
| 961 __ lw(args_count, |
| 962 FieldMemOperand(args_count, BytecodeArray::kParameterSizeOffset)); |
| 963 |
| 964 // Leave the frame (also dropping the register file). |
| 965 __ LeaveFrame(StackFrame::JAVA_SCRIPT); |
| 966 |
| 967 // Drop receiver + arguments. |
| 968 __ Addu(sp, sp, args_count); |
| 969 } |
| 970 |
955 // Generate code for entering a JS function with the interpreter. | 971 // Generate code for entering a JS function with the interpreter. |
956 // On entry to the function the receiver and arguments have been pushed on the | 972 // On entry to the function the receiver and arguments have been pushed on the |
957 // stack left to right. The actual argument count matches the formal parameter | 973 // stack left to right. The actual argument count matches the formal parameter |
958 // count expected by the function. | 974 // count expected by the function. |
959 // | 975 // |
960 // The live registers are: | 976 // The live registers are: |
961 // o a1: the JS function object being called. | 977 // o a1: the JS function object being called. |
962 // o a3: the new target | 978 // o a3: the new target |
963 // o cp: our context | 979 // o cp: our context |
964 // o fp: the caller's frame pointer | 980 // o fp: the caller's frame pointer |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 // Dispatch to the first bytecode handler for the function. | 1063 // Dispatch to the first bytecode handler for the function. |
1048 __ Addu(a0, kInterpreterBytecodeArrayRegister, | 1064 __ Addu(a0, kInterpreterBytecodeArrayRegister, |
1049 kInterpreterBytecodeOffsetRegister); | 1065 kInterpreterBytecodeOffsetRegister); |
1050 __ lbu(a0, MemOperand(a0)); | 1066 __ lbu(a0, MemOperand(a0)); |
1051 __ Lsa(at, kInterpreterDispatchTableRegister, a0, kPointerSizeLog2); | 1067 __ Lsa(at, kInterpreterDispatchTableRegister, a0, kPointerSizeLog2); |
1052 __ lw(at, MemOperand(at)); | 1068 __ lw(at, MemOperand(at)); |
1053 __ Call(at); | 1069 __ Call(at); |
1054 masm->isolate()->heap()->SetInterpreterEntryReturnPCOffset(masm->pc_offset()); | 1070 masm->isolate()->heap()->SetInterpreterEntryReturnPCOffset(masm->pc_offset()); |
1055 | 1071 |
1056 // The return value is in v0. | 1072 // The return value is in v0. |
1057 | 1073 LeaveInterpreterFrame(masm, t0); |
1058 // Get the arguments + reciever count. | |
1059 __ lw(t0, MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); | |
1060 __ lw(t0, FieldMemOperand(t0, BytecodeArray::kParameterSizeOffset)); | |
1061 | |
1062 // Leave the frame (also dropping the register file). | |
1063 __ LeaveFrame(StackFrame::JAVA_SCRIPT); | |
1064 | |
1065 // Drop receiver + arguments and return. | |
1066 __ Addu(sp, sp, t0); | |
1067 __ Jump(ra); | 1074 __ Jump(ra); |
1068 | 1075 |
1069 // Load debug copy of the bytecode array. | 1076 // Load debug copy of the bytecode array. |
1070 __ bind(&load_debug_bytecode_array); | 1077 __ bind(&load_debug_bytecode_array); |
1071 __ lw(kInterpreterBytecodeArrayRegister, | 1078 __ lw(kInterpreterBytecodeArrayRegister, |
1072 FieldMemOperand(debug_info, DebugInfo::kAbstractCodeIndex)); | 1079 FieldMemOperand(debug_info, DebugInfo::kAbstractCodeIndex)); |
1073 __ Branch(&bytecode_array_loaded); | 1080 __ Branch(&bytecode_array_loaded); |
1074 | 1081 |
1075 // If the bytecode array is no longer present, then the underlying function | 1082 // If the bytecode array is no longer present, then the underlying function |
1076 // has been switched to a different kind of code and we heal the closure by | 1083 // has been switched to a different kind of code and we heal the closure by |
1077 // switching the code entry field over to the new code object as well. | 1084 // switching the code entry field over to the new code object as well. |
1078 __ bind(&bytecode_array_not_present); | 1085 __ bind(&bytecode_array_not_present); |
1079 __ LeaveFrame(StackFrame::JAVA_SCRIPT); | 1086 __ LeaveFrame(StackFrame::JAVA_SCRIPT); |
1080 __ lw(t0, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); | 1087 __ lw(t0, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
1081 __ lw(t0, FieldMemOperand(t0, SharedFunctionInfo::kCodeOffset)); | 1088 __ lw(t0, FieldMemOperand(t0, SharedFunctionInfo::kCodeOffset)); |
1082 __ Addu(t0, t0, Operand(Code::kHeaderSize - kHeapObjectTag)); | 1089 __ Addu(t0, t0, Operand(Code::kHeaderSize - kHeapObjectTag)); |
1083 __ sw(t0, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); | 1090 __ sw(t0, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); |
1084 __ RecordWriteCodeEntryField(a1, t0, t1); | 1091 __ RecordWriteCodeEntryField(a1, t0, t1); |
1085 __ Jump(t0); | 1092 __ Jump(t0); |
1086 } | 1093 } |
1087 | 1094 |
| 1095 void Builtins::Generate_InterpreterMarkBaselineOnReturn(MacroAssembler* masm) { |
| 1096 // Save the function and context for call to CompileBaseline. |
| 1097 __ lw(a1, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); |
| 1098 __ lw(kContextRegister, |
| 1099 MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 1100 |
| 1101 // Leave the frame before recompiling for baseline so that we don't count as |
| 1102 // an activation on the stack. |
| 1103 LeaveInterpreterFrame(masm, t0); |
| 1104 |
| 1105 { |
| 1106 FrameScope frame_scope(masm, StackFrame::INTERNAL); |
| 1107 // Push return value. |
| 1108 __ push(v0); |
| 1109 |
| 1110 // Push function as argument and compile for baseline. |
| 1111 __ push(a1); |
| 1112 __ CallRuntime(Runtime::kCompileBaseline); |
| 1113 |
| 1114 // Restore return value. |
| 1115 __ pop(v0); |
| 1116 } |
| 1117 __ Jump(ra); |
| 1118 } |
| 1119 |
1088 // static | 1120 // static |
1089 void Builtins::Generate_InterpreterPushArgsAndCallImpl( | 1121 void Builtins::Generate_InterpreterPushArgsAndCallImpl( |
1090 MacroAssembler* masm, TailCallMode tail_call_mode) { | 1122 MacroAssembler* masm, TailCallMode tail_call_mode) { |
1091 // ----------- S t a t e ------------- | 1123 // ----------- S t a t e ------------- |
1092 // -- a0 : the number of arguments (not including the receiver) | 1124 // -- a0 : the number of arguments (not including the receiver) |
1093 // -- a2 : the address of the first argument to be pushed. Subsequent | 1125 // -- a2 : the address of the first argument to be pushed. Subsequent |
1094 // arguments should be consecutive above this, in the same order as | 1126 // arguments should be consecutive above this, in the same order as |
1095 // they are to be pushed onto the stack. | 1127 // they are to be pushed onto the stack. |
1096 // -- a1 : the target to call (can be any Object). | 1128 // -- a1 : the target to call (can be any Object). |
1097 // ----------------------------------- | 1129 // ----------------------------------- |
(...skipping 1730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2828 } | 2860 } |
2829 } | 2861 } |
2830 | 2862 |
2831 | 2863 |
2832 #undef __ | 2864 #undef __ |
2833 | 2865 |
2834 } // namespace internal | 2866 } // namespace internal |
2835 } // namespace v8 | 2867 } // namespace v8 |
2836 | 2868 |
2837 #endif // V8_TARGET_ARCH_MIPS | 2869 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |