OLD | NEW |
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 #include "src/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 #include "src/compiler.h" | 6 #include "src/compiler.h" |
7 #include "src/parsing/parser.h" | 7 #include "src/parsing/parser.h" |
8 #include "src/zone.h" | 8 #include "src/zone.h" |
9 | 9 |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 CHECK(descriptor); | 64 CHECK(descriptor); |
65 | 65 |
66 CHECK_EQ(1 + i, static_cast<int>(descriptor->JSParameterCount())); | 66 CHECK_EQ(1 + i, static_cast<int>(descriptor->JSParameterCount())); |
67 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); | 67 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); |
68 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | 68 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); |
69 CHECK_EQ(true, descriptor->IsJSFunctionCall()); | 69 CHECK_EQ(true, descriptor->IsJSFunctionCall()); |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 | 73 |
74 TEST(TestLinkageCodeStubIncoming) { | |
75 Isolate* isolate = CcTest::InitIsolateOnce(); | |
76 Zone zone; | |
77 ToNumberStub stub(isolate); | |
78 CompilationInfo info(&stub, isolate, &zone); | |
79 CallDescriptor* descriptor = Linkage::ComputeIncoming(&zone, &info); | |
80 CHECK(descriptor); | |
81 CHECK_EQ(0, static_cast<int>(descriptor->StackParameterCount())); | |
82 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); | |
83 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | |
84 CHECK_EQ(false, descriptor->IsJSFunctionCall()); | |
85 } | |
86 | |
87 | |
88 TEST(TestLinkageJSCall) { | 74 TEST(TestLinkageJSCall) { |
89 HandleAndZoneScope handles; | 75 HandleAndZoneScope handles; |
90 Handle<JSFunction> function = Compile("a + c"); | 76 Handle<JSFunction> function = Compile("a + c"); |
91 ParseInfo parse_info(handles.main_zone(), function); | 77 ParseInfo parse_info(handles.main_zone(), function); |
92 CompilationInfo info(&parse_info); | 78 CompilationInfo info(&parse_info); |
93 | 79 |
94 for (int i = 0; i < 32; i++) { | 80 for (int i = 0; i < 32; i++) { |
95 CallDescriptor* descriptor = Linkage::GetJSCallDescriptor( | 81 CallDescriptor* descriptor = Linkage::GetJSCallDescriptor( |
96 info.zone(), false, i, CallDescriptor::kNoFlags); | 82 info.zone(), false, i, CallDescriptor::kNoFlags); |
97 CHECK(descriptor); | 83 CHECK(descriptor); |
98 CHECK_EQ(i, static_cast<int>(descriptor->JSParameterCount())); | 84 CHECK_EQ(i, static_cast<int>(descriptor->JSParameterCount())); |
99 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); | 85 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); |
100 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | 86 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); |
101 CHECK_EQ(true, descriptor->IsJSFunctionCall()); | 87 CHECK_EQ(true, descriptor->IsJSFunctionCall()); |
102 } | 88 } |
103 } | 89 } |
104 | 90 |
105 | 91 |
106 TEST(TestLinkageRuntimeCall) { | 92 TEST(TestLinkageRuntimeCall) { |
107 // TODO(titzer): test linkage creation for outgoing runtime calls. | 93 // TODO(titzer): test linkage creation for outgoing runtime calls. |
108 } | 94 } |
109 | 95 |
110 | 96 |
111 TEST(TestLinkageStubCall) { | 97 TEST(TestLinkageStubCall) { |
| 98 Isolate* isolate = CcTest::InitIsolateOnce(); |
| 99 Zone zone; |
| 100 ToNumberStub stub(isolate); |
| 101 CompilationInfo info("test", isolate, &zone, Code::ComputeFlags(Code::STUB)); |
| 102 CallInterfaceDescriptor interface_descriptor = |
| 103 stub.GetCallInterfaceDescriptor(); |
| 104 CallDescriptor* descriptor = Linkage::GetStubCallDescriptor( |
| 105 isolate, &zone, interface_descriptor, stub.GetStackParameterCount(), |
| 106 CallDescriptor::kNoFlags, Operator::kNoProperties); |
| 107 CHECK(descriptor); |
| 108 CHECK_EQ(0, static_cast<int>(descriptor->StackParameterCount())); |
| 109 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); |
| 110 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); |
| 111 CHECK_EQ(false, descriptor->IsJSFunctionCall()); |
112 // TODO(titzer): test linkage creation for outgoing stub calls. | 112 // TODO(titzer): test linkage creation for outgoing stub calls. |
113 } | 113 } |
114 | 114 |
115 } // namespace compiler | 115 } // namespace compiler |
116 } // namespace internal | 116 } // namespace internal |
117 } // namespace v8 | 117 } // namespace v8 |
OLD | NEW |