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

Side by Side Diff: test/cctest/test-code-cache.cc

Issue 2052763003: [ic] [stubs] Remove InlineCacheState field from the code flags. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebasing Created 4 years, 6 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/heap/test-heap.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 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 "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/list.h" 7 #include "src/list.h"
8 #include "src/objects.h" 8 #include "src/objects.h"
9 #include "test/cctest/cctest.h" 9 #include "test/cctest/cctest.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 13
14 namespace { 14 namespace {
15 15
16 static Handle<Code> GetDummyCode(Isolate* isolate) { 16 static Handle<Code> GetDummyCode(Isolate* isolate) {
17 CodeDesc desc = {nullptr, // buffer 17 CodeDesc desc = {nullptr, // buffer
18 0, // buffer_size 18 0, // buffer_size
19 0, // instr_size 19 0, // instr_size
20 0, // reloc_size 20 0, // reloc_size
21 0, // constant_pool_size 21 0, // constant_pool_size
22 nullptr}; // origin 22 nullptr}; // origin
23 Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, MONOMORPHIC, 23 Code::Flags flags =
24 kNoExtraICState, kCacheOnReceiver); 24 Code::ComputeFlags(Code::LOAD_IC, kNoExtraICState, kCacheOnReceiver);
25 Handle<Code> self_ref; 25 Handle<Code> self_ref;
26 return isolate->factory()->NewCode(desc, flags, self_ref); 26 return isolate->factory()->NewCode(desc, flags, self_ref);
27 } 27 }
28 28
29 } // namespace 29 } // namespace
30 30
31 TEST(CodeCache) { 31 TEST(CodeCache) {
32 CcTest::InitializeVM(); 32 CcTest::InitializeVM();
33 Isolate* isolate = CcTest::i_isolate(); 33 Isolate* isolate = CcTest::i_isolate();
34 Factory* factory = isolate->factory(); 34 Factory* factory = isolate->factory();
35 HandleScope handle_scope(isolate); 35 HandleScope handle_scope(isolate);
36 36
37 Handle<Map> map = 37 Handle<Map> map =
38 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize, FAST_ELEMENTS); 38 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize, FAST_ELEMENTS);
39 39
40 // This number should be large enough to cause the code cache to use its 40 // This number should be large enough to cause the code cache to use its
41 // hash table storage format. 41 // hash table storage format.
42 static const int kEntries = 150; 42 static const int kEntries = 150;
43 43
44 // Prepare name/code pairs. 44 // Prepare name/code pairs.
45 List<Handle<Name>> names(kEntries); 45 List<Handle<Name>> names(kEntries);
46 List<Handle<Code>> codes(kEntries); 46 List<Handle<Code>> codes(kEntries);
47 for (int i = 0; i < kEntries; i++) { 47 for (int i = 0; i < kEntries; i++) {
48 names.Add(isolate->factory()->NewSymbol()); 48 names.Add(isolate->factory()->NewSymbol());
49 codes.Add(GetDummyCode(isolate)); 49 codes.Add(GetDummyCode(isolate));
50 } 50 }
51 Handle<Name> bad_name = isolate->factory()->NewSymbol(); 51 Handle<Name> bad_name = isolate->factory()->NewSymbol();
52 Code::Flags bad_flags = Code::ComputeFlags( 52 Code::Flags bad_flags =
53 Code::LOAD_IC, MONOMORPHIC, kNoExtraICState, kCacheOnPrototype); 53 Code::ComputeFlags(Code::LOAD_IC, kNoExtraICState, kCacheOnPrototype);
54 DCHECK(bad_flags != codes[0]->flags()); 54 DCHECK(bad_flags != codes[0]->flags());
55 55
56 // Cache name/code pairs. 56 // Cache name/code pairs.
57 for (int i = 0; i < kEntries; i++) { 57 for (int i = 0; i < kEntries; i++) {
58 Handle<Name> name = names.at(i); 58 Handle<Name> name = names.at(i);
59 Handle<Code> code = codes.at(i); 59 Handle<Code> code = codes.at(i);
60 Map::UpdateCodeCache(map, name, code); 60 Map::UpdateCodeCache(map, name, code);
61 CHECK_EQ(*code, map->LookupInCodeCache(*name, code->flags())); 61 CHECK_EQ(*code, map->LookupInCodeCache(*name, code->flags()));
62 CHECK_NULL(map->LookupInCodeCache(*name, bad_flags)); 62 CHECK_NULL(map->LookupInCodeCache(*name, bad_flags));
63 } 63 }
64 CHECK_NULL(map->LookupInCodeCache(*bad_name, bad_flags)); 64 CHECK_NULL(map->LookupInCodeCache(*bad_name, bad_flags));
65 65
66 // Check that lookup works not only right after storing. 66 // Check that lookup works not only right after storing.
67 for (int i = 0; i < kEntries; i++) { 67 for (int i = 0; i < kEntries; i++) {
68 Handle<Name> name = names.at(i); 68 Handle<Name> name = names.at(i);
69 Handle<Code> code = codes.at(i); 69 Handle<Code> code = codes.at(i);
70 CHECK_EQ(*code, map->LookupInCodeCache(*name, code->flags())); 70 CHECK_EQ(*code, map->LookupInCodeCache(*name, code->flags()));
71 } 71 }
72 } 72 }
73 73
74 } // namespace internal 74 } // namespace internal
75 } // namespace v8 75 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698