| 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 may 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 void set_data(const Array& data); | |
| 45 RawArray* data() const; | |
| 46 | |
| 47 RawString* FunctionName() const; | |
| 48 | |
| 49 intptr_t NumberOfArgumentsChecked() const; | |
| 50 intptr_t NumberOfChecks() const; | |
| 51 | |
| 52 // Also updates the instance call at 'return_address_'. | |
| 53 void AddCheck(const GrowableArray<const Class*>& classes, | |
| 54 const Function& target); | |
| 55 | |
| 56 void SetCheckAt(intptr_t index, | |
| 57 const GrowableArray<const Class*>& classes, | |
| 58 const Function& target); | |
| 59 | |
| 60 void GetOneClassCheckAt(intptr_t index, Class* cls, Function* target) const; | |
| 61 | |
| 62 void GetCheckAt(intptr_t index, | |
| 63 GrowableArray<const Class*>* classes, | |
| 64 Function* target) const; | |
| 65 | |
| 66 static const int kNameIndex = 0; | |
| 67 static const int kNumArgsCheckedIndex = 1; | |
| 68 static const int kChecksStartIndex = 2; | |
| 69 | |
| 70 private: | |
| 71 intptr_t ArrayElementsPerCheck() const; | |
| 72 | |
| 73 const Array* data_; | |
| 74 | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(ICData); | |
| 77 }; | |
| 78 | |
| 79 } // namespace dart | |
| 80 | |
| 81 #endif // VM_IC_DATA_H_ | |
| OLD | NEW |