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

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

Issue 1407313004: Adds the possibility of setting a Code object as the callback of a FunctionTemplate. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update. Created 5 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/ic/x87/handler-compiler-x87.cc ('k') | src/mips64/builtins-mips64.cc » ('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 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 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 void Builtins::Generate_NotifySoftDeoptimized(MacroAssembler* masm) { 1138 void Builtins::Generate_NotifySoftDeoptimized(MacroAssembler* masm) {
1139 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); 1139 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT);
1140 } 1140 }
1141 1141
1142 1142
1143 void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { 1143 void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) {
1144 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); 1144 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY);
1145 } 1145 }
1146 1146
1147 1147
1148 // Clobbers {t2, t3, t4, t5}.
1149 static void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver,
1150 Register function_template_info,
1151 Label* receiver_check_failed) {
1152 Register signature = t2;
1153 Register map = t3;
1154 Register constructor = t4;
1155 Register scratch = t5;
1156
1157 // If the receiver is not an object, jump to receiver_check_failed.
1158 __ GetObjectType(receiver, map, scratch);
1159 __ Branch(receiver_check_failed, lo, scratch, Operand(FIRST_JS_OBJECT_TYPE));
1160
1161 // If there is no signature, return the holder.
1162 __ lw(signature, FieldMemOperand(function_template_info,
1163 FunctionTemplateInfo::kSignatureOffset));
1164 Label receiver_check_passed;
1165 __ JumpIfRoot(signature, Heap::kUndefinedValueRootIndex,
1166 &receiver_check_passed);
1167
1168 // Walk the prototype chain.
1169 Label prototype_loop_start;
1170 __ bind(&prototype_loop_start);
1171
1172 // End if the receiver is null or if it's a hidden type.
1173 __ JumpIfRoot(receiver, Heap::kNullValueRootIndex, receiver_check_failed);
1174 __ lw(map, FieldMemOperand(receiver, HeapObject::kMapOffset));
1175 __ lw(scratch, FieldMemOperand(map, Map::kBitField3Offset));
1176 __ DecodeField<Map::IsHiddenPrototype>(scratch);
1177 __ Branch(receiver_check_failed, ne, scratch, Operand(zero_reg));
1178
1179 // Get the constructor, if any.
1180 __ GetMapConstructor(constructor, map, scratch, scratch);
1181 Label next_prototype;
1182 __ Branch(&next_prototype, ne, scratch, Operand(JS_FUNCTION_TYPE));
1183 Register type = constructor;
1184 __ lw(type,
1185 FieldMemOperand(constructor, JSFunction::kSharedFunctionInfoOffset));
1186 __ lw(type, FieldMemOperand(type, SharedFunctionInfo::kFunctionDataOffset));
1187
1188 // Loop through the chain of inheriting function templates.
1189 Label function_template_loop;
1190 __ bind(&function_template_loop);
1191
1192 // If the signatures match, we have a compatible receiver.
1193 __ Branch(&receiver_check_passed, eq, signature, Operand(type),
1194 USE_DELAY_SLOT);
1195
1196 // If the current type is not a FunctionTemplateInfo, load the next prototype
1197 // in the chain.
1198 __ JumpIfSmi(type, &next_prototype);
1199 __ GetObjectType(type, scratch, scratch);
1200 __ Branch(&next_prototype, ne, scratch, Operand(FUNCTION_TEMPLATE_INFO_TYPE));
1201
1202 // Otherwise load the parent function template and iterate.
1203 __ lw(type,
1204 FieldMemOperand(type, FunctionTemplateInfo::kParentTemplateOffset));
1205 __ Branch(&function_template_loop);
1206
1207 // Load the next prototype and iterate.
1208 __ bind(&next_prototype);
1209 __ lw(receiver, FieldMemOperand(map, Map::kPrototypeOffset));
1210 __ Branch(&prototype_loop_start);
1211
1212 __ bind(&receiver_check_passed);
1213 }
1214
1215
1216 void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) {
1217 // ----------- S t a t e -------------
1218 // -- a0 : number of arguments excluding receiver
1219 // -- a1 : callee
1220 // -- ra : return address
1221 // -- sp[0] : last argument
1222 // -- ...
1223 // -- sp[4 * (argc - 1)] : first argument
1224 // -- sp[4 * argc] : receiver
1225 // -----------------------------------
1226
1227 // Load the receiver.
1228 __ sll(at, a0, kPointerSizeLog2);
1229 __ Addu(t8, sp, at);
1230 __ lw(t0, MemOperand(t8));
1231
1232 // Update the receiver if this is a contextual call.
1233 Label set_global_proxy, valid_receiver;
1234 __ JumpIfRoot(t0, Heap::kUndefinedValueRootIndex, &set_global_proxy);
1235
1236 // Load the FunctionTemplateInfo.
1237 __ bind(&valid_receiver);
1238 __ lw(t1, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
1239 __ lw(t1, FieldMemOperand(t1, SharedFunctionInfo::kFunctionDataOffset));
1240
1241 // Do the compatible receiver check.
1242 Label receiver_check_failed;
1243 CompatibleReceiverCheck(masm, t0, t1, &receiver_check_failed);
1244
1245 // Get the callback offset from the FunctionTemplateInfo, and jump to the
1246 // beginning of the code.
1247 __ lw(t2, FieldMemOperand(t1, FunctionTemplateInfo::kCallCodeOffset));
1248 __ lw(t2, FieldMemOperand(t2, CallHandlerInfo::kFastHandlerOffset));
1249 __ Addu(t2, t2, Operand(Code::kHeaderSize - kHeapObjectTag));
1250 __ Jump(t2);
1251
1252 __ bind(&set_global_proxy);
1253 __ LoadGlobalProxy(t0);
1254 __ sw(t0, MemOperand(t8));
1255 __ Branch(&valid_receiver);
1256
1257 // Compatible receiver check failed: throw an Illegal Invocation exception.
1258 __ bind(&receiver_check_failed);
1259 // Drop the arguments (including the receiver);
1260 __ Addu(t8, t8, Operand(kPointerSize));
1261 __ addu(sp, t8, zero_reg);
1262 __ TailCallRuntime(Runtime::kThrowIllegalInvocation, 0, 1);
1263 }
1264
1265
1148 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { 1266 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
1149 // Lookup the function in the JavaScript frame. 1267 // Lookup the function in the JavaScript frame.
1150 __ lw(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1268 __ lw(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1151 { 1269 {
1152 FrameScope scope(masm, StackFrame::INTERNAL); 1270 FrameScope scope(masm, StackFrame::INTERNAL);
1153 // Pass function as argument. 1271 // Pass function as argument.
1154 __ push(a0); 1272 __ push(a0);
1155 __ CallRuntime(Runtime::kCompileForOnStackReplacement, 1); 1273 __ CallRuntime(Runtime::kCompileForOnStackReplacement, 1);
1156 } 1274 }
1157 1275
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
1872 } 1990 }
1873 } 1991 }
1874 1992
1875 1993
1876 #undef __ 1994 #undef __
1877 1995
1878 } // namespace internal 1996 } // namespace internal
1879 } // namespace v8 1997 } // namespace v8
1880 1998
1881 #endif // V8_TARGET_ARCH_MIPS 1999 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/ic/x87/handler-compiler-x87.cc ('k') | src/mips64/builtins-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698