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

Side by Side Diff: src/builtins/arm64/builtins-arm64.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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_ARM64 5 #if V8_TARGET_ARCH_ARM64
6 6
7 #include "src/arm64/frames-arm64.h" 7 #include "src/arm64/frames-arm64.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
(...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 1439
1440 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { 1440 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) {
1441 // ----------- S t a t e ------------- 1441 // ----------- S t a t e -------------
1442 // -- x0 : argument count (preserved for callee) 1442 // -- x0 : argument count (preserved for callee)
1443 // -- x1 : new target (preserved for callee) 1443 // -- x1 : new target (preserved for callee)
1444 // -- x3 : target function (preserved for callee) 1444 // -- x3 : target function (preserved for callee)
1445 // ----------------------------------- 1445 // -----------------------------------
1446 Label failed; 1446 Label failed;
1447 { 1447 {
1448 FrameScope scope(masm, StackFrame::INTERNAL); 1448 FrameScope scope(masm, StackFrame::INTERNAL);
1449 // Preserve argument count for later compare.
1450 __ Move(x4, x0);
1449 // Push a copy of the target function and the new target. 1451 // Push a copy of the target function and the new target.
1450 __ SmiTag(x0); 1452 __ SmiTag(x0);
1451 // Push another copy as a parameter to the runtime call. 1453 // Push another copy as a parameter to the runtime call.
1452 __ Push(x0, x1, x3, x1); 1454 __ Push(x0, x1, x3, x1);
1453 1455
1454 // Copy arguments from caller (stdlib, foreign, heap). 1456 // Copy arguments from caller (stdlib, foreign, heap).
1455 for (int i = 2; i >= 0; --i) { 1457 Label args_done;
1456 __ ldr(x4, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + 1458 __ cmp(x4, Operand(0));
1457 i * kPointerSize)); 1459 __ B(eq, &args_done);
1458 __ push(x4); 1460
1459 } 1461 Label args2;
1462 __ cmp(x4, Operand(1));
1463 __ B(ne, &args2);
1464 __ ldr(x5, MemOperand(fp, StandardFrameConstants::kCallerSPOffset +
1465 0 * kPointerSize));
1466 __ push(x5);
1467 __ jmp(&args_done);
1468
1469 __ bind(&args2);
1470 Label args3;
1471 __ cmp(x4, Operand(2));
1472 __ B(ne, &args3);
1473 __ ldr(x5, MemOperand(fp, StandardFrameConstants::kCallerSPOffset +
1474 1 * kPointerSize));
1475 __ push(x5);
1476 __ ldr(x5, MemOperand(fp, StandardFrameConstants::kCallerSPOffset +
1477 0 * kPointerSize));
1478 __ push(x5);
1479 __ jmp(&args_done);
1480
1481 __ bind(&args3);
1482 __ ldr(x5, MemOperand(fp, StandardFrameConstants::kCallerSPOffset +
1483 2 * kPointerSize));
1484 __ push(x5);
1485 __ ldr(x5, MemOperand(fp, StandardFrameConstants::kCallerSPOffset +
1486 1 * kPointerSize));
1487 __ push(x5);
1488 __ ldr(x5, MemOperand(fp, StandardFrameConstants::kCallerSPOffset +
1489 0 * kPointerSize));
1490 __ push(x5);
1491 __ bind(&args_done);
1492
1493 // Increment and restore argument count to call runtime method
1494 // with function as extra argument.
1495 __ add(x4, x4, Operand(1));
1496 __ Move(x0, x4);
1460 // Call runtime, on success unwind frame, and parent frame. 1497 // Call runtime, on success unwind frame, and parent frame.
1461 __ CallRuntime(Runtime::kInstantiateAsmJs, 4); 1498 __ CallRuntime(Runtime::kInstantiateAsmJs, -1);
1462 // A smi 0 is returned on failure, an object on success. 1499 // A smi 0 is returned on failure, an object on success.
1463 __ JumpIfSmi(x0, &failed); 1500 __ JumpIfSmi(x0, &failed);
1501
1502 __ pop(x4);
1503 __ pop(x4);
1504 __ pop(x4);
1505 __ SmiUntag(x4);
1464 scope.GenerateLeaveFrame(); 1506 scope.GenerateLeaveFrame();
1465 __ Drop(4); 1507
1508 __ pop(x5);
1509 __ add(x4, x4, Operand(1));
1510 __ add(jssp, jssp, Operand(x4, LSL, kPointerSizeLog2));
1511 __ push(x5);
1466 __ Ret(); 1512 __ Ret();
1467 1513
1468 __ bind(&failed); 1514 __ bind(&failed);
1469 // Restore target function and new target. 1515 // Restore target function and new target.
1470 __ Pop(x3, x1, x0); 1516 __ Pop(x3, x1, x0);
1471 __ SmiUntag(x0); 1517 __ SmiUntag(x0);
1472 } 1518 }
1473 // On failure, tail call back to regular js. 1519 // On failure, tail call back to regular js.
1474 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); 1520 GenerateTailCallToReturnedCode(masm, Runtime::kCompileBaseline);
1475 } 1521 }
1476 1522
1477 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { 1523 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) {
1478 // For now, we are relying on the fact that make_code_young doesn't do any 1524 // For now, we are relying on the fact that make_code_young doesn't do any
1479 // garbage collection which allows us to save/restore the registers without 1525 // garbage collection which allows us to save/restore the registers without
1480 // worrying about which of them contain pointers. We also don't build an 1526 // worrying about which of them contain pointers. We also don't build an
1481 // internal frame to make the code fast, since we shouldn't have to do stack 1527 // internal frame to make the code fast, since we shouldn't have to do stack
1482 // crawls in MakeCodeYoung. This seems a bit fragile. 1528 // crawls in MakeCodeYoung. This seems a bit fragile.
1483 1529
1484 // The following caller-saved registers must be saved and restored when 1530 // The following caller-saved registers must be saved and restored when
(...skipping 1548 matching lines...) Expand 10 before | Expand all | Expand 10 after
3033 __ Unreachable(); 3079 __ Unreachable();
3034 } 3080 }
3035 } 3081 }
3036 3082
3037 #undef __ 3083 #undef __
3038 3084
3039 } // namespace internal 3085 } // namespace internal
3040 } // namespace v8 3086 } // namespace v8
3041 3087
3042 #endif // V8_TARGET_ARCH_ARM 3088 #endif // V8_TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698