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

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

Issue 1583893002: PPC: [builtins] Sanitize receiver patching for API functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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_PPC 5 #if V8_TARGET_ARCH_PPC
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 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 1204
1205 // Clobbers registers {r7, r8, r9, r10}. 1205 // Clobbers registers {r7, r8, r9, r10}.
1206 void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver, 1206 void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver,
1207 Register function_template_info, 1207 Register function_template_info,
1208 Label* receiver_check_failed) { 1208 Label* receiver_check_failed) {
1209 Register signature = r7; 1209 Register signature = r7;
1210 Register map = r8; 1210 Register map = r8;
1211 Register constructor = r9; 1211 Register constructor = r9;
1212 Register scratch = r10; 1212 Register scratch = r10;
1213 1213
1214 __ CompareObjectType(receiver, map, no_reg, FIRST_JS_OBJECT_TYPE);
1215 __ blt(receiver_check_failed);
1216
1217 // If there is no signature, return the holder. 1214 // If there is no signature, return the holder.
1218 __ LoadP(signature, FieldMemOperand(function_template_info, 1215 __ LoadP(signature, FieldMemOperand(function_template_info,
1219 FunctionTemplateInfo::kSignatureOffset)); 1216 FunctionTemplateInfo::kSignatureOffset));
1220 Label receiver_check_passed; 1217 Label receiver_check_passed;
1221 __ JumpIfRoot(signature, Heap::kUndefinedValueRootIndex, 1218 __ JumpIfRoot(signature, Heap::kUndefinedValueRootIndex,
1222 &receiver_check_passed); 1219 &receiver_check_passed);
1223 1220
1224 // Walk the prototype chain. 1221 // Walk the prototype chain.
1225 Label prototype_loop_start; 1222 Label prototype_loop_start;
1226 __ bind(&prototype_loop_start); 1223 __ bind(&prototype_loop_start);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 // ----------- S t a t e ------------- 1273 // ----------- S t a t e -------------
1277 // -- r3 : number of arguments excluding receiver 1274 // -- r3 : number of arguments excluding receiver
1278 // -- r4 : callee 1275 // -- r4 : callee
1279 // -- lr : return address 1276 // -- lr : return address
1280 // -- sp[0] : last argument 1277 // -- sp[0] : last argument
1281 // -- ... 1278 // -- ...
1282 // -- sp[4 * (argc - 1)] : first argument 1279 // -- sp[4 * (argc - 1)] : first argument
1283 // -- sp[4 * argc] : receiver 1280 // -- sp[4 * argc] : receiver
1284 // ----------------------------------- 1281 // -----------------------------------
1285 1282
1286 // Load the receiver.
1287 __ ShiftLeftImm(r11, r3, Operand(kPointerSizeLog2));
1288 __ LoadPX(r5, MemOperand(sp, r11));
1289
1290 // Update the receiver if this is a contextual call.
1291 Label set_global_proxy, valid_receiver;
1292 __ JumpIfRoot(r5, Heap::kUndefinedValueRootIndex, &set_global_proxy);
1293 1283
1294 // Load the FunctionTemplateInfo. 1284 // Load the FunctionTemplateInfo.
1295 __ bind(&valid_receiver);
1296 __ LoadP(r6, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); 1285 __ LoadP(r6, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset));
1297 __ LoadP(r6, FieldMemOperand(r6, SharedFunctionInfo::kFunctionDataOffset)); 1286 __ LoadP(r6, FieldMemOperand(r6, SharedFunctionInfo::kFunctionDataOffset));
1298 1287
1299 // Do the compatible receiver check. 1288 // Do the compatible receiver check.
1300 Label receiver_check_failed; 1289 Label receiver_check_failed;
1290 __ ShiftLeftImm(r11, r3, Operand(kPointerSizeLog2));
1291 __ LoadPX(r5, MemOperand(sp, r11));
1301 CompatibleReceiverCheck(masm, r5, r6, &receiver_check_failed); 1292 CompatibleReceiverCheck(masm, r5, r6, &receiver_check_failed);
1302 1293
1303 // Get the callback offset from the FunctionTemplateInfo, and jump to the 1294 // Get the callback offset from the FunctionTemplateInfo, and jump to the
1304 // beginning of the code. 1295 // beginning of the code.
1305 __ LoadP(r7, FieldMemOperand(r6, FunctionTemplateInfo::kCallCodeOffset)); 1296 __ LoadP(r7, FieldMemOperand(r6, FunctionTemplateInfo::kCallCodeOffset));
1306 __ LoadP(r7, FieldMemOperand(r7, CallHandlerInfo::kFastHandlerOffset)); 1297 __ LoadP(r7, FieldMemOperand(r7, CallHandlerInfo::kFastHandlerOffset));
1307 __ addi(ip, r7, Operand(Code::kHeaderSize - kHeapObjectTag)); 1298 __ addi(ip, r7, Operand(Code::kHeaderSize - kHeapObjectTag));
1308 __ JumpToJSEntry(ip); 1299 __ JumpToJSEntry(ip);
1309 1300
1310 __ bind(&set_global_proxy);
1311 __ LoadGlobalProxy(r5);
1312 __ StorePX(r5, MemOperand(sp, r11));
1313 __ b(&valid_receiver);
1314
1315 // Compatible receiver check failed: throw an Illegal Invocation exception. 1301 // Compatible receiver check failed: throw an Illegal Invocation exception.
1316 __ bind(&receiver_check_failed); 1302 __ bind(&receiver_check_failed);
1317 // Drop the arguments (including the receiver); 1303 // Drop the arguments (including the receiver);
1318 __ addi(r11, r11, Operand(kPointerSize)); 1304 __ addi(r11, r11, Operand(kPointerSize));
1319 __ add(sp, sp, r11); 1305 __ add(sp, sp, r11);
1320 __ TailCallRuntime(Runtime::kThrowIllegalInvocation); 1306 __ TailCallRuntime(Runtime::kThrowIllegalInvocation);
1321 } 1307 }
1322 1308
1323 1309
1324 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { 1310 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
2422 __ bkpt(0); 2408 __ bkpt(0);
2423 } 2409 }
2424 } 2410 }
2425 2411
2426 2412
2427 #undef __ 2413 #undef __
2428 } // namespace internal 2414 } // namespace internal
2429 } // namespace v8 2415 } // namespace v8
2430 2416
2431 #endif // V8_TARGET_ARCH_PPC 2417 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698