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

Side by Side Diff: test/cctest/test-code-stub-assembler.cc

Issue 2825393003: [sim] Consistent support for C calls with up to 9 args (Closed)
Patch Set: enum -> const variable Created 3 years, 7 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 | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 #include <cmath> 5 #include <cmath>
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/base/utils/random-number-generator.h" 8 #include "src/base/utils/random-number-generator.h"
9 #include "src/builtins/builtins-promise-gen.h" 9 #include "src/builtins/builtins-promise-gen.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 10 matching lines...) Expand all
21 21
22 using compiler::CodeAssemblerTester; 22 using compiler::CodeAssemblerTester;
23 using compiler::FunctionTester; 23 using compiler::FunctionTester;
24 using compiler::Node; 24 using compiler::Node;
25 using compiler::CodeAssemblerLabel; 25 using compiler::CodeAssemblerLabel;
26 using compiler::CodeAssemblerVariable; 26 using compiler::CodeAssemblerVariable;
27 using compiler::CodeAssemblerVariableList; 27 using compiler::CodeAssemblerVariableList;
28 28
29 namespace { 29 namespace {
30 30
31 int sum9(int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
32 int a8) {
33 return a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8;
34 }
35
36 } // namespace
37
38 TEST(CallCFunction9) {
39 Isolate* isolate(CcTest::InitIsolateOnce());
40
41 const int kNumParams = 0;
42 CodeAssemblerTester data(isolate, kNumParams);
43 CodeStubAssembler m(data.state());
44
45 {
46 Node* const fun_constant = m.ExternalConstant(
47 ExternalReference(reinterpret_cast<Address>(sum9), isolate));
48
49 MachineType type_intptr = MachineType::IntPtr();
50
51 Node* const result = m.CallCFunction9(
52 type_intptr, type_intptr, type_intptr, type_intptr, type_intptr,
53 type_intptr, type_intptr, type_intptr, type_intptr, type_intptr,
54 fun_constant, m.IntPtrConstant(0), m.IntPtrConstant(1),
55 m.IntPtrConstant(2), m.IntPtrConstant(3), m.IntPtrConstant(4),
56 m.IntPtrConstant(5), m.IntPtrConstant(6), m.IntPtrConstant(7),
57 m.IntPtrConstant(8));
58 m.Return(m.SmiTag(result));
59 }
60
61 Handle<Code> code = data.GenerateCode();
62 FunctionTester ft(code, kNumParams);
63
64 Handle<Object> result = ft.Call().ToHandleChecked();
65 CHECK_EQ(36, Handle<Smi>::cast(result)->value());
66 }
67
68 namespace {
69
31 void CheckToUint32Result(uint32_t expected, Handle<Object> result) { 70 void CheckToUint32Result(uint32_t expected, Handle<Object> result) {
32 const int64_t result_int64 = NumberToInt64(*result); 71 const int64_t result_int64 = NumberToInt64(*result);
33 const uint32_t result_uint32 = NumberToUint32(*result); 72 const uint32_t result_uint32 = NumberToUint32(*result);
34 73
35 CHECK_EQ(static_cast<int64_t>(result_uint32), result_int64); 74 CHECK_EQ(static_cast<int64_t>(result_uint32), result_int64);
36 CHECK_EQ(expected, result_uint32); 75 CHECK_EQ(expected, result_uint32);
37 76
38 // Ensure that the result is normalized to a Smi, i.e. a HeapNumber is only 77 // Ensure that the result is normalized to a Smi, i.e. a HeapNumber is only
39 // returned if the result is not within Smi range. 78 // returned if the result is not within Smi range.
40 const bool expected_fits_into_intptr = 79 const bool expected_fits_into_intptr =
(...skipping 2560 matching lines...) Expand 10 before | Expand all | Expand 10 after
2601 m.Return(m.SmiConstant(0)); 2640 m.Return(m.SmiConstant(0));
2602 2641
2603 Handle<Code> code = data.GenerateCode(); 2642 Handle<Code> code = data.GenerateCode();
2604 CHECK(!code.is_null()); 2643 CHECK(!code.is_null());
2605 FunctionTester ft(code, kNumParams); 2644 FunctionTester ft(code, kNumParams);
2606 CHECK_EQ(1, Handle<Smi>::cast(ft.Call().ToHandleChecked())->value()); 2645 CHECK_EQ(1, Handle<Smi>::cast(ft.Call().ToHandleChecked())->value());
2607 } 2646 }
2608 2647
2609 } // namespace internal 2648 } // namespace internal
2610 } // namespace v8 2649 } // namespace v8
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698