OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2938 * return address resides. This can be used to identify the caller of | 2938 * return address resides. This can be used to identify the caller of |
2939 * \p function, and/or modified to divert execution when \p function exits. | 2939 * \p function, and/or modified to divert execution when \p function exits. |
2940 * | 2940 * |
2941 * \note the entry hook must not cause garbage collection. | 2941 * \note the entry hook must not cause garbage collection. |
2942 */ | 2942 */ |
2943 typedef void (*FunctionEntryHook)(uintptr_t function, | 2943 typedef void (*FunctionEntryHook)(uintptr_t function, |
2944 uintptr_t return_addr_location); | 2944 uintptr_t return_addr_location); |
2945 | 2945 |
2946 | 2946 |
2947 /** | 2947 /** |
2948 * A JIT code event is issued each time code is added, moved or removed. | |
2949 * | |
2950 * \note removal events are not currently issued. | |
2951 */ | |
2952 struct JitCodeEvent { | |
2953 enum EventType { | |
2954 CODE_ADDED, | |
2955 CODE_MOVED, | |
2956 CODE_REMOVED | |
2957 }; | |
2958 | |
2959 // Type of event. | |
2960 EventType type; | |
2961 // Start of the instructions. | |
2962 void* code_start; | |
2963 // Size of the instructions. | |
2964 size_t code_len; | |
2965 | |
2966 union { | |
2967 // Only valid for CODE_ADDED. | |
2968 struct { | |
2969 // Name of the object associated with the code, note that the string is | |
2970 // not zero-terminated. | |
2971 const char* str; | |
2972 // Number of chars in str. | |
2973 size_t len; | |
2974 } name; | |
2975 // New location of instructions. Only valid for CODE_MOVED. | |
2976 void* new_code_start; | |
2977 }; | |
2978 }; | |
2979 | |
2980 /** | |
2981 * Option flags passed to the SetJitCodeEventHandler function. | |
2982 */ | |
2983 enum JitCodeEventOptions { | |
2984 kJitCodeEventDefault = 0, | |
2985 // Generate callbacks for already existent code. | |
2986 kJitCodeEventEnumExisting = 1 | |
2987 }; | |
2988 | |
2989 | |
2990 /** | |
2991 * Callback function passed to SetJitCodeEventHandler. | |
2992 * | |
2993 * \param event code add, move or removal event. | |
2994 */ | |
2995 typedef void (*JitCodeEventHandler)(const JitCodeEvent* event); | |
2996 | |
2997 | |
2998 /** | |
2999 * Interface for iterating though all external resources in the heap. | 2948 * Interface for iterating though all external resources in the heap. |
3000 */ | 2949 */ |
3001 class V8EXPORT ExternalResourceVisitor { // NOLINT | 2950 class V8EXPORT ExternalResourceVisitor { // NOLINT |
3002 public: | 2951 public: |
3003 virtual ~ExternalResourceVisitor() {} | 2952 virtual ~ExternalResourceVisitor() {} |
3004 virtual void VisitExternalString(Handle<String> string) {} | 2953 virtual void VisitExternalString(Handle<String> string) {} |
3005 }; | 2954 }; |
3006 | 2955 |
3007 | 2956 |
3008 /** | 2957 /** |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3263 * | 3212 * |
3264 * \param entry_hook a function that will be invoked on entry to every | 3213 * \param entry_hook a function that will be invoked on entry to every |
3265 * V8-generated function. | 3214 * V8-generated function. |
3266 * \returns true on success on supported platforms, false on failure. | 3215 * \returns true on success on supported platforms, false on failure. |
3267 * \note Setting a new entry hook function when one is already active will | 3216 * \note Setting a new entry hook function when one is already active will |
3268 * fail. | 3217 * fail. |
3269 */ | 3218 */ |
3270 static bool SetFunctionEntryHook(FunctionEntryHook entry_hook); | 3219 static bool SetFunctionEntryHook(FunctionEntryHook entry_hook); |
3271 | 3220 |
3272 /** | 3221 /** |
3273 * Allows the host application to provide the address of a function that is | |
3274 * notified each time code is added, moved or removed. | |
3275 * | |
3276 * \param options options for the JIT code event handler. | |
3277 * \param event_handler the JIT code event handler, which will be invoked | |
3278 * each time code is added, moved or removed. | |
3279 * \note \p event_handler won't get notified of existent code. | |
3280 * \note since code removal notifications are not currently issued, the | |
3281 * \p event_handler may get notifications of code that overlaps earlier | |
3282 * code notifications. This happens when code areas are reused, and the | |
3283 * earlier overlapping code areas should therefore be discarded. | |
3284 * \note the events passed to \p event_handler and the strings they point to | |
3285 * are not guaranteed to live past each call. The \p event_handler must | |
3286 * copy strings and other parameters it needs to keep around. | |
3287 * \note the set of events declared in JitCodeEvent::EventType is expected to | |
3288 * grow over time, and the JitCodeEvent structure is expected to accrue | |
3289 * new members. The \p event_handler function must ignore event codes | |
3290 * it does not recognize to maintain future compatibility. | |
3291 */ | |
3292 static void SetJitCodeEventHandler(JitCodeEventOptions options, | |
3293 JitCodeEventHandler event_handler); | |
3294 | |
3295 /** | |
3296 * Adjusts the amount of registered external memory. Used to give | 3222 * Adjusts the amount of registered external memory. Used to give |
3297 * V8 an indication of the amount of externally allocated memory | 3223 * V8 an indication of the amount of externally allocated memory |
3298 * that is kept alive by JavaScript objects. V8 uses this to decide | 3224 * that is kept alive by JavaScript objects. V8 uses this to decide |
3299 * when to perform global garbage collections. Registering | 3225 * when to perform global garbage collections. Registering |
3300 * externally allocated memory will trigger global garbage | 3226 * externally allocated memory will trigger global garbage |
3301 * collections more often than otherwise in an attempt to garbage | 3227 * collections more often than otherwise in an attempt to garbage |
3302 * collect the JavaScript objects keeping the externally allocated | 3228 * collect the JavaScript objects keeping the externally allocated |
3303 * memory alive. | 3229 * memory alive. |
3304 * | 3230 * |
3305 * \param change_in_bytes the change in externally allocated memory | 3231 * \param change_in_bytes the change in externally allocated memory |
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4610 | 4536 |
4611 | 4537 |
4612 } // namespace v8 | 4538 } // namespace v8 |
4613 | 4539 |
4614 | 4540 |
4615 #undef V8EXPORT | 4541 #undef V8EXPORT |
4616 #undef TYPE_CHECK | 4542 #undef TYPE_CHECK |
4617 | 4543 |
4618 | 4544 |
4619 #endif // V8_H_ | 4545 #endif // V8_H_ |
OLD | NEW |