OLD | NEW |
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 #include "test/cctest/cctest.h" | 5 #include "test/cctest/cctest.h" |
6 | 6 |
7 #include "src/base/utils/random-number-generator.h" | 7 #include "src/base/utils/random-number-generator.h" |
8 #include "src/ic/accessor-assembler-impl.h" | 8 #include "src/ic/accessor-assembler.h" |
9 #include "src/ic/stub-cache.h" | 9 #include "src/ic/stub-cache.h" |
10 #include "test/cctest/compiler/code-assembler-tester.h" | 10 #include "test/cctest/compiler/code-assembler-tester.h" |
11 #include "test/cctest/compiler/function-tester.h" | 11 #include "test/cctest/compiler/function-tester.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 using compiler::CodeAssemblerTester; | 16 using compiler::CodeAssemblerTester; |
17 using compiler::FunctionTester; | 17 using compiler::FunctionTester; |
18 using compiler::Node; | 18 using compiler::Node; |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 void TestStubCacheOffsetCalculation(StubCache::Table table) { | 22 void TestStubCacheOffsetCalculation(StubCache::Table table) { |
23 Isolate* isolate(CcTest::InitIsolateOnce()); | 23 Isolate* isolate(CcTest::InitIsolateOnce()); |
24 const int kNumParams = 2; | 24 const int kNumParams = 2; |
25 CodeAssemblerTester data(isolate, kNumParams); | 25 CodeAssemblerTester data(isolate, kNumParams); |
26 AccessorAssemblerImpl m(data.state()); | 26 AccessorAssembler m(data.state()); |
27 | 27 |
28 { | 28 { |
29 Node* name = m.Parameter(0); | 29 Node* name = m.Parameter(0); |
30 Node* map = m.Parameter(1); | 30 Node* map = m.Parameter(1); |
31 Node* primary_offset = m.StubCachePrimaryOffsetForTesting(name, map); | 31 Node* primary_offset = m.StubCachePrimaryOffsetForTesting(name, map); |
32 Node* result; | 32 Node* result; |
33 if (table == StubCache::kPrimary) { | 33 if (table == StubCache::kPrimary) { |
34 result = primary_offset; | 34 result = primary_offset; |
35 } else { | 35 } else { |
36 CHECK_EQ(StubCache::kSecondary, table); | 36 CHECK_EQ(StubCache::kSecondary, table); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 114 } |
115 | 115 |
116 } // namespace | 116 } // namespace |
117 | 117 |
118 TEST(TryProbeStubCache) { | 118 TEST(TryProbeStubCache) { |
119 typedef CodeStubAssembler::Label Label; | 119 typedef CodeStubAssembler::Label Label; |
120 typedef CodeStubAssembler::Variable Variable; | 120 typedef CodeStubAssembler::Variable Variable; |
121 Isolate* isolate(CcTest::InitIsolateOnce()); | 121 Isolate* isolate(CcTest::InitIsolateOnce()); |
122 const int kNumParams = 3; | 122 const int kNumParams = 3; |
123 CodeAssemblerTester data(isolate, kNumParams); | 123 CodeAssemblerTester data(isolate, kNumParams); |
124 AccessorAssemblerImpl m(data.state()); | 124 AccessorAssembler m(data.state()); |
125 | 125 |
126 Code::Kind ic_kind = Code::LOAD_IC; | 126 Code::Kind ic_kind = Code::LOAD_IC; |
127 StubCache stub_cache(isolate, ic_kind); | 127 StubCache stub_cache(isolate, ic_kind); |
128 stub_cache.Clear(); | 128 stub_cache.Clear(); |
129 | 129 |
130 { | 130 { |
131 Node* receiver = m.Parameter(0); | 131 Node* receiver = m.Parameter(0); |
132 Node* name = m.Parameter(1); | 132 Node* name = m.Parameter(1); |
133 Node* expected_handler = m.Parameter(2); | 133 Node* expected_handler = m.Parameter(2); |
134 | 134 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 254 |
255 Handle<Object> expected_handler(handler, isolate); | 255 Handle<Object> expected_handler(handler, isolate); |
256 ft.CheckTrue(receiver, name, expected_handler); | 256 ft.CheckTrue(receiver, name, expected_handler); |
257 } | 257 } |
258 // Ensure we performed both kind of queries. | 258 // Ensure we performed both kind of queries. |
259 CHECK(queried_existing && queried_non_existing); | 259 CHECK(queried_existing && queried_non_existing); |
260 } | 260 } |
261 | 261 |
262 } // namespace internal | 262 } // namespace internal |
263 } // namespace v8 | 263 } // namespace v8 |
OLD | NEW |