OLD | NEW |
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 "src/base/utils/random-number-generator.h" | 5 #include "src/base/utils/random-number-generator.h" |
6 #include "src/ic/stub-cache.h" | 6 #include "src/ic/stub-cache.h" |
7 #include "src/isolate.h" | 7 #include "src/isolate.h" |
8 #include "test/cctest/compiler/code-assembler-tester.h" | 8 #include "test/cctest/compiler/code-assembler-tester.h" |
9 #include "test/cctest/compiler/function-tester.h" | 9 #include "test/cctest/compiler/function-tester.h" |
10 | 10 |
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 | 1209 |
1210 } // namespace | 1210 } // namespace |
1211 | 1211 |
1212 TEST(TryProbeStubCache) { | 1212 TEST(TryProbeStubCache) { |
1213 typedef CodeStubAssembler::Label Label; | 1213 typedef CodeStubAssembler::Label Label; |
1214 typedef CodeStubAssembler::Variable Variable; | 1214 typedef CodeStubAssembler::Variable Variable; |
1215 Isolate* isolate(CcTest::InitIsolateOnce()); | 1215 Isolate* isolate(CcTest::InitIsolateOnce()); |
1216 const int kNumParams = 3; | 1216 const int kNumParams = 3; |
1217 CodeStubAssemblerTester m(isolate, kNumParams); | 1217 CodeStubAssemblerTester m(isolate, kNumParams); |
1218 | 1218 |
| 1219 Code::Kind ic_kind = Code::LOAD_IC; |
1219 Code::Flags flags_to_query = | 1220 Code::Flags flags_to_query = |
1220 Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(Code::LOAD_IC)); | 1221 Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(ic_kind)); |
1221 | 1222 |
1222 StubCache stub_cache(isolate); | 1223 StubCache stub_cache(isolate, ic_kind); |
1223 stub_cache.Clear(); | 1224 stub_cache.Clear(); |
1224 | 1225 |
1225 { | 1226 { |
1226 Node* receiver = m.Parameter(0); | 1227 Node* receiver = m.Parameter(0); |
1227 Node* name = m.Parameter(1); | 1228 Node* name = m.Parameter(1); |
1228 Node* expected_handler = m.Parameter(2); | 1229 Node* expected_handler = m.Parameter(2); |
1229 | 1230 |
1230 Label passed(&m), failed(&m); | 1231 Label passed(&m), failed(&m); |
1231 | 1232 |
1232 Variable var_handler(&m, MachineRepresentation::kTagged); | 1233 Variable var_handler(&m, MachineRepresentation::kTagged); |
1233 Label if_handler(&m), if_miss(&m); | 1234 Label if_handler(&m), if_miss(&m); |
1234 | 1235 |
1235 m.TryProbeStubCache(&stub_cache, flags_to_query, receiver, name, | 1236 m.TryProbeStubCache(&stub_cache, receiver, name, &if_handler, &var_handler, |
1236 &if_handler, &var_handler, &if_miss); | 1237 &if_miss); |
1237 m.Bind(&if_handler); | 1238 m.Bind(&if_handler); |
1238 m.BranchIfWordEqual(expected_handler, var_handler.value(), &passed, | 1239 m.BranchIfWordEqual(expected_handler, var_handler.value(), &passed, |
1239 &failed); | 1240 &failed); |
1240 | 1241 |
1241 m.Bind(&if_miss); | 1242 m.Bind(&if_miss); |
1242 m.BranchIfWordEqual(expected_handler, m.IntPtrConstant(0), &passed, | 1243 m.BranchIfWordEqual(expected_handler, m.IntPtrConstant(0), &passed, |
1243 &failed); | 1244 &failed); |
1244 | 1245 |
1245 m.Bind(&passed); | 1246 m.Bind(&passed); |
1246 m.Return(m.BooleanConstant(true)); | 1247 m.Return(m.BooleanConstant(true)); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 | 1367 |
1367 Handle<Code> expected_handler(handler, isolate); | 1368 Handle<Code> expected_handler(handler, isolate); |
1368 ft.CheckTrue(receiver, name, expected_handler); | 1369 ft.CheckTrue(receiver, name, expected_handler); |
1369 } | 1370 } |
1370 // Ensure we performed both kind of queries. | 1371 // Ensure we performed both kind of queries. |
1371 CHECK(queried_existing && queried_non_existing); | 1372 CHECK(queried_existing && queried_non_existing); |
1372 } | 1373 } |
1373 | 1374 |
1374 } // namespace internal | 1375 } // namespace internal |
1375 } // namespace v8 | 1376 } // namespace v8 |
OLD | NEW |