| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // Class for handling inline cache stubs |
| 5 |
| 6 // The caller of an instance function passes the IC-data array in a specific |
| 7 // register (ECX on ia32). |
| 8 // That array contains information relevant for the call site: function name and |
| 9 // inline cache data. Class ICData is a wrapper around that array. |
| 10 // The array format is: |
| 11 // 0: function-name |
| 12 // 1: N, number of arguments checked. |
| 13 // 2 .. (length - 1): group of checks, each check containing: |
| 14 // - N classes. |
| 15 // - 1 target function. |
| 16 // Whenever first N arguments of an instance call have the same class as the |
| 17 // check, jump to the target function. |
| 18 // Array is null terminated (all classes and target are null objects). |
| 19 // The array does not contain Null-Classes. Null objects cannot be added. |
| 20 |
| 21 #ifndef VM_IC_DATA_H_ |
| 22 #define VM_IC_DATA_H_ |
| 23 |
| 24 #include "vm/allocation.h" |
| 25 #include "vm/growable_array.h" |
| 26 |
| 27 namespace dart { |
| 28 |
| 29 class Array; |
| 30 class Class; |
| 31 class Function; |
| 32 class String; |
| 33 class RawArray; |
| 34 class RawString; |
| 35 |
| 36 class ICData : public ValueObject { |
| 37 public: |
| 38 // Wrap IC data around 'array'. |
| 39 explicit ICData(const Array& array); |
| 40 |
| 41 // Create a new array with zero checks. |
| 42 ICData(const String& function_name, intptr_t num_args_checked); |
| 43 |
| 44 RawArray* data() const; |
| 45 |
| 46 RawString* FunctionName() const; |
| 47 |
| 48 intptr_t NumberOfArgumentsChecked() const; |
| 49 intptr_t NumberOfChecks() const; |
| 50 |
| 51 // Also updates the instance call at 'return_address_'. |
| 52 void AddCheck(const GrowableArray<const Class*>& classes, |
| 53 const Function& target); |
| 54 |
| 55 void SetCheckAt(intptr_t index, |
| 56 const GrowableArray<const Class*>& classes, |
| 57 const Function& target); |
| 58 |
| 59 void GetCheckAt(intptr_t index, |
| 60 GrowableArray<const Class*>* classes, |
| 61 Function* target) const; |
| 62 |
| 63 static const int kNameIndex = 0; |
| 64 |
| 65 private: |
| 66 intptr_t ArrayElementsPerCheck() const; |
| 67 |
| 68 const Array* data_; |
| 69 |
| 70 static const int kNumArgsCheckedIndex = 1; |
| 71 static const int kChecksStartIndex = 2; |
| 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(ICData); |
| 74 }; |
| 75 |
| 76 } // namespace dart |
| 77 |
| 78 #endif // VM_IC_DATA_H_ |
| OLD | NEW |