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

Side by Side Diff: src/builtins/mips/builtins-mips.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_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 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 1437
1438 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { 1438 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) {
1439 // ----------- S t a t e ------------- 1439 // ----------- S t a t e -------------
1440 // -- a0 : argument count (preserved for callee) 1440 // -- a0 : argument count (preserved for callee)
1441 // -- a1 : new target (preserved for callee) 1441 // -- a1 : new target (preserved for callee)
1442 // -- a3 : target function (preserved for callee) 1442 // -- a3 : target function (preserved for callee)
1443 // ----------------------------------- 1443 // -----------------------------------
1444 Label failed; 1444 Label failed;
1445 { 1445 {
1446 FrameScope scope(masm, StackFrame::INTERNAL); 1446 FrameScope scope(masm, StackFrame::INTERNAL);
1447 // Preserve argument count for later compare.
1448 __ Move(s4, a0);
1447 // Push a copy of the target function and the new target. 1449 // Push a copy of the target function and the new target.
1448 // Push function as parameter to the runtime call. 1450 // Push function as parameter to the runtime call.
1449 __ SmiTag(a0); 1451 __ SmiTag(a0);
1450 __ Push(a0, a1, a3, a1); 1452 __ Push(a0, a1, a3, a1);
1451 1453
1452 // Copy arguments from caller (stdlib, foreign, heap). 1454 // Copy arguments from caller (stdlib, foreign, heap).
1453 for (int i = 2; i >= 0; --i) { 1455 Label args_done;
1454 __ lw(a3, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + 1456 __ Branch(&args_done, eq, s4, Operand(0));
1455 i * kPointerSize)); 1457
1456 __ push(a3); 1458 Label args2;
1457 } 1459 __ Branch(&args2, ne, s4, Operand(1));
1460 __ lw(a3, MemOperand(fp, StandardFrameConstants::kCallerSPOffset +
1461 0 * kPointerSize));
1462 __ push(a3);
1463 __ jmp(&args_done);
1464
1465 __ bind(&args2);
1466 Label args3;
1467 __ Branch(&args3, ne, s4, Operand(2));
1468 __ lw(a3, MemOperand(fp, StandardFrameConstants::kCallerSPOffset +
1469 1 * kPointerSize));
1470 __ push(a3);
1471 __ lw(a3, Operand(fp, StandardFrameConstants::kCallerSPOffset +
1472 0 * kPointerSize));
1473 __ push(a3);
1474 __ jmp(&args_done);
1475
1476 __ bind(&args3);
1477 __ lw(a3, Operand(fp, StandardFrameConstants::kCallerSPOffset +
1478 2 * kPointerSize));
1479 __ push(a3);
1480 __ lw(a3, Operand(fp, StandardFrameConstants::kCallerSPOffset +
1481 1 * kPointerSize));
1482 __ push(a3);
1483 __ lw(a3, Operand(fp, StandardFrameConstants::kCallerSPOffset +
1484 0 * kPointerSize));
1485 __ push(a3);
1486 __ bind(&args_done);
1487 // Increment and restore argument count to call runtime method
1488 // with function as extra argument.
1489 __ Addu(s4, s4, Operand(1));
1490 __ Move(a0, s4);
1458 // Call runtime, on success unwind frame, and parent frame. 1491 // Call runtime, on success unwind frame, and parent frame.
1459 __ CallRuntime(Runtime::kInstantiateAsmJs, 4); 1492 __ CallRuntime(Runtime::kInstantiateAsmJs, 4);
1460 // A smi 0 is returned on failure, an object on success. 1493 // A smi 0 is returned on failure, an object on success.
1461 __ JumpIfSmi(a0, &failed); 1494 __ JumpIfSmi(a0, &failed);
1495
1496 __ pop(s4);
1497 __ pop(s4);
1498 __ pop(s4);
1499 __ SmiUntag(s4);
1500
1462 scope.GenerateLeaveFrame(); 1501 scope.GenerateLeaveFrame();
1463 __ Drop(4); 1502
1503 __ pop(s3);
1504 __ Addu(s4, s4, Operand(1));
1505 __ Lsa(sp, sp, s4, kPointerSizeLog2);
1506 __ push(s3);
1464 __ Ret(); 1507 __ Ret();
1465 1508
1466 __ bind(&failed); 1509 __ bind(&failed);
1467 // Restore target function and new target. 1510 // Restore target function and new target.
1468 __ Pop(a0, a1, a3); 1511 __ Pop(a0, a1, a3);
1469 __ SmiUntag(a0); 1512 __ SmiUntag(a0);
1470 } 1513 }
1471 // On failure, tail call back to regular js. 1514 // On failure, tail call back to regular js.
1472 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); 1515 GenerateTailCallToReturnedCode(masm, Runtime::kCompileBaseline);
1473 } 1516 }
1474 1517
1475 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { 1518 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) {
1476 // For now, we are relying on the fact that make_code_young doesn't do any 1519 // For now, we are relying on the fact that make_code_young doesn't do any
1477 // garbage collection which allows us to save/restore the registers without 1520 // garbage collection which allows us to save/restore the registers without
1478 // worrying about which of them contain pointers. We also don't build an 1521 // worrying about which of them contain pointers. We also don't build an
1479 // internal frame to make the code faster, since we shouldn't have to do stack 1522 // internal frame to make the code faster, since we shouldn't have to do stack
1480 // crawls in MakeCodeYoung. This seems a bit fragile. 1523 // crawls in MakeCodeYoung. This seems a bit fragile.
1481 1524
1482 // Set a0 to point to the head of the PlatformCodeAge sequence. 1525 // Set a0 to point to the head of the PlatformCodeAge sequence.
(...skipping 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after
3001 __ break_(0xCC); 3044 __ break_(0xCC);
3002 } 3045 }
3003 } 3046 }
3004 3047
3005 #undef __ 3048 #undef __
3006 3049
3007 } // namespace internal 3050 } // namespace internal
3008 } // namespace v8 3051 } // namespace v8
3009 3052
3010 #endif // V8_TARGET_ARCH_MIPS 3053 #endif // V8_TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698