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

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

Powered by Google App Engine
This is Rietveld 408576698