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 | 5 |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #if V8_TARGET_ARCH_MIPS | 9 #if V8_TARGET_ARCH_MIPS |
10 | 10 |
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 __ lw(a1, MemOperand(at)); | 1085 __ lw(a1, MemOperand(at)); |
1086 __ JumpIfSmi(a1, &non_function); | 1086 __ JumpIfSmi(a1, &non_function); |
1087 __ GetObjectType(a1, a2, a2); | 1087 __ GetObjectType(a1, a2, a2); |
1088 __ Branch(&slow, ne, a2, Operand(JS_FUNCTION_TYPE)); | 1088 __ Branch(&slow, ne, a2, Operand(JS_FUNCTION_TYPE)); |
1089 | 1089 |
1090 // 3a. Patch the first argument if necessary when calling a function. | 1090 // 3a. Patch the first argument if necessary when calling a function. |
1091 // a0: actual number of arguments | 1091 // a0: actual number of arguments |
1092 // a1: function | 1092 // a1: function |
1093 Label shift_arguments; | 1093 Label shift_arguments; |
1094 __ li(t0, Operand(0, RelocInfo::NONE32)); // Indicate regular JS_FUNCTION. | 1094 __ li(t0, Operand(0, RelocInfo::NONE32)); // Indicate regular JS_FUNCTION. |
1095 { Label convert_to_object, use_global_receiver, patch_receiver; | 1095 { Label convert_to_object, use_global_proxy, patch_receiver; |
1096 // Change context eagerly in case we need the global receiver. | 1096 // Change context eagerly in case we need the global receiver. |
1097 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); | 1097 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
1098 | 1098 |
1099 // Do not transform the receiver for strict mode functions. | 1099 // Do not transform the receiver for strict mode functions. |
1100 __ lw(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); | 1100 __ lw(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
1101 __ lw(a3, FieldMemOperand(a2, SharedFunctionInfo::kCompilerHintsOffset)); | 1101 __ lw(a3, FieldMemOperand(a2, SharedFunctionInfo::kCompilerHintsOffset)); |
1102 __ And(t3, a3, Operand(1 << (SharedFunctionInfo::kStrictModeFunction + | 1102 __ And(t3, a3, Operand(1 << (SharedFunctionInfo::kStrictModeFunction + |
1103 kSmiTagSize))); | 1103 kSmiTagSize))); |
1104 __ Branch(&shift_arguments, ne, t3, Operand(zero_reg)); | 1104 __ Branch(&shift_arguments, ne, t3, Operand(zero_reg)); |
1105 | 1105 |
1106 // Do not transform the receiver for native (Compilerhints already in a3). | 1106 // Do not transform the receiver for native (Compilerhints already in a3). |
1107 __ And(t3, a3, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize))); | 1107 __ And(t3, a3, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize))); |
1108 __ Branch(&shift_arguments, ne, t3, Operand(zero_reg)); | 1108 __ Branch(&shift_arguments, ne, t3, Operand(zero_reg)); |
1109 | 1109 |
1110 // Compute the receiver in sloppy mode. | 1110 // Compute the receiver in sloppy mode. |
1111 // Load first argument in a2. a2 = -kPointerSize(sp + n_args << 2). | 1111 // Load first argument in a2. a2 = -kPointerSize(sp + n_args << 2). |
1112 __ sll(at, a0, kPointerSizeLog2); | 1112 __ sll(at, a0, kPointerSizeLog2); |
1113 __ addu(a2, sp, at); | 1113 __ addu(a2, sp, at); |
1114 __ lw(a2, MemOperand(a2, -kPointerSize)); | 1114 __ lw(a2, MemOperand(a2, -kPointerSize)); |
1115 // a0: actual number of arguments | 1115 // a0: actual number of arguments |
1116 // a1: function | 1116 // a1: function |
1117 // a2: first argument | 1117 // a2: first argument |
1118 __ JumpIfSmi(a2, &convert_to_object, t2); | 1118 __ JumpIfSmi(a2, &convert_to_object, t2); |
1119 | 1119 |
1120 __ LoadRoot(a3, Heap::kUndefinedValueRootIndex); | 1120 __ LoadRoot(a3, Heap::kUndefinedValueRootIndex); |
1121 __ Branch(&use_global_receiver, eq, a2, Operand(a3)); | 1121 __ Branch(&use_global_proxy, eq, a2, Operand(a3)); |
1122 __ LoadRoot(a3, Heap::kNullValueRootIndex); | 1122 __ LoadRoot(a3, Heap::kNullValueRootIndex); |
1123 __ Branch(&use_global_receiver, eq, a2, Operand(a3)); | 1123 __ Branch(&use_global_proxy, eq, a2, Operand(a3)); |
1124 | 1124 |
1125 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); | 1125 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); |
1126 __ GetObjectType(a2, a3, a3); | 1126 __ GetObjectType(a2, a3, a3); |
1127 __ Branch(&shift_arguments, ge, a3, Operand(FIRST_SPEC_OBJECT_TYPE)); | 1127 __ Branch(&shift_arguments, ge, a3, Operand(FIRST_SPEC_OBJECT_TYPE)); |
1128 | 1128 |
1129 __ bind(&convert_to_object); | 1129 __ bind(&convert_to_object); |
1130 // Enter an internal frame in order to preserve argument count. | 1130 // Enter an internal frame in order to preserve argument count. |
1131 { | 1131 { |
1132 FrameScope scope(masm, StackFrame::INTERNAL); | 1132 FrameScope scope(masm, StackFrame::INTERNAL); |
1133 __ sll(a0, a0, kSmiTagSize); // Smi tagged. | 1133 __ sll(a0, a0, kSmiTagSize); // Smi tagged. |
1134 __ Push(a0, a2); | 1134 __ Push(a0, a2); |
1135 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | 1135 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
1136 __ mov(a2, v0); | 1136 __ mov(a2, v0); |
1137 | 1137 |
1138 __ pop(a0); | 1138 __ pop(a0); |
1139 __ sra(a0, a0, kSmiTagSize); // Un-tag. | 1139 __ sra(a0, a0, kSmiTagSize); // Un-tag. |
1140 // Leave internal frame. | 1140 // Leave internal frame. |
1141 } | 1141 } |
| 1142 |
1142 // Restore the function to a1, and the flag to t0. | 1143 // Restore the function to a1, and the flag to t0. |
1143 __ sll(at, a0, kPointerSizeLog2); | 1144 __ sll(at, a0, kPointerSizeLog2); |
1144 __ addu(at, sp, at); | 1145 __ addu(at, sp, at); |
1145 __ lw(a1, MemOperand(at)); | 1146 __ lw(a1, MemOperand(at)); |
1146 __ li(t0, Operand(0, RelocInfo::NONE32)); | 1147 __ Branch(USE_DELAY_SLOT, &patch_receiver); |
1147 __ Branch(&patch_receiver); | 1148 __ li(t0, Operand(0, RelocInfo::NONE32)); // In delay slot. |
1148 | 1149 |
1149 __ bind(&use_global_receiver); | 1150 __ bind(&use_global_proxy); |
1150 __ lw(a2, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX)); | 1151 __ lw(a2, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX)); |
1151 __ lw(a2, FieldMemOperand(a2, GlobalObject::kGlobalReceiverOffset)); | 1152 __ lw(a2, FieldMemOperand(a2, GlobalObject::kGlobalProxyOffset)); |
1152 | 1153 |
1153 __ bind(&patch_receiver); | 1154 __ bind(&patch_receiver); |
1154 __ sll(at, a0, kPointerSizeLog2); | 1155 __ sll(at, a0, kPointerSizeLog2); |
1155 __ addu(a3, sp, at); | 1156 __ addu(a3, sp, at); |
1156 __ sw(a2, MemOperand(a3, -kPointerSize)); | 1157 __ sw(a2, MemOperand(a3, -kPointerSize)); |
1157 | 1158 |
1158 __ Branch(&shift_arguments); | 1159 __ Branch(&shift_arguments); |
1159 } | 1160 } |
1160 | 1161 |
1161 // 3b. Check for function proxy. | 1162 // 3b. Check for function proxy. |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 __ GetObjectType(a1, a2, a2); | 1294 __ GetObjectType(a1, a2, a2); |
1294 __ Branch(&push_receiver, ne, a2, Operand(JS_FUNCTION_TYPE)); | 1295 __ Branch(&push_receiver, ne, a2, Operand(JS_FUNCTION_TYPE)); |
1295 | 1296 |
1296 // Change context eagerly to get the right global object if necessary. | 1297 // Change context eagerly to get the right global object if necessary. |
1297 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); | 1298 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
1298 // Load the shared function info while the function is still in a1. | 1299 // Load the shared function info while the function is still in a1. |
1299 __ lw(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); | 1300 __ lw(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
1300 | 1301 |
1301 // Compute the receiver. | 1302 // Compute the receiver. |
1302 // Do not transform the receiver for strict mode functions. | 1303 // Do not transform the receiver for strict mode functions. |
1303 Label call_to_object, use_global_receiver; | 1304 Label call_to_object, use_global_proxy; |
1304 __ lw(a2, FieldMemOperand(a2, SharedFunctionInfo::kCompilerHintsOffset)); | 1305 __ lw(a2, FieldMemOperand(a2, SharedFunctionInfo::kCompilerHintsOffset)); |
1305 __ And(t3, a2, Operand(1 << (SharedFunctionInfo::kStrictModeFunction + | 1306 __ And(t3, a2, Operand(1 << (SharedFunctionInfo::kStrictModeFunction + |
1306 kSmiTagSize))); | 1307 kSmiTagSize))); |
1307 __ Branch(&push_receiver, ne, t3, Operand(zero_reg)); | 1308 __ Branch(&push_receiver, ne, t3, Operand(zero_reg)); |
1308 | 1309 |
1309 // Do not transform the receiver for native (Compilerhints already in a2). | 1310 // Do not transform the receiver for native (Compilerhints already in a2). |
1310 __ And(t3, a2, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize))); | 1311 __ And(t3, a2, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize))); |
1311 __ Branch(&push_receiver, ne, t3, Operand(zero_reg)); | 1312 __ Branch(&push_receiver, ne, t3, Operand(zero_reg)); |
1312 | 1313 |
1313 // Compute the receiver in sloppy mode. | 1314 // Compute the receiver in sloppy mode. |
1314 __ JumpIfSmi(a0, &call_to_object); | 1315 __ JumpIfSmi(a0, &call_to_object); |
1315 __ LoadRoot(a1, Heap::kNullValueRootIndex); | 1316 __ LoadRoot(a1, Heap::kNullValueRootIndex); |
1316 __ Branch(&use_global_receiver, eq, a0, Operand(a1)); | 1317 __ Branch(&use_global_proxy, eq, a0, Operand(a1)); |
1317 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); | 1318 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); |
1318 __ Branch(&use_global_receiver, eq, a0, Operand(a2)); | 1319 __ Branch(&use_global_proxy, eq, a0, Operand(a2)); |
1319 | 1320 |
1320 // Check if the receiver is already a JavaScript object. | 1321 // Check if the receiver is already a JavaScript object. |
1321 // a0: receiver | 1322 // a0: receiver |
1322 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); | 1323 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); |
1323 __ GetObjectType(a0, a1, a1); | 1324 __ GetObjectType(a0, a1, a1); |
1324 __ Branch(&push_receiver, ge, a1, Operand(FIRST_SPEC_OBJECT_TYPE)); | 1325 __ Branch(&push_receiver, ge, a1, Operand(FIRST_SPEC_OBJECT_TYPE)); |
1325 | 1326 |
1326 // Convert the receiver to a regular object. | 1327 // Convert the receiver to a regular object. |
1327 // a0: receiver | 1328 // a0: receiver |
1328 __ bind(&call_to_object); | 1329 __ bind(&call_to_object); |
1329 __ push(a0); | 1330 __ push(a0); |
1330 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | 1331 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
1331 __ mov(a0, v0); // Put object in a0 to match other paths to push_receiver. | 1332 __ mov(a0, v0); // Put object in a0 to match other paths to push_receiver. |
1332 __ Branch(&push_receiver); | 1333 __ Branch(&push_receiver); |
1333 | 1334 |
1334 __ bind(&use_global_receiver); | 1335 __ bind(&use_global_proxy); |
1335 __ lw(a0, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX)); | 1336 __ lw(a0, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX)); |
1336 __ lw(a0, FieldMemOperand(a0, GlobalObject::kGlobalReceiverOffset)); | 1337 __ lw(a0, FieldMemOperand(a0, GlobalObject::kGlobalProxyOffset)); |
1337 | 1338 |
1338 // Push the receiver. | 1339 // Push the receiver. |
1339 // a0: receiver | 1340 // a0: receiver |
1340 __ bind(&push_receiver); | 1341 __ bind(&push_receiver); |
1341 __ push(a0); | 1342 __ push(a0); |
1342 | 1343 |
1343 // Copy all arguments from the array to the stack. | 1344 // Copy all arguments from the array to the stack. |
1344 Label entry, loop; | 1345 Label entry, loop; |
1345 __ lw(a0, MemOperand(fp, kIndexOffset)); | 1346 __ lw(a0, MemOperand(fp, kIndexOffset)); |
1346 __ Branch(&entry); | 1347 __ Branch(&entry); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1571 __ break_(0xCC); | 1572 __ break_(0xCC); |
1572 } | 1573 } |
1573 } | 1574 } |
1574 | 1575 |
1575 | 1576 |
1576 #undef __ | 1577 #undef __ |
1577 | 1578 |
1578 } } // namespace v8::internal | 1579 } } // namespace v8::internal |
1579 | 1580 |
1580 #endif // V8_TARGET_ARCH_MIPS | 1581 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |