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

Side by Side Diff: runtime/vm/ic_stubs.h

Issue 8357034: Transitioning to new IC structure: change IC data to include function name; pass IC data instead ... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/ic_data_test.cc ('k') | runtime/vm/ic_stubs.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // Class for handling inline cache stubs 4 // Class for handling inline cache stubs
5 // 5 //
6 // The initial target of an instance call is the resolving and patching runtime 6 // The initial target of an instance call is the resolving and patching runtime
7 // function 'ResolvePatchInstanceCall'. It resolves and compiles the 7 // function 'ResolvePatchInstanceCall'. It resolves and compiles the
8 // target function and patches the instance call to jump to it 8 // target function and patches the instance call to jump to it
9 // via an inline cache stub. 9 // via an inline cache stub.
10 // The inline cache stub checks receiver's class for a distinct set of classes 10 // The inline cache stub checks receiver's class for a distinct set of classes
11 // and jumps to the appropriate target. 11 // and jumps to the appropriate target.
12 // An inline-cache-miss occurs if none of the classes match. As a consequence 12 // An inline-cache-miss occurs if none of the classes match. As a consequence
13 // the old IC stub is replaced with a new one that adds the class check 13 // the old IC stub is replaced with a new one that adds the class check
14 // and target for the most recently seen receiver. 14 // and target for the most recently seen receiver.
15 15
16 #ifndef VM_IC_STUBS_H_ 16 #ifndef VM_IC_STUBS_H_
17 #define VM_IC_STUBS_H_ 17 #define VM_IC_STUBS_H_
18 18
19 #include "vm/allocation.h" 19 #include "vm/allocation.h"
20 #include "vm/growable_array.h" 20 #include "vm/growable_array.h"
21 21
22 namespace dart { 22 namespace dart {
23 23
24 // Forward declarations. 24 // Forward declarations.
25 class Class; 25 class Class;
26 class Code; 26 class Code;
27 class Function; 27 class Function;
28 class RawCode; 28 class RawCode;
29 29
30 // Class that interprets the array stored in ICData::ic_data_.
31 // The array format is:
32 // - number of arguments checked, i.e., N number of classes in each check.
33 // - group of checks, each check containing:
34 // - N classes.
35 // - 1 target function.
36 // Whenever first N arguments of a dynamic call have the same class as the
37 // check, jump to the matching target function.
38 // Array is terminated with a null group (all classes and target are NULL).
39 // The array does not contain Null-Classes. Null objects cannot be added.
40 class ICData : public ValueObject {
41 public:
42 explicit ICData(const Code& ic_stub);
43
44 intptr_t NumberOfClasses() const;
45 intptr_t NumberOfChecks() const;
46
47 // 'index' is 0..NumberOfChecks-1.
48 void GetCheckAt(intptr_t index,
49 GrowableArray<const Class*>* classes,
50 Function* target) const;
51 void SetCheckAt(intptr_t index,
52 const GrowableArray<const Class*>& classes,
53 const Function& target);
54
55 // Changes all 'from' targets to 'to' targets.
56 void ChangeTargets(const Function& from, const Function& to);
57
58 // Create and set an ic_data array in ic_stub_.
59 // Use 'SetCheckAt' to populate the array.
60 void SetICDataArray(intptr_t num_classes, intptr_t num_checks);
61
62 void AddCheck(const GrowableArray<const Class*>& classes,
63 const Function& target);
64
65 void Print();
66
67 // Temporary helper method to check that the existing inline
68 // cache information matches the ICData.
69 // TODO(srdjan): Remove once transitioned to IC data.
70 void CheckIsSame(const GrowableArray<const Class*>* classes,
71 const GrowableArray<const Function*>* targets) const;
72
73 private:
74 const Code& ic_stub_;
75 DISALLOW_COPY_AND_ASSIGN(ICData);
76 };
77
78
79 class ICStubs : public AllStatic { 30 class ICStubs : public AllStatic {
80 public: 31 public:
81 // Returns an IC stub that jumps to targets' entry points if the receiver 32 // Returns an IC stub that jumps to targets' entry points if the receiver
82 // matches a class contained in 'classes' array. 33 // matches a class contained in 'classes' array.
83 static RawCode* GetICStub(const GrowableArray<const Class*>& classes, 34 static RawCode* GetICStub(const GrowableArray<const Class*>& classes,
84 const GrowableArray<const Function*>& targets); 35 const GrowableArray<const Function*>& targets);
85 36
86 // Identify classes and their targets contained in the IC stub. 37 // Identify classes and their targets contained in the IC stub.
87 // 'ic_entry_point' is the start of the IC stubs. 'classes' and 'targets' 38 // 'ic_entry_point' is the start of the IC stubs. 'classes' and 'targets'
88 // are the implemented (class, target) tuples. 39 // are the implemented (class, target) tuples.
(...skipping 21 matching lines...) Expand all
110 static bool ParseICStub(uword ic_entry_point, 61 static bool ParseICStub(uword ic_entry_point,
111 GrowableArray<const Class*>* classes, 62 GrowableArray<const Class*>* classes,
112 GrowableArray<const Function*>* targets, 63 GrowableArray<const Function*>* targets,
113 uword from, 64 uword from,
114 uword to); 65 uword to);
115 }; 66 };
116 67
117 } // namespace dart 68 } // namespace dart
118 69
119 #endif // VM_IC_STUBS_H_ 70 #endif // VM_IC_STUBS_H_
OLDNEW
« no previous file with comments | « runtime/vm/ic_data_test.cc ('k') | runtime/vm/ic_stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698