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

Side by Side Diff: test/cctest/wasm/wasm-run-utils.h

Issue 2438603003: [wasm] Track in the interpreter if a NaN could have been produced. (Closed)
Patch Set: Fixed nits. Created 4 years, 2 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 | « test/cctest/wasm/test-run-wasm-interpreter.cc ('k') | test/common/wasm/wasm-module-runner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 #ifndef WASM_RUN_UTILS_H 5 #ifndef WASM_RUN_UTILS_H
6 #define WASM_RUN_UTILS_H 6 #define WASM_RUN_UTILS_H
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 } 619 }
620 620
621 WasmRunner(TestingModule* module, MachineType p0 = MachineType::None(), 621 WasmRunner(TestingModule* module, MachineType p0 = MachineType::None(),
622 MachineType p1 = MachineType::None(), 622 MachineType p1 = MachineType::None(),
623 MachineType p2 = MachineType::None(), 623 MachineType p2 = MachineType::None(),
624 MachineType p3 = MachineType::None()) 624 MachineType p3 = MachineType::None())
625 : zone(&allocator_, ZONE_NAME), 625 : zone(&allocator_, ZONE_NAME),
626 compiled_(false), 626 compiled_(false),
627 signature_(MachineTypeForC<ReturnType>() == MachineType::None() ? 0 : 1, 627 signature_(MachineTypeForC<ReturnType>() == MachineType::None() ? 0 : 1,
628 GetParameterCount(p0, p1, p2, p3), storage_), 628 GetParameterCount(p0, p1, p2, p3), storage_),
629 compiler_(&signature_, module) { 629 compiler_(&signature_, module),
630 possible_nondeterminism_(false) {
630 DCHECK(module); 631 DCHECK(module);
631 InitSigStorage(p0, p1, p2, p3); 632 InitSigStorage(p0, p1, p2, p3);
632 } 633 }
633 634
634 void InitSigStorage(MachineType p0, MachineType p1, MachineType p2, 635 void InitSigStorage(MachineType p0, MachineType p1, MachineType p2,
635 MachineType p3) { 636 MachineType p3) {
636 int index = 0; 637 int index = 0;
637 MachineType ret = MachineTypeForC<ReturnType>(); 638 MachineType ret = MachineTypeForC<ReturnType>();
638 if (ret != MachineType::None()) { 639 if (ret != MachineType::None()) {
639 storage_[index++] = WasmOpcodes::LocalTypeFor(ret); 640 storage_[index++] = WasmOpcodes::LocalTypeFor(ret);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 } 730 }
730 731
731 ReturnType CallInterpreter(Vector<WasmVal> args) { 732 ReturnType CallInterpreter(Vector<WasmVal> args) {
732 CHECK_EQ(args.length(), 733 CHECK_EQ(args.length(),
733 static_cast<int>(compiler_.function_->sig->parameter_count())); 734 static_cast<int>(compiler_.function_->sig->parameter_count()));
734 WasmInterpreter::Thread* thread = interpreter()->GetThread(0); 735 WasmInterpreter::Thread* thread = interpreter()->GetThread(0);
735 thread->Reset(); 736 thread->Reset();
736 thread->PushFrame(compiler_.function_, args.start()); 737 thread->PushFrame(compiler_.function_, args.start());
737 if (thread->Run() == WasmInterpreter::FINISHED) { 738 if (thread->Run() == WasmInterpreter::FINISHED) {
738 WasmVal val = thread->GetReturnValue(); 739 WasmVal val = thread->GetReturnValue();
740 possible_nondeterminism_ |= thread->PossibleNondeterminism();
739 return val.to<ReturnType>(); 741 return val.to<ReturnType>();
740 } else if (thread->state() == WasmInterpreter::TRAPPED) { 742 } else if (thread->state() == WasmInterpreter::TRAPPED) {
741 // TODO(titzer): return the correct trap code 743 // TODO(titzer): return the correct trap code
742 int64_t result = 0xdeadbeefdeadbeef; 744 int64_t result = 0xdeadbeefdeadbeef;
743 return static_cast<ReturnType>(result); 745 return static_cast<ReturnType>(result);
744 } else { 746 } else {
745 // TODO(titzer): falling off end 747 // TODO(titzer): falling off end
746 ReturnType val = 0; 748 ReturnType val = 0;
747 return val; 749 return val;
748 } 750 }
749 } 751 }
750 752
751 byte AllocateLocal(LocalType type) { return compiler_.AllocateLocal(type); } 753 byte AllocateLocal(LocalType type) { return compiler_.AllocateLocal(type); }
752 754
753 WasmFunction* function() { return compiler_.function_; } 755 WasmFunction* function() { return compiler_.function_; }
754 WasmInterpreter* interpreter() { return compiler_.interpreter_; } 756 WasmInterpreter* interpreter() { return compiler_.interpreter_; }
757 bool possible_nondeterminism() { return possible_nondeterminism_; }
755 758
756 protected: 759 protected:
757 v8::internal::AccountingAllocator allocator_; 760 v8::internal::AccountingAllocator allocator_;
758 Zone zone; 761 Zone zone;
759 bool compiled_; 762 bool compiled_;
760 LocalType storage_[WASM_RUNNER_MAX_NUM_PARAMETERS]; 763 LocalType storage_[WASM_RUNNER_MAX_NUM_PARAMETERS];
761 FunctionSig signature_; 764 FunctionSig signature_;
762 WasmFunctionCompiler compiler_; 765 WasmFunctionCompiler compiler_;
763 WasmFunctionWrapper<ReturnType> wrapper_; 766 WasmFunctionWrapper<ReturnType> wrapper_;
767 bool possible_nondeterminism_;
764 768
765 bool interpret() { return compiler_.execution_mode_ == kExecuteInterpreted; } 769 bool interpret() { return compiler_.execution_mode_ == kExecuteInterpreted; }
766 770
767 static size_t GetParameterCount(MachineType p0, MachineType p1, 771 static size_t GetParameterCount(MachineType p0, MachineType p1,
768 MachineType p2, MachineType p3) { 772 MachineType p2, MachineType p3) {
769 if (p0 == MachineType::None()) return 0; 773 if (p0 == MachineType::None()) return 0;
770 if (p1 == MachineType::None()) return 1; 774 if (p1 == MachineType::None()) return 1;
771 if (p2 == MachineType::None()) return 2; 775 if (p2 == MachineType::None()) return 2;
772 if (p3 == MachineType::None()) return 3; 776 if (p3 == MachineType::None()) return 3;
773 return 4; 777 return 4;
774 } 778 }
775 }; 779 };
776 780
777 // A macro to define tests that run in different engine configurations. 781 // A macro to define tests that run in different engine configurations.
778 // Currently only supports compiled tests, but a future 782 // Currently only supports compiled tests, but a future
779 // RunWasmInterpreted_##name version will allow each test to also run in the 783 // RunWasmInterpreted_##name version will allow each test to also run in the
780 // interpreter. 784 // interpreter.
781 #define WASM_EXEC_TEST(name) \ 785 #define WASM_EXEC_TEST(name) \
782 void RunWasm_##name(WasmExecutionMode execution_mode); \ 786 void RunWasm_##name(WasmExecutionMode execution_mode); \
783 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ 787 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \
784 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ 788 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \
785 void RunWasm_##name(WasmExecutionMode execution_mode) 789 void RunWasm_##name(WasmExecutionMode execution_mode)
786 790
787 } // namespace 791 } // namespace
788 792
789 #endif 793 #endif
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm-interpreter.cc ('k') | test/common/wasm/wasm-module-runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698