Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(859)

Side by Side Diff: include/v8.h

Issue 10795074: Add a new API V8::SetJitCodeEventHandler to push code name and location to users such as profilers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix instruction address calculation on move events. Fix test use of map, fix compilation on Win64. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 /**
2948 * Interface for iterating though all external resources in the heap. 2999 * Interface for iterating though all external resources in the heap.
2949 */ 3000 */
2950 class V8EXPORT ExternalResourceVisitor { // NOLINT 3001 class V8EXPORT ExternalResourceVisitor { // NOLINT
2951 public: 3002 public:
2952 virtual ~ExternalResourceVisitor() {} 3003 virtual ~ExternalResourceVisitor() {}
2953 virtual void VisitExternalString(Handle<String> string) {} 3004 virtual void VisitExternalString(Handle<String> string) {}
2954 }; 3005 };
2955 3006
2956 3007
2957 /** 3008 /**
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
3212 * 3263 *
3213 * \param entry_hook a function that will be invoked on entry to every 3264 * \param entry_hook a function that will be invoked on entry to every
3214 * V8-generated function. 3265 * V8-generated function.
3215 * \returns true on success on supported platforms, false on failure. 3266 * \returns true on success on supported platforms, false on failure.
3216 * \note Setting a new entry hook function when one is already active will 3267 * \note Setting a new entry hook function when one is already active will
3217 * fail. 3268 * fail.
3218 */ 3269 */
3219 static bool SetFunctionEntryHook(FunctionEntryHook entry_hook); 3270 static bool SetFunctionEntryHook(FunctionEntryHook entry_hook);
3220 3271
3221 /** 3272 /**
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 /**
3222 * Adjusts the amount of registered external memory. Used to give 3296 * Adjusts the amount of registered external memory. Used to give
3223 * V8 an indication of the amount of externally allocated memory 3297 * V8 an indication of the amount of externally allocated memory
3224 * that is kept alive by JavaScript objects. V8 uses this to decide 3298 * that is kept alive by JavaScript objects. V8 uses this to decide
3225 * when to perform global garbage collections. Registering 3299 * when to perform global garbage collections. Registering
3226 * externally allocated memory will trigger global garbage 3300 * externally allocated memory will trigger global garbage
3227 * collections more often than otherwise in an attempt to garbage 3301 * collections more often than otherwise in an attempt to garbage
3228 * collect the JavaScript objects keeping the externally allocated 3302 * collect the JavaScript objects keeping the externally allocated
3229 * memory alive. 3303 * memory alive.
3230 * 3304 *
3231 * \param change_in_bytes the change in externally allocated memory 3305 * \param change_in_bytes the change in externally allocated memory
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after
4536 4610
4537 4611
4538 } // namespace v8 4612 } // namespace v8
4539 4613
4540 4614
4541 #undef V8EXPORT 4615 #undef V8EXPORT
4542 #undef TYPE_CHECK 4616 #undef TYPE_CHECK
4543 4617
4544 4618
4545 #endif // V8_H_ 4619 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698