| OLD | NEW |
| 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 | 4 |
| 5 #ifndef VM_RUNTIME_ENTRY_H_ | 5 #ifndef VM_RUNTIME_ENTRY_H_ |
| 6 #define VM_RUNTIME_ENTRY_H_ | 6 #define VM_RUNTIME_ENTRY_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
| 10 #include "vm/native_arguments.h" | 10 #include "vm/native_arguments.h" |
| 11 #include "vm/runtime_entry_list.h" |
| 11 #include "vm/tags.h" | 12 #include "vm/tags.h" |
| 12 | 13 |
| 13 namespace dart { | 14 namespace dart { |
| 14 | 15 |
| 15 class Assembler; | 16 class Assembler; |
| 16 | 17 |
| 17 DECLARE_FLAG(bool, trace_runtime_calls); | 18 DECLARE_FLAG(bool, trace_runtime_calls); |
| 18 | 19 |
| 19 typedef void (*RuntimeFunction)(NativeArguments arguments); | 20 typedef void (*RuntimeFunction)(NativeArguments arguments); |
| 20 | 21 |
| 21 #define RUNTIME_ENTRY_LIST(V) \ | |
| 22 V(AllocateArray) \ | |
| 23 V(AllocateContext) \ | |
| 24 V(AllocateObject) \ | |
| 25 V(BreakpointRuntimeHandler) \ | |
| 26 V(SingleStepHandler) \ | |
| 27 V(CloneContext) \ | |
| 28 V(FixCallersTarget) \ | |
| 29 V(FixAllocationStubTarget) \ | |
| 30 V(InlineCacheMissHandlerOneArg) \ | |
| 31 V(InlineCacheMissHandlerTwoArgs) \ | |
| 32 V(InlineCacheMissHandlerThreeArgs) \ | |
| 33 V(StaticCallMissHandlerOneArg) \ | |
| 34 V(StaticCallMissHandlerTwoArgs) \ | |
| 35 V(Instanceof) \ | |
| 36 V(TypeCheck) \ | |
| 37 V(BadTypeError) \ | |
| 38 V(NonBoolTypeError) \ | |
| 39 V(InstantiateType) \ | |
| 40 V(InstantiateTypeArguments) \ | |
| 41 V(InvokeClosureNoSuchMethod) \ | |
| 42 V(InvokeNoSuchMethodDispatcher) \ | |
| 43 V(MegamorphicCacheMissHandler) \ | |
| 44 V(OptimizeInvokedFunction) \ | |
| 45 V(TraceICCall) \ | |
| 46 V(PatchStaticCall) \ | |
| 47 V(ReThrow) \ | |
| 48 V(StackOverflow) \ | |
| 49 V(Throw) \ | |
| 50 V(TraceFunctionEntry) \ | |
| 51 V(TraceFunctionExit) \ | |
| 52 V(DeoptimizeMaterialize) \ | |
| 53 V(UpdateFieldCid) \ | |
| 54 V(InitStaticField) \ | |
| 55 V(GrowRegExpStack) \ | |
| 56 V(CompileFunction) \ | |
| 57 | |
| 58 #define LEAF_RUNTIME_ENTRY_LIST(V) \ | |
| 59 V(void, PrintStopMessage, const char*) \ | |
| 60 V(intptr_t, DeoptimizeCopyFrame, uword) \ | |
| 61 V(void, DeoptimizeFillFrame, uword) \ | |
| 62 V(void, StoreBufferBlockProcess, Thread*) \ | |
| 63 V(intptr_t, BigintCompare, RawBigint*, RawBigint*) \ | |
| 64 | |
| 65 | |
| 66 enum RuntimeFunctionId { | 22 enum RuntimeFunctionId { |
| 67 kNoRuntimeFunctionId = -1, | 23 kNoRuntimeFunctionId = -1, |
| 68 #define DECLARE_ENUM_VALUE(name) \ | 24 #define DECLARE_ENUM_VALUE(name) \ |
| 69 k##name##Id, | 25 k##name##Id, |
| 70 RUNTIME_ENTRY_LIST(DECLARE_ENUM_VALUE) | 26 RUNTIME_ENTRY_LIST(DECLARE_ENUM_VALUE) |
| 71 #undef DECLARE_ENUM_VALUE | 27 #undef DECLARE_ENUM_VALUE |
| 72 | 28 |
| 73 #define DECLARE_LEAF_ENUM_VALUE(type, name, ...) \ | 29 #define DECLARE_LEAF_ENUM_VALUE(type, name, ...) \ |
| 74 k##name##Id, | 30 k##name##Id, |
| 75 LEAF_RUNTIME_ENTRY_LIST(DECLARE_LEAF_ENUM_VALUE) | 31 LEAF_RUNTIME_ENTRY_LIST(DECLARE_LEAF_ENUM_VALUE) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 92 // Strip off const for registration. | 48 // Strip off const for registration. |
| 93 VMTag::RegisterRuntimeEntry(const_cast<RuntimeEntry*>(this)); | 49 VMTag::RegisterRuntimeEntry(const_cast<RuntimeEntry*>(this)); |
| 94 } | 50 } |
| 95 ~RuntimeEntry() {} | 51 ~RuntimeEntry() {} |
| 96 | 52 |
| 97 const char* name() const { return name_; } | 53 const char* name() const { return name_; } |
| 98 RuntimeFunction function() const { return function_; } | 54 RuntimeFunction function() const { return function_; } |
| 99 intptr_t argument_count() const { return argument_count_; } | 55 intptr_t argument_count() const { return argument_count_; } |
| 100 bool is_leaf() const { return is_leaf_; } | 56 bool is_leaf() const { return is_leaf_; } |
| 101 bool is_float() const { return is_float_; } | 57 bool is_float() const { return is_float_; } |
| 102 uword GetEntryPoint() const { return reinterpret_cast<uword>(function()); } | 58 uword GetEntryPoint() const; |
| 103 | 59 |
| 104 // Generate code to call the runtime entry. | 60 // Generate code to call the runtime entry. |
| 105 void Call(Assembler* assembler, intptr_t argument_count) const; | 61 void Call(Assembler* assembler, intptr_t argument_count) const; |
| 106 | 62 |
| 107 void set_next(const RuntimeEntry* next) { next_ = next; } | 63 void set_next(const RuntimeEntry* next) { next_ = next; } |
| 108 const RuntimeEntry* next() const { return next_; } | 64 const RuntimeEntry* next() const { return next_; } |
| 109 | 65 |
| 110 static inline uword AddressFromId(RuntimeFunctionId id); | 66 static inline uword AddressFromId(RuntimeFunctionId id); |
| 111 static inline RuntimeFunctionId RuntimeFunctionIdFromAddress(uword address); | 67 static inline RuntimeFunctionId RuntimeFunctionIdFromAddress(uword address); |
| 112 | 68 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 extern "C" type DLRT_##name(__VA_ARGS__); \ | 116 extern "C" type DLRT_##name(__VA_ARGS__); \ |
| 161 extern const RuntimeEntry k##name##RuntimeEntry( \ | 117 extern const RuntimeEntry k##name##RuntimeEntry( \ |
| 162 "DLRT_"#name, reinterpret_cast<RuntimeFunction>(&DLRT_##name), \ | 118 "DLRT_"#name, reinterpret_cast<RuntimeFunction>(&DLRT_##name), \ |
| 163 argument_count, true, false); \ | 119 argument_count, true, false); \ |
| 164 type DLRT_##name(__VA_ARGS__) { \ | 120 type DLRT_##name(__VA_ARGS__) { \ |
| 165 CHECK_STACK_ALIGNMENT; \ | 121 CHECK_STACK_ALIGNMENT; \ |
| 166 NoSafepointScope no_safepoint_scope; \ | 122 NoSafepointScope no_safepoint_scope; \ |
| 167 | 123 |
| 168 #define END_LEAF_RUNTIME_ENTRY } | 124 #define END_LEAF_RUNTIME_ENTRY } |
| 169 | 125 |
| 126 // TODO(rmacnak): Fix alignment issue on simarm and simmips and use |
| 127 // DEFINE_LEAF_RUNTIME_ENTRY instead. |
| 128 #define DEFINE_RAW_LEAF_RUNTIME_ENTRY(name, argument_count, is_float, func) \ |
| 129 extern const RuntimeEntry k##name##RuntimeEntry( \ |
| 130 "DFLRT_"#name, func, argument_count, true, is_float) \ |
| 131 |
| 170 #define DECLARE_LEAF_RUNTIME_ENTRY(type, name, ...) \ | 132 #define DECLARE_LEAF_RUNTIME_ENTRY(type, name, ...) \ |
| 171 extern const RuntimeEntry k##name##RuntimeEntry; \ | 133 extern const RuntimeEntry k##name##RuntimeEntry; \ |
| 172 extern "C" type DLRT_##name(__VA_ARGS__); \ | 134 extern "C" type DLRT_##name(__VA_ARGS__); \ |
| 173 | 135 |
| 174 | 136 |
| 175 // Declare all runtime functions here. | 137 // Declare all runtime functions here. |
| 176 RUNTIME_ENTRY_LIST(DECLARE_RUNTIME_ENTRY) | 138 RUNTIME_ENTRY_LIST(DECLARE_RUNTIME_ENTRY) |
| 177 LEAF_RUNTIME_ENTRY_LIST(DECLARE_LEAF_RUNTIME_ENTRY) | 139 LEAF_RUNTIME_ENTRY_LIST(DECLARE_LEAF_RUNTIME_ENTRY) |
| 178 | 140 |
| 179 | 141 |
| 180 // Declare all runtime functions here. | 142 // Declare all runtime functions here. |
| 181 RUNTIME_ENTRY_LIST(DECLARE_RUNTIME_ENTRY) | 143 RUNTIME_ENTRY_LIST(DECLARE_RUNTIME_ENTRY) |
| 182 LEAF_RUNTIME_ENTRY_LIST(DECLARE_LEAF_RUNTIME_ENTRY) | 144 LEAF_RUNTIME_ENTRY_LIST(DECLARE_LEAF_RUNTIME_ENTRY) |
| 183 | 145 |
| 184 | 146 |
| 185 uword RuntimeEntry::AddressFromId(RuntimeFunctionId id) { | 147 uword RuntimeEntry::AddressFromId(RuntimeFunctionId id) { |
| 186 switch (id) { | 148 switch (id) { |
| 187 #define DEFINE_RUNTIME_CASE(name) \ | 149 #define DEFINE_RUNTIME_CASE(name) \ |
| 188 case k##name##Id: return reinterpret_cast<uword>(&DRT_##name); | 150 case k##name##Id: return k##name##RuntimeEntry.GetEntryPoint(); |
| 189 RUNTIME_ENTRY_LIST(DEFINE_RUNTIME_CASE) | 151 RUNTIME_ENTRY_LIST(DEFINE_RUNTIME_CASE) |
| 190 #undef DEFINE_RUNTIME_CASE | 152 #undef DEFINE_RUNTIME_CASE |
| 191 | 153 |
| 192 #define DEFINE_LEAF_RUNTIME_CASE(type, name, ...) \ | 154 #define DEFINE_LEAF_RUNTIME_CASE(type, name, ...) \ |
| 193 case k##name##Id: return reinterpret_cast<uword>(&DLRT_##name); | 155 case k##name##Id: return k##name##RuntimeEntry.GetEntryPoint(); |
| 194 LEAF_RUNTIME_ENTRY_LIST(DEFINE_LEAF_RUNTIME_CASE) | 156 LEAF_RUNTIME_ENTRY_LIST(DEFINE_LEAF_RUNTIME_CASE) |
| 195 #undef DEFINE_LEAF_RUNTIME_CASE | 157 #undef DEFINE_LEAF_RUNTIME_CASE |
| 196 default: | 158 default: |
| 197 break; | 159 break; |
| 198 } | 160 } |
| 199 return 0; | 161 return 0; |
| 200 } | 162 } |
| 201 | 163 |
| 202 | 164 |
| 203 RuntimeFunctionId RuntimeEntry::RuntimeFunctionIdFromAddress(uword address) { | 165 RuntimeFunctionId RuntimeEntry::RuntimeFunctionIdFromAddress(uword address) { |
| 204 #define CHECK_RUNTIME_ADDRESS(name) \ | 166 #define CHECK_RUNTIME_ADDRESS(name) \ |
| 205 if (address == reinterpret_cast<uword>(&DRT_##name)) return k##name##Id; | 167 if (address == k##name##RuntimeEntry.GetEntryPoint()) return k##name##Id; |
| 206 RUNTIME_ENTRY_LIST(CHECK_RUNTIME_ADDRESS) | 168 RUNTIME_ENTRY_LIST(CHECK_RUNTIME_ADDRESS) |
| 207 #undef CHECK_RUNTIME_ADDRESS | 169 #undef CHECK_RUNTIME_ADDRESS |
| 208 | 170 |
| 209 #define CHECK_LEAF_RUNTIME_ADDRESS(type, name, ...) \ | 171 #define CHECK_LEAF_RUNTIME_ADDRESS(type, name, ...) \ |
| 210 if (address == reinterpret_cast<uword>(&DLRT_##name)) return k##name##Id; | 172 if (address == k##name##RuntimeEntry.GetEntryPoint()) return k##name##Id; |
| 211 LEAF_RUNTIME_ENTRY_LIST(CHECK_LEAF_RUNTIME_ADDRESS) | 173 LEAF_RUNTIME_ENTRY_LIST(CHECK_LEAF_RUNTIME_ADDRESS) |
| 212 #undef CHECK_LEAF_RUNTIME_ADDRESS | 174 #undef CHECK_LEAF_RUNTIME_ADDRESS |
| 213 return kNoRuntimeFunctionId; | 175 return kNoRuntimeFunctionId; |
| 214 } | 176 } |
| 215 | 177 |
| 216 } // namespace dart | 178 } // namespace dart |
| 217 | 179 |
| 218 #endif // VM_RUNTIME_ENTRY_H_ | 180 #endif // VM_RUNTIME_ENTRY_H_ |
| OLD | NEW |