| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 // Copyright (c) 2016, 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 | 
|  | 5 #ifndef VM_SIMULATOR_DBC_H_ | 
|  | 6 #define VM_SIMULATOR_DBC_H_ | 
|  | 7 | 
|  | 8 #ifndef VM_SIMULATOR_H_ | 
|  | 9 #error Do not include simulator_dbc.h directly; use simulator.h. | 
|  | 10 #endif | 
|  | 11 | 
|  | 12 #include "vm/constants_dbc.h" | 
|  | 13 #include "vm/method_recognizer.h" | 
|  | 14 | 
|  | 15 namespace dart { | 
|  | 16 | 
|  | 17 class Isolate; | 
|  | 18 class RawObject; | 
|  | 19 class SimulatorSetjmpBuffer; | 
|  | 20 class Thread; | 
|  | 21 class Code; | 
|  | 22 class Array; | 
|  | 23 class RawICData; | 
|  | 24 class RawArray; | 
|  | 25 class RawObjectPool; | 
|  | 26 class RawFunction; | 
|  | 27 | 
|  | 28 // Simulator intrinsic handler. It is invoked on entry to the intrinsified | 
|  | 29 // function via Intrinsic bytecode before the frame is setup. | 
|  | 30 // If the handler returns true then Intrinsic bytecode works as a return | 
|  | 31 // instruction returning the value in result. Otherwise interpreter proceeds to | 
|  | 32 // execute the body of the function. | 
|  | 33 typedef bool (*IntrinsicHandler)(Thread* thread, | 
|  | 34                                  RawObject** FP, | 
|  | 35                                  RawObject** result); | 
|  | 36 | 
|  | 37 | 
|  | 38 class Simulator { | 
|  | 39  public: | 
|  | 40   static const uword kSimulatorStackUnderflowSize = 64; | 
|  | 41 | 
|  | 42   Simulator(); | 
|  | 43   ~Simulator(); | 
|  | 44 | 
|  | 45   // The currently executing Simulator instance, which is associated to the | 
|  | 46   // current isolate | 
|  | 47   static Simulator* Current(); | 
|  | 48 | 
|  | 49   // Accessors to the internal simulator stack base and top. | 
|  | 50   uword StackBase() const { return reinterpret_cast<uword>(stack_); } | 
|  | 51   uword StackTop() const; | 
|  | 52 | 
|  | 53   // The isolate's top_exit_frame_info refers to a Dart frame in the simulator | 
|  | 54   // stack. The simulator's top_exit_frame_info refers to a C++ frame in the | 
|  | 55   // native stack. | 
|  | 56   uword top_exit_frame_info() const { return top_exit_frame_info_; } | 
|  | 57   void set_top_exit_frame_info(uword value) { top_exit_frame_info_ = value; } | 
|  | 58 | 
|  | 59   // Call on program start. | 
|  | 60   static void InitOnce(); | 
|  | 61 | 
|  | 62   RawObject* Call(const Code& code, | 
|  | 63                   const Array& arguments_descriptor, | 
|  | 64                   const Array& arguments, | 
|  | 65                   Thread* thread); | 
|  | 66 | 
|  | 67   void Longjmp(uword pc, | 
|  | 68                uword sp, | 
|  | 69                uword fp, | 
|  | 70                RawObject* raw_exception, | 
|  | 71                RawObject* raw_stacktrace, | 
|  | 72                Thread* thread); | 
|  | 73 | 
|  | 74   uword get_sp() const { | 
|  | 75     return reinterpret_cast<uword>(sp_); | 
|  | 76   } | 
|  | 77 | 
|  | 78   enum IntrinsicId { | 
|  | 79 #define V(test_class_name, test_function_name, enum_name, fp) \ | 
|  | 80     k##enum_name##Intrinsic, | 
|  | 81   ALL_INTRINSICS_LIST(V) | 
|  | 82   GRAPH_INTRINSICS_LIST(V) | 
|  | 83 #undef V | 
|  | 84     kIntrinsicCount, | 
|  | 85   }; | 
|  | 86 | 
|  | 87   static bool IsSupportedIntrinsic(IntrinsicId id) { | 
|  | 88     return intrinsics_[id] != NULL; | 
|  | 89   } | 
|  | 90 | 
|  | 91   enum SpecialIndex { | 
|  | 92     kExceptionSpecialIndex, | 
|  | 93     kStacktraceSpecialIndex, | 
|  | 94     kSpecialIndexCount | 
|  | 95   }; | 
|  | 96 | 
|  | 97  private: | 
|  | 98   uintptr_t* stack_; | 
|  | 99 | 
|  | 100   RawObject** fp_; | 
|  | 101   RawObject** sp_; | 
|  | 102   uword pc_; | 
|  | 103 | 
|  | 104   SimulatorSetjmpBuffer* last_setjmp_buffer_; | 
|  | 105   uword top_exit_frame_info_; | 
|  | 106 | 
|  | 107   RawObject* special_[kSpecialIndexCount]; | 
|  | 108 | 
|  | 109   static IntrinsicHandler intrinsics_[kIntrinsicCount]; | 
|  | 110 | 
|  | 111   void Exit(Thread* thread, | 
|  | 112             RawObject** base, | 
|  | 113             RawObject** exit_frame, | 
|  | 114             uint32_t* pc); | 
|  | 115 | 
|  | 116   void CallRuntime(Thread* thread, | 
|  | 117                    RawObject** base, | 
|  | 118                    RawObject** exit_frame, | 
|  | 119                    uint32_t* pc, | 
|  | 120                    intptr_t argc_tag, | 
|  | 121                    RawObject** args, | 
|  | 122                    RawObject** result, | 
|  | 123                    uword target); | 
|  | 124 | 
|  | 125   void Invoke(Thread* thread, | 
|  | 126               RawObject** call_base, | 
|  | 127               RawObject** call_top, | 
|  | 128               RawObjectPool** pp, | 
|  | 129               uint32_t** pc, | 
|  | 130               RawObject*** B, | 
|  | 131               RawObject*** SP); | 
|  | 132 | 
|  | 133   void InlineCacheMiss(int checked_args, | 
|  | 134                        Thread* thread, | 
|  | 135                        RawICData* icdata, | 
|  | 136                        RawObject** call_base, | 
|  | 137                        RawObject** top, | 
|  | 138                        uint32_t* pc, | 
|  | 139                        RawObject** B, RawObject** SP); | 
|  | 140 | 
|  | 141   void InstanceCall1(Thread* thread, | 
|  | 142                      RawICData* icdata, | 
|  | 143                      RawObject** call_base, | 
|  | 144                      RawObject** call_top, | 
|  | 145                      RawArray** argdesc, | 
|  | 146                      RawObjectPool** pp, | 
|  | 147                      uint32_t** pc, | 
|  | 148                      RawObject*** B, RawObject*** SP); | 
|  | 149 | 
|  | 150   void InstanceCall2(Thread* thread, | 
|  | 151                      RawICData* icdata, | 
|  | 152                      RawObject** call_base, | 
|  | 153                      RawObject** call_top, | 
|  | 154                      RawArray** argdesc, | 
|  | 155                      RawObjectPool** pp, | 
|  | 156                      uint32_t** pc, | 
|  | 157                      RawObject*** B, RawObject*** SP); | 
|  | 158 | 
|  | 159   void InstanceCall3(Thread* thread, | 
|  | 160                      RawICData* icdata, | 
|  | 161                      RawObject** call_base, | 
|  | 162                      RawObject** call_top, | 
|  | 163                      RawArray** argdesc, | 
|  | 164                      RawObjectPool** pp, | 
|  | 165                      uint32_t** pc, | 
|  | 166                      RawObject*** B, RawObject*** SP); | 
|  | 167 | 
|  | 168   // Longjmp support for exceptions. | 
|  | 169   SimulatorSetjmpBuffer* last_setjmp_buffer() { | 
|  | 170     return last_setjmp_buffer_; | 
|  | 171   } | 
|  | 172   void set_last_setjmp_buffer(SimulatorSetjmpBuffer* buffer) { | 
|  | 173     last_setjmp_buffer_ = buffer; | 
|  | 174   } | 
|  | 175 | 
|  | 176   friend class SimulatorSetjmpBuffer; | 
|  | 177   DISALLOW_COPY_AND_ASSIGN(Simulator); | 
|  | 178 }; | 
|  | 179 | 
|  | 180 }  // namespace dart | 
|  | 181 | 
|  | 182 #endif  // VM_SIMULATOR_DBC_H_ | 
| OLD | NEW | 
|---|