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

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

Powered by Google App Engine
This is Rietveld 408576698