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

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

Issue 2229723002: [wasm] Support validation of asm.js modules with != 3 args. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 4 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
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_ARM 5 #if V8_TARGET_ARCH_ARM
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 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 1442
1443 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { 1443 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) {
1444 // ----------- S t a t e ------------- 1444 // ----------- S t a t e -------------
1445 // -- r0 : argument count (preserved for callee) 1445 // -- r0 : argument count (preserved for callee)
1446 // -- r1 : new target (preserved for callee) 1446 // -- r1 : new target (preserved for callee)
1447 // -- r3 : target function (preserved for callee) 1447 // -- r3 : target function (preserved for callee)
1448 // ----------------------------------- 1448 // -----------------------------------
1449 Label failed; 1449 Label failed;
1450 { 1450 {
1451 FrameScope scope(masm, StackFrame::INTERNAL); 1451 FrameScope scope(masm, StackFrame::INTERNAL);
1452 // Preserve argument count for later compare.
1453 __ Move(r4, r0);
1452 // Push the number of arguments to the callee. 1454 // Push the number of arguments to the callee.
1453 __ SmiTag(r0); 1455 __ SmiTag(r0);
1454 __ push(r0); 1456 __ push(r0);
1455 // Push a copy of the target function and the new target. 1457 // Push a copy of the target function and the new target.
1456 __ push(r1); 1458 __ push(r1);
1457 __ push(r3); 1459 __ push(r3);
1458 1460
1459 // The function. 1461 // The function.
1460 __ push(r1); 1462 __ push(r1);
1461 // Copy arguments from caller (stdlib, foreign, heap). 1463 // Copy arguments from caller (stdlib, foreign, heap).
1462 for (int i = 2; i >= 0; --i) { 1464 Label args_done;
1463 __ ldr(r4, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + 1465 __ cmp(r4, Operand(0));
1464 i * kPointerSize)); 1466 __ b(eq, &args_done);
1465 __ push(r4); 1467
1466 } 1468 Label args2;
1469 __ cmp(r4, Operand(1));
1470 __ b(ne, &args2);
1471 __ ldr(r5, MemOperand(fp, StandardFrameConstants::kCallerSPOffset +
1472 0 * kPointerSize));
1473 __ push(r5);
1474 __ jmp(&args_done);
1475
1476 __ bind(&args2);
1477 Label args3;
1478 __ cmp(r4, Operand(2));
1479 __ b(ne, &args3);
1480 __ ldr(r5, MemOperand(fp, StandardFrameConstants::kCallerSPOffset +
1481 1 * kPointerSize));
1482 __ push(r5);
1483 __ ldr(r5, MemOperand(fp, StandardFrameConstants::kCallerSPOffset +
1484 0 * kPointerSize));
1485 __ push(r5);
1486 __ jmp(&args_done);
1487
1488 __ bind(&args3);
1489 __ ldr(r5, MemOperand(fp, StandardFrameConstants::kCallerSPOffset +
1490 2 * kPointerSize));
1491 __ push(r5);
1492 __ ldr(r5, MemOperand(fp, StandardFrameConstants::kCallerSPOffset +
1493 1 * kPointerSize));
1494 __ push(r5);
1495 __ ldr(r5, MemOperand(fp, StandardFrameConstants::kCallerSPOffset +
1496 0 * kPointerSize));
1497 __ push(r5);
1498 __ bind(&args_done);
1499
1500 // Increment and restore argument count to call runtime method
1501 // with function as extra argument.
1502 __ add(r4, r4, Operand(1));
1503 __ Move(r0, r4);
1467 // Call runtime, on success unwind frame, and parent frame. 1504 // Call runtime, on success unwind frame, and parent frame.
1468 __ CallRuntime(Runtime::kInstantiateAsmJs, 4); 1505 __ CallRuntime(Runtime::kInstantiateAsmJs, -1);
1469 // A smi 0 is returned on failure, an object on success. 1506 // A smi 0 is returned on failure, an object on success.
1470 __ JumpIfSmi(r0, &failed); 1507 __ JumpIfSmi(r0, &failed);
1508
1509 __ pop(r4);
1510 __ pop(r4);
1511 __ pop(r4);
1512 __ SmiUntag(r4);
1471 scope.GenerateLeaveFrame(); 1513 scope.GenerateLeaveFrame();
1472 __ Drop(4); 1514
1515 __ pop(r5);
1516 __ add(r4, r4, Operand(1));
1517 __ add(sp, sp, Operand(r4, LSL, kPointerSizeLog2));
1518 __ push(r5);
1473 __ Ret(); 1519 __ Ret();
1474 1520
1475 __ bind(&failed); 1521 __ bind(&failed);
1476 // Restore target function and new target. 1522 // Restore target function and new target.
1477 __ pop(r3); 1523 __ pop(r3);
1478 __ pop(r1); 1524 __ pop(r1);
1479 __ pop(r0); 1525 __ pop(r0);
1480 __ SmiUntag(r0); 1526 __ SmiUntag(r0);
1481 } 1527 }
1482 // On failure, tail call back to regular js. 1528 // On failure, tail call back to regular js.
1483 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); 1529 GenerateTailCallToReturnedCode(masm, Runtime::kCompileBaseline);
1484 } 1530 }
1485 1531
1486 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { 1532 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) {
1487 // For now, we are relying on the fact that make_code_young doesn't do any 1533 // For now, we are relying on the fact that make_code_young doesn't do any
1488 // garbage collection which allows us to save/restore the registers without 1534 // garbage collection which allows us to save/restore the registers without
1489 // worrying about which of them contain pointers. We also don't build an 1535 // worrying about which of them contain pointers. We also don't build an
1490 // internal frame to make the code faster, since we shouldn't have to do stack 1536 // internal frame to make the code faster, since we shouldn't have to do stack
1491 // crawls in MakeCodeYoung. This seems a bit fragile. 1537 // crawls in MakeCodeYoung. This seems a bit fragile.
1492 1538
1493 // The following registers must be saved and restored when calling through to 1539 // The following registers must be saved and restored when calling through to
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
2919 __ bkpt(0); 2965 __ bkpt(0);
2920 } 2966 }
2921 } 2967 }
2922 2968
2923 #undef __ 2969 #undef __
2924 2970
2925 } // namespace internal 2971 } // namespace internal
2926 } // namespace v8 2972 } // namespace v8
2927 2973
2928 #endif // V8_TARGET_ARCH_ARM 2974 #endif // V8_TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698